Skip to content

Commit

Permalink
Merge branch 'main' into release-8.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Oct 21, 2024
2 parents 6a40633 + 7c85f02 commit 8341211
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 24 deletions.
4 changes: 4 additions & 0 deletions data/Application.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ launcher progressbar progress {
-gtk-icon-size: 9px;
margin-top: -3px;
}

.running-indicator:disabled {
color: @text_color;
}
2 changes: 1 addition & 1 deletion data/dock.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</key>

<key type="as" name="launchers">
<default>['gala-multitaskingview.desktop', 'io.elementary.files.desktop', 'org.gnome.Epiphany.desktop', 'io.elementary.mail.desktop', 'io.elementary.tasks.desktop', 'io.elementary.calendar.desktop', 'io.elementary.music.desktop', 'io.elementary.videos.desktop', 'io.elementary.photos.desktop', 'io.elementary.settings.desktop', 'io.elementary.appcenter.desktop']</default>
<default>['gala-multitaskingview.desktop', 'io.elementary.files.desktop', 'org.gnome.Epiphany.desktop', 'io.elementary.mail.desktop', 'io.elementary.tasks.desktop', 'io.elementary.calendar.desktop', 'io.elementary.music.desktop', 'io.elementary.videos.desktop', 'io.elementary.photos.desktop', 'io.elementary.settings.desktop', 'io.elementary.appcenter.desktop', 'io.elementary.installer.desktop']</default>
<summary>An ordered array of app id's to show as launchers</summary>
<description>An ordered array of app id's to show as launchers</description>
</key>
Expand Down
5 changes: 5 additions & 0 deletions data/dock.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@
<description>
<p>Updated translations</p>
<p>Fixes a crash when dragging a file that's not a launcher to the dock</p>
<p>Hide badges, progressbars, and running indicators while dragging a launcher</p>
</description>
<issues>
<issue url="https://github.com/elementary/dock/issues/242">Clicking a launcher almost always registers a scroll</issue>
<issue url="https://github.com/elementary/dock/issues/276">Changing Dock size left the dock with extra empty space</issue>
<issue url="https://github.com/elementary/dock/issues/279">Dock using too much CPU/RAM</issue>
<issue url="https://github.com/elementary/dock/issues/284">Hide notification badges when Do Not Disturb is on</issue>
<issue url="https://github.com/elementary/dock/issues/289">Drag running app to pin</issue>
</issues>
</release>

Expand Down
15 changes: 14 additions & 1 deletion po/extra/extra.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: extra\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-08 17:19+0000\n"
"POT-Creation-Date: 2024-10-07 15:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -30,5 +30,18 @@ msgid "elementary, Inc."
msgstr ""

#: data/dock.metainfo.xml.in:29
msgid "Updated translations"
msgstr ""

#: data/dock.metainfo.xml.in:30
msgid "Fixes a crash when dragging a file that's not a launcher to the dock"
msgstr ""

#: data/dock.metainfo.xml.in:31
msgid ""
"Hide badges, progressbars, and running indicators while dragging a launcher"
msgstr ""

