[nautilus/antonioffix-menus-and-popovers: 11/13] view-icon-controller: Simplify reveal_selection innards



commit 955a72cafc72e0f4919b15e1cbd78a1cb3691f51
Author: António Fernandes <antoniof gnome org>
Date:   Sat Jan 13 19:34:05 2018 +0000

    view-icon-controller: Simplify reveal_selection innards
    
    Now that get_revealed_rectangle is internal to reveal_selection,
    there is no need for the duplicated work it does.
    
    Since reveal_selection already knows everyting needed to fill
    the revealed_rectangle, do it inline.
    
    Also, make sure to free the selection list.

 src/nautilus-view-icon-controller.c | 41 +++++--------------------------------
 1 file changed, 5 insertions(+), 36 deletions(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index d34d715a9..8ecaeba23 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -387,45 +387,11 @@ real_select_all (NautilusFilesView *files_view)
     gtk_flow_box_select_all (GTK_FLOW_BOX (self->view_ui));
 }
 
-
-static void
-get_revealed_rectangle (NautilusFilesView *files_view,
-                        GdkRectangle      *rect)
-{
-    NautilusViewIconController *self;
-    GdkRectangle *allocation;
-    GtkAdjustment *vadjustment;
-    GtkAdjustment *hadjustment;
-    GtkWidget *parent_container;
-    g_autoptr (GQueue) selection_files = NULL;
-    g_autoptr (GQueue) selection_item_models = NULL;
-    GList *selection;
-    GtkWidget *icon_item_ui;
-
-    self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
-    allocation = g_new0 (GdkRectangle, 1);
-
-    parent_container = nautilus_files_view_get_content_widget (files_view);
-    vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (parent_container));
-    hadjustment = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (parent_container));
-    selection = nautilus_view_get_selection (NAUTILUS_VIEW (files_view));
-    selection_files = convert_glist_to_queue (selection);
-    selection_item_models = nautilus_view_model_get_items_from_files (self->model, selection_files);
-    /* We only allow one item to be renamed with a popover */
-    icon_item_ui = nautilus_view_item_model_get_item_ui (g_queue_peek_head (selection_item_models));
-    gtk_widget_get_allocation (icon_item_ui, allocation);
-
-    rect->x = allocation->x - gtk_adjustment_get_value (hadjustment);
-    rect->y = allocation->y - gtk_adjustment_get_value (vadjustment);
-    rect->width =allocation->width;
-    rect->height =allocation->height;
-}
-
 static void
 real_reveal_selection (NautilusFilesView *files_view,
                        GdkRectangle      *revealed_area)
 {
-    GList *selection;
+    g_autoptr (GList) selection = NULL;
     NautilusViewItemModel *item_model;
     NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
     GtkWidget *item_ui;
@@ -449,7 +415,10 @@ real_reveal_selection (NautilusFilesView *files_view,
 
     if (revealed_area)
     {
-        get_revealed_rectangle (files_view, revealed_area);
+        revealed_area->x = allocation.x;
+        revealed_area->y = allocation.y - gtk_adjustment_get_value (vadjustment);
+        revealed_area->width = allocation.width;
+        revealed_area->height = allocation.height;
     }
 
     g_list_foreach (selection, (GFunc) g_object_unref, NULL);


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