Merge lp:~3v1n0/libappindicator/scroll-event-support into lp:libappindicator

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merged at revision: 183
Proposed branch: lp:~3v1n0/libappindicator/scroll-event-support
Merge into: lp:libappindicator
Diff against target: 253 lines (+102/-6)
5 files modified
bindings/mono/libappindicator-api.metadata (+2/-0)
src/app-indicator.c (+82/-2)
src/app-indicator.h (+13/-2)
src/application-service-marshal.list (+1/-0)
src/notification-item.xml (+4/-2)
To merge this branch: bzr merge lp:~3v1n0/libappindicator/scroll-event-support
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Needs Information
Ted Gould (community) Approve
Review via email: mp+47611@code.launchpad.net

Description of the change

libappindicator now when it gets a dbus call from indicator-application about the incoming scroll event, sends a "scroll-event" signal to the appindicator application.

Depends on:
lp:~3v1n0/libindicator/scroll-event-support
lp:~3v1n0/indicator-application/scroll-event-support

This is part of the Indicators "scroll-event" support patch, see bug #708180

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

http://www.notmart.org/misc/statusnotifieritem/statusnotifieritem.html#Scroll

Same as indicator-application, should export the SNI method.

I also don't understand this code:

117 +
118 + char * name = g_dbus_proxy_get_name_owner(app->priv->watcher_proxy);
119 + if (name != NULL) {
120 + g_free(name);
121 + }

Why is the name being gotten here?

Lastly the reserved don't need to be taken away when there is already a slot reserved for it. You're taking away from the class structure twice:

- void (*app_indicator_reserved_6)(void);

review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> http://www.notmart.org/misc/statusnotifieritem/statusnotifieritem.html#Scroll
>
> Same as indicator-application, should export the SNI method.

Ok, I'll do it.

> I also don't understand this code:
>
> 117 +
> 118 + char * name = g_dbus_proxy_get_name_owner(app->priv->watcher_proxy);
> 119 + if (name != NULL) {
> 120 + g_free(name);
> 121 + }
> Why is the name being gotten here?

Oops, it was for debugging, I'll move it away.

> Lastly the reserved don't need to be taken away when there is already a slot
> reserved for it. You're taking away from the class structure twice:
>
> - void (*app_indicator_reserved_6)(void);

That's true... I removed it at the beginning, since I didn't know which one use. I'll reset it.

181. By Marco Trevisan (Treviño)

app-indicator: remove old debug code.

182. By Marco Trevisan (Treviño)

app-indicator: don't use two AppIndicator slots, reset one.

183. By Marco Trevisan (Treviño)

Using the SNI method "Scroll" instead of XAyatanaScrollAction

The indicator signal will use anyway the same syntax.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Fixed, now I'm using that method name and signature (wich uses a string for defining the orientation and a signed delta as scroll-event value), however I kept the scroll-entry signal of the AppIndicator as firstly implemented: using an integer for the delta and an unsigned int for the direction (which respect the GdkScrollDirection values in fact).

Is this fine? Or should I change the scroll-event signal signature too?

184. By Marco Trevisan (Treviño)

Merge against new trunk

Revision history for this message
Ted Gould (ted) :
review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Thanks... Ah, just for having a better interface (especially for vala or mono bindings), wouldn't be better to use GdkScrollDirection instead of guint when doing the signal (since that is used in sources)?

So defining the scroll_event signal as:
   void (* scroll_event) (AppIndicator * indicator, gint delta, GdkScrollDirection direction, gpointer user_data);

I guess it would allow a more clear interface for programmers.

Let me know if I should change that, thanks.

review: Needs Information
Revision history for this message
Ted Gould (ted) wrote :

