[gimp] app: base multiple selection API on the GtkSelectionMode enum



commit 788ba611af9435b8c5f6f8bda64416490ac5597a
Author: Michael Natterer <mitch gimp org>
Date:   Wed May 19 20:07:31 2010 +0200

    app: base multiple selection API on the GtkSelectionMode enum
    
    change get,set_multiple_selection(gboolean) to
    get,set_selection_mode(GtkSelectionMode) so the APIs are consistent
    with GTK+.

 app/widgets/gimpcontainereditor.c   |   14 +++---
 app/widgets/gimpcontainereditor.h   |    8 ++--
 app/widgets/gimpcontainertreeview.c |   38 +++++++--------
 app/widgets/gimpcontainerview.c     |   85 ++++++++++++++++++-----------------
 app/widgets/gimpcontainerview.h     |   84 +++++++++++++++++-----------------
 app/widgets/gimpdatafactoryview.c   |    2 +-
 6 files changed, 116 insertions(+), 115 deletions(-)
---
diff --git a/app/widgets/gimpcontainereditor.c b/app/widgets/gimpcontainereditor.c
index a403d70..d42a490 100644
--- a/app/widgets/gimpcontainereditor.c
+++ b/app/widgets/gimpcontainereditor.c
@@ -184,18 +184,18 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
   return TRUE;
 }
 
-gboolean
-gimp_container_editor_get_multiple_selection (GimpContainerEditor *editor)
+GtkSelectionMode
+gimp_container_editor_get_selection_mode (GimpContainerEditor *editor)
 {
-  return gimp_container_view_get_multiple_selection (GIMP_CONTAINER_VIEW (editor->view));
+  return gimp_container_view_get_selection_mode (GIMP_CONTAINER_VIEW (editor->view));
 }
 
 void
-gimp_container_editor_set_multiple_selection (GimpContainerEditor *editor,
-                                              gboolean             value)
+gimp_container_editor_set_selection_mode (GimpContainerEditor *editor,
+                                          GtkSelectionMode     mode)
 {
-  gimp_container_view_set_multiple_selection (GIMP_CONTAINER_VIEW (editor->view),
-                                              value);
+  gimp_container_view_set_selection_mode (GIMP_CONTAINER_VIEW (editor->view),
+                                          mode);
 }
 
 /*  private functions  */
diff --git a/app/widgets/gimpcontainereditor.h b/app/widgets/gimpcontainereditor.h
index 66f589c..510dd65 100644
--- a/app/widgets/gimpcontainereditor.h
+++ b/app/widgets/gimpcontainereditor.h
@@ -52,11 +52,11 @@ struct _GimpContainerEditorClass
 };
 
 
-GType     gimp_container_editor_get_type  (void) G_GNUC_CONST;
+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);
+GtkSelectionMode gimp_container_editor_get_selection_mode (GimpContainerEditor *editor);
+void             gimp_container_editor_set_selection_mode (GimpContainerEditor *editor,
+                                                           GtkSelectionMode     mode);
 
 
 /*  protected  */
