Skip to content

Commit

Permalink
Consistency improvement with dock menu item (#622)
Browse files Browse the repository at this point in the history
* Keep In Dock like the dock

* less to keep in sync: remove the docked variable

* Make the linter happy

* Consistency: have add to dock always present

* Update AppContextMenu.vala

* Removed comments

* Update AppContextMenu.vala

* Update AppContextMenu.vala

* Update AppContextMenu.vala

* RyoNakano's proposal for testing

* clean a newline
  • Loading branch information
teamcons authored Jan 29, 2025
1 parent 0bc3c16 commit a73561c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/Widgets/AppContextMenu.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public class Slingshot.AppContextMenu : Gtk.Menu {
private Slingshot.Backend.SwitcherooControl switcheroo_control;
private Gtk.MenuItem uninstall_menuitem;
private Gtk.MenuItem appcenter_menuitem;
private Gtk.MenuItem dock_menuitem;

private bool docked = false;
private Gtk.CheckMenuItem dock_menuitem;

public AppContextMenu (string desktop_id, string desktop_path) {
Object (
Expand Down Expand Up @@ -82,18 +80,21 @@ public class Slingshot.AppContextMenu : Gtk.Menu {
});
}

var dock = Backend.Dock.get_default ();
if (dock.dbus != null) {
if (Environment.find_program_in_path ("io.elementary.dock") != null) {
if (get_children ().length () > 0) {
add (new Gtk.SeparatorMenuItem ());
}

has_system_item = true;

dock_menuitem = new Gtk.MenuItem () {
var dock = Backend.Dock.get_default ();

dock_menuitem = new Gtk.CheckMenuItem () {
label = _("Add to _Dock"),
use_underline = true
use_underline = true,
sensitive = false
};

dock_menuitem.activate.connect (dock_menuitem_activate);

add (dock_menuitem);
Expand Down Expand Up @@ -183,16 +184,15 @@ public class Slingshot.AppContextMenu : Gtk.Menu {

private void on_dock_dbus_changed (Backend.Dock dock) {
if (dock.dbus != null) {
dock_menuitem.sensitive = true;

try {
docked = desktop_id in dock.dbus.list_launchers ();
if (docked) {
dock_menuitem.label = _("Remove from _Dock");
} else {
dock_menuitem.label = _("Add to _Dock");
}
dock_menuitem.active = desktop_id in dock.dbus.list_launchers ();
} catch (GLib.Error e) {
critical (e.message);
}
} else {
dock_menuitem.sensitive = false;
}
}

Expand All @@ -203,10 +203,10 @@ public class Slingshot.AppContextMenu : Gtk.Menu {
}

try {
if (docked) {
dock.dbus.remove_launcher (desktop_id);
} else {
if (dock_menuitem.active) {
dock.dbus.add_launcher (desktop_id);
} else {
dock.dbus.remove_launcher (desktop_id);
}
} catch (GLib.Error e) {
critical (e.message);
Expand Down

0 comments on commit a73561c

Please sign in to comment.