[gtksourceview] Completion: separate CompletionPrivate fields into sections



commit 78b16ec25e2dcd7e25b92673e6b3f5f14fafcfd8
Author: SÃbastien Wilmet <swilmet gnome org>
Date:   Thu Feb 14 16:55:33 2013 +0100

    Completion: separate CompletionPrivate fields into sections
    
    The fields are not renamed, they are just moved, and some comments are
    added to explain them.
    
    For the widgets, some IDs in the UI file are renamed, to have the same
    name as the struct field, or to have a better name (the struct fields
    will be renamed later in this case).

 gtksourceview/gtksourcecompletion.c  |  104 +++++++++++++++++-----------------
 gtksourceview/gtksourcecompletion.ui |   16 +++---
 2 files changed, 61 insertions(+), 59 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 3ad3f57..c476834 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -152,31 +152,41 @@ enum
 
 struct _GtkSourceCompletionPrivate
 {
-       /* Widget and popup variables*/
+       /**********
+        * Widgets
+        **********/
+
+       /* The main window */
        GtkWidget *window;
-       GtkWidget *info_window;
-       GtkWidget *info_button;
+
+       /* Image and label in the bottom bar, on the right, for showing which
+        * provider(s) are selected. */
+       GtkWidget *selection_image;
        GtkWidget *selection_label;
+
+       /* The CompletionInfo window */
+       GtkWidget *info_window;
+
+       /* The default widget (a GtkLabel) for the info window */
        GtkWidget *default_info;
-       GtkWidget *selection_image;
+
+       /* The "Details" button with its components, for showing the info window */
+       GtkWidget *info_button;
        GtkWidget *hgrid_info;
-       GtkWidget *label_info;
        GtkWidget *image_info;
+       GtkWidget *label_info;
+
+       /* List of proposals */
+       GtkWidget *tree_view_proposals;
        GtkTreeViewColumn *tree_view_column_accelerator;
        GtkCellRenderer *cell_renderer_accelerator;
        GtkCellRenderer *cell_renderer_icon;
 
-       GtkWidget *tree_view_proposals;
-       GtkSourceCompletionModel *model_proposals;
-
-       guint num_accelerators;
+       /************************
+        * Completion management
+        ************************/
 
-       /* Page size */
-       guint proposal_page_size;
-       guint provider_page_size;
-
-       /* Completion management */
-       GtkSourceView *view;
+       GtkSourceCompletionModel *model_proposals;
 
        GList *providers;
        GList *interactive_providers;
@@ -186,7 +196,6 @@ struct _GtkSourceCompletionPrivate
        GList *running_providers;
 
        guint show_timed_out_id;
-       guint auto_complete_delay;
 
        gint typing_line;
        gint typing_line_offset;
@@ -199,12 +208,27 @@ struct _GtkSourceCompletionPrivate
 
        gint block_count;
 
+       /*************
+        * Properties
+        *************/
+
+       GtkSourceView *view;
+       guint num_accelerators;
+       guint auto_complete_delay;
+       guint proposal_page_size;
+       guint provider_page_size;
+
        guint remember_info_visibility : 1;
-       guint info_visible : 1;
        guint select_on_show : 1;
        guint show_headers : 1;
-       guint select_first : 1;
        guint show_icons : 1;
+
+       /*********
+        * Others
+        *********/
+
+       guint info_visible : 1;
+       guint select_first : 1;
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
@@ -2632,7 +2656,6 @@ update_transient_for_info (GObject             *window,
 {
        gtk_window_set_transient_for (GTK_WINDOW (completion->priv->info_window),
                                      gtk_window_get_transient_for (GTK_WINDOW (completion->priv->window)));
-
 }
 
 static void
@@ -2917,7 +2940,6 @@ initialize_ui (GtkSourceCompletion *completion)
        GtkBuilder *builder;
        GtkTreeViewColumn *column;
        GtkTreeSelection *selection;
-       GtkWidget *toggle_button_info;
 
        builder = gtk_builder_new ();
        gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
@@ -2926,30 +2948,14 @@ initialize_ui (GtkSourceCompletion *completion)
                                       "/org/gnome/gtksourceview/ui/gtksourcecompletion.ui",
                                       NULL);
 
-       completion->priv->window =
-               GTK_WIDGET (gtk_builder_get_object (builder,
-                                                   "window_completion"));
-       completion->priv->info_button =
-               GTK_WIDGET (gtk_builder_get_object (builder,
-                                                   "toggle_button_info"));
-       completion->priv->selection_label =
-               GTK_WIDGET (gtk_builder_get_object (builder,
-                                                   "label_selection"));
-       completion->priv->selection_image =
-               GTK_WIDGET (gtk_builder_get_object (builder,
-                                                   "image_selection"));
-       completion->priv->tree_view_proposals =
-               GTK_WIDGET (gtk_builder_get_object (builder,
-                                                   "tree_view_completion"));
-       completion->priv->label_info =
-               GTK_WIDGET (gtk_builder_get_object (builder,
-                                                   "label_info"));
-       completion->priv->image_info =
-               GTK_WIDGET (gtk_builder_get_object (builder,
-                                                   "image_info"));
-       completion->priv->hgrid_info =
-               GTK_WIDGET (gtk_builder_get_object (builder,
-                                                   "hgrid_info"));
+       completion->priv->window = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+       completion->priv->tree_view_proposals = GTK_WIDGET (gtk_builder_get_object (builder, 
"tree_view_proposals"));
+       completion->priv->selection_image = GTK_WIDGET (gtk_builder_get_object (builder, "selection_image"));
+       completion->priv->selection_label = GTK_WIDGET (gtk_builder_get_object (builder, "selection_label"));
+       completion->priv->info_button = GTK_WIDGET (gtk_builder_get_object (builder, "info_button"));
+       completion->priv->hgrid_info = GTK_WIDGET (gtk_builder_get_object (builder, "info_button_hgrid"));
+       completion->priv->image_info = GTK_WIDGET (gtk_builder_get_object (builder, "info_button_image"));
+       completion->priv->label_info = GTK_WIDGET (gtk_builder_get_object (builder, "info_button_label"));
 
        gtk_window_set_attached_to (GTK_WINDOW (completion->priv->window),
                                    GTK_WIDGET (completion->priv->view));
@@ -3009,16 +3015,12 @@ initialize_ui (GtkSourceCompletion *completion)
                          G_CALLBACK (selection_changed_cb),
                          completion);
 
