From 1b109ffb30ed69a1be2b848496fb554cffc5e141 Mon Sep 17 00:00:00 2001
From: Hugo Villeneuve <hugo@hugovil.com>
Date: Thu, 20 Mar 2014 23:59:43 -0400
Subject: [PATCH] Refactor windows inittialization code

---
 src/dockapp.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/dockapp.c b/src/dockapp.c
index 7ce0fff..5a44389 100644
--- a/src/dockapp.c
+++ b/src/dockapp.c
@@ -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
-- 
2.20.1