[gimp] app: Add methods to enable multiple selection in GimpContainerView



commit b46a89a3022d2c93ffe0d86a5398027aa6aae7bd
Author: Aurimas Juška <aurimas juska gmail com>
Date:   Thu Mar 11 17:40:00 2010 +0200

    app: Add methods to enable multiple selection in GimpContainerView
    
    Enable multiple selection in GimpDataFactoryView now. It remains
    disabled everywhere else.

 app/widgets/gimpcontainereditor.c   |   13 ++++++++++
 app/widgets/gimpcontainereditor.h   |    4 +++
 app/widgets/gimpcontainertreeview.c |   20 +++++++++++++++
 app/widgets/gimpcontainerview.c     |   45 +++++++++++++++++++++++++++++++++++
 app/widgets/gimpcontainerview.h     |    8 ++++++
 app/widgets/gimpdatafactoryview.c   |    2 +
 6 files changed, 92 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpcontainereditor.c b/app/widgets/gimpcontainereditor.c
index d0f54cd..a403d70 100644
--- a/app/widgets/gimpcontainereditor.c
+++ b/app/widgets/gimpcontainereditor.c
@@ -184,6 +184,19 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
   return TRUE;
 }
 
+gboolean
+gimp_container_editor_get_multiple_selection (GimpContainerEditor *editor)
+{
+  return gimp_container_view_get_multiple_selection (GIMP_CONTAINER_VIEW (editor->view));
+}
+
+void
+gimp_container_editor_set_multiple_selection (GimpContainerEditor *editor,
+                                              gboolean             value)
+{
+  gimp_container_view_set_multiple_selection (GIMP_CONTAINER_VIEW (editor->view),
+                                              value);
+}
 
 /*  private functions  */
 
diff --git a/app/widgets/gimpcontainereditor.h b/app/widgets/gimpcontainereditor.h
index c543874..66f589c 100644
--- a/app/widgets/gimpcontainereditor.h
+++ b/app/widgets/gimpcontainereditor.h
@@ -54,6 +54,10 @@ struct _GimpContainerEditorClass
 
 GType     gimp_container_editor_get_type  (void) G_GNUC_CONST;
 
+gboolean  gimp_container_editor_get_multiple_selection (GimpContainerEditor *editor);
+void      gimp_container_editor_set_multiple_selection (GimpContainerEditor *editor,
+                                                        gboolean             value);
+
 
 /*  protected  */
 
diff --git a/app/widgets/gimpcontainertreeview.c b/app/widgets/gimpcontainertreeview.c
index 8aef9f5..8ef07e3 100644
--- a/app/widgets/gimpcontainertreeview.c
+++ b/app/widgets/gimpcontainertreeview.c
@@ -57,6 +57,9 @@ static void          gimp_container_tree_view_set_container     (GimpContainerVi
                                                                  GimpContainer               *container);
 static void          gimp_container_tree_view_set_context       (GimpContainerView           *view,
                                                                  GimpContext                 *context);
