aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore1
-rw-r--r--Makefile.am1
-rw-r--r--configure.ac2
-rw-r--r--libindicator/Makefile.am14
-rw-r--r--libindicator/indicator.h34
-rw-r--r--libindicator/indicator.pc.in16
-rw-r--r--src/Makefile.am2
-rw-r--r--src/applet-main.c51
8 files changed, 114 insertions, 7 deletions
diff --git a/.bzrignore b/.bzrignore
index a3a1e57..6e10243 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -60,6 +60,7 @@ libindicate/indicate-enum-types.h
libindicate/libindicate_la-indicate-enum-types.lo
libindicate/s-enum-types-c
libindicate/s-enum-types-h
+indicator.pc
examples/.deps
examples/.libs
examples/im-client
diff --git a/Makefile.am b/Makefile.am
index 2f11251..ac6fe90 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,7 @@
SUBDIRS = \
src \
libindicate \
+ libindicator \
examples \
tests \
data \
diff --git a/configure.ac b/configure.ac
index 496ae6a..939accd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,6 +161,8 @@ Makefile
src/Makefile
libindicate/Makefile
libindicate/indicate.pc
+libindicator/Makefile
+libindicator/indicator.pc
examples/Makefile
tests/Makefile
data/Makefile
diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am
new file mode 100644
index 0000000..be68721
--- /dev/null
+++ b/libindicator/Makefile.am
@@ -0,0 +1,14 @@
+EXTRA_DIST = \
+ indicator.pc.in
+
+libindicatorincludedir=$(includedir)/libindicator-0.1/libindicator
+
+indicator_headers = \
+ indicator.h
+
+libindicatorinclude_HEADERS = \
+ $(indicator_headers)
+
+pkgconfig_DATA = indicator.pc
+pkgconfigdir = $(libdir)/pkgconfig
+
diff --git a/libindicator/indicator.h b/libindicator/indicator.h
new file mode 100644
index 0000000..8947f5b
--- /dev/null
+++ b/libindicator/indicator.h
@@ -0,0 +1,34 @@
+
+#ifndef __LIBINDICATOR_INDICATOR_H_SEEN__
+#define __LIBINDICATOR_INDICATOR_H_SEEN__ 1
+
+#include <gtk/gtk.h>
+
+#define INDICATOR_GET_LABEL_S "get_label"
+typedef GtkLabel * (*get_label_t)(void);
+GtkLabel * get_label (void);
+
+#define INDICATOR_GET_ICON_S "get_icon"
+typedef GtkImage * (*get_icon_t) (void);
+GtkImage * get_icon (void);
+
+#define INDICATOR_GET_MENU_S "get_menu"
+typedef GtkMenu * (*get_menu_t) (void);
+GtkMenu * get_menu (void);
+
+#define INDICATOR_GET_VERSION_S "get_version"
+typedef gchar * (*get_version_t) (void);
+gchar * get_version (void);
+
+#define INDICATOR_VERSION "0.2.0"
+#define INDICATOR_SET_VERSION gchar * get_version(void) { return INDICATOR_VERSION; }
+#define INDICATOR_VERSION_CHECK(x) (!g_strcmp0(x, INDICATOR_VERSION))
+
+#define INDICATOR_GET_NAME_S "get_name"
+typedef gchar * (*get_name_t) (void);
+gchar * get_name (void);
+#define INDICATOR_SET_NAME(x) gchar * get_name(void) {return (x); }
+
+
+#endif /* __LIBINDICATOR_INDICATOR_H_SEEN__ */
+
diff --git a/libindicator/indicator.pc.in b/libindicator/indicator.pc.in
new file mode 100644
index 0000000..ba88032
--- /dev/null
+++ b/libindicator/indicator.pc.in
@@ -0,0 +1,16 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+bindir=@bindir@
+includedir=@includedir@
+
+indicatordir=${libdir}/indicators/2/
+
+Cflags: -I${includedir}/libindicator-0.1
+Requires: gtk+-2.0
+Libs:
+
+Name: libindicator
+Description: libindicator.
+Version: @VERSION@
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 818bdd9..02b70c1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,7 @@ libexec_PROGRAMS = \
indicator_applet_CFLAGS = \
-DG_LOG_DOMAIN=\""Indicator-Applet"\" \
-DDATADIR=\""$(datadir)"\" \
- -DINDICATOR_DIR=\""$(libdir)/indicators/1"\" \
+ -DINDICATOR_DIR=\""$(libdir)/indicators/2"\" \
$(APPLET_CFLAGS)
indicator_applet_SOURCES = \
diff --git a/src/applet-main.c b/src/applet-main.c
index 310cfe9..7c39d6d 100644
--- a/src/applet-main.c
+++ b/src/applet-main.c
@@ -24,7 +24,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <panel-applet.h>
#include <libgnomeui/gnome-ui-init.h>
-#define SYMBOL_NAME "get_menu_item"
+#include "libindicator/indicator.h"
+
#define ICONS_DIR (DATADIR G_DIR_SEPARATOR_S "indicator-applet" G_DIR_SEPARATOR_S "icons")
static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data);
@@ -79,14 +80,52 @@ load_module (const gchar * name, GtkWidget * menu)
g_free(fullpath);
g_return_val_if_fail(module != NULL, FALSE);
- GtkWidget * (*make_item)(void);
- g_return_val_if_fail(g_module_symbol(module, SYMBOL_NAME, (gpointer *)(&make_item)), FALSE);
- g_return_val_if_fail(make_item != NULL, FALSE);
+ get_version_t lget_version = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_VERSION_S, (gpointer *)(&lget_version)), FALSE);
+ if (!INDICATOR_VERSION_CHECK(lget_version())) {
+ g_warning("Indicator using API version '%s' we're expecting '%s'", lget_version(), INDICATOR_VERSION);
+ return FALSE;
+ }
+
+ get_label_t lget_label = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_LABEL_S, (gpointer *)(&lget_label)), FALSE);
+ g_return_val_if_fail(lget_label != NULL, FALSE);
+ GtkLabel * label = lget_label();
+
+ get_icon_t lget_icon = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_ICON_S, (gpointer *)(&lget_icon)), FALSE);
+ g_return_val_if_fail(lget_icon != NULL, FALSE);
+ GtkImage * icon = lget_icon();
+
+ get_menu_t lget_menu = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_MENU_S, (gpointer *)(&lget_menu)), FALSE);
+ g_return_val_if_fail(lget_menu != NULL, FALSE);
+ GtkMenu * lmenu = lget_menu();
+
+ if (label == NULL && icon == NULL) {
+ /* This is the case where there is nothing to display,
+ kinda odd that we'd have a module with nothing. */
+ g_warning("No label or icon. Odd.");
+ return FALSE;
+ }
+
+ GtkWidget * menuitem = gtk_menu_item_new();
+ GtkWidget * hbox = gtk_hbox_new(FALSE, 3);
+ if (icon != NULL) {
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(icon), FALSE, FALSE, 0);
+ }
+ if (label != NULL) {
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), FALSE, FALSE, 0);
+ }
+ gtk_container_add(GTK_CONTAINER(menuitem), hbox);
+ gtk_widget_show(hbox);
- GtkWidget * menuitem = make_item();
- g_return_val_if_fail(GTK_MENU_ITEM(menuitem), FALSE);
+ if (lmenu != NULL) {
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(lmenu));
+ }
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+ gtk_widget_show(menuitem);
return TRUE;
}