[gedit/gnome-3-8] prefs-dialog: create liststore in the ui file



commit f3482c22279cb41b6799fa70fcec94fec702b150
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sun Apr 21 16:03:49 2013 +0200

    prefs-dialog: create liststore in the ui file

 gedit/gedit-preferences-dialog.c  | 34 +++++++-------------------
 gedit/gedit-preferences-dialog.ui | 51 ++++++++++++++++++++++++++-------------
 2 files changed, 43 insertions(+), 42 deletions(-)
---
diff --git a/gedit/gedit-preferences-dialog.c b/gedit/gedit-preferences-dialog.c
index 2875a10..f4fd021 100644
--- a/gedit/gedit-preferences-dialog.c
+++ b/gedit/gedit-preferences-dialog.c
@@ -89,6 +89,8 @@ struct _GeditPreferencesDialogPrivate
        /* Style Scheme */
        GtkListStore    *schemes_treeview_model;
        GtkWidget       *schemes_treeview;
+       GtkTreeViewColumn *schemes_column;
+       GtkCellRenderer *schemes_renderer;
        GtkWidget       *install_scheme_button;
        GtkWidget       *uninstall_scheme_button;
        GtkWidget       *schemes_scrolled_window;
@@ -1059,41 +1061,19 @@ scheme_description_cell_data_func (GtkTreeViewColumn *column,
 static void
 setup_font_colors_page_style_scheme_section (GeditPreferencesDialog *dlg)
 {
-       GtkCellRenderer *renderer;
-       GtkTreeViewColumn *column;
+       GeditPreferencesDialogPrivate *priv = dlg->priv;
        GtkTreeSelection *selection;
        GtkStyleContext *context;
        const gchar *def_id;
 
        gedit_debug (DEBUG_PREFS);
 
-       /* Create GtkListStore for styles & setup treeview. */
-       dlg->priv->schemes_treeview_model = gtk_list_store_new (NUM_COLUMNS,
-                                                               G_TYPE_STRING,
-                                                               G_TYPE_STRING,
-                                                               G_TYPE_STRING,
-                                                               G_TYPE_STRING);
-
-       gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dlg->priv->schemes_treeview_model),
-                                             0,
-                                             GTK_SORT_ASCENDING);
-       gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->schemes_treeview),
-                                GTK_TREE_MODEL (dlg->priv->schemes_treeview_model));
-
-       column = gtk_tree_view_column_new ();
-
-       renderer = gtk_cell_renderer_text_new ();
-       g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
-       gtk_tree_view_column_pack_start (column, renderer, TRUE);
-       gtk_tree_view_column_set_cell_data_func (column,
-                                                renderer,
+       gtk_tree_view_column_set_cell_data_func (priv->schemes_column,
+                                                priv->schemes_renderer,
                                                 scheme_description_cell_data_func,
                                                 dlg,
                                                 NULL);
 
-       gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->schemes_treeview),
-                                    column);
-
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->schemes_treeview));
        gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
 
@@ -1158,6 +1138,7 @@ gedit_preferences_dialog_init (GeditPreferencesDialog *dlg)
                "adjustment1",
                "adjustment2",
                "adjustment3",
+               "schemes_treeview_model",
                NULL
        };
 
@@ -1215,7 +1196,10 @@ gedit_preferences_dialog_init (GeditPreferencesDialog *dlg)
        dlg->priv->default_font_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, 
"default_font_checkbutton"));
        dlg->priv->font_button = GTK_WIDGET (gtk_builder_get_object (builder, "font_button"));
        dlg->priv->font_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "font_hbox"));
+       dlg->priv->schemes_treeview_model = GTK_LIST_STORE (gtk_builder_get_object (builder, 
"schemes_treeview_model"));
        dlg->priv->schemes_treeview = GTK_WIDGET (gtk_builder_get_object (builder, "schemes_treeview"));
+       dlg->priv->schemes_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (builder, "schemes_column"));
+       dlg->priv->schemes_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (builder, 
"schemes_renderer"));
        dlg->priv->schemes_scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, 
