Merge lp:~jeremywootten/plank/fix-1063913 into lp:plank

Proposed by Jeremy Wootten
Status: Rejected
Rejected by: Rico Tzschichholz
Proposed branch: lp:~jeremywootten/plank/fix-1063913
Merge into: lp:plank
Diff against target: 214 lines (+90/-77)
3 files modified
lib/Items/ApplicationDockItem.vala (+84/-18)
lib/Items/DockItemPreferences.vala (+6/-0)
po/plank.pot (+0/-59)
To merge this branch: bzr merge lp:~jeremywootten/plank/fix-1063913
Reviewer Review Type Date Requested Status
Robert Dyer (community) Disapprove
Review via email: mp+202751@code.launchpad.net

Description of the change

Implements persistence of the bookmarks in the launcher when Files is not running. Requires modification of Files also to provide both labels and uris over DBus and to signal a quicklist update whenever the bookmarks change so that the launcher can be updated even if the right-click menu is not used again before Files closes. These modifications are contained in the branch lp:~jeremywootten/pantheon-files/quicklist-add-uris

The bookmark labels and uris are stored in the launcher preferences file. If the app is running the launcher bookmarks are taken from the Quicklist as usual; when the app is closed the bookmarks are taken from the preference file.

To post a comment you must log in.
Revision history for this message
Robert Dyer (psybers) wrote :

I do not approve of adding quicklist entries into the .dockitem.

review: Disapprove
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

I am not totally opposed to parts of this idea. Having a little restructuring of and extending the dockitem syntax seems interesting.

Like adding optional fields to override "Name" and "Icon" while also adding support for an equivalent of DesktopActions. Which would be capable to hold needed information to provide such an feature. Passing the information to plank in a nice way in another story while of course direct adjustment of the dockitem file is possible.

[Plank Entry]
Launcher=file:///.*.desktop
Name=... (optional localestring)
Icon=... (optional localestring)
Actions=...;...; (optional string-array)

[Plank Action %ACTION%]
Name=... (localestring)
Icon=... (optional localestring)
Exec=... (optional localestring)

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

@jeremywootten: Just a note. Make sure you are not proposing unwanted changes like commented code or removing files e.g. plank.pot.

Revision history for this message
Robert Dyer (psybers) wrote :

I don't see any reason to put these into the .dockitem. If you want a custom icon or text, make a new .desktop file and point your .dockitem to that.

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Don't just think about dockitems which point to desktop-files. Also copying and adjusting a desktop-file isn't actually comfortable and will also prevent you from receiving changes/update if the original system's desktop-file gets altered.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Hello Rico, Robert

This branch was in response to a bug filed against Pantheon Files and only
makes sense in the context of the ElementaryOS desktop with the
corresponding changes made to Pantheon Files. I perhaps should not
therefore have submitted for merging into Plank? I was not aware (being
relatively new to ElementaryOS development) that there was another trunk
(lp:pantheon-dock) that this perhaps should have been based on.

The bug could be fixed without altering Plank/Pantheon-Dock by having a
Files daemon running in the background all the time to serve up the
bookmark list to the Files launcher when Files is not running but that has
its own complications.

Its not a particularly important bug although it is moderately useful to be
open Files straight into a bookmarked directory using the Dock. So its not
a disaster if the branch is rejected - the corresponding Files branch is
not accepted yet anyway!

Re the missing .pot file: Sorry about that, it wasn't intentional.

On 23 January 2014 11:48, Rico Tzschichholz <email address hidden> wrote:

> Don't just think about dockitems which point to desktop-files. Also
> copying and adjusting a desktop-file isn't actually comfortable and will
> also prevent you from receiving changes/update if the original system's
> desktop-file gets altered.
> --
> https://code.launchpad.net/~jeremywootten/plank/fix-1063913/+merge/202751
> You are the owner of lp:~jeremywootten/plank/fix-1063913.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Unmerged revisions

950. By Jeremy Wootten

Update quicklist when bookmarks change even if menu not opened - required changes to pantheon-files as well

949. By Jeremy Wootten

