[vte] widget: Move some methods to VteTerminalPrivate



commit 1a9a660f19e30a8047dd368cc2ddd7fef9bc0cdc
Author: Christian Persch <chpe gnome org>
Date:   Fri Nov 20 20:58:30 2015 +0100

    widget: Move some methods to VteTerminalPrivate

 src/vte.cc         |  128 ++++++++++++++++++++--------------------------------
 src/vtegtk.cc      |   68 +++++++++++++++-------------
 src/vtegtk.hh      |    4 ++
 src/vteinternal.hh |    2 +
 4 files changed, 91 insertions(+), 111 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index cc7ae70..13dbafd 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -85,7 +85,6 @@ static gboolean vte_terminal_io_write(GIOChannel *channel,
                                      VteTerminal *terminal);
 static void vte_terminal_background_update(VteTerminal *data);
 static void vte_terminal_process_incoming(VteTerminal *terminal);
-static void vte_terminal_emit_pending_signals(VteTerminal *terminal);
 static gboolean vte_cell_is_selected(VteTerminal *terminal,
                                     glong col, glong row, gpointer data);
 static void vte_terminal_extend_selection(VteTerminal *terminal, long x, long y,
@@ -4258,7 +4257,7 @@ next_match:
                _vte_terminal_queue_contents_changed(terminal);
        }
 
-       vte_terminal_emit_pending_signals (terminal);
+       terminal->pvt->emit_pending_signals();
 
        if (invalidated_text) {
                /* Clip off any part of the box which isn't already on-screen. */
@@ -10939,97 +10938,68 @@ need_processing (VteTerminal *terminal)
        return _vte_incoming_chunks_length (terminal->pvt->incoming) != 0;
 }
 