+static void          gimp_container_tree_view_set_multiple_selection (GimpContainerView      *view,
+                                                                      gboolean                value);
+
 static gpointer      gimp_container_tree_view_insert_item       (GimpContainerView           *view,
                                                                  GimpViewable                *viewable,
                                                                  gpointer                     parent_insert_data,
@@ -143,8 +146,12 @@ gimp_container_tree_view_view_iface_init (GimpContainerViewInterface *iface)
 {
   parent_view_iface = g_type_interface_peek_parent (iface);
 
+  if (! parent_view_iface)
+    parent_view_iface = g_type_default_interface_peek (GIMP_TYPE_CONTAINER_VIEW);
+
   iface->set_container = gimp_container_tree_view_set_container;
   iface->set_context   = gimp_container_tree_view_set_context;
+  iface->set_multiple_selection = gimp_container_tree_view_set_multiple_selection;
   iface->insert_item   = gimp_container_tree_view_insert_item;
   iface->remove_item   = gimp_container_tree_view_remove_item;
   iface->reorder_item  = gimp_container_tree_view_reorder_item;
@@ -607,6 +614,19 @@ gimp_container_tree_view_set_context (GimpContainerView *view,
     }
 }
 
+static void
+gimp_container_tree_view_set_multiple_selection (GimpContainerView *view,
+                                                 gboolean           value)
+{
+  GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
+
+  gtk_tree_selection_set_mode (tree_view->priv->selection,
+                               value ? GTK_SELECTION_MULTIPLE :
+                                       GTK_SELECTION_NONE);
+
+  parent_view_iface->set_multiple_selection (view, value);
+}
+
 static gpointer
 gimp_container_tree_view_insert_item (GimpContainerView *view,
                                       GimpViewable      *viewable,
diff --git a/app/widgets/gimpcontainerview.c b/app/widgets/gimpcontainerview.c
index 0de7ccf..c8c0652 100644
--- a/app/widgets/gimpcontainerview.c
+++ b/app/widgets/gimpcontainerview.c
@@ -65,6 +65,7 @@ struct _GimpContainerViewPrivate
   gint             view_size;
   gint             view_border_width;
   gboolean         reorderable;
+  gboolean         multiple_selection;
 
   /*  initialized by subclass  */
   GtkWidget       *dnd_widget;
@@ -82,6 +83,8 @@ static void   gimp_container_view_real_set_container (GimpContainerView *view,
                                                       GimpContainer     *container);
 static void   gimp_container_view_real_set_context   (GimpContainerView *view,
                                                       GimpContext       *context);
+static void   gimp_container_view_real_set_multiple_selection (GimpContainerView *view,
+                                                               gboolean           value);
 
 static void   gimp_container_view_clear_items      (GimpContainerView  *view);
 static void   gimp_container_view_real_clear_items (GimpContainerView  *view);
@@ -207,6 +210,7 @@ gimp_container_view_iface_base_init (GimpContainerViewInterface *view_iface)
 
   view_iface->set_container     = gimp_container_view_real_set_container;
   view_iface->set_context       = gimp_container_view_real_set_context;
+  view_iface->set_multiple_selection = gimp_container_view_real_set_multiple_selection;
   view_iface->insert_item       = NULL;
   view_iface->insert_item_after = NULL;
   view_iface->remove_item       = NULL;
@@ -232,6 +236,12 @@ gimp_container_view_iface_base_init (GimpContainerViewInterface *view_iface)
                                                             GIMP_PARAM_READWRITE));
 
   g_object_interface_install_property (view_iface,
+                                       g_param_spec_boolean ("multiple-selection",
+                                                            NULL, NULL,
+                                                            FALSE,
+                                                            GIMP_PARAM_READWRITE));
+
+  g_object_interface_install_property (view_iface,
                                        g_param_spec_boolean ("reorderable",
                                                              NULL, NULL,
                                                              FALSE,
@@ -339,6 +349,9 @@ gimp_container_view_install_properties (GObjectClass *klass)
                                     GIMP_CONTAINER_VIEW_PROP_CONTEXT,
                                     "context");
   g_object_class_override_property (klass,
+                                    GIMP_CONTAINER_VIEW_PROP_MULTIPLE_SELECTION,
+                                    "multiple-selection");
+  g_object_class_override_property (klass,
                                     GIMP_CONTAINER_VIEW_PROP_REORDERABLE,
                                     "reorderable");
   g_object_class_override_property (klass,
@@ -486,6 +499,32 @@ gimp_container_view_real_set_context (GimpContainerView *view,
     }
 }
 
+gboolean
+gimp_container_view_get_multiple_selection (GimpContainerView *view)
+{
+  GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
+
+  return private->multiple_selection;
+}
+
+void
+gimp_container_view_set_multiple_selection (GimpContainerView *view,
+                                            gboolean           value)
+{
+  g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
+
+  GIMP_CONTAINER_VIEW_GET_INTERFACE (view)->set_multiple_selection (view, value);
+}
+
+static void
+gimp_container_view_real_set_multiple_selection (GimpContainerView *view,
+                                                 gboolean           value)
+{
+  GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
+
+  private->multiple_selection = value;
+}
+
 gint
 gimp_container_view_get_view_size (GimpContainerView *view,
                                    gint              *view_border_width)
@@ -839,6 +878,9 @@ gimp_container_view_set_property (GObject      *object,
     case GIMP_CONTAINER_VIEW_PROP_CONTEXT:
       gimp_container_view_set_context (view, g_value_get_object (value));
       break;
+    case GIMP_CONTAINER_VIEW_PROP_MULTIPLE_SELECTION:
+      gimp_container_view_set_multiple_selection (view, g_value_get_boolean (value));
+      break;
     case GIMP_CONTAINER_VIEW_PROP_REORDERABLE:
       gimp_container_view_set_reorderable (view, g_value_get_boolean (value));
       break;
@@ -879,6 +921,9 @@ gimp_container_view_get_property (GObject    *object,
     case GIMP_CONTAINER_VIEW_PROP_CONTEXT:
       g_value_set_object (value, gimp_container_view_get_context (view));
       break;
+    case GIMP_CONTAINER_VIEW_PROP_MULTIPLE_SELECTION:
+      g_value_set_boolean (value, gimp_container_view_get_multiple_selection (view));
+      break;
     case GIMP_CONTAINER_VIEW_PROP_REORDERABLE:
       g_value_set_boolean (value, gimp_container_view_get_reorderable (view));
       break;
diff --git a/app/widgets/gimpcontainerview.h b/app/widgets/gimpcontainerview.h
index 41b63a8..3ac903f 100644
--- a/app/widgets/gimpcontainerview.h
+++ b/app/widgets/gimpcontainerview.h
@@ -27,6 +27,7 @@ typedef enum
   GIMP_CONTAINER_VIEW_PROP_0,
   GIMP_CONTAINER_VIEW_PROP_CONTAINER,
   GIMP_CONTAINER_VIEW_PROP_CONTEXT,
+  GIMP_CONTAINER_VIEW_PROP_MULTIPLE_SELECTION,
   GIMP_CONTAINER_VIEW_PROP_REORDERABLE,
   GIMP_CONTAINER_VIEW_PROP_VIEW_SIZE,
   GIMP_CONTAINER_VIEW_PROP_VIEW_BORDER_WIDTH,
@@ -62,6 +63,9 @@ struct _GimpContainerViewInterface
                                   GimpContainer     *container);
   void     (* set_context)       (GimpContainerView *view,
                                   GimpContext       *context);
+  void     (* set_multiple_selection) (GimpContainerView *view,
+                                       gboolean           value);
+
   gpointer (* insert_item)       (GimpContainerView *view,
                                   GimpViewable      *object,
                                   gpointer           parent_insert_data,
@@ -101,6 +105,10 @@ GimpContext   * gimp_container_view_get_context   (GimpContainerView *view);
 void            gimp_container_view_set_context   (GimpContainerView *view,
                                                    GimpContext       *context);
 
+gboolean        gimp_container_view_get_multiple_selection (GimpContainerView *view);
+void            gimp_container_view_set_multiple_selection (GimpContainerView *view,
+                                                            gboolean           value);
+
 gint         gimp_container_view_get_view_size (GimpContainerView *view,
                                                 gint              *view_border_width);
 void         gimp_container_view_set_view_size (GimpContainerView *view,
diff --git a/app/widgets/gimpdatafactoryview.c b/app/widgets/gimpdatafactoryview.c
index 531f16c..c4e15a3 100644
--- a/app/widgets/gimpdatafactoryview.c
+++ b/app/widgets/gimpdatafactoryview.c
@@ -239,6 +239,8 @@ gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
 
   editor = GIMP_CONTAINER_EDITOR (factory_view);
 
+  gimp_container_editor_set_multiple_selection (editor, TRUE);
+
   if (GIMP_IS_CONTAINER_TREE_VIEW (editor->view))
     {
       GimpContainerTreeView *tree_view;



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