[Xfce4-commits] <xfdesktop:xfce-4.8> Scroll to the selected background in the settings (bug #7087).

Jannis Pohlmann noreply at xfce.org
Tue Jan 25 03:10:02 CET 2011


Updating branch refs/heads/xfce-4.8
         to 45916b4e00a878fcc6f530f30932220b43a2e7a9 (commit)
       from 928c28551b8dba8c8cc432dcf9552ca982390acb (commit)

commit 45916b4e00a878fcc6f530f30932220b43a2e7a9
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Tue Jan 25 03:07:28 2011 +0100

    Scroll to the selected background in the settings (bug #7087).
    
    This makes finding the current selection easier. With the default dialog
    size, the background selection tree view is rather narrow and it can be
    hard to find the selected background. It's fixed by scrolling to it
    after all previews have been created.

 NEWS            |    1 +
 settings/main.c |   23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index a55124f..7585786 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Xfdesktop 4.x.y
   * Use Name field as display name of desktop files (bug #6896).
   * Support absolute icon paths in desktop files (bug #7160).
     Patch by xaizek at gmail.com.
+  * Scroll to the selected background in the settings (bug #7087).
 
 
 Xfdesktop 4.8.0
diff --git a/settings/main.c b/settings/main.c
index ee5d464..9ae15cd 100644
--- a/settings/main.c
+++ b/settings/main.c
@@ -4,6 +4,7 @@
  *  Copyright (c) 2008 Stephan Arts <stephan at xfce.org>
  *  Copyright (c) 2008 Brian Tarricone <bjt23 at cornell.edu>
  *  Copyright (c) 2008 Jérôme Guelfucci <jerome.guelfucci at gmail.com>
+ *  Copyright (c) 2011 Jannis Pohlmann <jannis at xfce.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -212,6 +213,7 @@ static gpointer
 xfdesktop_settings_create_all_previews(gpointer data)
 {
     GtkTreeModel *model = data;
+    GtkTreeView *tree_view;
     GtkTreeIter iter;
 
     gdk_threads_enter();
@@ -220,6 +222,21 @@ xfdesktop_settings_create_all_previews(gpointer data)
             xfdesktop_settings_do_single_preview(model, &iter);
         } while(gtk_tree_model_iter_next(model, &iter));
     }
+
+    /* if possible, scroll to the selected image */
+    tree_view = g_object_get_data(G_OBJECT(model), "xfdesktop-tree-view");
+    if(tree_view) {
+        GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view);
+
+        if(gtk_tree_selection_get_mode(selection) != GTK_SELECTION_MULTIPLE
+           && gtk_tree_selection_get_selected(selection, NULL, &iter)) 
+        {
+            GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
+            gtk_tree_view_scroll_to_cell(tree_view, path, NULL, TRUE, 0.0, 0.0);
+        }
+    }
+    g_object_set_data(G_OBJECT(model), "xfdesktop-tree-view", NULL);
+
     gdk_threads_leave();
 
     g_object_unref(G_OBJECT(model));
@@ -693,6 +710,12 @@ xfdesktop_settings_dialog_populate_image_list(AppearancePanel *panel)
     if(image_file_iter) {
         gtk_tree_selection_select_iter(sel, image_file_iter);
         gtk_tree_iter_free(image_file_iter);
+
+        /* remember the tree view to scroll to the selected image in the
+         * thread that creates all the previews */
+        g_object_set_data_full(G_OBJECT(ls), "xfdesktop-tree-view", 
+                               g_object_ref(panel->image_treeview),
+                               g_object_unref);
     }
 
     /* generate previews of each image -- the new thread will own



More information about the Xfce4-commits mailing list