[Xfce4-commits] <xfce4-settings:bluesabre/display-settings> Revert "Changed TreeView to IconView"

Nick Schermer noreply at xfce.org
Mon Dec 9 12:57:39 CET 2013


Updating branch refs/heads/bluesabre/display-settings
         to da345c7d32e09978ad12c4478a49b6a111997fd4 (commit)
       from 6d509f1bd335adf60d81dffbafa6a3a83cdf4448 (commit)

commit da345c7d32e09978ad12c4478a49b6a111997fd4
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Fri Oct 26 01:26:48 2012 +0200

    Revert "Changed TreeView to IconView"
    
    This reverts commit 00d70e4258e69a5c47f7fd4623d806bc16332d18.

 dialogs/display-settings/display-dialog.glade |   10 +--
 dialogs/display-settings/main.c               |   81 +++++++++----------------
 2 files changed, 35 insertions(+), 56 deletions(-)

diff --git a/dialogs/display-settings/display-dialog.glade b/dialogs/display-settings/display-dialog.glade
index 10276ce..c7357a3 100644
--- a/dialogs/display-settings/display-dialog.glade
+++ b/dialogs/display-settings/display-dialog.glade
@@ -72,16 +72,16 @@
                 <property name="width_request">200</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">never</property>
+                <property name="hscrollbar_policy">automatic</property>
                 <property name="vscrollbar_policy">automatic</property>
                 <property name="shadow_type">etched-in</property>
                 <child>
-                  <object class="GtkIconView" id="randr-outputs">
+                  <object class="GtkTreeView" id="randr-outputs">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="item_orientation">horizontal</property>
-                    <property name="columns">1</property>
-                    <property name="spacing">6</property>
+                    <property name="headers_visible">False</property>
+                    <property name="enable_search">False</property>
+                    <property name="show_expanders">False</property>
                   </object>
                 </child>
               </object>
diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index bfd1cc9..ba80d05 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -142,7 +142,7 @@ static GOptionEntry option_entries[] =
 /* Global xfconf channel */
 static XfconfChannel *display_channel;
 
-/* output currently selected in the iconview */
+/* output currently selected in the treeview */
 static guint active_output;
 
 /* Pointer to the used randr structure */
@@ -1319,27 +1319,19 @@ display_setting_output_status_populate (GtkBuilder *builder)
 
 
 static void
-display_settings_iconview_selection_changed (GtkIconView *iconview,
+display_settings_treeview_selection_changed (GtkTreeSelection *selection,
                                              GtkBuilder       *builder)
 {
     GtkTreeModel *model;
-    GtkTreePath  *path = NULL;
     GtkTreeIter   iter;
     GtkWidget    *popup;
+    gboolean      has_selection;
     gint          active_id, previous_id;
-    GList        *selected_items;
-    guint        n;
-
-    model = gtk_icon_view_get_model(iconview);
-    
-    selected_items = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (iconview));
-    
-    if (g_list_length(selected_items) != 0)
+
+    /* Get the selection */
+    has_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
+    if (G_LIKELY (has_selection))
     {
-        path = selected_items->data;
-    
-        gtk_tree_model_get_iter(model, &iter, path);
-    
         /* Get the output info */
         gtk_tree_model_get (model, &iter, COLUMN_OUTPUT_ID, &active_id, -1);
 
@@ -1365,30 +1357,19 @@ display_settings_iconview_selection_changed (GtkIconView *iconview,
         if (popup)
             gtk_widget_queue_draw (popup);
     }
-    else
-    {
-        gtk_tree_model_get_iter_first(model, &iter);
-        for (n=0; n<active_output; n++)
-        gtk_tree_model_iter_next(model, &iter);
-        path = gtk_tree_model_get_path(model, &iter);
-        gtk_icon_view_select_path(GTK_ICON_VIEW(iconview), path);
-    }
-    
-    /* Release the path */
-    gtk_tree_path_free(path);
 }
 
 
 
 static void
-display_settings_iconview_populate (GtkBuilder *builder)
+display_settings_treeview_populate (GtkBuilder *builder)
 {
     guint             m;
     GtkListStore     *store;
-    GObject          *iconview;
+    GObject          *treeview;
     GtkTreeIter       iter;
     GdkPixbuf        *display_icon, *lucent_display_icon;
-    GtkTreePath      *path = NULL;
+    GtkTreeSelection *selection;
     gboolean          selected = FALSE;
 
     /* Create a new list store */
@@ -1397,9 +1378,10 @@ display_settings_iconview_populate (GtkBuilder *builder)
                                 GDK_TYPE_PIXBUF, /* COLUMN_OUTPUT_ICON */
                                 G_TYPE_INT);   /* COLUMN_OUTPUT_ID */
 
-    /* Set the iconview model */
-    iconview = gtk_builder_get_object (builder, "randr-outputs");
-    gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), GTK_TREE_MODEL (store));
+    /* Set the treeview model */
+    treeview = gtk_builder_get_object (builder, "randr-outputs");
+    gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
 
     /* Get the display icon */
     display_icon =
