Skip to content

Commit ba4cdb3

Browse files
authored
Launcher: Hide indicators while moving (#271)
1 parent 44889b2 commit ba4cdb3

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

data/dock.metainfo.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<description>
2929
<p>Updated translations</p>
3030
<p>Fixes a crash when dragging a file that's not a launcher to the dock</p>
31+
<p>Hide badges, progressbars, and running indicators while dragging a launcher</p>
3132
</description>
3233
<issues>
3334
<issue url="https://github.com/elementary/dock/issues/276">Changing Dock size left the dock with extra empty space</issue>

src/Launcher.vala

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,33 @@ public class Dock.Launcher : Gtk.Box {
1919

2020
public double current_pos { get; set; }
2121

22+
private bool _moving = false;
2223
public bool moving {
24+
get {
25+
return _moving;
26+
}
27+
2328
set {
29+
_moving = value;
30+
2431
if (value) {
2532
image.clear ();
2633
} else {
2734
image.gicon = app.app_info.get_icon ();
2835
}
36+
37+
update_badge_revealer ();
38+
update_progress_revealer ();
39+
update_running_revealer ();
2940
}
3041
}
3142

3243
private static Settings settings;
3344

3445
private Gtk.Image image;
35-
private Gtk.Image running_indicator;
46+
private Gtk.Revealer progress_revealer;
47+
private Gtk.Revealer badge_revealer;
48+
private Gtk.Revealer running_revealer;
3649
private Adw.TimedAnimation bounce_up;
3750
private Adw.TimedAnimation bounce_down;
3851
private Adw.TimedAnimation timed_animation;
@@ -83,7 +96,7 @@ public class Dock.Launcher : Gtk.Box {
8396
};
8497
badge.add_css_class (Granite.STYLE_CLASS_BADGE);
8598

86-
var badge_revealer = new Gtk.Revealer () {
99+
badge_revealer = new Gtk.Revealer () {
87100
can_target = false,
88101
child = badge,
89102
transition_type = SWING_UP
@@ -93,16 +106,16 @@ public class Dock.Launcher : Gtk.Box {
93106
valign = END
94107
};
95108

96-
var progress_revealer = new Gtk.Revealer () {
109+
progress_revealer = new Gtk.Revealer () {
97110
can_target = false,
98111
child = progressbar,
99112
transition_type = CROSSFADE
100113
};
101114

102-
running_indicator = new Gtk.Image.from_icon_name ("pager-checked-symbolic");
115+
var running_indicator = new Gtk.Image.from_icon_name ("pager-checked-symbolic");
103116
running_indicator.add_css_class ("running-indicator");
104117

105-
var running_revealer = new Gtk.Revealer () {
118+
running_revealer = new Gtk.Revealer () {
106119
can_target = false,
107120
child = running_indicator,
108121
overflow = VISIBLE,
@@ -206,7 +219,8 @@ public class Dock.Launcher : Gtk.Box {
206219

207220
settings.bind ("icon-size", image, "pixel-size", DEFAULT);
208221

209-
app.bind_property ("count-visible", badge_revealer, "reveal-child", SYNC_CREATE);
222+
app.notify["count-visible"].connect (update_badge_revealer);
223+
update_badge_revealer ();
210224
current_count_binding = app.bind_property ("current_count", badge, "label", SYNC_CREATE,
211225
(binding, srcval, ref targetval) => {
212226
var src = (int64) srcval;
@@ -221,9 +235,12 @@ public class Dock.Launcher : Gtk.Box {
221235
}, null
222236
);
223237

224-
app.bind_property ("progress-visible", progress_revealer, "reveal-child", SYNC_CREATE);
238+
app.notify["progress-visible"].connect (update_progress_revealer);
239+
update_progress_revealer ();
225240
app.bind_property ("progress", progressbar, "fraction", SYNC_CREATE);
226-
app.bind_property ("running-on-active-workspace", running_revealer, "reveal-child", SYNC_CREATE);
241+
242+
app.notify["running-on-active-workspace"].connect (update_running_revealer);
243+
update_running_revealer ();
227244

228245
var drop_target_file = new Gtk.DropTarget (typeof (File), COPY);
229246
add_controller (drop_target_file);
@@ -450,4 +467,16 @@ public class Dock.Launcher : Gtk.Box {
450467

451468
launcher_manager.move_launcher_after (source, target_index);
452469
}
470+
471+
private void update_badge_revealer () {
472+
badge_revealer.reveal_child = !moving && app.count_visible;
473+
}
474+
475+
private void update_progress_revealer () {
476+
progress_revealer.reveal_child = !moving && app.progress_visible;
477+
}
478+
479+
private void update_running_revealer () {
480+
running_revealer.reveal_child = !moving && app.running_on_active_workspace;
481+
}
453482
}

0 commit comments

Comments
 (0)