From 395bb2190150d7ca94b72877e26c6a45a9aeda57 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 2 Dec 2004 11:30:24 +0000 Subject: From Nathan Jennings: add a preference that supplies a prefix for window titles. svn path=/trunk/; revision=12657 --- gtk/ui_util.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'gtk/ui_util.c') diff --git a/gtk/ui_util.c b/gtk/ui_util.c index 97ab2dbc9c..d350ab7dd1 100644 --- a/gtk/ui_util.c +++ b/gtk/ui_util.c @@ -570,8 +570,13 @@ GtkWidget *xpm_to_widget(const char ** xpm) { void set_main_window_name(gchar *window_name) { - gtk_window_set_title(GTK_WINDOW(top_level), window_name); - gdk_window_set_icon_name(top_level->window, window_name); + gchar *title; + + /* use user-defined window title if preference is set */ + title = create_user_window_title(window_name); + gtk_window_set_title(GTK_WINDOW(top_level), title); + gdk_window_set_icon_name(top_level->window, title); + g_free(title); } @@ -1013,3 +1018,21 @@ copy_to_clipboard(GString *str) gtk_editable_copy_clipboard((GtkEditable *)text); /* Copy the byte data into the clipboard */ #endif } + +/* + * Create a new window title string with user-defined title preference. + * (Or ignore it if unspecified). + */ +gchar * +create_user_window_title(gchar *caption) +{ + /* fail-safe */ + if (caption == NULL) + return g_strdup(""); + + /* no user-defined title specified */ + if ((prefs.gui_window_title == NULL) || (*prefs.gui_window_title == '\0')) + return g_strdup(caption); + + return g_strdup_printf("%s %s", prefs.gui_window_title, caption); +} -- cgit v1.2.3