Factored some more code
This commit is contained in:
parent
57615321ea
commit
19960d14f6
|
@ -91,6 +91,8 @@ static void _helper_init(PanelAppletHelper * helper, Panel * panel,
|
||||||
/* useful */
|
/* useful */
|
||||||
#define HELPER_POSITION_MENU_WIDGET
|
#define HELPER_POSITION_MENU_WIDGET
|
||||||
#include "../src/helper.c"
|
#include "../src/helper.c"
|
||||||
|
static int _helper_append(PanelAppletHelper * helper, char const * applet,
|
||||||
|
GtkWidget * box);
|
||||||
|
|
||||||
|
|
||||||
/* public */
|
/* public */
|
||||||
|
@ -209,3 +211,28 @@ static void _helper_init(PanelAppletHelper * helper, Panel * panel,
|
||||||
helper->shutdown_dialog = _panel_helper_shutdown_dialog;
|
helper->shutdown_dialog = _panel_helper_shutdown_dialog;
|
||||||
helper->suspend = _panel_helper_suspend;
|
helper->suspend = _panel_helper_suspend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* useful */
|
||||||
|
/* helper_append */
|
||||||
|
static int _helper_append(PanelAppletHelper * helper, char const * applet,
|
||||||
|
GtkWidget * box)
|
||||||
|
{
|
||||||
|
Plugin * plugin;
|
||||||
|
PanelAppletDefinition * pad;
|
||||||
|
PanelApplet * pa;
|
||||||
|
GtkWidget * widget;
|
||||||
|
|
||||||
|
if((plugin = plugin_new(LIBDIR, "Panel", "applets", applet)) == NULL)
|
||||||
|
return error_print(PROGNAME);
|
||||||
|
if((pad = plugin_lookup(plugin, "applet")) == NULL)
|
||||||
|
{
|
||||||
|
plugin_delete(plugin);
|
||||||
|
return error_print(PROGNAME);
|
||||||
|
}
|
||||||
|
widget = NULL;
|
||||||
|
if((pa = pad->init(helper, &widget)) != NULL && widget != NULL)
|
||||||
|
gtk_box_pack_start(GTK_BOX(box), widget, pad->expand, pad->fill,
|
||||||
|
0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -68,12 +68,8 @@ static int _notify(GtkIconSize iconsize, int timeout, char * applets[])
|
||||||
PanelWindow top;
|
PanelWindow top;
|
||||||
char * filename;
|
char * filename;
|
||||||
GtkWidget * box;
|
GtkWidget * box;
|
||||||
GtkWidget * widget;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
Plugin * plugin;
|
|
||||||
PanelAppletHelper helper;
|
PanelAppletHelper helper;
|
||||||
PanelAppletDefinition * pad;
|
|
||||||
PanelApplet * pa;
|
|
||||||
GdkScreen * screen;
|
GdkScreen * screen;
|
||||||
GdkWindow * root;
|
GdkWindow * root;
|
||||||
GdkRectangle rect;
|
GdkRectangle rect;
|
||||||
|
@ -104,24 +100,7 @@ static int _notify(GtkIconSize iconsize, int timeout, char * applets[])
|
||||||
box = gtk_hbox_new(FALSE, 4);
|
box = gtk_hbox_new(FALSE, 4);
|
||||||
_helper_init(&helper, &panel, PANEL_APPLET_TYPE_NOTIFICATION, iconsize);
|
_helper_init(&helper, &panel, PANEL_APPLET_TYPE_NOTIFICATION, iconsize);
|
||||||
for(i = 0; applets[i] != NULL; i++)
|
for(i = 0; applets[i] != NULL; i++)
|
||||||
{
|
_helper_append(&helper, applets[i], box);
|
||||||
if((plugin = plugin_new(LIBDIR, "Panel", "applets", applets[i]))
|
|
||||||
== NULL)
|
|
||||||
{
|
|
||||||
error_print(PROGNAME);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if((pad = plugin_lookup(plugin, "applet")) == NULL)
|
|
||||||
{
|
|
||||||
plugin_delete(plugin);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
widget = NULL;
|
|
||||||
if((pa = pad->init(&helper, &widget)) != NULL
|
|
||||||
&& widget != NULL)
|
|
||||||
gtk_box_pack_start(GTK_BOX(box), widget, pad->expand,
|
|
||||||
pad->fill, 0);
|
|
||||||
}
|
|
||||||
gtk_container_add(GTK_CONTAINER(panel.window), box);
|
gtk_container_add(GTK_CONTAINER(panel.window), box);
|
||||||
gtk_widget_show_all(panel.window);
|
gtk_widget_show_all(panel.window);
|
||||||
panel.timeout = 0;
|
panel.timeout = 0;
|
||||||
|
|
23
tools/test.c
23
tools/test.c
|
@ -64,12 +64,8 @@ static int _test(GtkIconSize iconsize, char * applets[])
|
||||||
PanelWindow top;
|
PanelWindow top;
|
||||||
char * filename;
|
char * filename;
|
||||||
GtkWidget * box;
|
GtkWidget * box;
|
||||||
GtkWidget * widget;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
Plugin * plugin;
|
|
||||||
PanelAppletHelper helper;
|
PanelAppletHelper helper;
|
||||||
PanelAppletDefinition * pad;
|
|
||||||
PanelApplet * pa;
|
|
||||||
GdkScreen * screen;
|
GdkScreen * screen;
|
||||||
GdkWindow * root;
|
GdkWindow * root;
|
||||||
GdkRectangle rect;
|
GdkRectangle rect;
|
||||||
|
@ -92,24 +88,7 @@ static int _test(GtkIconSize iconsize, char * applets[])
|
||||||
box = gtk_hbox_new(FALSE, 4);
|
box = gtk_hbox_new(FALSE, 4);
|
||||||
_helper_init(&helper, &panel, PANEL_APPLET_TYPE_NORMAL, iconsize);
|
_helper_init(&helper, &panel, PANEL_APPLET_TYPE_NORMAL, iconsize);
|
||||||
for(i = 0; applets[i] != NULL; i++)
|
for(i = 0; applets[i] != NULL; i++)
|
||||||
{
|
_helper_append(&helper, applets[i], box);
|
||||||
if((plugin = plugin_new(LIBDIR, "Panel", "applets", applets[i]))
|
|
||||||
== NULL)
|
|
||||||
{
|
|
||||||
error_print(PROGNAME);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if((pad = plugin_lookup(plugin, "applet")) == NULL)
|
|
||||||
{
|
|
||||||
plugin_delete(plugin);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
widget = NULL;
|
|
||||||
if((pa = pad->init(&helper, &widget)) != NULL
|
|
||||||
&& widget != NULL)
|
|
||||||
gtk_box_pack_start(GTK_BOX(box), widget, pad->expand,
|
|
||||||
pad->fill, 0);
|
|
||||||
}
|
|
||||||
gtk_container_add(GTK_CONTAINER(panel.window), box);
|
gtk_container_add(GTK_CONTAINER(panel.window), box);
|
||||||
gtk_widget_show_all(panel.window);
|
gtk_widget_show_all(panel.window);
|
||||||
panel.timeout = 0;
|
panel.timeout = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user