#: data/dock.metainfo.xml.in:40
msgid "Complete rewrite 🎉️"
msgstr ""
2 changes: 1 addition & 1 deletion po/io.elementary.dock.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: io.elementary.dock\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-08 17:19+0000\n"
"POT-Creation-Date: 2024-10-07 15:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 2 additions & 0 deletions src/App.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Dock.App : Object {
public bool progress_visible { get; set; default = false; }
public double progress { get; set; default = 0; }
public bool prefers_nondefault_gpu { get; private set; default = false; }
public bool running { get { return windows.size > 0; } }
public bool running_on_active_workspace {
get {
foreach (var win in windows) {
Expand Down Expand Up @@ -174,6 +175,7 @@ public class Dock.App : Object {
}

notify_property ("running-on-active-workspace");
notify_property ("running");
}

public AppWindow? find_window (uint64 window_uid) {
Expand Down
96 changes: 75 additions & 21 deletions src/Launcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
*/

public class Dock.Launcher : Gtk.Box {
private static Settings settings;
private static Settings? notify_settings;

static construct {
settings = new Settings ("io.elementary.dock");

if (SettingsSchemaSource.get_default ().lookup ("io.elementary.notifications", true) != null) {
notify_settings = new Settings ("io.elementary.notifications");
}
}

public signal void revealed_done ();

// Matches icon size and padding in Launcher.css
Expand All @@ -19,20 +30,31 @@ public class Dock.Launcher : Gtk.Box {

public double current_pos { get; set; }

private bool _moving = false;
public bool moving {
get {
return _moving;
}

set {
_moving = value;

if (value) {
image.clear ();
} else {
image.gicon = app.app_info.get_icon ();
}

update_badge_revealer ();
update_progress_revealer ();
update_running_revealer ();
}
}

private static Settings settings;

private Gtk.Image image;
private Gtk.Image running_indicator;
private Gtk.Revealer progress_revealer;
private Gtk.Revealer badge_revealer;
private Gtk.Revealer running_revealer;
private Adw.TimedAnimation bounce_up;
private Adw.TimedAnimation bounce_down;
private Adw.TimedAnimation timed_animation;
Expand All @@ -57,10 +79,6 @@ public class Dock.Launcher : Gtk.Box {
set_css_name ("launcher");
}

static construct {
settings = new Settings ("io.elementary.dock");
}

construct {
popover = new Gtk.PopoverMenu.from_model (app.menu_model) {
autohide = true,
Expand All @@ -83,26 +101,21 @@ public class Dock.Launcher : Gtk.Box {
};
badge.add_css_class (Granite.STYLE_CLASS_BADGE);

var badge_revealer = new Gtk.Revealer () {
badge_revealer = new Gtk.Revealer () {
can_target = false,
child = badge,
transition_type = SWING_UP
};

var progressbar = new Gtk.ProgressBar () {
valign = END
};

var progress_revealer = new Gtk.Revealer () {
progress_revealer = new Gtk.Revealer () {
can_target = false,
child = progressbar,
transition_type = CROSSFADE
};

running_indicator = new Gtk.Image.from_icon_name ("pager-checked-symbolic");
var running_indicator = new Gtk.Image.from_icon_name ("pager-checked-symbolic");
running_indicator.add_css_class ("running-indicator");

var running_revealer = new Gtk.Revealer () {
running_revealer = new Gtk.Revealer () {
can_target = false,
child = running_indicator,
overflow = VISIBLE,
Expand All @@ -127,6 +140,14 @@ public class Dock.Launcher : Gtk.Box {

insert_action_group (ACTION_GROUP_PREFIX, app.action_group);

// We have to destroy the progressbar when it is not needed otherwise it will
// cause continuous layouting of the surface see https://github.com/elementary/dock/issues/279
progress_revealer.notify["child-revealed"].connect (() => {
if (!progress_revealer.child_revealed) {
progress_revealer.child = null;
}
});

app.launching.connect (animate_launch);

var bounce_animation_target = new Adw.CallbackAnimationTarget ((val) => {
Expand Down Expand Up @@ -198,15 +219,15 @@ public class Dock.Launcher : Gtk.Box {

var scroll_controller = new Gtk.EventControllerScroll (VERTICAL);
add_controller (scroll_controller);
scroll_controller.scroll_begin.connect (() => app.next_window.begin (false));
scroll_controller.scroll.connect ((dx, dy) => {
app.next_window.begin (dy > 0);
return Gdk.EVENT_STOP;
});

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

app.bind_property ("count-visible", badge_revealer, "reveal-child", SYNC_CREATE);
app.notify["count-visible"].connect (update_badge_revealer);
update_badge_revealer ();
current_count_binding = app.bind_property ("current_count", badge, "label", SYNC_CREATE,
(binding, srcval, ref targetval) => {
var src = (int64) srcval;
Expand All @@ -221,9 +242,17 @@ public class Dock.Launcher : Gtk.Box {
}, null
);

app.bind_property ("progress-visible", progress_revealer, "reveal-child", SYNC_CREATE);
app.bind_property ("progress", progressbar, "fraction", SYNC_CREATE);
app.bind_property ("running-on-active-workspace", running_revealer, "reveal-child", SYNC_CREATE);
if (notify_settings != null) {
notify_settings.changed["do-not-disturb"].connect (update_badge_revealer);
}

app.notify["progress-visible"].connect (update_progress_revealer);
update_progress_revealer ();

app.bind_property ("running-on-active-workspace", running_revealer, "sensitive", SYNC_CREATE);

app.notify["running"].connect (update_running_revealer);
update_running_revealer ();

var drop_target_file = new Gtk.DropTarget (typeof (File), COPY);
add_controller (drop_target_file);
Expand Down Expand Up @@ -367,6 +396,8 @@ public class Dock.Launcher : Gtk.Box {
var paintable = new Gtk.WidgetPaintable (image); //Maybe TODO How TF can I get a paintable from a gicon?!?!?
drag_source.set_icon (paintable.get_current_image (), drag_offset_x, drag_offset_y);
moving = true;

app.pinned = true; // Dragging communicates an implicit intention to pin the app
}

private bool on_drag_cancel (Gdk.Drag drag, Gdk.DragCancelReason reason) {
Expand Down Expand Up @@ -450,4 +481,27 @@ public class Dock.Launcher : Gtk.Box {

launcher_manager.move_launcher_after (source, target_index);
}

private void update_badge_revealer () {
badge_revealer.reveal_child = !moving && app.count_visible
&& (notify_settings == null || !notify_settings.get_boolean ("do-not-disturb"));
}

private void update_progress_revealer () {
progress_revealer.reveal_child = !moving && app.progress_visible;

// See comment above and https://github.com/elementary/dock/issues/279
if (progress_revealer.reveal_child && progress_revealer.child == null) {
var progress_bar = new Gtk.ProgressBar () {
valign = END
};
app.bind_property ("progress", progress_bar, "fraction", SYNC_CREATE);

progress_revealer.child = progress_bar;
}
}

private void update_running_revealer () {
running_revealer.reveal_child = !moving && app.running;
}
}

0 comments on commit 8341211

Please sign in to comment.