[Xfce4-commits] [apps/xfce4-terminal] 01/01: Continue moving TerminalWindow members to private struct

noreply at xfce.org noreply at xfce.org
Thu Nov 3 13:03:49 CET 2016


This is an automated email from the git hooks/post-receive script.

f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.

commit b74658ec81273d77e9ee021ccb8ec4a538dc8a2e
Author: Igor <f2404 at yandex.ru>
Date:   Thu Nov 3 15:03:44 2016 +0300

    Continue moving TerminalWindow members to private struct
---
 terminal/terminal-window-dropdown.c |  22 +++---
 terminal/terminal-window.c          | 138 +++++++++++++++++++++++-------------
 terminal/terminal-window.h          |  40 +++++------
 3 files changed, 122 insertions(+), 78 deletions(-)

diff --git a/terminal/terminal-window-dropdown.c b/terminal/terminal-window-dropdown.c
index bea130c..3088789 100644
--- a/terminal/terminal-window-dropdown.c
+++ b/terminal/terminal-window-dropdown.c
@@ -240,7 +240,7 @@ terminal_window_dropdown_init (TerminalWindowDropdown *dropdown)
 
   /* adjust notebook for drop-down usage */
   gtk_notebook_set_tab_pos (GTK_NOTEBOOK (window->notebook), GTK_POS_BOTTOM);
-  g_object_get (G_OBJECT (window->preferences), "misc-borders-default", &show_borders, NULL);
+  g_object_get (terminal_window_get_preferences (window), "misc-borders-default", &show_borders, NULL);
   gtk_notebook_set_show_border (GTK_NOTEBOOK (window->notebook), show_borders);
   terminal_window_notebook_show_tabs (window);
 
@@ -262,7 +262,7 @@ terminal_window_dropdown_init (TerminalWindowDropdown *dropdown)
   gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
 #endif
 
-  g_object_get (G_OBJECT (window->preferences), "dropdown-keep-open-default", &keep_open, NULL);
+  g_object_get (terminal_window_get_preferences (window), "dropdown-keep-open-default", &keep_open, NULL);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), keep_open);
 
   img = gtk_image_new_from_icon_name ("go-bottom", GTK_ICON_SIZE_MENU);
