PATCH: to change window title in gnome-terminal




Here is a patch against gnome-terminal 1.0.51 to change which adds a
menu item to change the current Windows Title.

Many, many times a have 3+ gnome-terminal windows open and, from the
task bar, I have no idea which one is which.  This patch allows me to
quickly set titles to the different terminal windows so that I can till
them apart.  Although it also possible to write a small shell script to
do the same thing using the xterm escape sequences it is often very
inconvenient to do so, such as if you are in the middle of an
application, on a remote host, etc...

I don't expect it to be included in gnome 1.50 but I hope it will be
included in the next minor release of gnome as it is a useful feature
and it the patch is fairly clean.

I am rather new to gnome development so please let me know if I did
anything stupid.

Thanks again.

PS: I am not subscribed to this list (as I am not a regular gnome
developer so please CC me).

-- 
Kevin Atkinson
kevinatk@home.com
http://metalab.unc.edu/kevina/
--- gnome-terminal.c.orig	Fri Oct  1 19:54:19 1999
+++ gnome-terminal.c	Sun Oct  3 05:07:39 1999
@@ -5,6 +5,7 @@
  * Authors: Miguel de Icaza (GNOME terminal)
  *          Erik Troan      (various configuration enhancements)
  *          Michael Zucchi  (zvt widget, various updates and enhancements)
+ *          Kevin Atkinson  (option to change the window title)
  *
  * Other contributors: George Lebl, Jeff Garzik, Jay Painter,
  * Christopher Blizzard, Jens Lautenbacher, Tom Tromey, Tristan Tarant,
@@ -152,16 +153,16 @@
  * you change the popup menus, these macros MUST be updated to reflect
  * the changes.
  */
-#define POPUP_MENU_TOGGLE_INDEX_MENUBAR 2
-#define POPUP_MENU_TOGGLE_INDEX_SECURE  3
+#define POPUP_MENU_TOGGLE_INDEX_MENUBAR 3
+#define POPUP_MENU_TOGGLE_INDEX_SECURE  4
 /* eek, multi-conditaional for backward compatability *sigh* */
 #ifdef ZVT_TERM_MATCH_SUPPORT
 # ifdef HAVE_ZVT_TERM_RESET
-#  define POPUP_MENU_DYNAMIC_INDEX 6
-#  define POPUP_MENU_LAST_INDEX 7
+#  define POPUP_MENU_DYNAMIC_INDEX 7
+#  define POPUP_MENU_LAST_INDEX 8
 # else
-#  define POPUP_MENU_DYNAMIC_INDEX 4
-#  define POPUP_MENU_LAST_INDEX 5
+#  define POPUP_MENU_DYNAMIC_INDEX 5
+#  define POPUP_MENU_LAST_INDEX 6
 # endif
 #endif
 
@@ -175,6 +176,7 @@
 void toggle_menubar_cmd   (GtkWidget *widget, ZvtTerm *term);
 void paste_cmd            (GtkWidget *widget, ZvtTerm *term);
 void preferences_cmd      (GtkWidget *widget, ZvtTerm *term);
+void window_title_cmd     (GtkWidget *widget, ZvtTerm *term);
 void toggle_secure_keyboard_cmd (GtkWidget *w, ZvtTerm *term);
 
 static int popup_menu_cmd (ZvtTerm *term, GdkEventButton *event,
@@ -201,6 +203,7 @@
 		"GNOME terminal: "
 		"    Miguel de Icaza (miguel@kernel.org)",
 		"    Erik Troan (ewt@redhat.com)",
+                "    Kevin Atkinson (kevinatk@home.com)",
 		NULL
 	};
 
@@ -1455,6 +1458,62 @@
 	save_preferences_cmd (widget, term);
 }
 
