[gedit/wip/browser-menu] filebrowser: remove indentation



commit 938cfe4e6d4ce29b0f5f0dabe0b520bd6e851eef
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat Apr 20 12:38:52 2013 +0200

    filebrowser: remove indentation
    
    It does not work anymore with new comboboxes anyway.
    If we want this at some point we will need a custom cell renderer.

 plugins/filebrowser/gedit-file-browser-widget.c  | 66 +-----------------------
 plugins/filebrowser/gedit-file-browser-widget.ui |  9 +---
 2 files changed, 4 insertions(+), 71 deletions(-)
---
diff --git a/plugins/filebrowser/gedit-file-browser-widget.c b/plugins/filebrowser/gedit-file-browser-widget.c
index 75840ed..5be02fc 100644
--- a/plugins/filebrowser/gedit-file-browser-widget.c
+++ b/plugins/filebrowser/gedit-file-browser-widget.c
@@ -57,7 +57,6 @@ enum
 
 enum
 {
-       COLUMN_INDENT,
        COLUMN_ICON,
        COLUMN_NAME,
        COLUMN_FILE,
@@ -127,7 +126,6 @@ struct _GeditFileBrowserWidgetPrivate
 
        GtkWidget *combo;
        GtkTreeStore *combo_model;
-       GtkCellRenderer *indent_renderer;
 
        GtkWidget *filter_entry;
 
@@ -513,7 +511,6 @@ gedit_file_browser_widget_class_init (GeditFileBrowserWidgetClass *klass)
                                                     
"/org/gnome/gedit/plugins/file-browser/ui/gedit-file-browser-widget.ui");
        gtk_widget_class_bind_child (widget_class, GeditFileBrowserWidgetPrivate, combo);
        gtk_widget_class_bind_child (widget_class, GeditFileBrowserWidgetPrivate, combo_model);
-       gtk_widget_class_bind_child (widget_class, GeditFileBrowserWidgetPrivate, indent_renderer);
        gtk_widget_class_bind_child (widget_class, GeditFileBrowserWidgetPrivate, treeview);
        gtk_widget_class_bind_child (widget_class, GeditFileBrowserWidgetPrivate, filter_entry);
 
@@ -599,8 +596,7 @@ static void
 insert_path_item (GeditFileBrowserWidget *obj,
                   GFile                  *file,
                  GtkTreeIter            *after,
-                 GtkTreeIter            *iter,
-                 guint                   indent)
+                 GtkTreeIter            *iter)
 {
        gchar *unescape;
        GdkPixbuf *icon = NULL;
@@ -620,7 +616,6 @@ insert_path_item (GeditFileBrowserWidget *obj,
 
        gtk_tree_store_set (obj->priv->combo_model,
                            iter,
-                           COLUMN_INDENT, indent,
                            COLUMN_ICON, icon,
                            COLUMN_NAME, unescape,
                            COLUMN_FILE, file,
@@ -656,31 +651,6 @@ combo_set_active_by_id (GeditFileBrowserWidget *obj,
                                               (obj->priv->combo), &iter);
 }
 
-static guint
-uri_num_parents (GFile *from,
-                GFile *to)
-{
-       /* Determine the number of 'levels' to get from #from to #to. */
-       guint parents = 0;
-       GFile *parent;
-
-       if (from == NULL)
-               return 0;
-
-       g_object_ref (from);
-
-       while ((parent = g_file_get_parent (from)) && !(to && g_file_equal (from, to)))
-       {
-               g_object_unref (from);
-               from = parent;
-
-               ++parents;
-       }
-
-       g_object_unref (from);
-       return parents;
-}
-
 static void
 insert_location_path (GeditFileBrowserWidget *obj)
 {
@@ -689,7 +659,6 @@ insert_location_path (GeditFileBrowserWidget *obj)
        GFile *tmp;
        GtkTreeIter separator;
        GtkTreeIter iter;
-       guint indent;
 
        if (!obj->priv->current_location)
        {
@@ -702,11 +671,9 @@ insert_location_path (GeditFileBrowserWidget *obj)
        current = loc->virtual_root;
        combo_find_by_id (obj, SEPARATOR_ID, &separator);
 
-       indent = uri_num_parents (loc->virtual_root, loc->root);
-
        while (current != NULL)
        {
-               insert_path_item (obj, current, &separator, &iter, indent--);
+               insert_path_item (obj, current, &separator, &iter);
 
                if (current == loc->virtual_root)
                {
@@ -799,31 +766,6 @@ fill_combo_model (GeditFileBrowserWidget *obj)
 }
 
 static void
-indent_cell_data_func (GtkCellLayout   *cell_layout,
-                       GtkCellRenderer *cell,
-                       GtkTreeModel    *model,
-                       GtkTreeIter     *iter,
-                       gpointer         data)
-{
-       gchar *indent;
-       guint num;
-
-       gtk_tree_model_get (model, iter, COLUMN_INDENT, &num, -1);
-
-       if (num == 0)
-       {
-               g_object_set (cell, "text", "", NULL);
-       }
-       else
-       {
-               indent = g_strnfill (num * 2, ' ');
-
-               g_object_set (cell, "text", indent, NULL);
-               g_free (indent);
-       }
-}
-
-static void
 set_enable_delete (GeditFileBrowserWidget *obj,
                   gboolean                enable)
 {
@@ -1028,10 +970,6 @@ gedit_file_browser_widget_init (GeditFileBrowserWidget *obj)
        gtk_widget_init_template (GTK_WIDGET (obj));
 
        /* combo */
-       gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (obj->priv->combo),
-                                           obj->priv->indent_renderer,
-                                           indent_cell_data_func, obj, NULL);
-
        fill_combo_model (obj);
        g_signal_connect (obj->priv->combo, "changed",
                          G_CALLBACK (on_combo_changed), obj);
diff --git a/plugins/filebrowser/gedit-file-browser-widget.ui 
b/plugins/filebrowser/gedit-file-browser-widget.ui
index 6612f5d..1c85172 100644
--- a/plugins/filebrowser/gedit-file-browser-widget.ui
+++ b/plugins/filebrowser/gedit-file-browser-widget.ui
@@ -3,8 +3,6 @@
   <!-- interface-requires gtk+ 3.6 -->
   <object class="GtkTreeStore" id="combo_model">
     <columns>
-      <!-- column-name indent -->
-      <column type="guint"/>
       <!-- column-name icon -->
       <column type="GdkPixbuf"/>
       <!-- column-name name -->
@@ -136,12 +134,9 @@
                 <property name="can_focus">False</property>
                 <property name="model">combo_model</property>
                 <child>
-                  <object class="GtkCellRendererText" id="indent_renderer"/>
-                </child>
-                <child>
                   <object class="GtkCellRendererPixbuf" id="icon_renderer"/>
                   <attributes>
-                    <attribute name="pixbuf">1</attribute>
+                    <attribute name="pixbuf">0</attribute>
                   </attributes>
                 </child>
                 <child>
@@ -149,7 +144,7 @@
                     <property name="ellipsize">end</property>
                   </object>
                   <attributes>
-                    <attribute name="text">2</attribute>
+                    <attribute name="text">1</attribute>
                   </attributes>
                 </child>
               </object>


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