@@ -289,7 +289,7 @@ terminal_window_dropdown_init (TerminalWindowDropdown *dropdown)
   for (n = 1; n < N_PROPERTIES; n++)
     {
       name = g_param_spec_get_name (dropdown_props[n]);
-      g_object_bind_property (G_OBJECT (window->preferences), name,
+      g_object_bind_property (terminal_window_get_preferences (window), name,
                               G_OBJECT (dropdown), name,
                               G_BINDING_SYNC_CREATE);
     }
@@ -357,8 +357,8 @@ terminal_window_dropdown_set_property (GObject      *object,
 
     case PROP_DROPDOWN_KEEP_ABOVE:
       gtk_window_set_keep_above (GTK_WINDOW (dropdown), g_value_get_boolean (value));
-      if (window->preferences_dialog != NULL)
-        terminal_util_activate_window (GTK_WINDOW (window->preferences_dialog));
+      if (terminal_window_get_preferences_dialog (window) != NULL)
+        terminal_util_activate_window (GTK_WINDOW (terminal_window_get_preferences_dialog (window)));
       return;
 
     case PROP_DROPDOWN_ANIMATION_TIME:
@@ -455,7 +455,7 @@ terminal_window_dropdown_focus_out_event (GtkWidget     *widget,
 
   /* check if keep open is not enabled */
   if (gtk_widget_get_visible (widget)
-      && TERMINAL_WINDOW (dropdown)->n_child_windows == 0
+      && !terminal_window_has_children (TERMINAL_WINDOW (dropdown))
       && gtk_grab_get_current () == NULL
       && dropdown->animation_dir != ANIMATION_DIR_UP) /* popup menu check */
     {
@@ -723,7 +723,7 @@ terminal_window_dropdown_show (TerminalWindowDropdown *dropdown,
       g_source_remove (dropdown->animation_timeout_id);
     }
 
-  g_object_get (G_OBJECT (window->preferences),
+  g_object_get (terminal_window_get_preferences (window),
                 "dropdown-move-to-active", &move_to_active,
                 NULL);
 
@@ -811,7 +811,7 @@ terminal_window_dropdown_show (TerminalWindowDropdown *dropdown,
     }
   else
     {
-      g_object_get (G_OBJECT (window->preferences),
+      g_object_get (terminal_window_get_preferences (window),
                     "dropdown-keep-above", &keep_above,
                     NULL);
       gtk_window_set_keep_above (GTK_WINDOW (dropdown), keep_above);
@@ -835,7 +835,9 @@ terminal_window_dropdown_toggle_real (TerminalWindowDropdown *dropdown,
       && gdk_window_is_visible (gtk_widget_get_window (GTK_WIDGET (dropdown)))
       && dropdown->animation_dir != ANIMATION_DIR_UP)
     {
-      g_object_get (G_OBJECT (window->preferences), "dropdown-toggle-focus", &toggle_focus, NULL);
+      g_object_get (terminal_window_get_preferences (window),
+                    "dropdown-toggle-focus", &toggle_focus,
+                    NULL);
 
       /* if the focus was lost for 0.1 second and toggle-focus is used, we had
        * focus until the shortcut was pressed, and then we hide the window */
@@ -919,7 +921,7 @@ terminal_window_dropdown_new (const gchar        *role,
   window = g_object_new (TERMINAL_TYPE_WINDOW_DROPDOWN, "role", role, NULL);
 
   /* read default preferences */
-  g_object_get (G_OBJECT (window->preferences),
+  g_object_get (terminal_window_get_preferences (window),
                 "misc-menubar-default", &show_menubar,
                 "misc-toolbar-default", &show_toolbar,
                 NULL);
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 3028b5a..4c6e80f 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -222,35 +222,41 @@ static void         terminal_window_tab_info_free                 (TerminalWindo
 
 struct _TerminalWindowPrivate
 {
-  GtkUIManager   *ui_manager;
+  GtkUIManager        *ui_manager;
 
-  guint           tabs_menu_merge_id;
-  GSList         *tabs_menu_actions;
+  /* for the drop-down to keep open with dialogs */
+  guint                n_child_windows;
 
-  GtkWidget      *search_dialog;
-  GtkWidget      *title_dialog;
+  guint                tabs_menu_merge_id;
+  GSList              *tabs_menu_actions;
+
+  TerminalPreferences *preferences;
+  GtkWidget           *preferences_dialog;
+
+  GtkWidget           *search_dialog;
+  GtkWidget           *title_dialog;
 
   /* pushed size of screen */
-  glong           grid_width;
-  glong           grid_height;
+  glong                grid_width;
+  glong                grid_height;
 
-  GtkAction      *encoding_action;
+  GtkAction           *encoding_action;
 
-  TerminalScreen *active;
+  TerminalScreen      *active;
 
   /* cached actions to avoid lookups */
-  GtkAction      *action_undo_close_tab;
-  GtkAction      *action_detach_tab;
-  GtkAction      *action_close_other_tabs;
-  GtkAction      *action_prev_tab;
-  GtkAction      *action_next_tab;
-  GtkAction      *action_move_tab_left;
-  GtkAction      *action_move_tab_right;
-  GtkAction      *action_copy;
-  GtkAction      *action_search_next;
-  GtkAction      *action_search_prev;
-
-  GQueue         *closed_tabs_list;
+  GtkAction           *action_undo_close_tab;
+  GtkAction           *action_detach_tab;
+  GtkAction           *action_close_other_tabs;
+  GtkAction           *action_prev_tab;
+  GtkAction           *action_next_tab;
+  GtkAction           *action_move_tab_left;
+  GtkAction           *action_move_tab_right;
+  GtkAction           *action_copy;
+  GtkAction           *action_search_next;
+  GtkAction           *action_search_prev;
+
+  GQueue              *closed_tabs_list;
 };
 
 static guint   window_signals[LAST_SIGNAL];
@@ -372,7 +378,7 @@ terminal_window_init (TerminalWindow *window)
 
   window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, TERMINAL_TYPE_WINDOW, TerminalWindowPrivate);
 
-  window->preferences = terminal_preferences_get ();
+  window->priv->preferences = terminal_preferences_get ();
 
   window->font = NULL;
   window->zoom = TERMINAL_ZOOM_LEVEL_DEFAULT;
@@ -416,7 +422,7 @@ terminal_window_init (TerminalWindow *window)
   gtk_style_context_add_class (context, GTK_STYLE_CLASS_BACKGROUND);
 
   /* allocate the notebook for the terminal screens */
-  g_object_get (G_OBJECT (window->preferences), "misc-always-show-tabs", &always_show_tabs, NULL);
+  g_object_get (G_OBJECT (window->priv->preferences), "misc-always-show-tabs", &always_show_tabs, NULL);
   window->notebook = g_object_new (GTK_TYPE_NOTEBOOK,
                                    "scrollable", TRUE,
                                    "show-border", FALSE,
@@ -484,7 +490,7 @@ terminal_window_finalize (GObject *object)
 {
   TerminalWindow *window = TERMINAL_WINDOW (object);
 
-  g_object_unref (G_OBJECT (window->preferences));
+  g_object_unref (G_OBJECT (window->priv->preferences));
   g_object_unref (G_OBJECT (window->action_group));
   g_object_unref (G_OBJECT (window->priv->ui_manager));
   g_object_unref (G_OBJECT (window->priv->encoding_action));
@@ -575,7 +581,7 @@ terminal_window_scroll_event (GtkWidget      *widget,
   gboolean mouse_wheel_zoom;
   TerminalWindow *window = TERMINAL_WINDOW (widget);
 
-  g_object_get (G_OBJECT (window->preferences),
+  g_object_get (G_OBJECT (window->priv->preferences),
                 "misc-mouse-wheel-zoom", &mouse_wheel_zoom, NULL);
 
   if (mouse_wheel_zoom && event->state == (GDK_SHIFT_MASK | GDK_CONTROL_MASK)
@@ -617,7 +623,7 @@ terminal_window_confirm_close (TerminalWindow *window)
   if (G_UNLIKELY (n_tabs < 2))
     return TRUE;
 
-  g_object_get (G_OBJECT (window->preferences), "misc-confirm-close", &confirm_close, NULL);
+  g_object_get (G_OBJECT (window->priv->preferences), "misc-confirm-close", &confirm_close, NULL);
   if (!confirm_close)
     return TRUE;
 
@@ -672,7 +678,7 @@ terminal_window_confirm_close (TerminalWindow *window)
     {
       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)))
         {
-          g_object_set (G_OBJECT (window->preferences),
+          g_object_set (G_OBJECT (window->priv->preferences),
                         "misc-confirm-close", FALSE,
                         NULL);
         }
@@ -799,7 +805,7 @@ terminal_window_update_actions (TerminalWindow *window)
     {
       page_num = gtk_notebook_page_num (notebook, GTK_WIDGET (window->priv->active));
 
-      g_object_get (G_OBJECT (window->preferences),
+      g_object_get (G_OBJECT (window->priv->preferences),
                     "misc-cycle-tabs", &cycle_tabs,
                     NULL);
 
@@ -1142,7 +1148,7 @@ terminal_window_notebook_button_press_event (GtkNotebook    *notebook,
       if (event->button == 2)
         {
           /* close the tab on middle click */
-          g_object_get (G_OBJECT (window->preferences),
+          g_object_get (G_OBJECT (window->priv->preferences),
                         "misc-tab-close-middle-click", &close_middle_click, NULL);
           if (close_middle_click)
             gtk_widget_destroy (page);
@@ -1444,7 +1450,7 @@ terminal_window_action_new_tab (GtkAction      *action,
   TerminalScreen *terminal;
 
   terminal = TERMINAL_SCREEN (g_object_new (TERMINAL_TYPE_SCREEN, NULL));
-  g_object_get (G_OBJECT (window->preferences), "misc-default-working-dir", &default_dir, NULL);
+  g_object_get (G_OBJECT (window->priv->preferences), "misc-default-working-dir", &default_dir, NULL);
 
   if (g_strcmp0 (default_dir, "") != 0)
     directory = default_dir;
@@ -1469,7 +1475,7 @@ terminal_window_action_new_window (GtkAction      *action,
   const gchar *directory = NULL;
   gchar       *default_dir;
 
-  g_object_get (G_OBJECT (window->preferences), "misc-default-working-dir", &default_dir, NULL);
+  g_object_get (G_OBJECT (window->priv->preferences), "misc-default-working-dir", &default_dir, NULL);
 
   if (g_strcmp0 (default_dir, "") != 0)
     directory = default_dir;
@@ -1615,8 +1621,8 @@ terminal_window_action_prefs_died (gpointer  user_data,
 {
   TerminalWindow *window = TERMINAL_WINDOW (user_data);
 
-  window->preferences_dialog = NULL;
-  window->n_child_windows--;
+  window->priv->preferences_dialog = NULL;
+  window->priv->n_child_windows--;
 
   if (window->drop_down)
     terminal_util_activate_window (GTK_WINDOW (window));
@@ -1628,21 +1634,21 @@ static void
 terminal_window_action_prefs (GtkAction      *action,
                               TerminalWindow *window)
 {
-  if (window->preferences_dialog == NULL)
+  if (window->priv->preferences_dialog == NULL)
     {
-      window->preferences_dialog = terminal_preferences_dialog_new (window->drop_down);
-      if (G_LIKELY (window->preferences_dialog != NULL))
+      window->priv->preferences_dialog = terminal_preferences_dialog_new (window->drop_down);
+      if (G_LIKELY (window->priv->preferences_dialog != NULL))
         {
-          window->n_child_windows++;
-          g_object_weak_ref (G_OBJECT (window->preferences_dialog),
+          window->priv->n_child_windows++;
+          g_object_weak_ref (G_OBJECT (window->priv->preferences_dialog),
                              terminal_window_action_prefs_died, window);
         }
     }
 
-  if (window->preferences_dialog != NULL)
+  if (window->priv->preferences_dialog != NULL)
     {
-      gtk_window_set_transient_for (GTK_WINDOW (window->preferences_dialog), GTK_WINDOW (window));
-      gtk_window_present (GTK_WINDOW (window->preferences_dialog));
+      gtk_window_set_transient_for (GTK_WINDOW (window->priv->preferences_dialog), GTK_WINDOW (window));
+      gtk_window_present (GTK_WINDOW (window->priv->preferences_dialog));
     }
 }
 
@@ -1858,7 +1864,7 @@ title_dialog_close (GtkWidget      *dialog,
     terminal_util_activate_window (GTK_WINDOW (window));
 
   /* close the dialog */
-  window->n_child_windows--;
+  window->priv->n_child_windows--;
   gtk_widget_destroy (dialog);
   window->priv->title_dialog = NULL;
 }
@@ -1945,7 +1951,7 @@ terminal_window_action_set_title (GtkAction      *action,
     }
 
     if (!gtk_widget_get_visible (window->priv->title_dialog))
-      window->n_child_windows++;
+      window->priv->n_child_windows++;
 
     gtk_widget_show_all (window->priv->title_dialog);
     gtk_window_present (GTK_WINDOW (window->priv->title_dialog));
@@ -1997,7 +2003,7 @@ terminal_window_action_search_response (GtkWidget      *dialog,
         terminal_util_activate_window (GTK_WINDOW (window));
 
       /* hide dialog */
-      window->n_child_windows--;
+      window->priv->n_child_windows--;
       gtk_widget_hide (dialog);
     }
 
@@ -2024,7 +2030,7 @@ terminal_window_action_search (GtkAction      *action,
 
   /* increase child counter */
   if (!gtk_widget_get_visible (window->priv->search_dialog))
-    window->n_child_windows++;
+    window->priv->n_child_windows++;
 
   terminal_search_dialog_present (TERMINAL_SEARCH_DIALOG (window->priv->search_dialog));
 }
@@ -2263,7 +2269,7 @@ terminal_window_new (const gchar       *role,
   window = g_object_new (TERMINAL_TYPE_WINDOW, "role", role, NULL);
 
   /* read default preferences */
-  g_object_get (G_OBJECT (window->preferences),
+  g_object_get (G_OBJECT (window->priv->preferences),
                 "misc-menubar-default", &show_menubar,
                 "misc-toolbar-default", &show_toolbar,
                 "misc-borders-default", &show_borders,
@@ -2292,7 +2298,7 @@ terminal_window_new (const gchar       *role,
   gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_borders);
 
   /* property that is not suitable for init */
-  g_object_bind_property (G_OBJECT (window->preferences), "misc-tab-position",
+  g_object_bind_property (G_OBJECT (window->priv->preferences), "misc-tab-position",
                           G_OBJECT (window->notebook), "tab-pos",
                           G_BINDING_SYNC_CREATE);
 
@@ -2379,7 +2385,7 @@ terminal_window_notebook_show_tabs (TerminalWindow *window)
   npages = gtk_notebook_get_n_pages (notebook);
   if (npages < 2)
     {
-      g_object_get (G_OBJECT (window->preferences),
+      g_object_get (G_OBJECT (window->priv->preferences),
                     window->drop_down ? "dropdown-always-show-tabs" :
                     "misc-always-show-tabs", &show_tabs, NULL);
     }
@@ -2493,3 +2499,39 @@ terminal_window_set_grid_size (TerminalWindow *window,
   window->priv->grid_width = width;
   window->priv->grid_height = height;
 }
+
+
+
+/**
+ * terminal_window_has_children:
+ * @window  : A #TerminalWindow.
+ **/
+gboolean
+terminal_window_has_children (TerminalWindow *window)
+{
+  return window->priv->n_child_windows != 0;
+}
+
+
+
+/**
+ * terminal_window_get_preferences:
+ * @window  : A #TerminalWindow.
+ **/
+GObject*
+terminal_window_get_preferences (TerminalWindow *window)
+{
+  return G_OBJECT (window->priv->preferences);
+}
+
+
+
+/**
+ * terminal_window_get_preferences_dialog:
+ * @window  : A #TerminalWindow.
+ **/
+GtkWidget*
+terminal_window_get_preferences_dialog (TerminalWindow *window)
+{
+  return window->priv->preferences_dialog;
+}
diff --git a/terminal/terminal-window.h b/terminal/terminal-window.h
index 650e5be..5ae7255 100644
--- a/terminal/terminal-window.h
+++ b/terminal/terminal-window.h
@@ -49,12 +49,6 @@ typedef struct
   /* if this is a TerminalWindowDropdown */
   guint                  drop_down : 1;
 
-  /* for the drop-down to keep open with dialogs */
-  guint                  n_child_windows;
-
-  TerminalPreferences   *preferences;
-  GtkWidget             *preferences_dialog;
-
   GtkActionGroup        *action_group;
 
   GtkWidget             *vbox;
@@ -70,26 +64,32 @@ typedef struct
   TerminalVisibility     scrollbar_visibility;
 } TerminalWindow;
 
-GType           terminal_window_get_type            (void) G_GNUC_CONST;
+GType           terminal_window_get_type               (void) G_GNUC_CONST;
+
+GtkWidget      *terminal_window_new                    (const gchar        *role,
+                                                        gboolean            fullscreen,
+                                                        TerminalVisibility  menubar,
+                                                        TerminalVisibility  borders,
+                                                        TerminalVisibility  toolbar);
+
+void            terminal_window_add                    (TerminalWindow     *window,
+                                                        TerminalScreen     *screen);
+
+TerminalScreen *terminal_window_get_active             (TerminalWindow     *window);
 
-GtkWidget      *terminal_window_new                 (const gchar        *role,
-                                                     gboolean            fullscreen,
-                                                     TerminalVisibility  menubar,
-                                                     TerminalVisibility  borders,
-                                                     TerminalVisibility  toolbar);
+void            terminal_window_notebook_show_tabs     (TerminalWindow     *window);
 
-void            terminal_window_add                 (TerminalWindow     *window,
-                                                     TerminalScreen     *screen);
+GSList         *terminal_window_get_restart_command    (TerminalWindow     *window);
 
-TerminalScreen *terminal_window_get_active          (TerminalWindow     *window);
+void            terminal_window_set_grid_size          (TerminalWindow     *window,
+                                                        glong               width,
+                                                        glong               height);
 
-void            terminal_window_notebook_show_tabs  (TerminalWindow     *window);
+gboolean        terminal_window_has_children           (TerminalWindow     *window);
 
-GSList         *terminal_window_get_restart_command (TerminalWindow     *window);
+GObject        *terminal_window_get_preferences        (TerminalWindow     *window);
 
-void            terminal_window_set_grid_size       (TerminalWindow     *window,
-                                                     glong               width,
-                                                     glong               height);
+GtkWidget      *terminal_window_get_preferences_dialog (TerminalWindow     *window);
 
 G_END_DECLS
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list