Merge lp:~aprilis/plank/get_position_dbus into lp:plank

Proposed by Jarosław Kwiecień
Status: Rejected
Rejected by: Rico Tzschichholz
Proposed branch: lp:~aprilis/plank/get_position_dbus
Merge into: lp:plank
Diff against target: 77 lines (+47/-0)
3 files modified
lib/DBus/Client.vala (+21/-0)
lib/DBus/Interfaces.vala (+7/-0)
lib/DBusManager.vala (+19/-0)
To merge this branch: bzr merge lp:~aprilis/plank/get_position_dbus
Reviewer Review Type Date Requested Status
Rico Tzschichholz Disapprove
Review via email: mp+325258@code.launchpad.net

Description of the change

Hi

I've created a Facebook Messenger desktop app which received very enthusiastic feedback (https://www.reddit.com/r/elementaryos/comments/6fml4c/desktop_app_for_facebook_messenger/). It shows conversations in chat bubbles anchored to the Plank dock. To do this, I had to add one function to Plank's D-Bus API - it just returns the result of get_menu_position.

I'd be very grateful if you accepted these changes - that would allow me to publish my app in the elementary's AppCenter.

Of course you can change the function name and the format of returned value - get_menu_position and array of two ints maybe aren't the best choice.

To post a comment you must log in.
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Yeah, this design seems a bit weird. Afaics you will be better off with an position/direction where to point to? Using the requisition internally is fine, but seems out of place in such an external use-case.

So I would suggest to retrieve the x,y coords for the (nearest) appropriate position "above" the given item.

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

Also a merge-proposal against the git repository is preferred.

https://code.launchpad.net/plank
https://github.com/ricotz/plank

Revision history for this message
Jarosław Kwiecień (aprilis) wrote :

For me it was quite convenient to receive coordinates of a window with specified size hovering over a given item but retrieving only the coords of the nearest point above would be OK too. Does Gtk have any structure suitable for storing coordinates? I couldn't find any so I guess it should be created (it's not a problem of course but I wanted to add as little code as possible).

I've never used launchpad before and I couldn't find a way to fork the git repository, that's why I submited the proposal to bazaar repo.

Revision history for this message
Jarosław Kwiecień (aprilis) wrote :

Uhm, I've just noticed that the same repo is on github, so it's easy to fork. Forget the last paragraph from the previous message

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

Don't invent new structures, simply use 3 out parameters (x, y, direction)

Revision history for this message
Jarosław Kwiecień (aprilis) wrote :

Wow I didn't know that out parameters works so easily with D-Bus too. Vala is cool :)
So I'll do some code changes and propose merge on the github repository. Thanks for help!

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

Unmerged revisions

1599. By Jarosław Kwiecień

Added dbus get_menu_position function

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/DBus/Client.vala'
2--- lib/DBus/Client.vala 2016-02-15 20:19:49 +0000
3+++ lib/DBus/Client.vala 2017-06-07 17:20:27 +0000
4@@ -307,5 +307,26 @@
5
6 return null;
7 }
8+
9+ /**
10+ * Returns an array of 2 integers - x and y position of the menu or null in case of failure
11+ *
12+ * @return the array 2 integers or null
13+ */
14+ public int[]? get_menu_position (string uri, Gtk.Requisition requisition)
15+ {
16+ if (items_proxy == null) {
17+ warning ("No proxy connected");
18+ return null;
19+ }
20+
21+ try {
22+ return items_proxy.get_menu_position (uri, requisition);
23+ } catch (IOError e) {
24+ warning (e.message);
25+ }
26+
27+ return null;
28+ }
29 }
30 }
31
32=== modified file 'lib/DBus/Interfaces.vala'
33--- lib/DBus/Interfaces.vala 2015-11-03 10:37:19 +0000
34+++ lib/DBus/Interfaces.vala 2017-06-07 17:20:27 +0000
35@@ -71,5 +71,12 @@
36 * @return the array of uris
37 */
38 public abstract string[] get_transient_applications () throws GLib.IOError;
39+
40+ /**
41+ * Returns an array of 2 integers - x and y position of the menu or null in case of failure
42+ *
43+ * @return the array 2 integers or null
44+ */
45+ public abstract int[]? get_menu_position (string uri, Gtk.Requisition requisition) throws GLib.IOError;
46 }
47 }
48
49=== modified file 'lib/DBusManager.vala'
50--- lib/DBusManager.vala 2016-02-22 10:12:31 +0000
51+++ lib/DBusManager.vala 2017-06-07 17:20:27 +0000
52@@ -136,6 +136,25 @@
53
54 return result;
55 }
56+
57+ public int[]? get_menu_position (string uri, Gtk.Requisition requisition) {
58+
59+ unowned ApplicationDockItemProvider? provider = (controller.default_provider as ApplicationDockItemProvider);
60+ if (provider == null)
61+ return null;
62+
63+ unowned DockItem? item = provider.item_for_uri (uri);
64+ if (item == null)
65+ return null;
66+
67+ unowned PositionManager? manager = controller.position_manager;
68+ if (manager == null)
69+ return null;
70+
71+ int x, y;
72+ manager.get_menu_position (item, requisition, out x, out y);
73+ return { x, y };
74+ }
75 }
76
77 /**

Subscribers

People subscribed via source and target branches

to status/vote changes: