From 62f0373e2b8c8bb54fd4c72182d40622fad1215b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 23 Nov 2009 15:44:18 -0600 Subject: Making a simple client --- .bzrignore | 3 +++ Makefile.am | 1 + configure.ac | 1 + example/Makefile.am | 19 +++++++++++++++++++ example/simple-client.c | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+) create mode 100644 example/Makefile.am create mode 100644 example/simple-client.c diff --git a/.bzrignore b/.bzrignore index b582d67..0a09d4f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -32,3 +32,6 @@ src/stamp-marshal src/dbus-properties-client.h src/dbus-properties-server.h tests/test-simple-app +example/.deps +example/.libs +example/simple-client diff --git a/Makefile.am b/Makefile.am index 4eb69d7..33f9f3e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,6 @@ SUBDIRS = data \ src \ + example \ tests DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/configure.ac b/configure.ac index 015677c..d76aec8 100644 --- a/configure.ac +++ b/configure.ac @@ -81,6 +81,7 @@ Makefile src/Makefile data/Makefile tests/Makefile +example/Makefile ]) ########################### diff --git a/example/Makefile.am b/example/Makefile.am new file mode 100644 index 0000000..954b04e --- /dev/null +++ b/example/Makefile.am @@ -0,0 +1,19 @@ + +check_PROGRAMS = \ + simple-client + +######################################### +## simple-client +######################################### + +simple_client_SOURCES = \ + simple-client.c + +simple_client_CFLAGS = \ + $(INDICATOR_CFLAGS) \ + -Wall -Werror \ + -I$(top_srcdir)/src + +simple_client_LDADD = \ + $(INDICATOR_LIBS) \ + $(top_builddir)/src/libcustomindicator.la diff --git a/example/simple-client.c b/example/simple-client.c new file mode 100644 index 0000000..1c29647 --- /dev/null +++ b/example/simple-client.c @@ -0,0 +1,34 @@ + +#include "libcustomindicator/custom-indicator.h" +#include "libdbusmenu-glib/server.h" +#include "libdbusmenu-glib/menuitem.h" + +GMainLoop * mainloop = NULL; + +int +main (int argc, char ** argv) +{ + g_type_init(); + + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, NULL)); + g_assert(ci != NULL); + + custom_indicator_set_id(ci, "example-simple-client"); + custom_indicator_set_category(ci, CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); + custom_indicator_set_icon(ci, "indicator-messages"); + custom_indicator_set_attention_icon(ci, "indicator-messages-new"); + + DbusmenuMenuitem * root = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(root, "label", "Root"); + + DbusmenuServer * menuservice = dbusmenu_server_new ("/need/a/menu/path"); + dbusmenu_server_set_root(menuservice, root); + + custom_indicator_set_menu(ci, menuservice); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return 0; +} -- cgit v1.2.3 From 009e468befbd97cf69263b47a01bc66d9a119d66 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 23 Nov 2009 15:59:30 -0600 Subject: Adding a debug message on getting an application. --- src/custom-service-appstore.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/custom-service-appstore.c b/src/custom-service-appstore.c index 6cb2dd9..fdb227a 100644 --- a/src/custom-service-appstore.c +++ b/src/custom-service-appstore.c @@ -174,6 +174,8 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err void custom_service_appstore_application_add (CustomServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { + g_debug("Adding new application: %s:%s", dbus_name, dbus_object); + /* Make sure we got a sensible request */ g_return_if_fail(IS_CUSTOM_SERVICE_APPSTORE(appstore)); g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); -- cgit v1.2.3 From 25d690a42cb12ca9136932d7ace759bbe4185f86 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 23 Nov 2009 16:35:45 -0600 Subject: Registering marshallers for DBus in the indicator. --- src/Makefile.am | 1 + src/indicator-custom.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/Makefile.am b/src/Makefile.am index 21d7cf8..102804e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ include $(top_srcdir)/Makefile.am.marshal customlibdir = $(INDICATORDIR) customlib_LTLIBRARIES = libcustom.la libcustom_la_SOURCES = \ + custom-service-marshal.c \ dbus-shared.h \ indicator-custom.c libcustom_la_CFLAGS = $(INDICATOR_CFLAGS) \ diff --git a/src/indicator-custom.c b/src/indicator-custom.c index 3bd2aa9..53e2269 100644 --- a/src/indicator-custom.c +++ b/src/indicator-custom.c @@ -16,6 +16,7 @@ /* Local Stuff */ #include "dbus-shared.h" #include "custom-service-client.h" +#include "custom-service-marshal.h" #define INDICATOR_CUSTOM_TYPE (indicator_custom_get_type ()) #define INDICATOR_CUSTOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_CUSTOM_TYPE, IndicatorCustom)) @@ -87,6 +88,10 @@ indicator_custom_class_init (IndicatorCustomClass *klass) io_class->get_entries = get_entries; + /* Register the marshallers for the dbus signals */ + dbus_g_object_register_marshaller(g_cclosure_marshal_VOID__INT, G_TYPE_INT, G_TYPE_INVALID); + dbus_g_object_register_marshaller(_custom_service_marshal_VOID__STRING_INT_STRING_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + return; } @@ -184,6 +189,7 @@ connected (IndicatorServiceManager * sm, gboolean connected, IndicatorCustom * c G_TYPE_INT, G_TYPE_NONE); + /* Connect to them */ dbus_g_proxy_connect_signal(priv->service_proxy, "ApplicationAdded", G_CALLBACK(application_added), -- cgit v1.2.3