diff --git a/app/widgets/gimpcontainertreeview.c b/app/widgets/gimpcontainertreeview.c
index 6f9fcb8..875c454 100644
--- a/app/widgets/gimpcontainertreeview.c
+++ b/app/widgets/gimpcontainertreeview.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimpcontainertreeview.c
- * Copyright (C) 2003-2004 Michael Natterer <mitch gimp org>
+ * Copyright (C) 2003-2010 Michael Natterer <mitch gimp 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
@@ -58,8 +58,8 @@ 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 void          gimp_container_tree_view_set_selection_mode(GimpContainerView           *view,
+                                                                 GtkSelectionMode             mode);
 
 static gpointer      gimp_container_tree_view_insert_item       (GimpContainerView           *view,
                                                                  GimpViewable                *viewable,
@@ -148,17 +148,17 @@ gimp_container_tree_view_view_iface_init (GimpContainerViewInterface *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;
-  iface->rename_item   = gimp_container_tree_view_rename_item;
-  iface->select_item   = gimp_container_tree_view_select_item;
-  iface->clear_items   = gimp_container_tree_view_clear_items;
-  iface->set_view_size = gimp_container_tree_view_set_view_size;
-  iface->get_selected  = gimp_container_tree_view_get_selected;
+  iface->set_container      = gimp_container_tree_view_set_container;
+  iface->set_context        = gimp_container_tree_view_set_context;
+  iface->set_selection_mode = gimp_container_tree_view_set_selection_mode;
+  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;
+  iface->rename_item        = gimp_container_tree_view_rename_item;
+  iface->select_item        = gimp_container_tree_view_select_item;
+  iface->clear_items        = gimp_container_tree_view_clear_items;
+  iface->set_view_size      = gimp_container_tree_view_set_view_size;
+  iface->get_selected       = gimp_container_tree_view_get_selected;
 
   iface->insert_data_free = (GDestroyNotify) gtk_tree_iter_free;
 }
@@ -547,16 +547,14 @@ gimp_container_tree_view_set_context (GimpContainerView *view,
 }
 
 static void
-gimp_container_tree_view_set_multiple_selection (GimpContainerView *view,
-                                                 gboolean           value)
+gimp_container_tree_view_set_selection_mode (GimpContainerView *view,
+                                             GtkSelectionMode   mode)
 {
   GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
 
-  gtk_tree_selection_set_mode (tree_view->priv->selection,
-                               value ? GTK_SELECTION_MULTIPLE :
-                                       GTK_SELECTION_NONE);
+  gtk_tree_selection_set_mode (tree_view->priv->selection, mode);
 
-  parent_view_iface->set_multiple_selection (view, value);
+  parent_view_iface->set_selection_mode (view, mode);
 }
 
 static gpointer
diff --git a/app/widgets/gimpcontainerview.c b/app/widgets/gimpcontainerview.c
index e652c5d..8b4f9ca 100644
--- a/app/widgets/gimpcontainerview.c
+++ b/app/widgets/gimpcontainerview.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimpcontainerview.c
- * Copyright (C) 2001-2009 Michael Natterer <mitch gimp org>
+ * Copyright (C) 2001-2010 Michael Natterer <mitch gimp 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
@@ -65,7 +65,7 @@ struct _GimpContainerViewPrivate
   gint             view_size;
   gint             view_border_width;
   gboolean         reorderable;
-  gboolean         multiple_selection;
+  GtkSelectionMode selection_mode;
 
   /*  initialized by subclass  */
   GtkWidget       *dnd_widget;
@@ -83,8 +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_real_set_selection_mode (GimpContainerView *view,
+                                                           GtkSelectionMode   mode);
 
 static void   gimp_container_view_clear_items      (GimpContainerView  *view);
 static void   gimp_container_view_real_clear_items (GimpContainerView  *view);
@@ -204,24 +204,24 @@ gimp_container_view_iface_base_init (GimpContainerViewInterface *view_iface)
                   GIMP_TYPE_OBJECT,
                   G_TYPE_POINTER);
 