Save quicklist labels and uris in DockItemPreferences file

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Items/ApplicationDockItem.vala'
2--- lib/Items/ApplicationDockItem.vala 2014-01-21 12:42:02 +0000
3+++ lib/Items/ApplicationDockItem.vala 2014-01-22 21:15:30 +0000
4@@ -390,16 +390,10 @@
5 }
6
7 #if HAVE_DBUSMENU
8- if (Quicklist != null) {
9- items.add (new SeparatorMenuItem ());
10-
11- var dm_root = Quicklist.get_root ();
12- if (dm_root != null) {
13- Logger.verbose ("%i quicklist menuitems for %s", dm_root.get_children ().length (), Text);
14- foreach (var menuitem in dm_root.get_children ())
15- items.add (Quicklist.menuitem_get (menuitem));
16- }
17- }
18+ if (Quicklist != null)
19+ add_items_from_quicklist (ref items);
20+ else
21+ add_items_from_preferences (ref items);
22 #endif
23
24 if (!is_window () && actions.size > 0) {
25@@ -440,6 +434,73 @@
26 return items;
27 }
28
29+#if HAVE_DBUSMENU
30+ void add_items_from_quicklist (ref ArrayList<Gtk.MenuItem> items) {
31+ var dm_root = Quicklist.get_root ();
32+ if (dm_root != null) {
33+ var n_children = dm_root.get_children ().length ();
34+ Logger.verbose ("%u quicklist menuitems for %s", n_children , Text);
35+ if (n_children > 0)
36+ items.add (new SeparatorMenuItem ());
37+
38+ foreach (Dbusmenu.Menuitem menuitem in dm_root.get_children ())
39+ items.add (Quicklist.menuitem_get (menuitem));
40+
41+ //update_preferences_from_quicklist ();
42+
43+ } else
44+ add_items_from_preferences (ref items);
45+ }
46+
47+ void update_preferences_from_quicklist () {
48+ var dm_root = Quicklist.get_root ();
49+ if (dm_root != null) {
50+ string ql_uris = "";
51+ string ql_labels = "";
52+ foreach (Dbusmenu.Menuitem menuitem in dm_root.get_children ()) {
53+ if (menuitem.property_exist ("uri")) {
54+ /* Add label and uri to quicklist strings for saving in Preferences*/
55+ if (ql_uris.length > 0)
56+ ql_uris+= ";;";
57+
58+ ql_uris+= menuitem.property_get ("uri");
59+
60+ if (ql_labels.length > 0)
61+ ql_labels+= ";;";
62+
63+ ql_labels+= menuitem.property_get ("label");
64+ }
65+ }
66+ Prefs.QuicklistUris = ql_uris;
67+ Prefs.QuicklistLabels = ql_labels;
68+ }
69+ }
70+
71+ void add_items_from_preferences (ref ArrayList<Gtk.MenuItem> items) {
72+ string[] uris = Prefs.QuicklistUris.split (";;");
73+ string[] labels = Prefs.QuicklistLabels.split (";;");
74+ if (uris.length == labels.length && uris.length > 0) {
75+ items.add (new SeparatorMenuItem ());
76+ for (int i = 0; i < uris.length; i++) {
77+ if (uris[i] == null)
78+ continue;
79+
80+ var uri = uris[i];
81+ var label = labels[i];
82+ var item = create_menu_item (label, null, true);
83+ item.activate.connect (() => {
84+ var app = File.new_for_uri (Prefs.Launcher);
85+ File[] files = new File [1];
86+ files [0] = File.new_for_uri (uri);
87+ Services.System.launch_with_files (app, files);
88+ });
89+
90+ items.add (item);
91+ }
92+ }
93+ }
94+#endif
95+
96 /**
97 * {@inheritDoc}
98 */
99@@ -765,14 +826,19 @@
100 else if (prop_key == "quicklist") {
101 /* The value is the object path of the dbusmenu */
102 var dbus_path = prop_value.get_string ();
103- // Make sure we don't update our Quicklist instance if isn't necessary
104- if (Quicklist == null || Quicklist.dbus_object != dbus_path)
105- if (dbus_path != "") {
106- Logger.verbose ("Loading dynamic quicklists for %s (%s)", Text, sender_name);
107- Quicklist = new DbusmenuGtk.Client (sender_name, dbus_path);
108- } else {
109- Quicklist = null;
110- }
111+ /* Update Quicklist whenever it changes in order that preferences
112+ * are updated even if the menu is not shown, ensuring persistence
113+ * of the quicklist when app is not running */
114+ if (dbus_path != "") {
115+ Logger.verbose ("Loading dynamic quicklists for %s (%s)", Text, sender_name);
116+ Quicklist = new DbusmenuGtk.Client (sender_name, dbus_path);
117+ } else
118+ Quicklist = null;
119+ /* wait to make sure remote menu is available */
120+ Timeout.add (100, () => {
121+ update_preferences_from_quicklist ();
122+ return false;
123+ });
124 }
125 #endif
126 }
127
128=== modified file 'lib/Items/DockItemPreferences.vala'
129--- lib/Items/DockItemPreferences.vala 2013-04-11 12:16:34 +0000
130+++ lib/Items/DockItemPreferences.vala 2014-01-22 21:15:30 +0000
131@@ -26,6 +26,10 @@
132 {
133 [Description(nick = "launcher", blurb = "The uri for this item.")]
134 public string Launcher { get; set; }
135+ [Description(nick = "quicklisturis", blurb = "The quicklist uris for this item.")]
136+ public string QuicklistUris { get; set; default = ""; }
137+ [Description(nick = "quicklistlabels", blurb = "The quicklist labels for this item.")]
138+ public string QuicklistLabels { get; set; default = ""; }
139
140 /**
141 * {@inheritDoc}
142@@ -58,6 +62,8 @@
143 protected override void reset_properties ()
144 {
145 Launcher = "";
146+ QuicklistUris = "";
147+ QuicklistLabels = "";
148 }
149
150 /**
151
152=== removed file 'po/plank.pot'
153--- po/plank.pot 2012-10-13 09:09:54 +0000
154+++ po/plank.pot 1970-01-01 00:00:00 +0000
155@@ -1,59 +0,0 @@
156-# SOME DESCRIPTIVE TITLE.
157-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
158-# This file is distributed under the same license as the PACKAGE package.
159-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
160-#
161-#, fuzzy
162-msgid ""
163-msgstr ""
164-"Project-Id-Version: PACKAGE VERSION\n"
165-"Report-Msgid-Bugs-To: \n"
166-"POT-Creation-Date: 2012-10-13 11:09+0200\n"
167-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
168-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
169-"Language-Team: LANGUAGE <LL@li.org>\n"
170-"Language: \n"
171-"MIME-Version: 1.0\n"
172-"Content-Type: text/plain; charset=CHARSET\n"
173-"Content-Transfer-Encoding: 8bit\n"
174-
175-#: ../data/plank.desktop.in.h:1
176-msgid "Plank. Stupidly simple."
177-msgstr ""
178-
179-#: ../lib/Items/ApplicationDockItem.vala:326
180-#: ../lib/Items/FileDockItem.vala:251 ../lib/Items/FileDockItem.vala:269
181-msgid "_Keep in Dock"
182-msgstr ""
183-
184-#: ../lib/Items/ApplicationDockItem.vala:336
185-msgid "Unma_ximize"
186-msgstr ""
187-
188-#: ../lib/Items/ApplicationDockItem.vala:340
189-msgid "Ma_ximize"
190-msgstr ""
191-
192-#: ../lib/Items/ApplicationDockItem.vala:345
193-msgid "_Close All"
194-msgstr ""
195-
196-#: ../lib/Items/FileDockItem.vala:256
197-msgid "_Open in File Browser"
198-msgstr ""
199-
200-#: ../lib/Items/FileDockItem.vala:274
201-msgid "_Open"
202-msgstr ""
203-
204-#: ../lib/Items/FileDockItem.vala:278
205-msgid "Open Containing _Folder"
206-msgstr ""
207-
208-#: ../lib/Items/PlankDockItem.vala:79
209-msgid "Get _Help Online..."
210-msgstr ""
211-
212-#: ../lib/Items/PlankDockItem.vala:83
213-msgid "_Translate This Application..."
214-msgstr ""

Subscribers

People subscribed via source and target branches

to status/vote changes: