[vte/vte-next: 145/223] Move window and icon title to VteBuffer



commit 4867a1d7ffa51c128c4abf79c204291a2f6c3bb9
Author: Christian Persch <chpe gnome org>
Date:   Fri Jun 10 21:59:51 2011 +0200

    Move window and icon title to VteBuffer

 doc/reference/vte-sections.txt |    4 +-
 src/vte.c                      |  187 +++++++++++++++++++++-------------------
 src/vte.h                      |    4 -
 src/vteaccess.c                |    4 +-
 src/vteapp.c                   |   26 ++----
 src/vtebuffer.h                |    6 ++
 6 files changed, 115 insertions(+), 116 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index a95801e..3817c61 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -88,9 +88,7 @@ VTE_TERMINAL_CLASS
 vte_terminal_get_char_height
 vte_terminal_get_char_width
 vte_terminal_get_column_count
-vte_terminal_get_icon_title
 vte_terminal_get_row_count
-vte_terminal_get_window_title
 
 <SUBSECTION Private>
 VteCharAttributes
@@ -114,6 +112,8 @@ vte_buffer_feed
 vte_buffer_feed_child
 vte_buffer_feed_child_binary
 vte_buffer_reset
+vte_buffer_get_icon_title
+vte_buffer_get_window_title
 
 <SUBSECTION Standard>
 VTE_TYPE_BUFFER