-  view_iface->select_item       = NULL;
-  view_iface->activate_item     = NULL;
-  view_iface->context_item      = NULL;
-
-  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;
-  view_iface->reorder_item      = NULL;
-  view_iface->rename_item       = NULL;
-  view_iface->clear_items       = gimp_container_view_real_clear_items;
-  view_iface->set_view_size     = NULL;
-  view_iface->get_selected      = gimp_container_view_real_get_selected;
-
-  view_iface->insert_data_free  = NULL;
-  view_iface->model_is_tree     = FALSE;
+  view_iface->select_item        = NULL;
+  view_iface->activate_item      = NULL;
+  view_iface->context_item       = NULL;
+
+  view_iface->set_container      = gimp_container_view_real_set_container;
+  view_iface->set_context        = gimp_container_view_real_set_context;
+  view_iface->set_selection_mode = gimp_container_view_real_set_selection_mode;
+  view_iface->insert_item        = NULL;
+  view_iface->insert_item_after  = NULL;
+  view_iface->remove_item        = NULL;
+  view_iface->reorder_item       = NULL;
+  view_iface->rename_item        = NULL;
+  view_iface->clear_items        = gimp_container_view_real_clear_items;
+  view_iface->set_view_size      = NULL;
+  view_iface->get_selected       = gimp_container_view_real_get_selected;
+
+  view_iface->insert_data_free   = NULL;
+  view_iface->model_is_tree      = FALSE;
 
   g_object_interface_install_property (view_iface,
                                        g_param_spec_object ("container",
@@ -236,10 +236,11 @@ 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_param_spec_enum ("selection-mode",
+                                                          NULL, NULL,
+                                                          GTK_TYPE_SELECTION_MODE,
+                                                          GTK_SELECTION_SINGLE,
+                                                          GIMP_PARAM_READWRITE));
 
   g_object_interface_install_property (view_iface,
                                        g_param_spec_boolean ("reorderable",
@@ -349,8 +350,8 @@ 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");
+                                    GIMP_CONTAINER_VIEW_PROP_SELECTION_MODE,
+                                    "selection-mode");
   g_object_class_override_property (klass,
                                     GIMP_CONTAINER_VIEW_PROP_REORDERABLE,
                                     "reorderable");
@@ -499,30 +500,32 @@ gimp_container_view_real_set_context (GimpContainerView *view,
     }
 }
 
-gboolean
-gimp_container_view_get_multiple_selection (GimpContainerView *view)
+GtkSelectionMode
+gimp_container_view_get_selection_mode (GimpContainerView *view)
 {
   GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
 
-  return private->multiple_selection;
+  return private->selection_mode;
 }
 
 void
-gimp_container_view_set_multiple_selection (GimpContainerView *view,
-                                            gboolean           value)
+gimp_container_view_set_selection_mode (GimpContainerView *view,
+                                        GtkSelectionMode   mode)
 {
   g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
+  g_return_if_fail (mode == GTK_SELECTION_SINGLE ||
+                    mode == GTK_SELECTION_MULTIPLE);
 
-  GIMP_CONTAINER_VIEW_GET_INTERFACE (view)->set_multiple_selection (view, value);
+  GIMP_CONTAINER_VIEW_GET_INTERFACE (view)->set_selection_mode (view, mode);
 }
 
 static void
-gimp_container_view_real_set_multiple_selection (GimpContainerView *view,
-                                                 gboolean           value)
+gimp_container_view_real_set_selection_mode (GimpContainerView *view,
+                                             GtkSelectionMode   mode)
 {
   GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
 
-  private->multiple_selection = value;
+  private->selection_mode = mode;
 }
 
 gint
@@ -870,8 +873,8 @@ 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));
+    case GIMP_CONTAINER_VIEW_PROP_SELECTION_MODE:
+      gimp_container_view_set_selection_mode (view, g_value_get_enum (value));
       break;
     case GIMP_CONTAINER_VIEW_PROP_REORDERABLE:
       gimp_container_view_set_reorderable (view, g_value_get_boolean (value));
@@ -913,8 +916,8 @@ 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));
+    case GIMP_CONTAINER_VIEW_PROP_SELECTION_MODE:
+      g_value_set_enum (value, gimp_container_view_get_selection_mode (view));
       break;
     case GIMP_CONTAINER_VIEW_PROP_REORDERABLE:
       g_value_set_boolean (value, gimp_container_view_get_reorderable (view));
diff --git a/app/widgets/gimpcontainerview.h b/app/widgets/gimpcontainerview.h
index 3ac903f..7573417 100644
--- a/app/widgets/gimpcontainerview.h
+++ b/app/widgets/gimpcontainerview.h
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimpcontainerview.h
- * Copyright (C) 2001-2006 Michael Natterer <mitch gimp org>
+ * Copyright (C) 2001-2010 Michael Natterer <mitch gimp 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
@@ -27,7 +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_SELECTION_MODE,
   GIMP_CONTAINER_VIEW_PROP_REORDERABLE,
   GIMP_CONTAINER_VIEW_PROP_VIEW_SIZE,
   GIMP_CONTAINER_VIEW_PROP_VIEW_BORDER_WIDTH,
@@ -48,45 +48,45 @@ struct _GimpContainerViewInterface
   GTypeInterface base_iface;
 
   /*  signals  */