-/* Emit an "icon-title-changed" signal. */
-static void
-vte_terminal_emit_icon_title_changed(VteTerminal *terminal)
-{
-       _vte_debug_print(VTE_DEBUG_SIGNALS,
-                       "Emitting `icon-title-changed'.\n");
-       g_signal_emit_by_name(terminal, "icon-title-changed");
-}
-
-/* Emit a "window-title-changed" signal. */
-static void
-vte_terminal_emit_window_title_changed(VteTerminal *terminal)
-{
-       _vte_debug_print(VTE_DEBUG_SIGNALS,
-                       "Emitting `window-title-changed'.\n");
-       g_signal_emit_by_name(terminal, "window-title-changed");
-}
-
-static void
-vte_terminal_emit_current_directory_uri_changed(VteTerminal *terminal)
-{
-        _vte_debug_print(VTE_DEBUG_SIGNALS,
-                        "Emitting `current-directory-uri-changed'.\n");
-        g_signal_emit_by_name(terminal, "current-directory-uri-changed");
-}
-
-static void
-vte_terminal_emit_current_file_uri_changed(VteTerminal *terminal)
-{
-        _vte_debug_print(VTE_DEBUG_SIGNALS,
-                        "Emitting `current-file-uri-changed'.\n");
-        g_signal_emit_by_name(terminal, "current-file-uri-changed");
-}
-
-static void
-vte_terminal_emit_pending_signals(VteTerminal *terminal)
+void
+VteTerminalPrivate::emit_pending_signals()
 {
-        GObject *object;
-       GdkWindow *window;
-
-       object = G_OBJECT (terminal);
-       window = gtk_widget_get_window (&terminal->widget);
+       GdkWindow *window = gtk_widget_get_window(m_widget);
 
+       GObject *object = G_OBJECT(m_terminal);
         g_object_freeze_notify(object);
 
-       terminal->pvt->emit_adjustment_changed();
+       emit_adjustment_changed();
 
-       if (terminal->pvt->window_title_changed) {
-               g_free (terminal->pvt->window_title);
-               terminal->pvt->window_title = terminal->pvt->window_title_changed;
-               terminal->pvt->window_title_changed = NULL;
+       if (m_window_title_changed) {
+               g_free (m_window_title);
+               m_window_title = m_window_title_changed;
+               m_window_title_changed = NULL;
 
                if (window)
-                       gdk_window_set_title (window, terminal->pvt->window_title);
-               vte_terminal_emit_window_title_changed(terminal);
-                g_object_notify(object, "window-title");
+                       gdk_window_set_title (window, m_window_title);
+                _vte_debug_print(VTE_DEBUG_SIGNALS,
+                                 "Emitting `window-title-changed'.\n");
+                g_signal_emit(object, signals[SIGNAL_WINDOW_TITLE_CHANGED], 0);
+                g_object_notify_by_pspec(object, pspecs[PROP_WINDOW_TITLE]);
        }
 
-       if (terminal->pvt->icon_title_changed) {
-               g_free (terminal->pvt->icon_title);
-               terminal->pvt->icon_title = terminal->pvt->icon_title_changed;
-               terminal->pvt->icon_title_changed = NULL;
+       if (m_icon_title_changed) {
+               g_free (m_icon_title);
+               m_icon_title = m_icon_title_changed;
+               m_icon_title_changed = NULL;
 
                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");
-       }
-
-       if (terminal->pvt->current_directory_uri_changed) {
-                g_free (terminal->pvt->current_directory_uri);
-                terminal->pvt->current_directory_uri = terminal->pvt->current_directory_uri_changed;
-                terminal->pvt->current_directory_uri_changed = NULL;
-
-                vte_terminal_emit_current_directory_uri_changed(terminal);
-                g_object_notify(object, "current-directory-uri");
+                       gdk_window_set_icon_name (window, m_icon_title);
+                _vte_debug_print(VTE_DEBUG_SIGNALS,
+                                 "Emitting `icon-title-changed'.\n");
+                g_signal_emit(object, signals[SIGNAL_ICON_TITLE_CHANGED], 0);
+                g_object_notify_by_pspec(object, pspecs[PROP_ICON_TITLE]);
+       }
+
+       if (m_current_directory_uri_changed) {
+                g_free (m_current_directory_uri);
+                m_current_directory_uri = m_current_directory_uri_changed;
+                m_current_directory_uri_changed = NULL;
+
+                _vte_debug_print(VTE_DEBUG_SIGNALS,
+                                 "Emitting `current-directory-uri-changed'.\n");
+                g_signal_emit(object, signals[SIGNAL_CURRENT_DIRECTORY_URI_CHANGED], 0);
+                g_object_notify_by_pspec(object, pspecs[PROP_CURRENT_DIRECTORY_URI]);
         }
 
-        if (terminal->pvt->current_file_uri_changed) {
-                g_free (terminal->pvt->current_file_uri);
-                terminal->pvt->current_file_uri = terminal->pvt->current_file_uri_changed;
-                terminal->pvt->current_file_uri_changed = NULL;
+        if (m_current_file_uri_changed) {
+                g_free (m_current_file_uri);
+                m_current_file_uri = m_current_file_uri_changed;
+                m_current_file_uri_changed = NULL;
 
-                vte_terminal_emit_current_file_uri_changed(terminal);
-                g_object_notify(object, "current-file-uri");
+                _vte_debug_print(VTE_DEBUG_SIGNALS,
+                                 "Emitting `current-file-uri-changed'.\n");
+                g_signal_emit(object, signals[SIGNAL_CURRENT_FILE_URI_CHANGED], 0);
+                g_object_notify_by_pspec(object, pspecs[PROP_CURRENT_FILE_URI]);
         }
 
        /* Flush any pending "inserted" signals. */
-       vte_terminal_emit_cursor_moved(terminal);
-       vte_terminal_emit_pending_text_signals(terminal);
-       vte_terminal_emit_contents_changed (terminal);
+       vte_terminal_emit_cursor_moved(m_terminal);
+       vte_terminal_emit_pending_text_signals(m_terminal);
+       vte_terminal_emit_contents_changed (m_terminal);
 
         g_object_thaw_notify(object);
 }
@@ -11094,7 +11064,7 @@ process_timeout (gpointer data)
                        }
                        terminal->pvt->input_bytes = 0;
                } else
-                       vte_terminal_emit_pending_signals (terminal);
+                       terminal->pvt->emit_pending_signals();
                if (!active && terminal->pvt->update_regions == NULL) {
                        if (terminal->pvt->active != NULL) {
                                _vte_debug_print(VTE_DEBUG_TIMEOUT,
@@ -11226,7 +11196,7 @@ update_repeat_timeout (gpointer data)
                        }
                        terminal->pvt->input_bytes = 0;
                } else
-                       vte_terminal_emit_pending_signals (terminal);
+                       terminal->pvt->emit_pending_signals();
 
                again = update_regions (terminal);
                if (!again) {
@@ -11339,7 +11309,7 @@ update_timeout (gpointer data)
                        }
                        terminal->pvt->input_bytes = 0;
                } else
-                       vte_terminal_emit_pending_signals (terminal);
+                       terminal->pvt->emit_pending_signals();
 
                redraw |= update_regions (terminal);
        }
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 433e433..83e516d 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -675,14 +675,15 @@ vte_terminal_class_init(VteTerminalClass *klass)
          *
          * 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);