Sure, I think that'd be a good fix. Put it in a different branch though as I merged this one and it'll get confusing if it's not in a different branch :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bindings/mono/libappindicator-api.metadata'
2--- bindings/mono/libappindicator-api.metadata 2010-09-20 18:46:30 +0000
3+++ bindings/mono/libappindicator-api.metadata 2011-02-03 11:51:50 +0000
4@@ -9,6 +9,8 @@
5 <attr path="/api/namespace/object[@cname='AppIndicator']/signal[@field_name='new_label']" name="cname">new-label</attr>
6 <attr path="/api/namespace/object[@cname='AppIndicator']/signal[@field_name='connection_changed']" name="name">ConnectionChanged</attr>
7 <attr path="/api/namespace/object[@cname='AppIndicator']/signal[@field_name='connection_changed']" name="cname">connection-changed</attr>
8+ <attr path="/api/namespace/object[@cname='AppIndicator']/signal[@field_name='scroll_event']" name="name">ScrollEvent</attr>
9+ <attr path="/api/namespace/object[@cname='AppIndicator']/signal[@field_name='scroll_event']" name="cname">scroll-event</attr>
10 <attr path="/api/namespace/object[@cname='AppIndicator']/signal[@field_name='new_icon']" name="name">NewIcon</attr>
11 <attr path="/api/namespace/object[@cname='AppIndicator']/signal[@field_name='new_icon']" name="cname">new-icon</attr>
12 <attr path="/api/namespace/object[@cname='AppIndicator']/signal[@field_name='new_icon_theme_path']" name="name">NewIconThemePath</attr>
13
14=== modified file 'src/app-indicator.c'
15--- src/app-indicator.c 2011-01-25 15:44:43 +0000
16+++ src/app-indicator.c 2011-02-03 11:51:50 +0000
17@@ -103,6 +103,7 @@
18 NEW_LABEL,
19 CONNECTION_CHANGED,
20 NEW_ICON_THEME_PATH,
21+ SCROLL_EVENT,
22 LAST_SIGNAL
23 };
24
25@@ -170,19 +171,22 @@
26 static gboolean fallback_timer_expire (gpointer data);
27 static GtkStatusIcon * fallback (AppIndicator * self);
28 static void status_icon_status_wrapper (AppIndicator * self, const gchar * status, gpointer data);
29+static gboolean scroll_event_wrapper(GtkWidget *status_icon, GdkEventScroll *event, gpointer user_data);
30 static void status_icon_changes (AppIndicator * self, gpointer data);
31 static void status_icon_activate (GtkStatusIcon * icon, gpointer data);
32+static void status_icon_menu_activate (GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data);
33 static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon);
34 static gchar * append_panel_icon_suffix (const gchar * icon_name);
35 static void watcher_owner_changed (GObject * obj, GParamSpec * pspec, gpointer user_data);
36 static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator);
37 static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data);
38 static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data);
39+static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data);
40 static void bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data);
41 static void bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data);
42
43 static const GDBusInterfaceVTable item_interface_table = {
44- method_call: NULL, /* No methods on this object */
45+ method_call: bus_method_call,
46 get_property: bus_get_prop,
47 set_property: NULL /* No properties that can be set */
48 };
49@@ -469,6 +473,21 @@
50 g_cclosure_marshal_VOID__STRING,
51 G_TYPE_NONE, 1, G_TYPE_STRING);
52
53+ /**
54+ AppIndicator::scroll-event:
55+ @arg0: The #AppIndicator object
56+
57+ Signaled when there is a new icon set for the
58+ object.
59+ */
60+ signals[SCROLL_EVENT] = g_signal_new (APP_INDICATOR_SIGNAL_SCROLL_EVENT,
61+ G_TYPE_FROM_CLASS(klass),
62+ G_SIGNAL_RUN_LAST,
63+ G_STRUCT_OFFSET (AppIndicatorClass, scroll_event),
64+ NULL, NULL,
65+ _application_service_marshal_VOID__INT_UINT,
66+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_UINT);
67+
68 /* DBus interfaces */
69 if (item_node_info == NULL) {
70 GError * error = NULL;
71@@ -899,6 +918,43 @@
72 return;
73 }
74
75+static void
76+bus_method_call (GDBusConnection * connection, const gchar * sender,
77+ const gchar * path, const gchar * interface,
78+ const gchar * method, GVariant * params,
79+ GDBusMethodInvocation * invocation, gpointer user_data)
80+{
81+ g_return_if_fail(IS_APP_INDICATOR(user_data));
82+
83+ AppIndicator * app = APP_INDICATOR(user_data);
84+ GVariant * retval = NULL;
85+
86+ if (g_strcmp0(method, "Scroll") == 0) {
87+ guint direction;
88+ gint delta;
89+ const gchar *orientation;
90+
91+ g_variant_get(params, "(i&s)", &delta, &orientation);
92+
93+ if (g_strcmp0(orientation, "horizontal") == 0) {
94+ direction = (delta >= 0) ? GDK_SCROLL_RIGHT : GDK_SCROLL_LEFT;
95+ } else if (g_strcmp0(orientation, "vertical") == 0) {
96+ direction = (delta >= 0) ? GDK_SCROLL_DOWN : GDK_SCROLL_UP;
97+ } else {
98+ g_dbus_method_invocation_return_value(invocation, retval);
99+ return;
100+ }
101+
102+ delta = ABS(delta);
103+ g_signal_emit(app, signals[SCROLL_EVENT], 0, delta, direction);
104+
105+ } else {
106+ g_warning("Calling method '%s' on the app-indicator and it's unknown", method);
107+ }
108+
109+ g_dbus_method_invocation_return_value(invocation, retval);
110+}
111+
112 /* DBus is asking for a property so we should figure out what it
113 wants and try and deliver. */
114 static GVariant *
115@@ -1053,7 +1109,8 @@
116 if (priv->watcher_proxy == NULL) {
117 /* Build Watcher Proxy */
118 g_dbus_proxy_new(priv->connection,
119- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, /* We don't use these, don't bother with them */
120+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|
121+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, /* We don't use these, don't bother with them */
122 watcher_interface_info,
123 NOTIFICATION_WATCHER_DBUS_ADDR,
124 NOTIFICATION_WATCHER_DBUS_OBJ,
125@@ -1315,6 +1372,8 @@
126 status_icon_changes(self, icon);
127
128 g_signal_connect(G_OBJECT(icon), "activate", G_CALLBACK(status_icon_activate), self);
129+ g_signal_connect(G_OBJECT(icon), "popup-menu", G_CALLBACK(status_icon_menu_activate), self);
130+ g_signal_connect(G_OBJECT(icon), "scroll-event", G_CALLBACK(scroll_event_wrapper), self);
131
132 return icon;
133 }
134@@ -1327,6 +1386,18 @@
135 return status_icon_changes(self, data);
136 }
137
138+/* A wrapper for redirecting the scroll events to the app-indicator from status
139+ icon widget. */
140+static gboolean
141+scroll_event_wrapper(GtkWidget *status_icon, GdkEventScroll *event, gpointer data)
142+{
143+ g_return_val_if_fail(IS_APP_INDICATOR(data), FALSE);
144+ AppIndicator * app = APP_INDICATOR(data);
145+ g_signal_emit(app, signals[SCROLL_EVENT], 0, 1, event->direction);
146+
147+ return FALSE;
148+}
149+
150 /* This tracks changes to either the status or the icons
151 that are associated with the app indicator */
152 static void
153@@ -1388,6 +1459,14 @@
154 return;
155 }
156
157+/* Handles the right-click action by the status icon by showing
158+ the menu in a popup. */
159+static void
160+status_icon_menu_activate (GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data)
161+{
162+ status_icon_activate(status_icon, user_data);
163+}
164+
165 /* Removes the status icon as the application indicator area
166 is now up and running again. */
167 static void
168@@ -1395,6 +1474,7 @@
169 {
170 g_signal_handlers_disconnect_by_func(G_OBJECT(self), status_icon_status_wrapper, status_icon);
171 g_signal_handlers_disconnect_by_func(G_OBJECT(self), status_icon_changes, status_icon);
172+ g_signal_handlers_disconnect_by_func(G_OBJECT(self), scroll_event_wrapper, status_icon);
173 gtk_status_icon_set_visible(status_icon, FALSE);
174 g_object_unref(G_OBJECT(status_icon));
175 return;
176
177=== modified file 'src/app-indicator.h'
178--- src/app-indicator.h 2010-11-08 16:25:40 +0000
179+++ src/app-indicator.h 2011-02-03 11:51:50 +0000
180@@ -107,12 +107,18 @@
181
182 String identifier for the #AppIndicator::new-icon-theme-path signal.
183 */
184+/**
185+ APP_INDICATOR_SIGNAL_SCROLL_EVENT:
186+
187+ String identifier for the #AppIndicator::scroll-event signal.
188+*/
189 #define APP_INDICATOR_SIGNAL_NEW_ICON "new-icon"
190 #define APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON "new-attention-icon"
191 #define APP_INDICATOR_SIGNAL_NEW_STATUS "new-status"
192 #define APP_INDICATOR_SIGNAL_NEW_LABEL "new-label"
193 #define APP_INDICATOR_SIGNAL_CONNECTION_CHANGED "connection-changed"
194 #define APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH "new-icon-theme-path"
195+#define APP_INDICATOR_SIGNAL_SCROLL_EVENT "scroll-event"
196
197 /**
198 AppIndicatorCategory:
199@@ -163,7 +169,7 @@
200 @new_icon_theme_path: Slot for #AppIndicator::new-icon-theme-path
201 @new_label: Slot for #AppIndicator::new-label.
202 @connection_changed: Slot for #AppIndicator::connection-changed.
203- @app_indicator_reserved_sw: Reserved for future use.
204+ @scroll-event: Slot for #AppIndicator::scroll-event
205 @app_indicator_reserved_ats: Reserved for future use.
206 @fallback: Function that gets called to make a #GtkStatusIcon when
207 there is no Application Indicator area available.
208@@ -203,7 +209,12 @@
209 void (* connection_changed) (AppIndicator * indicator,
210 gboolean connected,
211 gpointer user_data);
212- void (*app_indicator_reserved_sw)(void);
213+
214+ void (* scroll_event) (AppIndicator * indicator,
215+ gint delta,
216+ guint direction,
217+ gpointer user_data);
218+
219 void (*app_indicator_reserved_ats)(void);
220
221 /* Overridable Functions */
222
223=== modified file 'src/application-service-marshal.list'
224--- src/application-service-marshal.list 2010-08-18 19:02:47 +0000
225+++ src/application-service-marshal.list 2011-02-03 11:51:50 +0000
226@@ -21,3 +21,4 @@
227 VOID: INT, STRING
228 VOID: STRING, STRING
229 VOID: BOOL, STRING, OBJECT
230+VOID: INT, UINT
231
232=== modified file 'src/notification-item.xml'
233--- src/notification-item.xml 2010-08-11 20:55:25 +0000
234+++ src/notification-item.xml 2011-02-03 11:51:50 +0000
235@@ -17,7 +17,10 @@
236 <property name="XAyatanaOrderingIndex" type="u" access="read" />
237
238 <!-- Methods -->
239- <!-- None currently -->
240+ <method name="Scroll">
241+ <arg type="i" name="delta" direction="in" />
242+ <arg type="s" name="orientation" direction="in" />
243+ </method>
244
245 <!-- Signals -->
246 <signal name="NewIcon">
247@@ -34,6 +37,5 @@
248 <arg type="s" name="label" direction="out" />
249 <arg type="s" name="guide" direction="out" />
250 </signal>
251-
252 </interface>
253 </node>

Subscribers

People subscribed via source and target branches