@@ -1433,8 +1415,7 @@ display_settings_iconview_populate (GtkBuilder *builder)
         /* Select active output */
         if (m == active_output)
         {
-            path = gtk_tree_model_get_path(GTK_TREE_MODEL (store), &iter);
-            gtk_icon_view_select_path(GTK_ICON_VIEW(iconview), path);
+            gtk_tree_selection_select_iter (selection, &iter);
             selected = TRUE;
         }
     }
@@ -1442,10 +1423,7 @@ display_settings_iconview_populate (GtkBuilder *builder)
     /* If nothing was selected the active output is no longer valid,
      * select the last display in the list. */
     if (!selected)
-    {
-        path = gtk_tree_model_get_path(GTK_TREE_MODEL (store), &iter);
-        gtk_icon_view_select_path(GTK_ICON_VIEW(iconview), path);
-    }
+        gtk_tree_selection_select_iter (selection, &iter);
 
     /* Release the store */
     g_object_unref (G_OBJECT (store));
@@ -1454,9 +1432,6 @@ display_settings_iconview_populate (GtkBuilder *builder)
     g_object_unref (display_icon);
     if (lucent_display_icon != NULL)
         g_object_unref (lucent_display_icon);
-        
-    /* Release the path */
-    gtk_tree_path_free(path);
 }
 
 
@@ -1497,29 +1472,33 @@ display_settings_dialog_response (GtkDialog  *dialog,
 static GtkWidget *
 display_settings_dialog_new (GtkBuilder *builder)
 {
-    GObject          *iconview;
+    GObject          *treeview;
     GtkCellRenderer  *renderer;
+    GtkTreeSelection *selection;
     GObject          *combobox;
     GObject          *label, *check, *mirror;
 
-    /* Get the iconview */
-    iconview = gtk_builder_get_object (builder, "randr-outputs");
-    gtk_icon_view_set_text_column (GTK_ICON_VIEW (iconview), COLUMN_OUTPUT_NAME);
-    gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (iconview), COLUMN_OUTPUT_ICON);
+    /* Get the treeview */
+    treeview = gtk_builder_get_object (builder, "randr-outputs");
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (treeview), COLUMN_OUTPUT_NAME);
 
     /* Icon renderer */
     renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), 0, "", renderer, "pixbuf", COLUMN_OUTPUT_ICON, NULL);
     g_object_set (G_OBJECT (renderer), "stock-size", GTK_ICON_SIZE_DND, NULL);
 
     /* Text renderer */
     renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), 1, "", renderer, "text", COLUMN_OUTPUT_NAME, NULL);
     g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
 
     /* Identification popups */
     display_setting_identity_popups_populate ();
 
-    /* Iconview selection */
-    g_signal_connect (GTK_ICON_VIEW(iconview), "selection-changed", G_CALLBACK (display_settings_iconview_selection_changed), builder);
+    /* Treeview selection */
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+    g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (display_settings_treeview_selection_changed), builder);
 
     /* Setup the combo boxes */
     check = gtk_builder_get_object (builder, "output-on");
@@ -1565,8 +1544,8 @@ display_settings_dialog_new (GtkBuilder *builder)
     display_settings_combo_box_create (GTK_COMBO_BOX (combobox));
     g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (display_setting_rotations_changed), builder);
 
-    /* Populate the iconview */
-    display_settings_iconview_populate (builder);
+    /* Populate the treeview */
+    display_settings_treeview_populate (builder);
 
     return GTK_WIDGET (gtk_builder_get_object (builder, "display-dialog"));
 }
@@ -1739,7 +1718,7 @@ screen_on_event (GdkXEvent *xevent,
     if (event_num == RRScreenChangeNotify)
     {
         xfce_randr_reload (xfce_randr);
-        display_settings_iconview_populate (builder);
+        display_settings_treeview_populate (builder);
 
         /* recreate the identify display popups */
         g_hash_table_destroy (display_popups);


More information about the Xfce4-commits mailing list