From 4385b4835dc16d392fe6ca8d84ab6aba4a725dfe Mon Sep 17 00:00:00 2001 From: monsta Date: Wed, 8 Jun 2016 12:20:26 +0300 Subject: move module loading code into separate function --- src/applet-main.c | 67 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/src/applet-main.c b/src/applet-main.c index 7cbc18a..36a165d 100644 --- a/src/applet-main.c +++ b/src/applet-main.c @@ -550,6 +550,43 @@ load_module (const gchar * name, GtkWidget * menubar) return TRUE; } +static void +load_modules (GtkWidget *menubar, gint *indicators_loaded) +{ + if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { + GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL); + + const gchar * name; + gint count = 0; + while ((name = g_dir_read_name(dir)) != NULL) { +#ifdef INDICATOR_APPLET_APPMENU + if (g_strcmp0(name, "libappmenu.so")) { + continue; + } +#else + if (!g_strcmp0(name, "libappmenu.so")) { + continue; + } +#endif +#ifdef INDICATOR_APPLET + if (!g_strcmp0(name, "libme.so")) { + continue; + } + if (!g_strcmp0(name, "libdatetime.so")) { + continue; + } +#endif + if (load_module(name, menubar)) { + count++; + } + } + + *indicators_loaded = count; + + g_dir_close (dir); + } +} + static void hotkey_filter (char * keystring G_GNUC_UNUSED, gpointer data) { @@ -903,35 +940,7 @@ applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED, /* Add in filter func */ tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar); - /* load 'em */ - if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { - GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL); - - const gchar * name; - while ((name = g_dir_read_name(dir)) != NULL) { -#ifdef INDICATOR_APPLET_APPMENU - if (g_strcmp0(name, "libappmenu.so")) { - continue; - } -#else - if (!g_strcmp0(name, "libappmenu.so")) { - continue; - } -#endif -#ifdef INDICATOR_APPLET - if (!g_strcmp0(name, "libme.so")) { - continue; - } - if (!g_strcmp0(name, "libdatetime.so")) { - continue; - } -#endif - if (load_module(name, menubar)) { - indicators_loaded++; - } - } - g_dir_close (dir); - } + load_modules(menubar, &indicators_loaded); if (indicators_loaded == 0) { /* A label to allow for click through */ -- cgit v1.2.1