Refactor windows inittialization code
authorHugo Villeneuve <hugo@hugovil.com>
Fri, 21 Mar 2014 03:59:43 +0000 (23:59 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Fri, 21 Mar 2014 03:59:43 +0000 (23:59 -0400)
src/dockapp.c

index 7ce0fff..5a44389 100644 (file)
@@ -118,6 +118,20 @@ dockapp_set_mask(GtkWidget *iconwin, char **xpm)
        gtk_widget_shape_combine_mask(iconwin, mask, 0, 0);
 }
 
+static GtkWidget *
+dockapp_win_init(GtkWindowType window_type)
+{
+       GtkWidget *win;
+
+       win = gtk_window_new(window_type);
+       gtk_window_set_wmclass(GTK_WINDOW(win), g_get_prgname(), "DockApp");
+       gtk_widget_set_size_request(win, ICON_SIZE, ICON_SIZE);
+       gtk_widget_set_app_paintable(win, true);
+       gtk_widget_realize(win);
+
+       return win;
+}
+
 /*******************************************************************************
  * New window creation and initialization for a Dockable Application
  ******************************************************************************/
@@ -129,29 +143,16 @@ dockapp_init(int argc, char *argv[])
 
        gtk_init(&argc, &argv);
 
-       dockwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-       iconwin = gtk_window_new(GTK_WINDOW_POPUP);
-
-       gtk_window_set_wmclass(GTK_WINDOW(dockwin), g_get_prgname(), "DockApp");
-       gtk_window_set_wmclass(GTK_WINDOW(iconwin), g_get_prgname(), "DockApp");
-
-       gtk_widget_set_size_request(dockwin, ICON_SIZE, ICON_SIZE);
-       gtk_widget_set_size_request(iconwin, ICON_SIZE, ICON_SIZE);
-       gtk_widget_set_app_paintable(dockwin, TRUE);
-       gtk_widget_set_app_paintable(iconwin, TRUE);
+       dockwin = dockapp_win_init(GTK_WINDOW_TOPLEVEL);
+       iconwin = dockapp_win_init(GTK_WINDOW_POPUP);
 
        gtk_window_set_default_size(GTK_WINDOW(dockwin), ICON_SIZE, ICON_SIZE);
-
        g_signal_connect(dockwin, "destroy", G_CALLBACK(gtk_main_quit), NULL);
 
-       gtk_widget_realize(dockwin);
-       gtk_widget_realize(iconwin);
-
        /* Sets the icon of dockwin as iconwin. */
        gdk_window_set_icon(dockwin->window, iconwin->window, NULL, NULL);
 
        hvclock_init(iconwin);
-
        gtk_widget_show(iconwin);
 
 #ifdef GTK_WITHDRAWN_HACK