comparison src/main.c @ 289:6a7298988a7a

Simplify and unify gtk_window creation with the help of the new window_new() function, that wraps gtk_window_new() call. Subclass, title and icon are set in the same call.
author zas_
date Wed, 09 Apr 2008 16:37:54 +0000
parents d1f74154463e
children b16b9b8979e5
comparison
equal deleted inserted replaced
288:d1f74154463e 289:6a7298988a7a
49 /* 49 /*
50 *----------------------------------------------------------------------------- 50 *-----------------------------------------------------------------------------
51 * misc (public) 51 * misc (public)
52 *----------------------------------------------------------------------------- 52 *-----------------------------------------------------------------------------
53 */ 53 */
54
55 GtkWidget *window_new(GtkWindowType type, const gchar *name, const gchar *icon,
56 const gchar *icon_file, const gchar *subtitle)
57 {
58 gchar *title;
59 GtkWidget *window;
60
61 window = gtk_window_new(type);
62 if (!window) return NULL;
63
64 if (subtitle)
65 {
66 title = g_strdup_printf("%s - %s", subtitle, GQ_APPNAME);
67 }
68 else
69 {
70 title = g_strdup_printf("%s", GQ_APPNAME);
71 }
72
73 gtk_window_set_title(GTK_WINDOW(window), title);
74 g_free(title);
75
76 window_set_icon(window, icon, icon_file);
77 gtk_window_set_role(GTK_WINDOW(window), name);
78 gtk_window_set_wmclass(GTK_WINDOW(window), name, GQ_WMCLASS);
79
80 return window;
81 }
54 82
55 void window_set_icon(GtkWidget *window, const gchar *icon, const gchar *file) 83 void window_set_icon(GtkWidget *window, const gchar *icon, const gchar *file)
56 { 84 {
57 if (!icon && !file) icon = PIXBUF_INLINE_ICON; 85 if (!icon && !file) icon = PIXBUF_INLINE_ICON;
58 86