Factored some more code

This commit is contained in:
Pierre Pronchery 2013-11-21 05:40:49 +01:00
parent 5502c26fa9
commit dbcf0dc6c5
3 changed files with 10 additions and 18 deletions

View File

@ -124,6 +124,10 @@ static int _helper_append(PanelAppletHelper * helper, PanelWindow * window,
/* panel_init */
int panel_init(Panel * panel, GtkIconSize iconsize)
{
GdkScreen * screen;
GdkWindow * root;
GdkRectangle rect;
if((panel->config = config_new()) == NULL)
return -1;
panel_window_init(&panel->top, iconsize);
@ -132,6 +136,12 @@ int panel_init(Panel * panel, GtkIconSize iconsize)
panel->ab_window = NULL;
panel->lo_window = NULL;
panel->sh_window = NULL;
/* root window */
screen = gdk_screen_get_default();
root = gdk_screen_get_root_window(screen);
gdk_screen_get_monitor_geometry(screen, 0, &rect);
panel->root_height = rect.height;
panel->root_width = rect.width;
return 0;
}

View File

@ -68,9 +68,6 @@ static int _notify(GtkIconSize iconsize, int timeout, char * applets[])
char * filename;
size_t i;
PanelAppletHelper helper;
GdkScreen * screen;
GdkWindow * root;
GdkRectangle rect;
panel_init(&panel, iconsize);
if((filename = _config_get_filename()) != NULL
@ -94,12 +91,6 @@ static int _notify(GtkIconSize iconsize, int timeout, char * applets[])
if(timeout > 0)
panel.timeout = g_timeout_add(timeout * 1000,
_notify_on_timeout, &panel);
/* root window */
screen = gdk_screen_get_default();
root = gdk_screen_get_root_window(screen);
gdk_screen_get_monitor_geometry(screen, 0, &rect);
panel.root_height = rect.height;
panel.root_width = rect.width;
gtk_main();
panel_destroy(&panel);
return 0;

View File

@ -64,9 +64,6 @@ static int _test(GtkIconSize iconsize, char * applets[])
char * filename;
size_t i;
PanelAppletHelper helper;
GdkScreen * screen;
GdkWindow * root;
GdkRectangle rect;
panel_init(&panel, iconsize);
if((filename = _config_get_filename()) != NULL
@ -79,12 +76,6 @@ static int _test(GtkIconSize iconsize, char * applets[])
_helper_append(&helper, &panel.top, applets[i]);
gtk_widget_show_all(panel.top.window);
panel.timeout = 0;
/* root window */
screen = gdk_screen_get_default();
root = gdk_screen_get_root_window(screen);
gdk_screen_get_monitor_geometry(screen, 0, &rect);
panel.root_height = rect.height;
panel.root_width = rect.width;
gtk_main();
panel_destroy(&panel);
return 0;