diff --git a/src/Launcher.vala b/src/Launcher.vala index 497d0ec8..5392e696 100644 --- a/src/Launcher.vala +++ b/src/Launcher.vala @@ -38,11 +38,11 @@ public class Dock.Launcher : Gtk.Button { ); } - var pinned_menu_item = new MenuItem (null, null); - pinned_menu_item.set_attribute_value ("custom", "pinned-item"); - var pinned_section = new Menu (); - pinned_section.append_item (pinned_menu_item); + pinned_section.append ( + _("Keep in Dock"), + MainWindow.ACTION_PREFIX + MainWindow.LAUNCHER_PINNED_ACTION_TEMPLATE.printf (app_info.get_id ()) + ); var model = new Menu (); if (action_section.get_n_items () > 0) { @@ -50,28 +50,11 @@ public class Dock.Launcher : Gtk.Button { } model.append_section (null, pinned_section); - var pinned_label = new Gtk.Label ("Keep in Dock") { - xalign = 0, - hexpand = true - }; - - var pinned_check_button = new Gtk.CheckButton (); - - var pinned_box = new Gtk.Box (HORIZONTAL, 3); - pinned_box.append (pinned_label); - pinned_box.append (pinned_check_button); - - var pinned_button = new Gtk.ToggleButton () { - child = pinned_box - }; - pinned_button.add_css_class (Granite.STYLE_CLASS_MENUITEM); - popover = new Gtk.PopoverMenu.from_model (model) { autohide = true, position = TOP }; popover.set_parent (this); - popover.add_child (pinned_button, "pinned-item"); var image = new Gtk.Image () { gicon = app_info.get_icon () @@ -81,9 +64,6 @@ public class Dock.Launcher : Gtk.Button { child = image; tooltip_text = app_info.get_display_name (); - bind_property ("pinned", pinned_button, "active", BIDIRECTIONAL | SYNC_CREATE); - pinned_button.bind_property ("active", pinned_check_button, "active", SYNC_CREATE); - notify["pinned"].connect (() => ((MainWindow) get_root ()).sync_pinned ()); var gesture_click = new Gtk.GestureClick () { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 34882421..98a93cb0 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -6,6 +6,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow { // First %s is the app id second %s the action name public const string LAUNCHER_ACTION_TEMPLATE = "%s.%s"; + public const string LAUNCHER_PINNED_ACTION_TEMPLATE = "%s-pinned"; public const string ACTION_GROUP_PREFIX = "win"; public const string ACTION_PREFIX = ACTION_GROUP_PREFIX + "."; @@ -72,11 +73,22 @@ public class Dock.MainWindow : Gtk.ApplicationWindow { unowned var app_id = app_info.get_id (); app_to_launcher.insert (app_id, launcher); box.append (launcher); + + var pinned_action = new SimpleAction.stateful ( + LAUNCHER_PINNED_ACTION_TEMPLATE.printf (app_id), + null, + new Variant.boolean (launcher.pinned) + ); + launcher.notify["pinned"].connect (() => pinned_action.set_state (launcher.pinned)); + pinned_action.change_state.connect ((new_state) => launcher.pinned = (bool) new_state); + add_action (pinned_action); + foreach (var action in app_info.list_actions ()) { var simple_action = new SimpleAction (LAUNCHER_ACTION_TEMPLATE.printf (app_id, action), null); simple_action.activate.connect (() => launcher.launch (action)); add_action (simple_action); } + return app_to_launcher[app_id]; }