[gimp/wip/Jehan/layers-dockable-refresh: 40/78] app: all remaining select-item handlers replaced by select-items ones.




commit 81f7efd1f34a2cdf2c33c7fd81216367e46f2d07
Author: Jehan <jehan girinstud io>
Date:   Sat Jun 19 23:11:38 2021 +0200

    app: all remaining select-item handlers replaced by select-items ones.

 app/widgets/gimpcontrollerlist.c | 26 +++++++++------
 app/widgets/gimpdeviceeditor.c   | 72 +++++++++++++++++++++++++---------------
 app/widgets/gimpsettingsbox.c    | 23 ++++++++-----
 app/widgets/gimpsettingseditor.c | 26 +++++++++------
 4 files changed, 89 insertions(+), 58 deletions(-)
---
diff --git a/app/widgets/gimpcontrollerlist.c b/app/widgets/gimpcontrollerlist.c
index 0b85e641d7..8dcec7e5fd 100644
--- a/app/widgets/gimpcontrollerlist.c
+++ b/app/widgets/gimpcontrollerlist.c
@@ -89,9 +89,9 @@ static void gimp_controller_list_row_activated   (GtkTreeView        *tv,
                                                   GtkTreeViewColumn  *column,
                                                   GimpControllerList *list);
 
-static void gimp_controller_list_select_item     (GimpContainerView  *view,
-                                                  GimpViewable       *viewable,
-                                                  gpointer            insert_data,
+static gboolean gimp_controller_list_select_items(GimpContainerView  *view,
+                                                  GList              *viewables,
+                                                  GList              *paths,
                                                   GimpControllerList *list);
 static void gimp_controller_list_activate_item   (GimpContainerView  *view,
                                                   GimpViewable       *viewable,
@@ -282,8 +282,8 @@ gimp_controller_list_init (GimpControllerList *list)
   gtk_box_pack_start (GTK_BOX (list->hbox), list->dest, TRUE, TRUE, 0);
   gtk_widget_show (list->dest);
 
-  g_signal_connect_object (list->dest, "select-item",
-                           G_CALLBACK (gimp_controller_list_select_item),
+  g_signal_connect_object (list->dest, "select-items",
+                           G_CALLBACK (gimp_controller_list_select_items),
                            G_OBJECT (list), 0);
   g_signal_connect_object (list->dest, "activate-item",
                            G_CALLBACK (gimp_controller_list_activate_item),
@@ -451,15 +451,17 @@ gimp_controller_list_row_activated (GtkTreeView        *tv,
     gtk_button_clicked (GTK_BUTTON (list->add_button));
 }
 
-static void
-gimp_controller_list_select_item (GimpContainerView  *view,
-                                  GimpViewable       *viewable,
-                                  gpointer            insert_data,
-                                  GimpControllerList *list)
+static gboolean
+gimp_controller_list_select_items (GimpContainerView  *view,
+                                   GList              *viewables,
+                                   GList              *paths,
+                                   GimpControllerList *list)
 {
   gboolean selected;
 
-  list->dest_info = GIMP_CONTROLLER_INFO (viewable);
+  g_return_val_if_fail (g_list_length (viewables) < 2, FALSE);
+
+  list->dest_info = viewables ? GIMP_CONTROLLER_INFO (viewables->data) : NULL;
 
   selected = GIMP_IS_CONTROLLER_INFO (list->dest_info);
 
@@ -482,6 +484,8 @@ gimp_controller_list_select_item (GimpContainerView  *view,
   gtk_widget_set_sensitive (list->edit_button, selected);
   gtk_widget_set_sensitive (list->up_button,   selected);
   gtk_widget_set_sensitive (list->down_button, selected);
+
+  return TRUE;
 }
 
 static void
diff --git a/app/widgets/gimpdeviceeditor.c b/app/widgets/gimpdeviceeditor.c
index 41ec62e0b3..e3e89e37fc 100644
--- a/app/widgets/gimpdeviceeditor.c
+++ b/app/widgets/gimpdeviceeditor.c
@@ -43,6 +43,7 @@
 #include "gimpdevices.h"
 #include "gimpmessagebox.h"
 #include "gimpmessagedialog.h"
+#include "gimpviewrenderer.h"
 
 #include "gimp-intl.h"
 
@@ -96,10 +97,10 @@ static void   gimp_device_editor_remove_device  (GimpContainer     *container,
 static void   gimp_device_editor_device_changed (GimpDeviceInfo    *info,
                                                  GimpDeviceEditor  *editor);
 
-static void   gimp_device_editor_select_device  (GimpContainerView *view,
-                                                 GimpViewable      *viewable,
-                                                 gpointer           insert_data,
-                                                 GimpDeviceEditor  *editor);
+static gboolean gimp_device_editor_select_device (GimpContainerView *view,
+                                                  GList             *viewables,
+                                                  GList             *paths,
+                                                  GimpDeviceEditor  *editor);
 
 static void   gimp_device_editor_delete_clicked (GtkWidget         *button,
                                                  GimpDeviceEditor  *editor);
@@ -149,7 +150,7 @@ gimp_device_editor_init (GimpDeviceEditor *editor)
   gtk_paned_pack1 (GTK_PANED (editor), private->treeview, TRUE, FALSE);
   gtk_widget_show (private->treeview);
 
-  g_signal_connect_object (private->treeview, "select-item",
+  g_signal_connect_object (private->treeview, "select-items",
                            G_CALLBACK (gimp_device_editor_select_device),
                            G_OBJECT (editor), 0);
 
@@ -431,48 +432,65 @@ gimp_device_editor_device_changed (GimpDeviceInfo   *info,
     }
 }
 
-static void
+static gboolean
 gimp_device_editor_select_device (GimpContainerView *view,
-                                  GimpViewable      *viewable,
-                                  gpointer           insert_data,
+                                  GList             *viewables,
+                                  GList             *paths,
                                   GimpDeviceEditor  *editor)
 {
   GimpDeviceEditorPrivate *private = GIMP_DEVICE_EDITOR_GET_PRIVATE (editor);
 
-  if (viewable && insert_data)
+  g_return_val_if_fail (g_list_length (viewables) < 2, FALSE);
+
+  if (viewables)
     {
       GimpContainerTreeView *treeview;
       GtkWidget             *widget;
+      GtkTreeIter            iter;
+      gboolean               iter_valid;
 
       treeview = GIMP_CONTAINER_TREE_VIEW (private->treeview);
 
-      gtk_tree_model_get (treeview->model, insert_data,
-                          GIMP_CONTAINER_TREE_STORE_COLUMN_USER_DATA, &widget,
-                          -1);
-
-      if (widget)
+      for (iter_valid = gtk_tree_model_get_iter_first (treeview->model, &iter);
+           iter_valid;
+           iter_valid = gtk_tree_model_iter_next (treeview->model, &iter))
         {
-          GimpDeviceInfo *info;
-          gboolean        delete_sensitive = FALSE;
+          GimpViewRenderer *renderer;
+
+          gtk_tree_model_get (treeview->model, &iter,
+                              GIMP_CONTAINER_TREE_STORE_COLUMN_USER_DATA, &widget,
+                              GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER,  &renderer,
+                              -1);
+          if (renderer->viewable == viewables->data && widget)
+            {
+              GimpDeviceInfo *info;
+              gboolean        delete_sensitive = FALSE;
 
-          gtk_stack_set_visible_child (GTK_STACK (private->stack), widget);
+              gtk_stack_set_visible_child (GTK_STACK (private->stack), widget);
 
-          g_object_get (widget ,"info", &info, NULL);
+              g_object_get (widget ,"info", &info, NULL);
 
-          gtk_label_set_text (GTK_LABEL (private->label),
-                              gimp_object_get_name (info));
-          gtk_image_set_from_icon_name (GTK_IMAGE (private->image),
-                                        gimp_viewable_get_icon_name (GIMP_VIEWABLE (info)),
-                                        GTK_ICON_SIZE_BUTTON);
+              gtk_label_set_text (GTK_LABEL (private->label),
+                                  gimp_object_get_name (info));
+              gtk_image_set_from_icon_name (GTK_IMAGE (private->image),
+                                            gimp_viewable_get_icon_name (GIMP_VIEWABLE (info)),
+                                            GTK_ICON_SIZE_BUTTON);
 
-          if (! gimp_device_info_get_device (info, NULL))
-            delete_sensitive = TRUE;
+              if (! gimp_device_info_get_device (info, NULL))
+                delete_sensitive = TRUE;
 
-          gtk_widget_set_sensitive (private->delete_button, delete_sensitive);
+              gtk_widget_set_sensitive (private->delete_button, delete_sensitive);
 
-          g_object_unref (info);
+              g_object_unref (info);
+              g_object_unref (renderer);
+
+              break;
+            }
+          g_object_unref (renderer);
         }
     }
+
+  return TRUE;
 }
 
 static void
diff --git a/app/widgets/gimpsettingsbox.c b/app/widgets/gimpsettingsbox.c
index 8f4f3c8d20..e20557e69a 100644
--- a/app/widgets/gimpsettingsbox.c
+++ b/app/widgets/gimpsettingsbox.c
@@ -111,9 +111,10 @@ static gboolean
             gimp_settings_box_row_separator_func (GtkTreeModel      *model,
                                                   GtkTreeIter       *iter,
                                                   gpointer           data);
-static void   gimp_settings_box_setting_selected (GimpContainerView *view,
-                                                  GimpViewable      *object,
-                                                  gpointer           insert_data,
+static gboolean
+              gimp_settings_box_setting_selected (GimpContainerView *view,
+                                                  GList             *objects,
+                                                  GList             *paths,
                                                   GimpSettingsBox   *box);
 static gboolean gimp_settings_box_menu_press     (GtkWidget         *widget,
                                                   GdkEventButton    *bevent,
@@ -298,7 +299,7 @@ gimp_settings_box_constructed (GObject *object)
   gimp_help_set_help_data (private->combo, _("Pick a preset from the list"),
                            NULL);
 
-  g_signal_connect_after (private->combo, "select-item",
+  g_signal_connect_after (private->combo, "select-items",
                           G_CALLBACK (gimp_settings_box_setting_selected),
                           box);
 
@@ -546,15 +547,19 @@ gimp_settings_box_row_separator_func (GtkTreeModel *model,
   return name == NULL;
 }
 
-static void
+static gboolean
 gimp_settings_box_setting_selected (GimpContainerView *view,
-                                    GimpViewable      *object,
-                                    gpointer           insert_data,
+                                    GList             *objects,
+                                    GList             *paths,
                                     GimpSettingsBox   *box)
 {
-  if (object)
+  g_return_val_if_fail (g_list_length (objects) < 2, FALSE);
+
+  if (objects)
     g_signal_emit (box, settings_box_signals[SELECTED], 0,
-                   object);
+                   objects->data);
+
+  return TRUE;
 }
 
 static gboolean
diff --git a/app/widgets/gimpsettingseditor.c b/app/widgets/gimpsettingseditor.c
index b86f4100e2..af29f6d488 100644
--- a/app/widgets/gimpsettingseditor.c
+++ b/app/widgets/gimpsettingseditor.c
@@ -89,9 +89,9 @@ static gboolean
           gimp_settings_editor_row_separator_func (GtkTreeModel        *model,
                                                    GtkTreeIter         *iter,
                                                    gpointer             data);
-static void   gimp_settings_editor_select_item    (GimpContainerView   *view,
-                                                   GimpViewable        *viewable,
-                                                   gpointer             insert_data,
+static gboolean gimp_settings_editor_select_items (GimpContainerView   *view,
+                                                   GList               *viewables,
+                                                   GList               *paths,
                                                    GimpSettingsEditor  *editor);
 static void   gimp_settings_editor_import_clicked (GtkWidget           *widget,
                                                    GimpSettingsEditor  *editor);
@@ -178,8 +178,8 @@ gimp_settings_editor_constructed (GObject *object)
                                         gimp_settings_editor_row_separator_func,
                                         private->view, NULL);
 
-  g_signal_connect (tree_view, "select-item",
-                    G_CALLBACK (gimp_settings_editor_select_item),
+  g_signal_connect (tree_view, "select-items",
+                    G_CALLBACK (gimp_settings_editor_select_items),
                     editor);
 
   gimp_container_tree_view_connect_name_edited (tree_view,
@@ -298,22 +298,26 @@ gimp_settings_editor_row_separator_func (GtkTreeModel *model,
   return name == NULL;
 }
 
-static void
-gimp_settings_editor_select_item (GimpContainerView  *view,
-                                  GimpViewable       *viewable,
-                                  gpointer            insert_data,
-                                  GimpSettingsEditor *editor)
+static gboolean
+gimp_settings_editor_select_items (GimpContainerView  *view,
+                                   GList              *viewables,
+                                   GList              *paths,
+                                   GimpSettingsEditor *editor)
 {
   GimpSettingsEditorPrivate *private = GET_PRIVATE (editor);
   gboolean                   sensitive;
 
-  private->selected_setting = G_OBJECT (viewable);
+  g_return_val_if_fail (g_list_length (viewables) < 2, FALSE);
+
+  private->selected_setting = viewables ? G_OBJECT (viewables->data) : NULL;
 
   sensitive = (private->selected_setting != NULL &&
                gimp_object_get_name (private->selected_setting));
 
   gtk_widget_set_sensitive (private->export_button, sensitive);
   gtk_widget_set_sensitive (private->delete_button, sensitive);
+
+  return TRUE;
 }
 
 static void


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