Skip to content

Commit 0edae90

Browse files
authored
fix order (#2005)
1 parent d2beef8 commit 0edae90

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/Layouts/LabelRow.vala

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class Layouts.LabelRow : Gtk.ListBoxRow {
2828
private Gtk.Revealer main_revealer;
2929
private Gtk.Image widget_color;
3030
private Gtk.Box handle_grid;
31-
private Widgets.ReorderChild reorder_child;
31+
private Widgets.ReorderChild reorder;
3232

3333
private Gee.HashMap<ulong, weak GLib.Object> signal_map = new Gee.HashMap<ulong, weak GLib.Object> ();
3434

@@ -94,16 +94,16 @@ public class Layouts.LabelRow : Gtk.ListBoxRow {
9494
handle_grid.append (count_revealer);
9595
handle_grid.append (buttons_box);
9696

97-
reorder_child = new Widgets.ReorderChild (handle_grid, this);
97+
reorder = new Widgets.ReorderChild (handle_grid, this);
9898

9999
main_revealer = new Gtk.Revealer () {
100100
transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN,
101-
child = reorder_child
101+
child = reorder
102102
};
103103

104104
child = main_revealer;
105+
reorder.build_drag_and_drop ();
105106
update_request ();
106-
reorder_child.build_drag_and_drop ();
107107

108108
Timeout.add (main_revealer.transition_duration, () => {
109109
main_revealer.reveal_child = true;
@@ -119,9 +119,9 @@ public class Layouts.LabelRow : Gtk.ListBoxRow {
119119
count_revealer.reveal_child = int.parse (count_label.label) > 0;
120120
})] = label;
121121

122-
signal_map[reorder_child.on_drop_end.connect ((listbox) => {
122+
signal_map[reorder.on_drop_end.connect ((listbox) => {
123123
update_labels_item_order (listbox);
124-
})] = reorder_child;
124+
})] = reorder;
125125

126126
signal_map[label.loading_change.connect (() => {
127127
loading_button.is_loading = label.loading;
@@ -130,6 +130,10 @@ public class Layouts.LabelRow : Gtk.ListBoxRow {
130130
signal_map[loading_button.clicked.connect (() => {
131131
Services.EventBus.get_default ().pane_selected (PaneType.LABEL, label.id);
132132
})] = loading_button;
133+
134+
signal_map[main_revealer.notify["child-revealed"].connect (() => {
135+
reorder.draw_motion_widgets ();
136+
})] = main_revealer;
133137
}
134138

135139
public void update_request () {
@@ -199,9 +203,9 @@ public class Layouts.LabelRow : Gtk.ListBoxRow {
199203

200204
signal_map.clear ();
201205

202-
if (reorder_child != null) {
203-
reorder_child.clean_up ();
204-
reorder_child = null;
206+
if (reorder != null) {
207+
reorder.clean_up ();
208+
reorder = null;
205209
}
206210
}
207211
}

src/Widgets/ReorderChild.vala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public class Widgets.ReorderChild : Adw.Bin {
111111

112112
signal_map[drag_source.drag_begin.connect ((source, drag) => {
113113
var paintable = new Gtk.WidgetPaintable (widget);
114-
source.set_icon (paintable, row.get_width () / 3, row.get_height () / 2);
114+
source.set_icon (paintable, 0, 0);
115115
drag_begin ();
116116
})] = drag_source;
117117

@@ -191,8 +191,13 @@ public class Widgets.ReorderChild : Adw.Bin {
191191
}
192192

193193
public void draw_motion_widgets () {
194-
motion_top_grid.height_request = row.get_height ();
195-
motion_bottom_grid.height_request = row.get_height ();
194+
var height = row.get_height ();
195+
if (height == 0) {
196+
height = 32;
197+
}
198+
199+
motion_top_grid.height_request = height;
200+
motion_bottom_grid.height_request = height;
196201
}
197202

198203
public void clean_up () {

0 commit comments

Comments
 (0)