+struct window_title_dialog_info {
+	GtkWidget * title_entry;
+	GtkWindow * app;
+};
+
+void
+window_title_dialog_clk (GnomeDialog *dialog, gint num, 
+			 struct window_title_dialog_info *i) 
+{
+	if (num != 0) return;
+     
+	gtk_window_set_title(i->app, 
+			     gtk_entry_get_text(GTK_ENTRY(i->title_entry)));
+}
+
+void
+window_title_dialog_destroy (GnomeDialog *dialog,
+			     struct window_title_dialog_info *i) 
+{
+	free(i);
+}
+
+void
+window_title_cmd (GtkWidget *widget, ZvtTerm *term)
+{
+        GnomeDialog *dialog;
+	GtkWidget *g_title_entry;
+	struct window_title_dialog_info * i = 
+		malloc(sizeof(struct window_title_dialog_info));
+	
+	dialog = GNOME_DIALOG(gnome_dialog_new("Window Title", 
+					       GNOME_STOCK_BUTTON_OK,
+					       GNOME_STOCK_BUTTON_CANCEL, 
+					       NULL));
+	i->app = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET (term)));
+	gnome_dialog_set_parent(dialog, i->app);
+	gnome_dialog_set_default(dialog, 0);
+
+	g_title_entry = gnome_entry_new("Window Title");
+        gtk_box_pack_start (GTK_BOX(dialog->vbox), g_title_entry, TRUE, TRUE, 0);
+
+	i->title_entry = gnome_entry_gtk_entry(GNOME_ENTRY (g_title_entry));
+	gtk_entry_set_text(GTK_ENTRY(i->title_entry), i->app->title);
+
+	gnome_dialog_editable_enters(dialog, GTK_EDITABLE(i->title_entry));
+
+	gtk_signal_connect(GTK_OBJECT(dialog), "clicked", 
+			   GTK_SIGNAL_FUNC(window_title_dialog_clk), i);
+	gtk_signal_connect(GTK_OBJECT(dialog), "destroy", 
+			   GTK_SIGNAL_FUNC(window_title_dialog_destroy), i);
+
+	gtk_widget_show(g_title_entry);
+
+	gnome_dialog_run_and_close(dialog);
+}
+
 #ifdef HAVE_ZVT_TERM_RESET
 static void
 reset_terminal_soft_cmd (GtkWidget *widget, ZvtTerm *term)
@@ -1518,7 +1577,7 @@
 	GNOMEUIINFO_ITEM_NONE (N_("_Hide menubar"), NULL, toggle_menubar_cmd),
 	GNOMEUIINFO_SEPARATOR,
 	GNOMEUIINFO_ITEM_STOCK (N_("_Close terminal"), NULL, close_terminal_cmd,
-													GNOME_STOCK_MENU_EXIT),
+				GNOME_STOCK_MENU_EXIT),
 	GNOMEUIINFO_END
 };
 
@@ -1532,6 +1591,7 @@
 static GnomeUIInfo gnome_terminal_popup_menu [] = {
         GNOMEUIINFO_MENU_NEW_ITEM (N_("_New terminal"), N_("Creates a new terminal window"), new_terminal, NULL),
         GNOMEUIINFO_MENU_PREFERENCES_ITEM(preferences_cmd, NULL),
+	GNOMEUIINFO_ITEM_NONE (N_("Window _Title"), NULL, window_title_cmd),
 	GNOMEUIINFO_TOGGLEITEM (N_("_Show menubar"), N_("Toggles whether or not the menubar is displayed."),
 				toggle_menubar_cmd, NULL),
 	GNOMEUIINFO_TOGGLEITEM (N_("_Secure keyboard"),
@@ -1566,6 +1626,7 @@
 
 static GnomeUIInfo gnome_terminal_settings_menu [] = {
         GNOMEUIINFO_MENU_PREFERENCES_ITEM(preferences_cmd, NULL),
+	GNOMEUIINFO_ITEM_NONE (N_("Window _Title"), NULL, window_title_cmd),
 #ifdef HAVE_ZVT_TERM_RESET
 	GNOMEUIINFO_ITEM_NONE (N_("_Reset Terminal"), NULL, reset_terminal_soft_cmd),
 	GNOMEUIINFO_ITEM_NONE (N_("Reset and _Clear"), NULL, reset_terminal_hard_cmd),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]