diff --git a/src/vte.c b/src/vte.c
index bbbff6c..aae69ea 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -142,12 +142,10 @@ enum {
         PROP_HSCROLL_POLICY,
         PROP_VSCROLL_POLICY,
         PROP_AUDIBLE_BELL,
-        PROP_ICON_TITLE,
         PROP_MOUSE_POINTER_AUTOHIDE,
         PROP_PTY_OBJECT,
         PROP_SCROLL_ON_KEYSTROKE,
         PROP_SCROLL_ON_OUTPUT,
-        PROP_WINDOW_TITLE,
         PROP_WORD_CHARS,
         PROP_VISIBLE_BELL,
         PROP_FONT_SCALE
@@ -159,13 +157,17 @@ enum {
         BUFFER_PROP_DELETE_BINDING,
         BUFFER_PROP_EMULATION,
         BUFFER_PROP_ENCODING,
-        BUFFER_PROP_SCROLLBACK_LINES
+        BUFFER_PROP_SCROLLBACK_LINES,
+        BUFFER_PROP_ICON_TITLE,
+        BUFFER_PROP_WINDOW_TITLE,
 };
 
 enum {
         BUFFER_COMMIT,
         BUFFER_EMULATION_CHANGED,
         BUFFER_ENCODING_CHANGED,
+        BUFFER_WINDOW_TITLE_CHANGED,
+        BUFFER_ICON_TITLE_CHANGED,
         LAST_BUFFER_SIGNAL,
 };
 
@@ -10671,9 +10673,6 @@ vte_terminal_get_property (GObject *object,
                 case PROP_AUDIBLE_BELL:
                         g_value_set_boolean (value, vte_terminal_get_audible_bell (terminal));
                         break;
-                case PROP_ICON_TITLE:
-                        g_value_set_string (value, vte_terminal_get_icon_title (terminal));
-                        break;
                 case PROP_MOUSE_POINTER_AUTOHIDE:
                         g_value_set_boolean (value, vte_terminal_get_mouse_autohide (terminal));
                         break;
@@ -10686,9 +10685,6 @@ vte_terminal_get_property (GObject *object,
                 case PROP_SCROLL_ON_OUTPUT:
                         g_value_set_boolean (value, pvt->scroll_on_output);
                         break;
-                case PROP_WINDOW_TITLE:
-                        g_value_set_string (value, vte_terminal_get_window_title (terminal));
-                        break;
                 case PROP_WORD_CHARS:
                         g_value_set_string (value, NULL /* FIXME */);
                         break;
@@ -10757,8 +10753,6 @@ vte_terminal_set_property (GObject *object,
 
                 /* Not writable */
                 case PROP_BUFFER:
-                case PROP_ICON_TITLE:
-                case PROP_WINDOW_TITLE:
                         g_assert_not_reached ();
                         break;
 
@@ -10839,8 +10833,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
 	klass->eof = NULL;
 	klass->child_exited = NULL;
 	klass->char_size_changed = NULL;
-	klass->window_title_changed = NULL;
-	klass->icon_title_changed = NULL;
 	klass->selection_changed = NULL;
 	klass->contents_changed = NULL;
 	klass->cursor_moved = NULL;
@@ -10913,36 +10905,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
                              1, G_TYPE_INT);
 
         /**
-         * VteTerminal::window-title-changed:
-         * @vteterminal: the object which received the signal
-         *
-         * Emitted when the terminal's %window_title field is modified.
-         */
-                g_signal_new(I_("window-title-changed"),
-			     G_OBJECT_CLASS_TYPE(klass),
-			     G_SIGNAL_RUN_LAST,
-			     G_STRUCT_OFFSET(VteTerminalClass, window_title_changed),
-			     NULL,
-			     NULL,
-                             g_cclosure_marshal_VOID__VOID,
-			     G_TYPE_NONE, 0);
-
-        /**
-         * VteTerminal::icon-title-changed:
-         * @vteterminal: the object which received the signal
-         *
-         * Emitted when the terminal's %icon_title field is modified.
-         */
-                g_signal_new(I_("icon-title-changed"),
-			     G_OBJECT_CLASS_TYPE(klass),
-			     G_SIGNAL_RUN_LAST,
-			     G_STRUCT_OFFSET(VteTerminalClass, icon_title_changed),
-			     NULL,
-			     NULL,
-                             g_cclosure_marshal_VOID__VOID,
-			     G_TYPE_NONE, 0);
-
-        /**
          * VteTerminal::char-size-changed:
          * @vteterminal: the object which received the signal
          * @width: the new character cell width
@@ -11355,20 +11317,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
         /**
-         * VteTerminal:icon-title:
-         *
-         * The terminal's so-called icon title, or %NULL if no icon title has been set.
-         * 
-         * Since: 0.20
-         */
-        g_object_class_install_property
-                (gobject_class,
-                 PROP_ICON_TITLE,
-                 g_param_spec_string ("icon-title", NULL, NULL,
-                                      NULL,
-                                      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-     
-        /**
          * VteTerminal:pointer-autohide:
          *
          * Controls the value of the terminal's mouse autohide setting.  When autohiding
@@ -11431,20 +11379,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
      
         /**
-         * VteTerminal:window-title:
-         *
-         * The terminal's title.
-         * 
-         * Since: 0.20
-         */
-        g_object_class_install_property
-                (gobject_class,
-                 PROP_WINDOW_TITLE,
-                 g_param_spec_string ("window-title", NULL, NULL,
-                                      NULL,
-                                      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-     
-        /**
          * VteTerminal:word-chars:
          *
          * When the user double-clicks to start selection, the terminal will extend
@@ -12492,29 +12426,29 @@ vte_terminal_get_column_count(VteTerminal *terminal)
 }
 
 /**
- * vte_terminal_get_window_title:
- * @terminal: a #VteTerminal
+ * vte_buffer_get_window_title:
+ * @buffer: a #VteBuffer
  *
  * Returns: (transfer none): the window title
  */
 const char *
-vte_terminal_get_window_title(VteTerminal *terminal)
+vte_buffer_get_window_title(VteBuffer *buffer)
 {
-	g_return_val_if_fail(VTE_IS_TERMINAL(terminal), "");
-	return terminal->pvt->window_title;
+	g_return_val_if_fail(VTE_IS_BUFFER(buffer), "");
+	return buffer->pvt->window_title;
 }
 
 /**
- * vte_terminal_get_icon_title:
- * @terminal: a #VteTerminal
+ * vte_buffer_get_icon_title:
+ * @buffer: a #VteBuffer
  *
  * Returns: (transfer none): the icon title
  */
 const char *
-vte_terminal_get_icon_title(VteTerminal *terminal)
+vte_buffer_get_icon_title(VteBuffer *buffer)
 {
-	g_return_val_if_fail(VTE_IS_TERMINAL(terminal), "");
-	return terminal->pvt->icon_title;
+	g_return_val_if_fail(VTE_IS_BUFFER(buffer), "");
+	return buffer->pvt->icon_title;
 }
 
 /**
@@ -12841,32 +12775,34 @@ need_processing (VteTerminal *terminal)
 
 /* Emit an "icon-title-changed" signal. */
 static void
-vte_terminal_emit_icon_title_changed(VteTerminal *terminal)
+vte_buffer_emit_icon_title_changed(VteBuffer *buffer)
 {
 	_vte_debug_print(VTE_DEBUG_SIGNALS,
 			"Emitting `icon-title-changed'.\n");
-	g_signal_emit_by_name(terminal, "icon-title-changed");
+	g_signal_emit(buffer, buffer_signals[BUFFER_ICON_TITLE_CHANGED], 0);
 }
 
 /* Emit a "window-title-changed" signal. */
 static void
-vte_terminal_emit_window_title_changed(VteTerminal *terminal)
+vte_buffer_emit_window_title_changed(VteBuffer *buffer)
 {
 	_vte_debug_print(VTE_DEBUG_SIGNALS,
 			"Emitting `window-title-changed'.\n");
-	g_signal_emit_by_name(terminal, "window-title-changed");
+	g_signal_emit(buffer, buffer_signals[BUFFER_WINDOW_TITLE_CHANGED], 0);
 }
 
 static void
 vte_terminal_emit_pending_signals(VteTerminal *terminal)
 {
-        GObject *object;
+        GObject *object, *buffer_object;
 	GdkWindow *window;
 
 	object = G_OBJECT (terminal);
 	window = gtk_widget_get_window (&terminal->widget);
+        buffer_object = G_OBJECT(terminal->term_pvt->buffer);
 
         g_object_freeze_notify(object);
+        g_object_freeze_notify(buffer_object);
 
 	vte_terminal_emit_adjustment_changed (terminal);
 
@@ -12882,8 +12818,8 @@ vte_terminal_emit_pending_signals(VteTerminal *terminal)
 
 		if (window)
 			gdk_window_set_title (window, terminal->pvt->window_title);
-		vte_terminal_emit_window_title_changed(terminal);
-                g_object_notify(object, "window-title");
+		vte_buffer_emit_window_title_changed(terminal->term_pvt->buffer);
+                g_object_notify(buffer_object, "window-title");
 	}
 
 	if (terminal->pvt->icon_title_changed) {
@@ -12893,8 +12829,8 @@ vte_terminal_emit_pending_signals(VteTerminal *terminal)
 
 		if (window)
 			gdk_window_set_icon_name (window, terminal->pvt->icon_title);
-		vte_terminal_emit_icon_title_changed(terminal);
-                g_object_notify(object, "icon-title");
+		vte_buffer_emit_icon_title_changed(terminal->term_pvt->buffer);
+                g_object_notify(buffer_object, "icon-title");
 	}
 
 	/* Flush any pending "inserted" signals. */
@@ -12902,6 +12838,7 @@ vte_terminal_emit_pending_signals(VteTerminal *terminal)
 	vte_terminal_emit_pending_text_signals(terminal, 0);
 	vte_terminal_emit_contents_changed (terminal);
 
+        g_object_thaw_notify(buffer_object);
         g_object_thaw_notify(object);
 }
 
@@ -13642,6 +13579,12 @@ vte_buffer_get_property (GObject *object,
         case BUFFER_PROP_SCROLLBACK_LINES:
                 g_value_set_uint (value, buffer->pvt->scrollback_lines);
                 break;
+        case BUFFER_PROP_ICON_TITLE:
+                g_value_set_string(value, vte_buffer_get_icon_title(buffer));
+                break;
+        case BUFFER_PROP_WINDOW_TITLE:
+                g_value_set_string(value, vte_buffer_get_window_title(buffer));
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 return;
@@ -13672,6 +13615,12 @@ vte_buffer_set_property (GObject *object,
         case BUFFER_PROP_SCROLLBACK_LINES:
                 vte_buffer_set_scrollback_lines (buffer, g_value_get_uint (value));
                 break;
+        /* Not writable */
+        case BUFFER_PROP_ICON_TITLE:
+        case BUFFER_PROP_WINDOW_TITLE:
+                g_assert_not_reached ();
+                break;
+
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 return;
@@ -13695,6 +13644,8 @@ vte_buffer_class_init(VteBufferClass *klass)
         klass->commit = NULL;
         klass->emulation_changed = NULL;
         klass->encoding_changed = NULL;
+        klass->window_title_changed = NULL;
+        klass->icon_title_changed = NULL;
 
         /**
          * VteBuffer::commit:
@@ -13752,6 +13703,38 @@ vte_buffer_class_init(VteBufferClass *klass)
                              g_cclosure_marshal_VOID__VOID,
                              G_TYPE_NONE, 0);
 
+        /**
+         * VteBuffer::window-title-changed:
+         * @vtebuffer: the object which received the signal
+         *
+         * Emitted when the buffer's %window_title field is modified.
+         */
+        buffer_signals[BUFFER_WINDOW_TITLE_CHANGED] =
+                g_signal_new(I_("window-title-changed"),
+                             G_OBJECT_CLASS_TYPE(klass),
+                             G_SIGNAL_RUN_LAST,
+                             G_STRUCT_OFFSET(VteBufferClass, window_title_changed),
+                             NULL,
+                             NULL,
+                             g_cclosure_marshal_VOID__VOID,
+                             G_TYPE_NONE, 0);
+
+        /**
+         * VteBuffer::icon-title-changed:
+         * @vtebuffer: the object which received the signal
+         *
+         * Emitted when the buffer's %icon_title field is modified.
+         */
+        buffer_signals[BUFFER_ICON_TITLE_CHANGED] =
+                g_signal_new(I_("icon-title-changed"),
+                             G_OBJECT_CLASS_TYPE(klass),
+                             G_SIGNAL_RUN_LAST,
+                             G_STRUCT_OFFSET(VteBufferClass, icon_title_changed),
+                             NULL,
+                             NULL,
+                             g_cclosure_marshal_VOID__VOID,
+                             G_TYPE_NONE, 0);
+
         /* Properties */
 
         /**
@@ -13832,6 +13815,30 @@ vte_buffer_class_init(VteBufferClass *klass)
                                     0, G_MAXUINT,
                                     VTE_SCROLLBACK_INIT,
                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+        /**
+         * VteBuffer:icon-title:
+         *
+         * The buffer's so-called icon title, or %NULL if no icon title has been set.
+         */
+        g_object_class_install_property
+                (gobject_class,
+                 BUFFER_PROP_ICON_TITLE,
+                 g_param_spec_string ("icon-title", NULL, NULL,
+                                      NULL,
+                                      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+        /**
+         * VteBuffer:window-title:
+         *
+         * The buffer's title.
+         */
+        g_object_class_install_property
+                (gobject_class,
+                 BUFFER_PROP_WINDOW_TITLE,
+                 g_param_spec_string ("window-title", NULL, NULL,
+                                      NULL,
+                                      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 }
 
 /**
diff --git a/src/vte.h b/src/vte.h
index 8e7a896..f1516e8 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -78,8 +78,6 @@ struct _VteTerminalClass {
 	void (*eof)(VteTerminal* terminal);
 	void (*child_exited)(VteTerminal* terminal, int status);
 	void (*char_size_changed)(VteTerminal* terminal, guint char_width, guint char_height);
-	void (*window_title_changed)(VteTerminal* terminal);
-	void (*icon_title_changed)(VteTerminal* terminal);
 	void (*selection_changed)(VteTerminal* terminal);
 	void (*contents_changed)(VteTerminal* terminal);
 	void (*cursor_moved)(VteTerminal* terminal);
@@ -277,8 +275,6 @@ glong vte_terminal_get_char_width(VteTerminal *terminal);
 glong vte_terminal_get_char_height(VteTerminal *terminal);
 glong vte_terminal_get_row_count(VteTerminal *terminal);
 glong vte_terminal_get_column_count(VteTerminal *terminal);
-const char *vte_terminal_get_window_title(VteTerminal *terminal);
-const char *vte_terminal_get_icon_title(VteTerminal *terminal);
 
 /* Writing contents out */
 
diff --git a/src/vteaccess.c b/src/vteaccess.c
index c07d3e6..9c26a8f 100644
--- a/src/vteaccess.c
+++ b/src/vteaccess.c
@@ -696,7 +696,7 @@ vte_terminal_accessible_title_changed(VteTerminal *terminal, gpointer data)
 {
 	g_assert(VTE_IS_TERMINAL_ACCESSIBLE(data));
 	g_assert(VTE_IS_TERMINAL(terminal));
-	atk_object_set_description(ATK_OBJECT(data), vte_terminal_get_window_title(terminal));
+	atk_object_set_description(ATK_OBJECT(data), vte_buffer_get_window_title(vte_terminal_get_buffer(terminal)));
 }
 
 /* Reflect focus-in events. */
@@ -828,7 +828,7 @@ vte_terminal_initialize (AtkObject *obj, gpointer data)
 	}
 
 	atk_object_set_name(obj, "Terminal");
-        window_title = vte_terminal_get_window_title(terminal);
+        window_title = vte_buffer_get_window_title(vte_terminal_get_buffer(terminal));
 	atk_object_set_description(obj, window_title ? window_title : "");
 
 	atk_object_notify_state_change(obj,
diff --git a/src/vteapp.c b/src/vteapp.c
index 2dab076..18467c2 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -45,28 +45,16 @@ static const char *builtin_dingus[] = {
 };
 
 static void
-window_title_changed(GtkWidget *widget, gpointer win)
+window_title_changed(VteBuffer *buffer, GtkWindow *window)
 {
-	GtkWindow *window;
-
-	g_assert(VTE_TERMINAL(widget));
-	g_assert(GTK_IS_WINDOW(win));
-	window = GTK_WINDOW(win);
-
-	gtk_window_set_title(window, vte_terminal_get_window_title(VTE_TERMINAL(widget)));
+	gtk_window_set_title(window, vte_buffer_get_window_title(buffer));
 }
 
 static void
-icon_title_changed(GtkWidget *widget, gpointer win)
+icon_title_changed(VteBuffer *buffer, GtkWindow *window)
 {
-	GtkWindow *window;
-
-	g_assert(VTE_TERMINAL(widget));
-	g_assert(GTK_IS_WINDOW(win));
-	window = GTK_WINDOW(win);
-
 	g_message("Icon title changed to \"%s\".\n",
-		  vte_terminal_get_icon_title(VTE_TERMINAL(widget)));
+		  vte_buffer_get_icon_title(buffer));
 }
 
 static void
@@ -599,6 +587,7 @@ main(int argc, char **argv)
 	GdkVisual *visual;
 	GtkWidget *window, *widget,*hbox = NULL, *scrollbar, *scrolled_window = NULL;
 	VteTerminal *terminal;
+        VteBuffer *buffer;
 	char *env_add[] = {
 #ifdef VTE_DEBUG
 		(char *) "FOO=BAR", (char *) "BOO=BIZ",
@@ -947,6 +936,7 @@ main(int argc, char **argv)
 	/* Create the terminal widget and add it to the scrolling shell. */
 	widget = vteapp_terminal_new();
 	terminal = VTE_TERMINAL (widget);
+        buffer = vte_terminal_get_buffer(terminal);
         if (!dbuffer) {
 		gtk_widget_set_double_buffered(widget, dbuffer);
 	}
@@ -970,10 +960,10 @@ main(int argc, char **argv)
 
 	/* Connect to the "window_title_changed" signal to set the main
 	 * window's title. */
-	g_signal_connect(widget, "window-title-changed",
+	g_signal_connect(buffer, "window-title-changed",
 			 G_CALLBACK(window_title_changed), window);
 	if (icon_title) {
-		g_signal_connect(widget, "icon-title-changed",
+		g_signal_connect(buffer, "icon-title-changed",
 				 G_CALLBACK(icon_title_changed), window);
 	}
 
diff --git a/src/vtebuffer.h b/src/vtebuffer.h
index 61b3a3c..129eba0 100644
--- a/src/vtebuffer.h
+++ b/src/vtebuffer.h
@@ -49,6 +49,8 @@ struct _VteBufferClass {
                                 guint size);
   void (*emulation_changed)    (VteBuffer *buffer);
   void (*encoding_changed)     (VteBuffer *buffer);
+  void (*icon_title_changed)   (VteBuffer* buffer);
+  void (*window_title_changed) (VteBuffer* buffer);
 
   /*< private >*/
   VteBufferClassPrivate *priv;
@@ -98,6 +100,10 @@ void vte_buffer_reset                   (VteBuffer *buffer,
                                          gboolean clear_tabstops,
                                          gboolean clear_history);
 
+const char *vte_buffer_get_window_title (VteBuffer *buffer);
+
+const char *vte_buffer_get_icon_title   (VteBuffer *buffer);
+
 G_END_DECLS
 
 #endif /* VTE_BUFFER_H */



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