-  gboolean (* select_item)       (GimpContainerView *view,
-                                  GimpViewable      *object,
-                                  gpointer           insert_data);
-  void     (* activate_item)     (GimpContainerView *view,
-                                  GimpViewable      *object,
-                                  gpointer           insert_data);
-  void     (* context_item)      (GimpContainerView *view,
-                                  GimpViewable      *object,
-                                  gpointer           insert_data);
+  gboolean (* select_item)        (GimpContainerView *view,
+                                   GimpViewable      *object,
+                                   gpointer           insert_data);
+  void     (* activate_item)      (GimpContainerView *view,
+                                   GimpViewable      *object,
+                                   gpointer           insert_data);
+  void     (* context_item)       (GimpContainerView *view,
+                                   GimpViewable      *object,
+                                   gpointer           insert_data);
 
   /*  virtual functions  */
-  void     (* set_container)     (GimpContainerView *view,
-                                  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,
-                                  gint               index);
-  void     (* insert_item_after) (GimpContainerView *view,
-                                  GimpViewable      *object,
-                                  gpointer           insert_data);
-  void     (* remove_item)       (GimpContainerView *view,
-                                  GimpViewable      *object,
-                                  gpointer           insert_data);
-  void     (* reorder_item)      (GimpContainerView *view,
-                                  GimpViewable      *object,
-                                  gint               new_index,
-                                  gpointer           insert_data);
-  void     (* rename_item)       (GimpContainerView *view,
-                                  GimpViewable      *object,
-                                  gpointer           insert_data);
-  void     (* clear_items)       (GimpContainerView *view);
-  void     (* set_view_size)     (GimpContainerView *view);
-  gint     (* get_selected)      (GimpContainerView  *view,
-                                  GList             **items);
+  void     (* set_container)      (GimpContainerView *view,
+                                   GimpContainer     *container);
+  void     (* set_context)        (GimpContainerView *view,
+                                   GimpContext       *context);
+  void     (* set_selection_mode) (GimpContainerView *view,
+                                   GtkSelectionMode   mode);
+
+  gpointer (* insert_item)        (GimpContainerView *view,
+                                   GimpViewable      *object,
+                                   gpointer           parent_insert_data,
+                                   gint               index);
+  void     (* insert_item_after)  (GimpContainerView *view,
+                                   GimpViewable      *object,
+                                   gpointer           insert_data);
+  void     (* remove_item)        (GimpContainerView *view,
+                                   GimpViewable      *object,
+                                   gpointer           insert_data);
+  void     (* reorder_item)       (GimpContainerView *view,
+                                   GimpViewable      *object,
+                                   gint               new_index,
+                                   gpointer           insert_data);
+  void     (* rename_item)        (GimpContainerView *view,
+                                   GimpViewable      *object,
+                                   gpointer           insert_data);
+  void     (* clear_items)        (GimpContainerView *view);
+  void     (* set_view_size)      (GimpContainerView *view);
+  gint     (* get_selected)       (GimpContainerView  *view,
+                                   GList             **items);
 
 
   /*  the destroy notifier for private->hash_table's values  */
@@ -105,9 +105,9 @@ 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);
+GtkSelectionMode gimp_container_view_get_selection_mode (GimpContainerView *view);
+void             gimp_container_view_set_selection_mode (GimpContainerView *view,
+                                                         GtkSelectionMode   mode);
 
 gint         gimp_container_view_get_view_size (GimpContainerView *view,
                                                 gint              *view_border_width);
diff --git a/app/widgets/gimpdatafactoryview.c b/app/widgets/gimpdatafactoryview.c
index 1d1a98a..b7e8f5d 100644
--- a/app/widgets/gimpdatafactoryview.c
+++ b/app/widgets/gimpdatafactoryview.c
@@ -240,7 +240,7 @@ gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
 
   editor = GIMP_CONTAINER_EDITOR (factory_view);
 
-  gimp_container_editor_set_multiple_selection (editor, TRUE);
+  gimp_container_editor_set_selection_mode (editor, GTK_SELECTION_MULTIPLE);
 
   if (GIMP_IS_CONTAINER_TREE_VIEW (editor->view))
     {



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