Emit "window_title_changed" and "icon_title_changed" when the titles change,
authorNalin Dahyabhai <nalin@src.gnome.org>
Mon, 11 Mar 2002 07:05:47 +0000 (07:05 +0000)
committerNalin Dahyabhai <nalin@src.gnome.org>
Mon, 11 Mar 2002 07:05:47 +0000 (07:05 +0000)
and store the new values in a public field so that a handler can retrieve the
values (patch from Anders Carlsson).

Makefile.am
configure.in
src/vte.c
src/vte.h
src/vteapp.c

index 86dae6a..700cf55 100644 (file)
@@ -1,2 +1,5 @@
 SUBDIRS = src
-EXTRA_DIST = HACKING vte.spec
+EXTRA_DIST = HACKING vte.spec vte.pc.in
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = vte.pc
index 5d68576..ff0352a 100644 (file)
@@ -41,4 +41,4 @@ if test x$VTE_DEBUG = x1 ; then
 fi
 
 AM_CONFIG_HEADER(config.h)
-AC_OUTPUT([Makefile src/Makefile])
+AC_OUTPUT([Makefile src/Makefile vte.pc])
index 00e5add..50232e0 100644 (file)
--- a/src/vte.c
+++ b/src/vte.c
@@ -1528,9 +1528,16 @@ vte_sequence_handler_set_title_int(VteTerminal *terminal,
                        }
                }
                if (outbufptr != NULL) {
-                       /* Emit the signal, passing the string. */
-                       g_signal_emit_by_name(terminal, signal, outbufptr);
-                       g_free(outbufptr);
+                       /* Emit the signal */
+                       if (strcmp(signal, "window_title_changed") == 0) {
+                               g_free(terminal->window_title);
+                               terminal->window_title = outbufptr;
+                       }
+                       else if (strcmp (signal, "icon_title_changed") == 0) {
+                               g_free (terminal->icon_title);
+                               terminal->icon_title = outbufptr;
+                       }
+                       g_signal_emit_by_name(terminal, signal);
                }
        }
 }
@@ -1543,7 +1550,7 @@ vte_sequence_handler_set_icon_title(VteTerminal *terminal,
                                    GValueArray *params)
 {
        vte_sequence_handler_set_title_int(terminal, match, match_quark,
-                                          params, "set_icon_title");
+                                          params, "icon_title_changed");
 }
 static void
 vte_sequence_handler_set_window_title(VteTerminal *terminal,
@@ -1552,7 +1559,7 @@ vte_sequence_handler_set_window_title(VteTerminal *terminal,
                                      GValueArray *params)
 {
        vte_sequence_handler_set_title_int(terminal, match, match_quark,
-                                          params, "set_window_title");
+                                          params, "window_title_changed");
 }
 
 /* Set both the window and icon titles to the same string. */
@@ -1563,9 +1570,9 @@ vte_sequence_handler_set_icon_and_window_title(VteTerminal *terminal,
                                                  GValueArray *params)
 {
        vte_sequence_handler_set_title_int(terminal, match, match_quark,
-                                          params, "set_icon_title");
+                                          params, "icon_title_changed");
        vte_sequence_handler_set_title_int(terminal, match, match_quark,
-                                          params, "set_window_title");
+                                          params, "window_title_changed");
 }
 
 /* Restrict the scrolling region. */