"schemes-scrolled-window"));
        dlg->priv->install_scheme_button = GTK_WIDGET (gtk_builder_get_object (builder, 
"install_scheme_button"));
        dlg->priv->uninstall_scheme_button = GTK_WIDGET (gtk_builder_get_object (builder, 
"uninstall_scheme_button"));
diff --git a/gedit/gedit-preferences-dialog.ui b/gedit/gedit-preferences-dialog.ui
index 65d3f2c..f0888a9 100644
--- a/gedit/gedit-preferences-dialog.ui
+++ b/gedit/gedit-preferences-dialog.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-requires gtk+ 3.6 -->
   <object class="GtkAdjustment" id="adjustment1">
     <property name="lower">1</property>
     <property name="upper">1000</property>
@@ -22,6 +22,16 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
+  <object class="GtkListStore" id="schemes_treeview_model">
+    <columns>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+      <!-- column-name description -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="preferences_dialog">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Preferences</property>
@@ -45,7 +55,6 @@
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">False</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -61,7 +70,6 @@
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">False</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -107,8 +115,8 @@
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
-                            <property name="use_action_appearance">False</property>
                             <property name="use_underline">True</property>
+                            <property name="xalign">0.5</property>
                             <property name="draw_indicator">True</property>
                           </object>
                           <packing>
@@ -128,8 +136,8 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
+                                <property name="xalign">0.5</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
@@ -214,8 +222,8 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
+                                <property name="xalign">0.5</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
@@ -230,8 +238,8 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
+                                <property name="xalign">0.5</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
@@ -295,8 +303,8 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
+                                <property name="xalign">0.5</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
@@ -311,8 +319,8 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
+                                <property name="xalign">0.5</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
@@ -437,8 +445,8 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
+                                <property name="xalign">0.5</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
@@ -453,8 +461,8 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
+                                <property name="xalign">0.5</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
@@ -518,8 +526,8 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
+                                <property name="xalign">0.5</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
@@ -539,8 +547,8 @@
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
-                                    <property name="use_action_appearance">False</property>
                                     <property name="use_underline">True</property>
+                                    <property name="xalign">0.5</property>
                                     <property name="draw_indicator">True</property>
                                   </object>
                                   <packing>
@@ -664,8 +672,8 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
+                                <property name="xalign">0.5</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
@@ -700,7 +708,6 @@
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">True</property>
-                                    <property name="use_action_appearance">False</property>
                                     <property name="title" translatable="yes">Pick the editor font</property>
                                     <property name="use_font">True</property>
                                   </object>
@@ -771,11 +778,23 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="model">schemes_treeview_model</property>
                                 <property name="headers_visible">False</property>
                                 <property name="rules_hint">True</property>
+                                <property name="search_column">0</property>
                                 <child internal-child="selection">
                                   <object class="GtkTreeSelection" id="treeview-selection"/>
                                 </child>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="schemes_column">
+                                    <property name="title" translatable="yes">column</property>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="schemes_renderer">
+                                        <property name="ellipsize">end</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                </child>
                               </object>
                             </child>
                           </object>
@@ -801,7 +820,6 @@
                                 <property name="has_tooltip">True</property>
                                 <property name="tooltip_markup" translatable="yes">Install scheme</property>
                                 <property name="tooltip_text" translatable="yes">Install scheme</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="label" translatable="yes">Install Scheme</property>
                                 <property name="use_underline">True</property>
                                 <property name="icon_name">list-add-symbolic</property>
@@ -818,7 +836,6 @@
                                 <property name="has_tooltip">True</property>
                                 <property name="tooltip_markup" translatable="yes">Uninstall 
scheme</property>
                                 <property name="tooltip_text" translatable="yes">Uninstall scheme</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="label" translatable="yes">Uninstall Scheme</property>
                                 <property name="use_underline">True</property>
                                 <property name="icon_name">list-remove-symbolic</property>


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