diff options
| author | monsta <[email protected]> | 2016-06-08 12:20:26 +0300 | 
|---|---|---|
| committer | monsta <[email protected]> | 2016-06-08 12:20:26 +0300 | 
| commit | 4385b4835dc16d392fe6ca8d84ab6aba4a725dfe (patch) | |
| tree | f3ce0e4feef8b4a5262f7014968395552014062b /src | |
| parent | 814638d93298f71bad472658ac74a643d96e624d (diff) | |
| download | mate-indicator-applet-4385b4835dc16d392fe6ca8d84ab6aba4a725dfe.tar.bz2 mate-indicator-applet-4385b4835dc16d392fe6ca8d84ab6aba4a725dfe.tar.xz | |
move module loading code into separate function
Diffstat (limited to 'src')
| -rw-r--r-- | src/applet-main.c | 67 | 
1 files 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 @@ -551,6 +551,43 @@ load_module (const gchar * name, GtkWidget * menubar)  }  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)  {  	g_return_if_fail(GTK_IS_MENU_SHELL(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 */ | 