+        signals[SIGNAL_WINDOW_TITLE_CHANGED] =
+                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:
@@ -690,14 +691,15 @@ vte_terminal_class_init(VteTerminalClass *klass)
          *
          * 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);
+        signals[SIGNAL_ICON_TITLE_CHANGED] =
+                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::current-directory-uri-changed:
@@ -705,14 +707,15 @@ vte_terminal_class_init(VteTerminalClass *klass)
          *
          * Emitted when the current directory URI is modified.
          */
-       g_signal_new(I_("current-directory-uri-changed"),
-                    G_OBJECT_CLASS_TYPE(klass),
-                    G_SIGNAL_RUN_LAST,
-                    0,
-                    NULL,
-                    NULL,
-                    g_cclosure_marshal_VOID__VOID,
-                    G_TYPE_NONE, 0);
+        signals[SIGNAL_CURRENT_DIRECTORY_URI_CHANGED] =
+                g_signal_new(I_("current-directory-uri-changed"),
+                             G_OBJECT_CLASS_TYPE(klass),
+                             G_SIGNAL_RUN_LAST,
+                             0,
+                             NULL,
+                             NULL,
+                             g_cclosure_marshal_VOID__VOID,
+                             G_TYPE_NONE, 0);
 
         /**
          * VteTerminal::current-file-uri-changed:
@@ -720,14 +723,15 @@ vte_terminal_class_init(VteTerminalClass *klass)
          *
          * Emitted when the current file URI is modified.
          */
-       g_signal_new(I_("current-file-uri-changed"),
-                    G_OBJECT_CLASS_TYPE(klass),
-                    G_SIGNAL_RUN_LAST,
-                    0,
-                    NULL,
-                    NULL,
-                    g_cclosure_marshal_VOID__VOID,
-                    G_TYPE_NONE, 0);
+        signals[SIGNAL_CURRENT_FILE_URI_CHANGED] =
+                g_signal_new(I_("current-file-uri-changed"),
+                             G_OBJECT_CLASS_TYPE(klass),
+                             G_SIGNAL_RUN_LAST,
+                             0,
+                             NULL,
+                             NULL,
+                             g_cclosure_marshal_VOID__VOID,
+                             G_TYPE_NONE, 0);
 
         /**
          * VteTerminal::encoding-changed:
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
index 2e34935..45bde4f 100644
--- a/src/vtegtk.hh
+++ b/src/vtegtk.hh
@@ -26,6 +26,10 @@
 #pragma once
 
 enum {
+        SIGNAL_CURRENT_DIRECTORY_URI_CHANGED,
+        SIGNAL_CURRENT_FILE_URI_CHANGED,
+        SIGNAL_ICON_TITLE_CHANGED,
+        SIGNAL_WINDOW_TITLE_CHANGED,
         COPY_CLIPBOARD,
         PASTE_CLIPBOARD,
         LAST_SIGNAL
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 7649a73..94b1a86 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -542,6 +542,8 @@ public:
         void maybe_scroll_to_top();
         void maybe_scroll_to_bottom();
 
+        void emit_pending_signals();
+
         void match_contents_clear();
         void match_contents_refresh();
         void set_cursor_from_regex_match(struct vte_match_regex *regex);


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