-       toggle_button_info =
-               GTK_WIDGET (gtk_builder_get_object (builder,
-                                                   "toggle_button_info"));
-
-       g_signal_connect (toggle_button_info,
+       g_signal_connect (completion->priv->info_button,
                          "toggled",
                          G_CALLBACK (info_toggled_cb),
                          completion);
 
-       g_signal_connect (toggle_button_info,
+       g_signal_connect (completion->priv->info_button,
                          "style-updated",
                          G_CALLBACK (info_button_style_updated),
                          completion);
@@ -3431,7 +3433,7 @@ gtk_source_completion_add_provider (GtkSourceCompletion          *completion,
  *
  * Returns: %TRUE if @provider was successfully removed, otherwise if @error
  *          is provided, it will be set with the error and %FALSE is returned.
- **/
+ */
 gboolean
 gtk_source_completion_remove_provider (GtkSourceCompletion          *completion,
                                       GtkSourceCompletionProvider  *provider,
diff --git a/gtksourceview/gtksourcecompletion.ui b/gtksourceview/gtksourcecompletion.ui
index ea61f16..9c2f302 100644
--- a/gtksourceview/gtksourcecompletion.ui
+++ b/gtksourceview/gtksourcecompletion.ui
@@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 <interface>
   <requires lib="gtk+" version="3.0"/>
-  <object class="GtkWindow" id="window_completion">
+  <object class="GtkWindow" id="main_window">
     <property name="border_width">1</property>
     <property name="type">popup</property>
     <property name="type_hint">combo</property>
@@ -43,7 +43,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <child>
-              <object class="GtkTreeView" id="tree_view_completion">
+              <object class="GtkTreeView" id="tree_view_proposals">
                 <property name="visible">True</property>
                 <property name="headers_visible">False</property>
                 <property name="headers_clickable">False</property>
@@ -81,7 +81,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
             <property name="visible">True</property>
             <property name="orientation">horizontal</property>
             <child>
-              <object class="GtkToggleButton" id="toggle_button_info">
+              <object class="GtkToggleButton" id="info_button">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="receives_default">True</property>
@@ -89,19 +89,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
                 <property name="focus_on_click">False</property>
                 <property name="relief">GTK_RELIEF_NONE</property>
                 <child>
-                  <object class="GtkGrid" id="hgrid_info">
+                  <object class="GtkGrid" id="info_button_hgrid">
                     <property name="visible">True</property>
                     <property name="orientation">horizontal</property>
                     <property name="column_spacing">2</property>
                     <property name="valign">center</property>
                     <child>
-                      <object class="GtkImage" id="image_info">
+                      <object class="GtkImage" id="info_button_image">
                         <property name="visible">True</property>
                         <property name="stock">gtk-info</property>
                       </object>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="label_info">
+                      <object class="GtkLabel" id="info_button_label">
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">_Details...</property>
                         <property name="use_underline">True</property>
@@ -115,7 +115,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
               </object>
             </child>
             <child>
-              <object class="GtkImage" id="image_selection">
+              <object class="GtkImage" id="selection_image">
                 <property name="visible">True</property>
                 <property name="halign">end</property>
                 <property name="hexpand">True</property>
@@ -125,7 +125,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="label_selection">
+              <object class="GtkLabel" id="selection_label">
                 <property name="visible">True</property>
                 <property name="margin">6</property>
               </object>


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