From 93650be784700d574f25eb28114784d88d767ced Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 10:04:28 -0600 Subject: Adding a small little tool to load an indicator from the command line. --- .bzrignore | 1 + tools/Makefile.am | 22 +++++++++++++- tools/indicator-loader.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 tools/indicator-loader.c diff --git a/.bzrignore b/.bzrignore index 19ee10d..f11a31f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -134,3 +134,4 @@ tests/service-manager-connect-service tests/service-manager-connect-tester tests/session.conf tests/service-manager-connect.service +tools/indicator-loader diff --git a/tools/Makefile.am b/tools/Makefile.am index 9de44fc..5e5ef8d 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1 +1,21 @@ -#Something + +libexec_PROGRAMS = \ + indicator-loader + +############################# +# Indicator Loader +############################# + +indicator_loader_SOURCES = \ + indicator-loader.c + +indicator_loader_CFLAGS = \ + -Wall -Werror \ + $(LIBINDICATOR_CFLAGS) -I$(top_srcdir) \ + -DBUILD_DIR="\"$(builddir)\"" + +indicator_loader_LDADD = \ + $(LIBINDICATOR_LIBS) \ + -L$(top_builddir)/libindicator/.libs \ + -lindicator + diff --git a/tools/indicator-loader.c b/tools/indicator-loader.c new file mode 100644 index 0000000..7963656 --- /dev/null +++ b/tools/indicator-loader.c @@ -0,0 +1,74 @@ + +#include +#include + +static void +entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data) +{ + g_debug("Signal: Entry Added"); + return; +} + +static void +entry_removed (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data) +{ + g_debug("Signal: Entry Removed"); + return; +} + +static gboolean +load_module (const gchar * name, GtkWidget * menu) +{ + g_debug("Looking at Module: %s", name); + g_return_val_if_fail(name != NULL, FALSE); + + if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) { + return FALSE; + } + + g_debug("Loading Module: %s", name); + + /* Build the object for the module */ + IndicatorObject * io = indicator_object_new_from_file(name); + + /* Connect to it's signals */ + g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menu); + g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menu); + + /* Work on the entries */ + GList * entries = indicator_object_get_entries(io); + GList * entry = NULL; + + for (entry = entries; entry != NULL; entry = g_list_next(entry)) { + IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data; + entry_added(io, entrydata, menu); + } + + g_list_free(entries); + + return TRUE; +} + +int +main (int argc, char ** argv) +{ + gtk_init(&argc, &argv); + + if (argc != 2) { + g_error("Need filename"); + return 1; + } + + GtkWidget * menubar = gtk_menu_bar_new(); + if (!load_module(argv[1], menubar)) { + g_error("Unable to load module"); + return 1; + } + + GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_container_add(GTK_CONTAINER(window), menubar); + + gtk_main(); + + return 0; +} -- cgit v1.2.3 From a9b6d6fe3b408ff0827eb123a4c5bf62ae42f141 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 10:11:36 -0600 Subject: Showing the menubar and window --- tools/indicator-loader.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/indicator-loader.c b/tools/indicator-loader.c index 7963656..88cf537 100644 --- a/tools/indicator-loader.c +++ b/tools/indicator-loader.c @@ -68,6 +68,9 @@ main (int argc, char ** argv) GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_add(GTK_CONTAINER(window), menubar); + gtk_widget_show(menubar); + gtk_widget_show(window); + gtk_main(); return 0; -- cgit v1.2.3 From cd27c1b5e235076bed739375900e986d89d28e2b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 10:13:44 -0600 Subject: Grabbing the entry added function as well, didn't realize how much it did :) --- tools/indicator-loader.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/indicator-loader.c b/tools/indicator-loader.c index 88cf537..9857647 100644 --- a/tools/indicator-loader.c +++ b/tools/indicator-loader.c @@ -6,6 +6,26 @@ static void entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data) { g_debug("Signal: Entry Added"); + + GtkWidget * menuitem = gtk_menu_item_new(); + GtkWidget * hbox = gtk_hbox_new(FALSE, 3); + + if (entry->image != NULL) { + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry->image), FALSE, FALSE, 0); + } + if (entry->label != NULL) { + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry->label), FALSE, FALSE, 0); + } + gtk_container_add(GTK_CONTAINER(menuitem), hbox); + gtk_widget_show(hbox); + + if (entry->menu != NULL) { + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu)); + } + + gtk_menu_shell_append(GTK_MENU_SHELL(user_data), menuitem); + gtk_widget_show(menuitem); + return; } -- cgit v1.2.3 From b6f78fa67858712e0345c233575104902be9e5dc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 10:19:34 -0600 Subject: Stopping the app when the window closes. --- tools/indicator-loader.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/indicator-loader.c b/tools/indicator-loader.c index 9857647..feb0344 100644 --- a/tools/indicator-loader.c +++ b/tools/indicator-loader.c @@ -69,6 +69,13 @@ load_module (const gchar * name, GtkWidget * menu) return TRUE; } +static void +destroy (gpointer data) +{ + gtk_main_quit(); + return; +} + int main (int argc, char ** argv) { @@ -86,6 +93,8 @@ main (int argc, char ** argv) } GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); + gtk_container_add(GTK_CONTAINER(window), menubar); gtk_widget_show(menubar); -- cgit v1.2.3 From 5a914cab764be1b49e5aad9c6c50c9d4365f819d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 10:33:21 -0600 Subject: debian/control, debian/libindicator-tools: Adding in a new package for the tools of libindicator. --- debian/changelog | 2 ++ debian/control | 7 +++++++ debian/libindicator-tools.install | 1 + 3 files changed, 10 insertions(+) create mode 100644 debian/libindicator-tools.install diff --git a/debian/changelog b/debian/changelog index bda1693..e6a0715 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ libindicator (0.3.0~dev-0ubuntu1~ppa6~tl1) UNRELEASED; urgency=low * Adding a new tool to load indicators from the command line. + * debian/control, debian/libindicator-tools: Adding in a new + package for the tools of libindicator. -- Ted Gould Tue, 24 Nov 2009 10:28:21 -0600 diff --git a/debian/control b/debian/control index f0b27ee..394ec97 100644 --- a/debian/control +++ b/debian/control @@ -38,3 +38,10 @@ Description: GNOME panel indicator applet - shared library . This package contains files that are needed to build applications. +Package: libindicator-tools +Section: devel +Architecture: any +Depends: ${shlibs:Depends}, + ${misc:Depends} +Description: Need a better description + diff --git a/debian/libindicator-tools.install b/debian/libindicator-tools.install new file mode 100644 index 0000000..e9565f0 --- /dev/null +++ b/debian/libindicator-tools.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libindicator/* -- cgit v1.2.3 From 06ac252b809a6d7ca932a694ff499d7db2bab6e5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 10:34:31 -0600 Subject: releasing version 0.3.0~dev-0ubuntu1~ppa6~tl1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index e6a0715..b1829b6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -libindicator (0.3.0~dev-0ubuntu1~ppa6~tl1) UNRELEASED; urgency=low +libindicator (0.3.0~dev-0ubuntu1~ppa6~tl1) karmic; urgency=low * Adding a new tool to load indicators from the command line. * debian/control, debian/libindicator-tools: Adding in a new package for the tools of libindicator. - -- Ted Gould Tue, 24 Nov 2009 10:28:21 -0600 + -- Ted Gould Tue, 24 Nov 2009 10:34:29 -0600 libindicator (0.3.0~dev-0ubuntu1~ppa5) karmic; urgency=low -- cgit v1.2.3 From bfb7a29cb4e8de7ac9bd8376ecdedfded0cbcac0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 14:50:53 -0600 Subject: Adding support for removing entries --- tools/indicator-loader.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/indicator-loader.c b/tools/indicator-loader.c index feb0344..4df430e 100644 --- a/tools/indicator-loader.c +++ b/tools/indicator-loader.c @@ -2,6 +2,8 @@ #include #include +#define ENTRY_DATA_NAME "indicator-custom-entry-data" + static void entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data) { @@ -26,6 +28,21 @@ entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_d gtk_menu_shell_append(GTK_MENU_SHELL(user_data), menuitem); gtk_widget_show(menuitem); + g_object_set_data(G_OBJECT(menuitem), ENTRY_DATA_NAME, entry); + + return; +} + +static void +entry_removed_cb (GtkWidget * widget, gpointer userdata) +{ + gpointer data = g_object_get_data(G_OBJECT(widget), ENTRY_DATA_NAME); + + if (data != userdata) { + return; + } + + gtk_widget_destroy(widget); return; } @@ -33,6 +50,9 @@ static void entry_removed (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data) { g_debug("Signal: Entry Removed"); + + gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry); + return; } -- cgit v1.2.3 From 8e829711dd95a8e94bf63ec16f4d3a266f5ddc39 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 14:52:43 -0600 Subject: releasing version 0.3.0~dev-0ubuntu1~ppa6~tl2 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 728b2bd..beacae9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -libindicator (0.3.0~dev-0ubuntu1~ppa6~tl2) UNRELEASED; urgency=low +libindicator (0.3.0~dev-0ubuntu1~ppa6~tl2) karmic; urgency=low * Adding support for remove. - -- Ted Gould Tue, 24 Nov 2009 14:51:09 -0600 + -- Ted Gould Tue, 24 Nov 2009 14:52:41 -0600 libindicator (0.3.0~dev-0ubuntu1~ppa6~tl1) karmic; urgency=low -- cgit v1.2.3 From 411182c39c63d7d7ad35edf133ba58e2295f5bef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 14:55:22 -0600 Subject: debian/control: Making sure the tools package is using the same version of the library that it was built with. --- debian/changelog | 7 +++++++ debian/control | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index beacae9..f1ce3b7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +libindicator (0.3.0~dev-0ubuntu1~ppa6~tl3) UNRELEASED; urgency=low + + * debian/control: Making sure the tools package is using the + same version of the library that it was built with. + + -- Ted Gould Tue, 24 Nov 2009 14:54:28 -0600 + libindicator (0.3.0~dev-0ubuntu1~ppa6~tl2) karmic; urgency=low * Adding support for remove. diff --git a/debian/control b/debian/control index 394ec97..d4fd2f2 100644 --- a/debian/control +++ b/debian/control @@ -42,6 +42,7 @@ Package: libindicator-tools Section: devel Architecture: any Depends: ${shlibs:Depends}, - ${misc:Depends} + ${misc:Depends}, + libindicator0 (= ${binary:Version}) Description: Need a better description -- cgit v1.2.3 From d66daf8d768fcff762c14fa41161b2115fbeaee6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Nov 2009 14:56:18 -0600 Subject: releasing version 0.3.0~dev-0ubuntu1~ppa6~tl3 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index f1ce3b7..42a970f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -libindicator (0.3.0~dev-0ubuntu1~ppa6~tl3) UNRELEASED; urgency=low +libindicator (0.3.0~dev-0ubuntu1~ppa6~tl3) karmic; urgency=low * debian/control: Making sure the tools package is using the same version of the library that it was built with. - -- Ted Gould Tue, 24 Nov 2009 14:54:28 -0600 + -- Ted Gould Tue, 24 Nov 2009 14:56:15 -0600 libindicator (0.3.0~dev-0ubuntu1~ppa6~tl2) karmic; urgency=low -- cgit v1.2.3