Merge lp://qastaging/~ted/libindicator/entry-ordering into lp://qastaging/libindicator/0.4

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~ted/libindicator/entry-ordering
Merge into: lp://qastaging/libindicator/0.4
Diff against target: 358 lines (+155/-13)
9 files modified
.bzrignore (+4/-0)
Makefile.am.marshal (+45/-0)
configure.ac (+2/-0)
libindicator/Makefile.am (+8/-0)
libindicator/indicator-object-marshal.list (+1/-0)
libindicator/indicator-object.c (+52/-2)
libindicator/indicator-object.h (+9/-4)
tests/dummy-indicator-signaler.c (+1/-0)
tests/test-loader.c (+33/-7)
To merge this branch: bzr merge lp://qastaging/~ted/libindicator/entry-ordering
Reviewer Review Type Date Requested Status
David Barth Approve
Review via email: mp+17489@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

A couple little changes to the interface so that indicators can support
ordering of their entries if they so choose.

Revision history for this message
David Barth (dbarth) wrote :

Works for me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2009-12-02 21:58:52 +0000
3+++ .bzrignore 2010-01-15 22:20:22 +0000
4@@ -143,3 +143,7 @@
5 tests/service-version-tester
6 tests/service-manager-connect-nostart-tester
7 tests/service-manager-nostart-connect
8+libindicator/indicator-object-marshal.c
9+libindicator/indicator-object-marshal.h
10+libindicator/libindicator_la-indicator-object-marshal.lo
11+libindicator/stamp-marshal
12
13=== added file 'Makefile.am.marshal'
14--- Makefile.am.marshal 1970-01-01 00:00:00 +0000
15+++ Makefile.am.marshal 2010-01-15 22:20:22 +0000
16@@ -0,0 +1,45 @@
17+# Rules for generating marshal files using glib-genmarshal
18+#
19+# Define:
20+# glib_marshal_list = marshal list file
21+# glib_marshal_prefix = prefix for marshal functions
22+#
23+# before including Makefile.am.marshal. You will also need to have
24+# the following targets already defined:
25+#
26+# CLEANFILES
27+# DISTCLEANFILES
28+# BUILT_SOURCES
29+# EXTRA_DIST
30+#
31+# Author: Emmanuele Bassi <ebassi@linux.intel.com>
32+
33+marshal_h = $(glib_marshal_list:.list=.h)
34+marshal_c = $(glib_marshal_list:.list=.c)
35+
36+CLEANFILES += stamp-marshal
37+DISTCLEANFILES += $(marshal_h) $(marshal_c)
38+BUILT_SOURCES += $(marshal_h) $(marshal_c)
39+EXTRA_DIST += $(glib_marshal_list)
40+
41+stamp-marshal: $(glib_marshal_list)
42+ $(QUIET_GEN)$(GLIB_GENMARSHAL) \
43+ --prefix=$(glib_marshal_prefix) \
44+ --header \
45+ $(srcdir)/$(glib_marshal_list) > xgen-mh \
46+ && (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \
47+ && rm -f xgen-mh \
48+ && echo timestamp > $(@F)
49+
50+$(marshal_h): stamp-marshal
51+ @true
52+
53+$(marshal_c): $(marshal_h)
54+ $(QUIET_GEN)(echo "#include \"$(marshal_h)\"" ; \
55+ $(GLIB_GENMARSHAL) \
56+ --prefix=$(glib_marshal_prefix) \
57+ --body \
58+ $(srcdir)/$(glib_marshal_list)) > xgen-mc \
59+ && cp xgen-mc $(marshal_c) \
60+ && rm -f xgen-mc
61+
62
63=== modified file 'configure.ac'
64--- configure.ac 2009-11-04 17:34:00 +0000
65+++ configure.ac 2010-01-15 22:20:22 +0000
66@@ -15,6 +15,8 @@
67 AC_STDC_HEADERS
68 AC_PROG_LIBTOOL
69
70+AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
71+
72 AC_SUBST(VERSION)
73 AC_CONFIG_MACRO_DIR([m4])
74
75
76=== modified file 'libindicator/Makefile.am'
77--- libindicator/Makefile.am 2009-12-02 19:56:44 +0000
78+++ libindicator/Makefile.am 2010-01-15 22:20:22 +0000
79@@ -1,8 +1,11 @@
80 BUILT_SOURCES =
81 CLEANFILES =
82+DISTCLEANFILES =
83 EXTRA_DIST = \
84 indicator.pc.in
85
86+include $(top_srcdir)/Makefile.am.marshal
87+
88 libindicatorincludedir=$(includedir)/libindicator-0.3/libindicator
89
90 indicator_headers = \
91@@ -21,6 +24,8 @@
92 $(indicator_headers) \
93 dbus-shared.h \
94 indicator-object.c \
95+ indicator-object-marshal.h \
96+ indicator-object-marshal.c \
97 indicator-service.c \
98 indicator-service-manager.c
99
100@@ -35,6 +40,9 @@
101 pkgconfig_DATA = indicator.pc
102 pkgconfigdir = $(libdir)/pkgconfig
103
104+glib_marshal_list = indicator-object-marshal.list
105+glib_marshal_prefix = _indicator_object_marshal
106+
107 ##################################
108 # DBus Specs
109 ##################################
110
111=== added file 'libindicator/indicator-object-marshal.list'
112--- libindicator/indicator-object-marshal.list 1970-01-01 00:00:00 +0000
113+++ libindicator/indicator-object-marshal.list 2010-01-15 22:20:22 +0000
114@@ -0,0 +1,1 @@
115+VOID: POINTER, UINT, UINT
116
117=== modified file 'libindicator/indicator-object.c'
118--- libindicator/indicator-object.c 2009-11-05 16:56:41 +0000
119+++ libindicator/indicator-object.c 2010-01-15 22:20:22 +0000
120@@ -27,6 +27,7 @@
121
122 #include "indicator.h"
123 #include "indicator-object.h"
124+#include "indicator-object-marshal.h"
125
126 /**
127 IndicatorObjectPrivate:
128@@ -54,6 +55,7 @@
129 enum {
130 ENTRY_ADDED,
131 ENTRY_REMOVED,
132+ ENTRY_MOVED,
133 LAST_SIGNAL
134 };
135
136@@ -86,11 +88,14 @@
137 klass->get_image = NULL;
138
139 klass->get_entries = get_entries_default;
140+ klass->get_location = NULL;
141
142 /**
143 IndicatorObject::entry-added:
144 @arg0: The #IndicatorObject object
145-
146+ @arg1: A pointer to the #IndicatorObjectEntry that
147+ is being added.
148+
149 Signaled when a new entry is added and should
150 be shown by the person using this object.
151 */
152@@ -105,7 +110,9 @@
153 /**
154 IndicatorObject::entry-removed:
155 @arg0: The #IndicatorObject object
156-
157+ @arg1: A pointer to the #IndicatorObjectEntry that
158+ is being removed.
159+
160 Signaled when an entry is removed and should
161 be removed by the person using this object.
162 */
163@@ -116,6 +123,24 @@
164 NULL, NULL,
165 g_cclosure_marshal_VOID__POINTER,
166 G_TYPE_NONE, 1, G_TYPE_POINTER, G_TYPE_NONE);
167+ /**
168+ IndicatorObject::entry-moved:
169+ @arg0: The #IndicatorObject object
170+ @arg1: A pointer to the #IndicatorObjectEntry that
171+ is being moved.
172+ @arg2: The old location of the entry
173+ @arg3: The new location of the entry
174+
175+ When the order of the entries change, then this signal
176+ is sent to tell the new location.
177+ */
178+ signals[ENTRY_MOVED] = g_signal_new (INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED,
179+ G_TYPE_FROM_CLASS(klass),
180+ G_SIGNAL_RUN_LAST,
181+ G_STRUCT_OFFSET (IndicatorObjectClass, entry_moved),
182+ NULL, NULL,
183+ _indicator_object_marshal_VOID__POINTER_UINT_UINT,
184+ G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_NONE);
185
186 return;
187 }
188@@ -342,3 +367,28 @@
189 g_error("No get_entries function on object. It must have been deleted?!?!");
190 return NULL;
191 }
192+
193+/**
194+ indicator_object_get_location:
195+ @io: #IndicatorObject to query
196+ @entry: The #IndicatorObjectEntry to look for.
197+
198+ This function looks on the class for the object and calls
199+ it's #IndicatorObjectClass::get_location function. If the
200+ function doesn't exist it returns zero.
201+
202+ Return value: Location of the @entry in the display or
203+ zero if no location is specified.
204+*/
205+guint
206+indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry)
207+{
208+ g_return_val_if_fail(INDICATOR_IS_OBJECT(io), 0);
209+ IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io);
210+
211+ if (class->get_location) {
212+ return class->get_location(io, entry);
213+ }
214+
215+ return 0;
216+}
217
218=== modified file 'libindicator/indicator-object.h'
219--- libindicator/indicator-object.h 2009-11-04 17:24:25 +0000
220+++ libindicator/indicator-object.h 2010-01-15 22:20:22 +0000
221@@ -40,6 +40,8 @@
222 #define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, INDICATOR_OBJECT_TYPE))
223 #define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED "entry-removed"
224 #define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, INDICATOR_OBJECT_TYPE))
225+#define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED "entry-moved"
226+#define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, INDICATOR_OBJECT_TYPE))
227
228 typedef struct _IndicatorObject IndicatorObject;
229 typedef struct _IndicatorObjectClass IndicatorObjectClass;
230@@ -62,12 +64,14 @@
231 a #GList of #IndicatorObjectEntries. The list should be
232 under the ownership of the caller but the entires will
233 not be.
234+ @get_location: Returns the location that a particular entry
235+ should be placed in. This is really only relevant for
236+ indicators that have more than one entry.
237 @entry_added: Slot for #IndicatorObject::entry-added
238 @entry_removed: Slot for #IndicatorObject::entry-removed
239+ @entry_moved: Slot for #IndicatorObject::entry-moved
240 @indicator_object_reserved_1: Reserved for future use
241 @indicator_object_reserved_2: Reserved for future use
242- @indicator_object_reserved_3: Reserved for future use
243- @indicator_object_reserved_4: Reserved for future use
244 */
245 struct _IndicatorObjectClass {
246 GObjectClass parent_class;
247@@ -78,16 +82,16 @@
248 GtkMenu * (*get_menu) (IndicatorObject * io);
249
250 GList * (*get_entries) (IndicatorObject * io);
251+ guint (*get_location) (IndicatorObject * io, IndicatorObjectEntry * entry);
252
253 /* Signals */
254 void (*entry_added) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);
255 void (*entry_removed) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);
256+ void (*entry_moved) (IndicatorObject * io, IndicatorObjectEntry * entry, guint old_pos, guint new_pos, gpointer user_data);
257
258 /* Reserved */
259 void (* indicator_object_reserved_1) (void);
260 void (* indicator_object_reserved_2) (void);
261- void (* indicator_object_reserved_3) (void);
262- void (* indicator_object_reserved_4) (void);
263 };
264
265 /**
266@@ -117,6 +121,7 @@
267 IndicatorObject * indicator_object_new_from_file (const gchar * file);
268
269 GList * indicator_object_get_entries (IndicatorObject * io);
270+guint indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry);
271
272 G_END_DECLS
273
274
275=== modified file 'tests/dummy-indicator-signaler.c'
276--- tests/dummy-indicator-signaler.c 2009-11-04 17:14:22 +0000
277+++ tests/dummy-indicator-signaler.c 2010-01-15 22:20:22 +0000
278@@ -81,6 +81,7 @@
279
280 g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, GUINT_TO_POINTER(5), TRUE);
281 g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, GUINT_TO_POINTER(5), TRUE);
282+ g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID, 0, GUINT_TO_POINTER(5), 0, 1, TRUE);
283
284 return FALSE; /* Don't queue again */
285 }
286
287=== modified file 'tests/test-loader.c'
288--- tests/test-loader.c 2009-11-04 17:14:22 +0000
289+++ tests/test-loader.c 2010-01-15 22:20:22 +0000
290@@ -12,15 +12,22 @@
291 }
292
293 void
294+entry_move_cb (IndicatorObject * io, IndicatorObjectEntry * entry, gint old, gint new, gpointer data)
295+{
296+ return entry_change_cb(io, entry, data);
297+}
298+
299+void
300 test_loader_filename_dummy_signaler (void)
301 {
302 IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-signaler.so");
303 g_assert(object != NULL);
304
305- gpointer added_value = NULL, removed_value = NULL;
306+ gpointer added_value = NULL, removed_value = NULL, moved_value = NULL;
307
308 g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_change_cb), &added_value);
309 g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_change_cb), &removed_value);
310+ g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_move_cb), &moved_value);
311
312 GList * list = indicator_object_get_entries(object);
313 g_assert(list != NULL);
314@@ -32,12 +39,30 @@
315
316 g_assert(GPOINTER_TO_UINT(added_value) == 5);
317 g_assert(GPOINTER_TO_UINT(removed_value) == 5);
318-
319- g_object_unref(object);
320-
321- return;
322-}
323-
324+ g_assert(GPOINTER_TO_UINT(moved_value) == 5);
325+
326+ g_object_unref(object);
327+
328+ return;
329+}
330+
331+void
332+test_loader_filename_dummy_simple_location (void)
333+{
334+ IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-simple.so");
335+ g_assert(object != NULL);
336+
337+ GList * entries = indicator_object_get_entries(object);
338+ g_assert(entries != NULL);
339+ g_assert(g_list_length(entries) == 1);
340+
341+ g_assert(indicator_object_get_location(object, (IndicatorObjectEntry *)entries->data) == 0);
342+ g_assert(indicator_object_get_location(object, NULL) == 0);
343+
344+ g_object_unref(object);
345+
346+ return;
347+}
348
349 void
350 test_loader_filename_dummy_simple_accessors (void)
351@@ -125,6 +150,7 @@
352 g_test_add_func ("/libindicator/loader/dummy/blank_load", test_loader_filename_dummy_null);
353 g_test_add_func ("/libindicator/loader/dummy/simple_load", test_loader_filename_dummy_simple);
354 g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors);
355+ g_test_add_func ("/libindicator/loader/dummy/simple_location", test_loader_filename_dummy_simple_location);
356 g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler);
357
358 return;

Subscribers

People subscribed via source and target branches