@@ -3265,8 +3272,7 @@ vte_uniform_class(VteTerminal *terminal, long row, long scol, long ecol)
 static gboolean
 vte_cell_is_selected(VteTerminal *terminal, long row, long col)
 {
-       guint scol, ecol, cclass, ccol;
-       struct vte_charcell *pcell;
+       guint scol, ecol;
 
        /* If there's nothing selected, it's an easy question to answer. */
        g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
@@ -4364,7 +4370,6 @@ vte_terminal_draw_char(VteTerminal *terminal,
 {
        int fore, back, dcol;
        long xcenter, ycenter, xright, ybottom;
-       long delta;
        gboolean drawn, reverse;
        XwcTextItem textitem;
 
@@ -4718,10 +4723,9 @@ vte_terminal_paint(GtkWidget *widget, GdkRectangle *area)
        Visual *visual;
        GC gc;
        struct vte_charcell *cell;
-       int row, drow, col, dcol, row_stop, col_stop, x_offs = 0, y_offs = 0;
-       int fore, back, width, height, ascent, descent, tmp;
+       int row, drow, col, row_stop, col_stop, x_offs = 0, y_offs = 0;
+       int width, height, ascent, descent;
        long delta;
-       XwcTextItem textitem;
 #ifdef HAVE_XFT
        XftDraw *ftdraw = NULL;
 #endif
@@ -4895,24 +4899,24 @@ vte_terminal_class_init(VteTerminalClass *klass, gconstpointer data)
                             NULL,
                             _vte_marshal_VOID__VOID,
                             G_TYPE_NONE, 0);
-       klass->set_window_title_signal =
-               g_signal_new("set_window_title",
+       klass->window_title_changed_signal =
+               g_signal_new("window_title_changed",
                             G_OBJECT_CLASS_TYPE(klass),
                             G_SIGNAL_RUN_LAST,
                             0,
                             NULL,
                             NULL,
-                            _vte_marshal_VOID__STRING,
-                            G_TYPE_NONE, 1, G_TYPE_STRING);
-       klass->set_icon_title_signal =
-               g_signal_new("set_icon_title",
+                            _vte_marshal_VOID__VOID,
+                            G_TYPE_NONE, 0);
+       klass->icon_title_changed_signal =
+               g_signal_new("icon_title_changed",
                             G_OBJECT_CLASS_TYPE(klass),
                             G_SIGNAL_RUN_LAST,
                             0,
                             NULL,
                             NULL,
-                            _vte_marshal_VOID__STRING,
-                            G_TYPE_NONE, 1, G_TYPE_STRING);
+                            _vte_marshal_VOID__VOID,
+                            G_TYPE_NONE, 0);
        klass->char_size_changed_signal =
                g_signal_new("char_size_changed",
                             G_OBJECT_CLASS_TYPE(klass),
index d034448..7b99295 100644 (file)
--- a/src/vte.h
+++ b/src/vte.h
@@ -48,6 +48,9 @@ typedef struct _VteTerminal {
        guint char_ascent, char_descent;/* important font metrics */
        guint row_count, column_count;  /* dimensions of the window */
 
+       /* Titles. */
+       char *window_title, *icon_title;
+       
        /*< private >*/
        struct _VteTerminalPrivate *pvt;
 } VteTerminal;
@@ -62,8 +65,8 @@ typedef struct _VteTerminalClass {
        /* Signals we might omit. */
        guint eof_signal;
        guint char_size_changed_signal;
-       guint set_window_title_signal;
-       guint set_icon_title_signal;
+       guint window_title_changed_signal;
+       guint icon_title_changed_signal;
 } VteTerminalClass;
 
 /* The widget's type. */
index 96aa448..4870052 100644 (file)
 #include "vte.h"
 
 static void
-set_window_title(GtkWidget *widget, const char *title, gpointer win)
+window_title_changed(GtkWidget *widget, gpointer win)
 {
        GtkWindow *window;
+
        g_return_if_fail(VTE_TERMINAL(widget));
        g_return_if_fail(GTK_IS_WINDOW(win));
-       g_return_if_fail(title != NULL);
+       g_return_if_fail(VTE_TERMINAL (widget)->window_title != NULL);
        window = GTK_WINDOW(win);
-       gtk_window_set_title(window, title);
+
+       gtk_window_set_title(window, VTE_TERMINAL (widget)->window_title);
 }
 
 static void
@@ -87,10 +89,10 @@ main(int argc, char **argv)
        g_signal_connect_object(G_OBJECT(widget), "char_size_changed",
                                G_CALLBACK(char_size_changed), window, 0);
 
-       /* Connect to the "set_window_title" signal to set the main window's
-        * title. */
-       g_signal_connect(G_OBJECT(widget), "set_window_title",
-                        G_CALLBACK(set_window_title), window);
+       /* Connect to the "window_title_changed" signal to set the main
+        * window's title. */
+       g_signal_connect(G_OBJECT(widget), "window_title_changed",
+                        G_CALLBACK(window_title_changed), window);
 
        /* Connect to the "eof" signal to quit when the session ends. */
        g_signal_connect(G_OBJECT(widget), "eof",