[gimp] app: move the alt-click selection feature to GimpItemTreeView
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: move the alt-click selection feature to GimpItemTreeView
- Date: Tue, 20 Jul 2010 21:37:58 +0000 (UTC)
commit 4165dfb217557fe5d857125f40ec5fddf41e152f
Author: Michael Natterer <mitch gimp org>
Date: Tue Jul 20 23:36:16 2010 +0200
app: move the alt-click selection feature to GimpItemTreeView
so it works the same for layers, channels and vectors and remove the
separate (and different) implementations from all subclasses.
app/widgets/gimpchanneltreeview.c | 44 -----------------------
app/widgets/gimpitemtreeview.c | 68 +++++++++++++++++++++++++++++++++++
app/widgets/gimplayertreeview.c | 71 -------------------------------------
app/widgets/gimpvectorstreeview.c | 39 --------------------
4 files changed, 68 insertions(+), 154 deletions(-)
---
diff --git a/app/widgets/gimpchanneltreeview.c b/app/widgets/gimpchanneltreeview.c
index 623a4ef..f0bbc27 100644
--- a/app/widgets/gimpchanneltreeview.c
+++ b/app/widgets/gimpchanneltreeview.c
@@ -79,11 +79,6 @@ static void gimp_channel_tree_view_set_context (GimpContainerView *view,
GimpContext *context);
static void gimp_channel_tree_view_set_view_size (GimpContainerView *view);
-static void gimp_channel_tree_view_channel_clicked (GimpCellRendererViewable *cell,
- const gchar *path_str,
- GdkModifierType state,
- GimpContainerTreeView *tree_view);
-
G_DEFINE_TYPE_WITH_CODE (GimpChannelTreeView, gimp_channel_tree_view,
GIMP_TYPE_DRAWABLE_TREE_VIEW,
@@ -170,10 +165,6 @@ gimp_channel_tree_view_constructor (GType type,
view = GIMP_CHANNEL_TREE_VIEW (object);
tree_view = GIMP_CONTAINER_TREE_VIEW (object);
- g_signal_connect (tree_view->renderer_cell, "clicked",
- G_CALLBACK (gimp_channel_tree_view_channel_clicked),
- view);
-
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_LAYER,
NULL, tree_view);
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_LAYER_MASK,
@@ -380,38 +371,3 @@ gimp_channel_tree_view_set_view_size (GimpContainerView *view)
gimp_component_editor_set_view_size (GIMP_COMPONENT_EDITOR (channel_view->priv->component_editor),
view_size);
}
-
-
-/* signal handlers */
-
-static void
-gimp_channel_tree_view_channel_clicked (GimpCellRendererViewable *cell,
- const gchar *path_str,
- GdkModifierType state,
- GimpContainerTreeView *tree_view)
-{
- if (state & GDK_MOD1_MASK)
- {
- GimpUIManager *ui_manager = GIMP_EDITOR (tree_view)->ui_manager;
- GimpActionGroup *group;
- const gchar *action = "channels-selection-replace";
-
- group = gimp_ui_manager_get_action_group (ui_manager, "channels");
-
- if ((state & GDK_SHIFT_MASK) && (state & GDK_CONTROL_MASK))
- {
- action = "channels-selection-intersect";
- }
- else if (state & GDK_SHIFT_MASK)
- {
- action = "channels-selection-add";
- }
- else if (state & GDK_CONTROL_MASK)
- {
- action = "channels-selection-subtract";
- }
-
- gimp_action_group_activate_action (group, action);
- }
-}
-
diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c
index 57b8230..cb941d0 100644
--- a/app/widgets/gimpitemtreeview.c
+++ b/app/widgets/gimpitemtreeview.c
@@ -186,6 +186,11 @@ static void gimp_item_tree_view_lock_content_toggled
static void gimp_item_tree_view_update_options (GimpItemTreeView *view,
GimpItem *item);
+static gboolean gimp_item_tree_view_item_pre_clicked(GimpCellRendererViewable *cell,
+ const gchar *path_str,
+ GdkModifierType state,
+ GimpItemTreeView *item_view);
+
/* utility function to avoid code duplication */
static void gimp_item_tree_view_toggle_clicked (GtkCellRendererToggle *toggle,
gchar *path_str,
@@ -346,6 +351,10 @@ gimp_item_tree_view_constructor (GType type,
G_CALLBACK (gimp_item_tree_view_row_expanded),
tree_view);
+ g_signal_connect (tree_view->renderer_cell, "pre-clicked",
+ G_CALLBACK (gimp_item_tree_view_item_pre_clicked),
+ item_view);
+
column = gtk_tree_view_column_new ();
gtk_tree_view_insert_column (tree_view->view, column, 0);
@@ -1354,6 +1363,65 @@ gimp_item_tree_view_lock_content_toggled (GtkWidget *widget,
}
}
+static gboolean
+gimp_item_tree_view_item_pre_clicked (GimpCellRendererViewable *cell,
+ const gchar *path_str,
+ GdkModifierType state,
+ GimpItemTreeView *item_view)
+{
+ GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (item_view);
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gboolean handled = FALSE;
+
+ path = gtk_tree_path_new_from_string (path_str);
+
+ if (gtk_tree_model_get_iter (tree_view->model, &iter, path) &&
+ state & GDK_MOD1_MASK)
+ {
+ GimpImage *image = gimp_item_tree_view_get_image (item_view);
+ GimpViewRenderer *renderer = NULL;
+
+ gtk_tree_model_get (tree_view->model, &iter,
+ GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER, &renderer,
+ -1);
+
+ if (renderer)
+ {
+ GimpItem *item;
+ GimpChannelOps op = GIMP_CHANNEL_OP_REPLACE;
+
+ item = GIMP_ITEM (renderer->viewable);
+
+ if ((state & GDK_SHIFT_MASK) && (state & GDK_CONTROL_MASK))
+ {
+ op = GIMP_CHANNEL_OP_INTERSECT;
+ }
+ else if (state & GDK_SHIFT_MASK)
+ {
+ op = GIMP_CHANNEL_OP_ADD;
+ }
+ else if (state & GDK_CONTROL_MASK)
+ {
+ op = GIMP_CHANNEL_OP_SUBTRACT;
+ }
+
+ gimp_item_to_selection (item, op,
+ TRUE, FALSE, 0.0, 0.0);
+ gimp_image_flush (image);
+
+ g_object_unref (renderer);
+
+ /* Don't select the clicked layer */
+ handled = TRUE;
+ }
+ }
+
+ gtk_tree_path_free (path);
+
+ return handled;
+}
+
static void
gimp_item_tree_view_update_options (GimpItemTreeView *view,
GimpItem *item)
diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c
index 8a2b0da..9a2a1b4 100644
--- a/app/widgets/gimplayertreeview.c
+++ b/app/widgets/gimplayertreeview.c
@@ -32,7 +32,6 @@
#include "widgets-types.h"
#include "core/gimp.h"
-#include "core/gimpchannel-select.h"
#include "core/gimpcontainer.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage.h"
@@ -152,10 +151,6 @@ static void gimp_layer_tree_view_update_borders (GimpLayerTree
GtkTreeIter *iter);
static void gimp_layer_tree_view_mask_callback (GimpLayerMask *mask,
GimpLayerTreeView *view);
-static gboolean gimp_layer_tree_view_layer_pre_clicked (GimpCellRendererViewable *cell,
- const gchar *path_str,
- GdkModifierType state,
- GimpLayerTreeView *layer_view);
static void gimp_layer_tree_view_layer_clicked (GimpCellRendererViewable *cell,
const gchar *path,
GdkModifierType state,
@@ -365,9 +360,6 @@ gimp_layer_tree_view_constructor (GType type,
gimp_container_tree_view_add_renderer_cell (tree_view,
layer_view->priv->mask_cell);
- g_signal_connect (tree_view->renderer_cell, "pre-clicked",
- G_CALLBACK (gimp_layer_tree_view_layer_pre_clicked),
- layer_view);
g_signal_connect (tree_view->renderer_cell, "clicked",
G_CALLBACK (gimp_layer_tree_view_layer_clicked),
layer_view);
@@ -1305,69 +1297,6 @@ gimp_layer_tree_view_mask_callback (GimpLayerMask *mask,
gimp_layer_tree_view_update_borders (layer_view, iter);
}
-static gboolean
-gimp_layer_tree_view_layer_pre_clicked (GimpCellRendererViewable *cell,
- const gchar *path_str,
- GdkModifierType state,
- GimpLayerTreeView *layer_view)
-{
- GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (layer_view);
- GtkTreePath *path;
- GtkTreeIter iter;
- gboolean handled = FALSE;
-
- path = gtk_tree_path_new_from_string (path_str);
-
- if (gtk_tree_model_get_iter (tree_view->model, &iter, path) &&
- state & GDK_MOD1_MASK)
- {
- GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view);
- GimpImage *image = gimp_item_tree_view_get_image (item_view);
- GimpViewRenderer *layer_renderer = NULL;
- GimpDrawable *layer = NULL;
- GimpChannelOps op;
-
- gtk_tree_model_get (tree_view->model, &iter,
- GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER, &layer_renderer,
- -1);
-
- if (layer_renderer)
- layer = GIMP_DRAWABLE (layer_renderer->viewable);
-
- op = GIMP_CHANNEL_OP_REPLACE;
-
- if ((state & GDK_SHIFT_MASK) && (state & GDK_CONTROL_MASK))
- {
- op = GIMP_CHANNEL_OP_INTERSECT;
- }
- else if (state & GDK_SHIFT_MASK)
- {
- op = GIMP_CHANNEL_OP_ADD;
- }
- else if (state & GDK_CONTROL_MASK)
- {
- op = GIMP_CHANNEL_OP_SUBTRACT;
- }
-
- gimp_channel_select_alpha (gimp_image_get_mask (image),
- layer,
- op,
- FALSE /*feather*/,
- 0.0, 0.0 /*feather_radius_x,y*/);
- gimp_image_flush (image);
-
- if (layer_renderer)
- g_object_unref (layer_renderer);
-
- /* Don't select the clicked layer */
- handled = TRUE;
- }
-
- gtk_tree_path_free (path);
-
- return handled;
-}
-
static void
gimp_layer_tree_view_layer_clicked (GimpCellRendererViewable *cell,
const gchar *path_str,
diff --git a/app/widgets/gimpvectorstreeview.c b/app/widgets/gimpvectorstreeview.c
index 8ee7524..3d477ab 100644
--- a/app/widgets/gimpvectorstreeview.c
+++ b/app/widgets/gimpvectorstreeview.c
@@ -61,10 +61,6 @@ static void gimp_vectors_tree_view_drop_svg (GimpContainerTreeView
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos);
static GimpItem * gimp_vectors_tree_view_item_new (GimpImage *image);
-static void gimp_vectors_tree_view_vectors_clicked (GimpCellRendererViewable *cell,
- const gchar *path_str,
- GdkModifierType state,
- GimpContainerTreeView *tree_view);
static guchar * gimp_vectors_tree_view_drag_svg (GtkWidget *widget,
gsize *svg_data_len,
gpointer data);
@@ -145,10 +141,6 @@ gimp_vectors_tree_view_constructor (GType type,
tree_view = GIMP_CONTAINER_TREE_VIEW (object);
view = GIMP_VECTORS_TREE_VIEW (object);
- g_signal_connect (tree_view->renderer_cell, "clicked",
- G_CALLBACK (gimp_vectors_tree_view_vectors_clicked),
- view);
-
/* hide basically useless edit button */
gtk_widget_hide (gimp_item_tree_view_get_edit_button (GIMP_ITEM_TREE_VIEW (view)));
@@ -265,37 +257,6 @@ gimp_vectors_tree_view_item_new (GimpImage *image)
return GIMP_ITEM (new_vectors);
}
-static void
-gimp_vectors_tree_view_vectors_clicked (GimpCellRendererViewable *cell,
- const gchar *path_str,
- GdkModifierType state,
- GimpContainerTreeView *tree_view)
-{
- if (state & GDK_MOD1_MASK)
- {
- GimpUIManager *ui_manager = GIMP_EDITOR (tree_view)->ui_manager;
- GimpActionGroup *group;
- const gchar *action = "vectors-selection-replace";
-
- group = gimp_ui_manager_get_action_group (ui_manager, "vectors");
-
- if ((state & GDK_SHIFT_MASK) && (state & GDK_CONTROL_MASK))
- {
- action = "vectors-selection-intersect";
- }
- else if (state & GDK_SHIFT_MASK)
- {
- action = "vectors-selection-add";
- }
- else if (state & GDK_CONTROL_MASK)
- {
- action = "vectors-selection-subtract";
- }
-
- gimp_action_group_activate_action (group, action);
- }
-}
-
static guchar *
gimp_vectors_tree_view_drag_svg (GtkWidget *widget,
gsize *svg_data_len,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]