aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-01-19 08:46:48 -0600
committerTed Gould <ted@gould.cx>2010-01-19 08:46:48 -0600
commiteaf87facbcfdf77ffe62ea35fd1601ea164e0cde (patch)
treee0625d9b129dcecb1d36e3a4c49663561b0ccf80
parente36616bc9cd4db807a3fd009502dcca31222d755 (diff)
parenta1032ca3e9954f40451c1d0cddcf5e1dcbedd721 (diff)
downloadlibayatana-indicator-eaf87facbcfdf77ffe62ea35fd1601ea164e0cde.tar.gz
libayatana-indicator-eaf87facbcfdf77ffe62ea35fd1601ea164e0cde.tar.bz2
libayatana-indicator-eaf87facbcfdf77ffe62ea35fd1601ea164e0cde.zip
Support for entries having a location and moving that location.
-rw-r--r--.bzrignore4
-rw-r--r--Makefile.am.marshal45
-rw-r--r--configure.ac2
-rw-r--r--libindicator/Makefile.am8
-rw-r--r--libindicator/indicator-object-marshal.list1
-rw-r--r--libindicator/indicator-object.c54
-rw-r--r--libindicator/indicator-object.h13
-rw-r--r--tests/dummy-indicator-signaler.c1
-rw-r--r--tests/test-loader.c28
9 files changed, 149 insertions, 7 deletions
diff --git a/.bzrignore b/.bzrignore
index 1d9c02d..22df703 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -143,3 +143,7 @@ tests/service-version-manager
tests/service-version-tester
tests/service-manager-connect-nostart-tester
tests/service-manager-nostart-connect
+libindicator/indicator-object-marshal.c
+libindicator/indicator-object-marshal.h
+libindicator/libindicator_la-indicator-object-marshal.lo
+libindicator/stamp-marshal
diff --git a/Makefile.am.marshal b/Makefile.am.marshal
new file mode 100644
index 0000000..a6ab024
--- /dev/null
+++ b/Makefile.am.marshal
@@ -0,0 +1,45 @@
+# Rules for generating marshal files using glib-genmarshal
+#
+# Define:
+# glib_marshal_list = marshal list file
+# glib_marshal_prefix = prefix for marshal functions
+#
+# before including Makefile.am.marshal. You will also need to have
+# the following targets already defined:
+#
+# CLEANFILES
+# DISTCLEANFILES
+# BUILT_SOURCES
+# EXTRA_DIST
+#
+# Author: Emmanuele Bassi <ebassi@linux.intel.com>
+
+marshal_h = $(glib_marshal_list:.list=.h)
+marshal_c = $(glib_marshal_list:.list=.c)
+
+CLEANFILES += stamp-marshal
+DISTCLEANFILES += $(marshal_h) $(marshal_c)
+BUILT_SOURCES += $(marshal_h) $(marshal_c)
+EXTRA_DIST += $(glib_marshal_list)
+
+stamp-marshal: $(glib_marshal_list)
+ $(QUIET_GEN)$(GLIB_GENMARSHAL) \
+ --prefix=$(glib_marshal_prefix) \
+ --header \
+ $(srcdir)/$(glib_marshal_list) > xgen-mh \
+ && (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \
+ && rm -f xgen-mh \
+ && echo timestamp > $(@F)
+
+$(marshal_h): stamp-marshal
+ @true
+
+$(marshal_c): $(marshal_h)
+ $(QUIET_GEN)(echo "#include \"$(marshal_h)\"" ; \
+ $(GLIB_GENMARSHAL) \
+ --prefix=$(glib_marshal_prefix) \
+ --body \
+ $(srcdir)/$(glib_marshal_list)) > xgen-mc \
+ && cp xgen-mc $(marshal_c) \
+ && rm -f xgen-mc
+
diff --git a/configure.ac b/configure.ac
index 676af4e..04d7d38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,6 +15,8 @@ AM_PROG_CC_C_O
AC_STDC_HEADERS
AC_PROG_LIBTOOL
+AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
+
AC_SUBST(VERSION)
AC_CONFIG_MACRO_DIR([m4])
diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am
index 6d5c627..19247ce 100644
--- a/libindicator/Makefile.am
+++ b/libindicator/Makefile.am
@@ -1,8 +1,11 @@
BUILT_SOURCES =
CLEANFILES =
+DISTCLEANFILES =
EXTRA_DIST = \
indicator.pc.in
+include $(top_srcdir)/Makefile.am.marshal
+
libindicatorincludedir=$(includedir)/libindicator-0.3/libindicator
indicator_headers = \
@@ -21,6 +24,8 @@ libindicator_la_SOURCES = \
$(indicator_headers) \
dbus-shared.h \
indicator-object.c \
+ indicator-object-marshal.h \
+ indicator-object-marshal.c \
indicator-service.c \
indicator-service-manager.c
@@ -35,6 +40,9 @@ libindicator_la_LIBADD = \
pkgconfig_DATA = indicator.pc
pkgconfigdir = $(libdir)/pkgconfig
+glib_marshal_list = indicator-object-marshal.list
+glib_marshal_prefix = _indicator_object_marshal
+
##################################
# DBus Specs
##################################
diff --git a/libindicator/indicator-object-marshal.list b/libindicator/indicator-object-marshal.list
new file mode 100644
index 0000000..5c11033
--- /dev/null
+++ b/libindicator/indicator-object-marshal.list
@@ -0,0 +1 @@
+VOID: POINTER, UINT, UINT
diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c
index e87fa5f..87cd648 100644
--- a/libindicator/indicator-object.c
+++ b/libindicator/indicator-object.c
@@ -27,6 +27,7 @@ License along with this library. If not, see
#include "indicator.h"
#include "indicator-object.h"
+#include "indicator-object-marshal.h"
/**
IndicatorObjectPrivate:
@@ -54,6 +55,7 @@ struct _IndicatorObjectPrivate {
enum {
ENTRY_ADDED,
ENTRY_REMOVED,
+ ENTRY_MOVED,
LAST_SIGNAL
};
@@ -86,11 +88,14 @@ indicator_object_class_init (IndicatorObjectClass *klass)
klass->get_image = NULL;
klass->get_entries = get_entries_default;
+ klass->get_location = NULL;
/**
IndicatorObject::entry-added:
@arg0: The #IndicatorObject object
-
+ @arg1: A pointer to the #IndicatorObjectEntry that
+ is being added.
+
Signaled when a new entry is added and should
be shown by the person using this object.
*/
@@ -105,7 +110,9 @@ indicator_object_class_init (IndicatorObjectClass *klass)
/**
IndicatorObject::entry-removed:
@arg0: The #IndicatorObject object
-
+ @arg1: A pointer to the #IndicatorObjectEntry that
+ is being removed.
+
Signaled when an entry is removed and should
be removed by the person using this object.
*/
@@ -116,6 +123,24 @@ indicator_object_class_init (IndicatorObjectClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER, G_TYPE_NONE);
+ /**
+ IndicatorObject::entry-moved:
+ @arg0: The #IndicatorObject object
+ @arg1: A pointer to the #IndicatorObjectEntry that
+ is being moved.
+ @arg2: The old location of the entry
+ @arg3: The new location of the entry
+
+ When the order of the entries change, then this signal
+ is sent to tell the new location.
+ */
+ signals[ENTRY_MOVED] = g_signal_new (INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED,
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IndicatorObjectClass, entry_moved),
+ NULL, NULL,
+ _indicator_object_marshal_VOID__POINTER_UINT_UINT,
+ G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_NONE);
return;
}
@@ -342,3 +367,28 @@ indicator_object_get_entries (IndicatorObject * io)
g_error("No get_entries function on object. It must have been deleted?!?!");
return NULL;
}
+
+/**
+ indicator_object_get_location:
+ @io: #IndicatorObject to query
+ @entry: The #IndicatorObjectEntry to look for.
+
+ This function looks on the class for the object and calls
+ it's #IndicatorObjectClass::get_location function. If the
+ function doesn't exist it returns zero.
+
+ Return value: Location of the @entry in the display or
+ zero if no location is specified.
+*/
+guint
+indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry)
+{
+ g_return_val_if_fail(INDICATOR_IS_OBJECT(io), 0);
+ IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io);
+
+ if (class->get_location) {
+ return class->get_location(io, entry);
+ }
+
+ return 0;
+}
diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h
index c100d02..0356d1c 100644
--- a/libindicator/indicator-object.h
+++ b/libindicator/indicator-object.h
@@ -40,6 +40,8 @@ G_BEGIN_DECLS
#define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED "entry-removed"
#define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, INDICATOR_OBJECT_TYPE))
+#define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED "entry-moved"
+#define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, INDICATOR_OBJECT_TYPE))
typedef struct _IndicatorObject IndicatorObject;
typedef struct _IndicatorObjectClass IndicatorObjectClass;
@@ -62,12 +64,14 @@ typedef struct _IndicatorObjectEntry IndicatorObjectEntry;
a #GList of #IndicatorObjectEntries. The list should be
under the ownership of the caller but the entires will
not be.
+ @get_location: Returns the location that a particular entry
+ should be placed in. This is really only relevant for
+ indicators that have more than one entry.
@entry_added: Slot for #IndicatorObject::entry-added
@entry_removed: Slot for #IndicatorObject::entry-removed
+ @entry_moved: Slot for #IndicatorObject::entry-moved
@indicator_object_reserved_1: Reserved for future use
@indicator_object_reserved_2: Reserved for future use
- @indicator_object_reserved_3: Reserved for future use
- @indicator_object_reserved_4: Reserved for future use
*/
struct _IndicatorObjectClass {
GObjectClass parent_class;
@@ -78,16 +82,16 @@ struct _IndicatorObjectClass {
GtkMenu * (*get_menu) (IndicatorObject * io);
GList * (*get_entries) (IndicatorObject * io);
+ guint (*get_location) (IndicatorObject * io, IndicatorObjectEntry * entry);
/* Signals */
void (*entry_added) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);
void (*entry_removed) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);
+ void (*entry_moved) (IndicatorObject * io, IndicatorObjectEntry * entry, guint old_pos, guint new_pos, gpointer user_data);
/* Reserved */
void (* indicator_object_reserved_1) (void);
void (* indicator_object_reserved_2) (void);
- void (* indicator_object_reserved_3) (void);
- void (* indicator_object_reserved_4) (void);
};
/**
@@ -117,6 +121,7 @@ GType indicator_object_get_type (void);
IndicatorObject * indicator_object_new_from_file (const gchar * file);
GList * indicator_object_get_entries (IndicatorObject * io);
+guint indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry);
G_END_DECLS
diff --git a/tests/dummy-indicator-signaler.c b/tests/dummy-indicator-signaler.c
index 0444110..9bd01bf 100644
--- a/tests/dummy-indicator-signaler.c
+++ b/tests/dummy-indicator-signaler.c
@@ -81,6 +81,7 @@ idle_signal (gpointer data)
g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, GUINT_TO_POINTER(5), TRUE);
g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, GUINT_TO_POINTER(5), TRUE);
+ g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID, 0, GUINT_TO_POINTER(5), 0, 1, TRUE);
return FALSE; /* Don't queue again */
}
diff --git a/tests/test-loader.c b/tests/test-loader.c
index 485a951..f5e05dc 100644
--- a/tests/test-loader.c
+++ b/tests/test-loader.c
@@ -12,15 +12,22 @@ entry_change_cb (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer da
}
void
+entry_move_cb (IndicatorObject * io, IndicatorObjectEntry * entry, gint old, gint new, gpointer data)
+{
+ return entry_change_cb(io, entry, data);
+}
+
+void
test_loader_filename_dummy_signaler (void)
{
IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-signaler.so");
g_assert(object != NULL);
- gpointer added_value = NULL, removed_value = NULL;
+ gpointer added_value = NULL, removed_value = NULL, moved_value = NULL;
g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_change_cb), &added_value);
g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_change_cb), &removed_value);
+ g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_move_cb), &moved_value);
GList * list = indicator_object_get_entries(object);
g_assert(list != NULL);
@@ -32,12 +39,30 @@ test_loader_filename_dummy_signaler (void)
g_assert(GPOINTER_TO_UINT(added_value) == 5);
g_assert(GPOINTER_TO_UINT(removed_value) == 5);
+ g_assert(GPOINTER_TO_UINT(moved_value) == 5);
g_object_unref(object);
return;
}
+void
+test_loader_filename_dummy_simple_location (void)
+{
+ IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-simple.so");
+ g_assert(object != NULL);
+
+ GList * entries = indicator_object_get_entries(object);
+ g_assert(entries != NULL);
+ g_assert(g_list_length(entries) == 1);
+
+ g_assert(indicator_object_get_location(object, (IndicatorObjectEntry *)entries->data) == 0);
+ g_assert(indicator_object_get_location(object, NULL) == 0);
+
+ g_object_unref(object);
+
+ return;
+}
void
test_loader_filename_dummy_simple_accessors (void)
@@ -125,6 +150,7 @@ test_loader_creation_deletion_suite (void)
g_test_add_func ("/libindicator/loader/dummy/blank_load", test_loader_filename_dummy_null);
g_test_add_func ("/libindicator/loader/dummy/simple_load", test_loader_filename_dummy_simple);
g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors);
+ g_test_add_func ("/libindicator/loader/dummy/simple_location", test_loader_filename_dummy_simple_location);
g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler);
return;