aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2008-12-04 20:23:23 -0800
committerTed Gould <ted@canonical.com>2008-12-04 20:23:23 -0800
commit438133c2b41302c89905edb3b3705aceb43289de (patch)
tree6a094da29afa0f043fa9a7f6ea2d0abf9ab29d53
parent2253177c635527479c2d6b096dcb870b9600f3da (diff)
downloadlibayatana-indicator-438133c2b41302c89905edb3b3705aceb43289de.tar.gz
libayatana-indicator-438133c2b41302c89905edb3b3705aceb43289de.tar.bz2
libayatana-indicator-438133c2b41302c89905edb3b3705aceb43289de.zip
Building in a module loader
-rw-r--r--src/applet-main.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/applet-main.c b/src/applet-main.c
index f21112c..6ce1a96 100644
--- a/src/applet-main.c
+++ b/src/applet-main.c
@@ -20,10 +20,39 @@ PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_IndicatorApplet_Factory",
* init function
* ***********/
static gboolean
-load_module (const gchar * name)
+load_module (const gchar * name, GtkWidget * menu)
{
+ g_debug("Looking at Module: %s", name);
+ g_return_val_if_fail(name != NULL, FALSE);
- return FALSE;
+ guint suffix_len = strlen(G_MODULE_SUFFIX);
+ guint name_len = strlen(name);
+
+ g_return_val_if_fail(name_len > suffix_len, FALSE);
+
+ int i;
+ for (i = 0; i < suffix_len; i++) {
+ if (name[(name_len - suffix_len) + i] != (G_MODULE_SUFFIX)[i])
+ return FALSE;
+ }
+ g_debug("Loading Module: %s", name);
+
+ gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL);
+ GModule * module = g_module_open(fullpath,
+ G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+ 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);
+
+ GtkWidget * menuitem = make_item();
+ g_return_val_if_fail(GTK_MENU_ITEM(menuitem), FALSE);
+
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+
+ return TRUE;
}
static gboolean
@@ -46,7 +75,7 @@ applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data)
const gchar * name;
while ((name = g_dir_read_name(dir)) != NULL) {
- if (load_module(name))
+ if (load_module(name, menubar))
indicators_loaded++;
}
}