[gimp/wip/Jehan/issue-498-quick-brush-edit] WIP.



commit 71709367813e572fb0bdedfd01ed5e75d05caae5
Author: Jehan <jehan girinstud io>
Date:   Tue Aug 16 15:20:58 2022 +0200

    WIP.

 app/display/display-enums.c       |   2 +
 app/display/display-enums.h       |  18 ++---
 app/widgets/gimpmodifierseditor.c | 137 ++++++++++++++++++++++++++++++++++----
 3 files changed, 137 insertions(+), 20 deletions(-)
---
diff --git a/app/display/display-enums.c b/app/display/display-enums.c
index c9be1369dc..9ba4003a47 100644
--- a/app/display/display-enums.c
+++ b/app/display/display-enums.c
@@ -604,6 +604,7 @@ gimp_modifier_action_get_type (void)
     { GIMP_MODIFIER_ACTION_STEP_ROTATING, "GIMP_MODIFIER_ACTION_STEP_ROTATING", "step-rotating" },
     { GIMP_MODIFIER_ACTION_LAYER_PICKING, "GIMP_MODIFIER_ACTION_LAYER_PICKING", "layer-picking" },
     { GIMP_MODIFIER_ACTION_MENU, "GIMP_MODIFIER_ACTION_MENU", "menu" },
+    { GIMP_MODIFIER_ACTION_ACTION, "GIMP_MODIFIER_ACTION_ACTION", "action" },
     { GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE, "GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE", "brush-pixel-size" },
     { GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE, "GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE", 
"brush-radius-pixel-size" },
     { 0, NULL, NULL }
@@ -618,6 +619,7 @@ gimp_modifier_action_get_type (void)
     { GIMP_MODIFIER_ACTION_STEP_ROTATING, NC_("modifier-action", "Rotate View by 15 degree steps"), NULL },
     { GIMP_MODIFIER_ACTION_LAYER_PICKING, NC_("modifier-action", "Pick a layer"), NULL },
     { GIMP_MODIFIER_ACTION_MENU, NC_("modifier-action", "Display the menu"), NULL },
+    { GIMP_MODIFIER_ACTION_ACTION, NC_("modifier-action", "Custom action"), NULL },
     { GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE, NC_("modifier-action", "Change brush size in canvas pixels"), 
NULL },
     { GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE, NC_("modifier-action", "Change brush radius' size in 
canvas pixels"), NULL },
     { 0, NULL, NULL }
diff --git a/app/display/display-enums.h b/app/display/display-enums.h
index bcb81028e5..fb969bca0d 100644
--- a/app/display/display-enums.h
+++ b/app/display/display-enums.h
@@ -267,16 +267,18 @@ GType gimp_modifier_action_get_type (void) G_GNUC_CONST;
 
 typedef enum
 {
-  GIMP_MODIFIER_ACTION_NONE,                    /*< desc="No action"                          >*/
-  GIMP_MODIFIER_ACTION_PANNING,                 /*< desc="Pan"                                >*/
-  GIMP_MODIFIER_ACTION_ZOOMING,                 /*< desc="Zoom"                               >*/
-  GIMP_MODIFIER_ACTION_ROTATING,                /*< desc="Rotate View"                        >*/
-  GIMP_MODIFIER_ACTION_STEP_ROTATING,           /*< desc="Rotate View by 15 degree steps"     >*/
-  GIMP_MODIFIER_ACTION_LAYER_PICKING,           /*< desc="Pick a layer"                       >*/
+  GIMP_MODIFIER_ACTION_NONE,                    /*< desc="No action"                                  >*/
+  GIMP_MODIFIER_ACTION_PANNING,                 /*< desc="Pan"                                        >*/
+  GIMP_MODIFIER_ACTION_ZOOMING,                 /*< desc="Zoom"                                       >*/
+  GIMP_MODIFIER_ACTION_ROTATING,                /*< desc="Rotate View"                                >*/
+  GIMP_MODIFIER_ACTION_STEP_ROTATING,           /*< desc="Rotate View by 15 degree steps"             >*/
+  GIMP_MODIFIER_ACTION_LAYER_PICKING,           /*< desc="Pick a layer"                               >*/
 
-  GIMP_MODIFIER_ACTION_MENU,                    /*< desc="Display the menu"                   >*/
+  GIMP_MODIFIER_ACTION_MENU,                    /*< desc="Display the menu"                           >*/
 
-  GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE,        /*< desc="Change brush size in canvas pixels" >*/
+  GIMP_MODIFIER_ACTION_ACTION,                  /*< desc="Custom action"                              >*/
+
+  GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE,        /*< desc="Change brush size in canvas pixels"         >*/
   GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE, /*< desc="Change brush radius' size in canvas pixels" >*/
 } GimpModifierAction;
 
diff --git a/app/widgets/gimpmodifierseditor.c b/app/widgets/gimpmodifierseditor.c
index 68e4c87c05..36ae5b4bdf 100644
--- a/app/widgets/gimpmodifierseditor.c
+++ b/app/widgets/gimpmodifierseditor.c
@@ -59,6 +59,7 @@ struct _GimpModifiersEditorPrivate
 
   GtkSizeGroup         *mod_size_group;
   GtkSizeGroup         *action_size_group;
+  GtkSizeGroup         *action_action_size_group;
   GtkSizeGroup         *minus_size_group;
 
   GimpModifiersManager *manager;
@@ -86,6 +87,8 @@ static void     gimp_modifiers_editor_minus_button_clicked (GtkButton
 static void     gimp_modifiers_editor_notify_accelerator   (GtkWidget           *widget,
                                                             const GParamSpec    *pspec,
                                                             GimpModifiersEditor *editor);
+static void     gimp_modifiers_editor_search_clicked       (GtkWidget           *button,
+                                                            GimpModifiersEditor *editor)
 
 static void     gimp_modifiers_editor_show_settings         (GimpModifiersEditor *editor,
                                                              GdkDevice           *device,
@@ -127,12 +130,13 @@ gimp_modifiers_editor_init (GimpModifiersEditor *editor)
   gchar     *text;
 
   editor->priv = gimp_modifiers_editor_get_instance_private (editor);
-  editor->priv->device            = NULL;
-  editor->priv->plus_button       = NULL;
-  editor->priv->current_settings  = NULL;
-  editor->priv->mod_size_group    = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-  editor->priv->action_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-  editor->priv->minus_size_group  = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+  editor->priv->device                   = NULL;
+  editor->priv->plus_button              = NULL;
+  editor->priv->current_settings         = NULL;
+  editor->priv->mod_size_group           = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+  editor->priv->action_size_group        = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+  editor->priv->action_action_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+  editor->priv->minus_size_group         = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
   /* Setup the title. */
   gtk_frame_set_label_align (GTK_FRAME (editor), 0.5, 0.5);
@@ -203,6 +207,7 @@ gimp_modifiers_editor_finalize (GObject *object)
   g_clear_object (&editor->priv->device);
   g_object_unref (editor->priv->mod_size_group);
   g_object_unref (editor->priv->action_size_group);
+  g_object_unref (editor->priv->action_action_size_group);
   g_object_unref (editor->priv->minus_size_group);
 }
 
@@ -399,9 +404,11 @@ gimp_modifiers_editor_add_mapping (GimpModifiersEditor *editor,
 {
   GtkWidget   *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
   GtkWidget   *box_row;
+  GtkWidget   *combo_action_box;
   GtkWidget   *combo;
   GtkWidget   *shortcut;
   GtkWidget   *minus_button;
+  GtkWidget   *action_button;
   GtkWidget   *plus_button;
 
   plus_button = g_object_get_data (G_OBJECT (editor->priv->current_settings), "plus-button");
@@ -414,12 +421,21 @@ gimp_modifiers_editor_add_mapping (GimpModifiersEditor *editor,
   gtk_size_group_add_widget (editor->priv->mod_size_group, shortcut);
   gtk_widget_show (shortcut);
 
+  combo_action_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
+  gtk_box_pack_start (GTK_BOX (box), combo_action_box, FALSE, FALSE, 0);
+  gtk_size_group_add_widget (editor->priv->action_action_size_group, combo_action_box);
+  gtk_widget_show (combo_action_box);
+
   combo = gimp_enum_combo_box_new (GIMP_TYPE_MODIFIER_ACTION);
-  gtk_box_pack_start (GTK_BOX (box), combo, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (combo_action_box), combo, FALSE, FALSE, 0);
   gtk_combo_box_set_active (GTK_COMBO_BOX (combo), mod_action);
   gtk_size_group_add_widget (editor->priv->action_size_group, combo);
   gtk_widget_show (combo);
 
+  action_button = gtk_button_new_from_icon_name ("system-search", GTK_ICON_SIZE_SMALL_TOOLBAR);
+  gtk_box_pack_start (GTK_BOX (combo_action_box), action_button, FALSE, FALSE, 0);
+  gtk_widget_set_visible (action_button, mod_action == GIMP_MODIFIER_ACTION_ACTION);
+
   minus_button = gtk_button_new_from_icon_name ("list-remove", GTK_ICON_SIZE_SMALL_TOOLBAR);
   gtk_size_group_add_widget (editor->priv->minus_size_group, minus_button);
   gtk_box_pack_start (GTK_BOX (box), minus_button, FALSE, FALSE, 0);
@@ -434,6 +450,7 @@ gimp_modifiers_editor_add_mapping (GimpModifiersEditor *editor,
   g_object_set_data (G_OBJECT (shortcut), "shortcut-action", combo);
   g_object_set_data (G_OBJECT (combo),    "shortcut-button", shortcut);
   g_object_set_data (G_OBJECT (combo),    "shortcut-action", combo);
+  g_object_set_data (G_OBJECT (combo),    "shortcut-action-action", action_button);
   g_signal_connect (shortcut, "notify::accelerator",
                     G_CALLBACK (gimp_modifiers_editor_notify_accelerator),
                     editor);
@@ -441,6 +458,10 @@ gimp_modifiers_editor_add_mapping (GimpModifiersEditor *editor,
                     G_CALLBACK (gimp_modifiers_editor_notify_accelerator),
                     editor);
 
+  g_signal_connect (action_button, "clicked",
+                    G_CALLBACK (gimp_modifiers_editor_search_clicked),
+                    editor);
+
   gtk_list_box_insert (GTK_LIST_BOX (editor->priv->current_settings), box, -1);
 
   if (plus_button)
@@ -501,17 +522,109 @@ gimp_modifiers_editor_notify_accelerator (GtkWidget           *widget,
 {
   GtkWidget          *shortcut;
   GtkWidget          *combo;
+  GtkWidget          *action_button;
   GimpModifierAction  action = GIMP_MODIFIER_ACTION_NONE;
 
   GdkModifierType  modifiers;
 
-  shortcut = g_object_get_data (G_OBJECT (widget), "shortcut-button");
-  combo    = g_object_get_data (G_OBJECT (widget), "shortcut-action");
+  shortcut      = g_object_get_data (G_OBJECT (widget), "shortcut-button");
+  combo         = g_object_get_data (G_OBJECT (widget), "shortcut-action");
+  action_button = g_object_get_data (G_OBJECT (widget), "shortcut-action-action");
 
   gimp_shortcut_button_get_keys (GIMP_SHORTCUT_BUTTON (shortcut), NULL, &modifiers);
 
   if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo), (gint *) &action))
-    gimp_modifiers_manager_set (editor->priv->manager, editor->priv->device,
-                                editor->priv->button, modifiers,
-                                action);
+    {
+      gimp_modifiers_manager_set (editor->priv->manager, editor->priv->device,
+                                  editor->priv->button, modifiers,
+                                  action);
+      gtk_widget_set_visible (action_button, action == GIMP_MODIFIER_ACTION_ACTION);
+    }
+}
+
+static void
+gimp_modifiers_editor_search_clicked (GtkWidget           *button,
+                                      GimpModifiersEditor *editor)
+{
+  /*GtkTreeModel *model;*/
+  /*GtkTreeIter   iter;*/
+  gchar        *event_name  = "event name";
+  gchar        *event_blurb = "blurb";
+  gchar        *action_name = "action name";
+
+  /*gimp_controller_info_set_event_snooper (editor->info, NULL, NULL);*/
+
+/*  if (gtk_tree_selection_get_selected (editor->sel, &model, &iter))
+    gtk_tree_model_get (model, &iter,
+                        COLUMN_EVENT,  &event_name,
+                        COLUMN_BLURB,  &event_blurb,
+                        COLUMN_ACTION, &action_name,
+                        -1);*/
+
+  if (event_name)
+    {
+      GtkWidget *view;
+      GtkWidget *edit_dialog;
+      gchar     *title;
+
+      title = g_strdup_printf (_("Select Action for Event '%s'"),
+                               event_blurb);
+
+      edit_dialog =
+        gimp_viewable_dialog_new (g_list_prepend (NULL, editor->info), editor->context,
+                                  _("Select Controller Event Action"),
+                                  "gimp-controller-action-dialog",
+                                  GIMP_ICON_EDIT,
+                                  title,
+                                  gtk_widget_get_toplevel (GTK_WIDGET (editor)),
+                                  gimp_standard_help_func,
+                                  GIMP_HELP_PREFS_INPUT_CONTROLLERS,
+
+                                  _("_Cancel"), GTK_RESPONSE_CANCEL,
+                                  _("_OK"),     GTK_RESPONSE_OK,
+
+                                  NULL);
+
+      g_free (title);
+
+      gimp_dialog_set_alternative_button_order (GTK_DIALOG (edit_dialog),
+                                               GTK_RESPONSE_OK,
+                                               GTK_RESPONSE_CANCEL,
+                                               -1);
+
+      g_object_add_weak_pointer (G_OBJECT (edit_dialog),
+                                 (gpointer) &edit_dialog);
+
+      gimp_dialog_factory_add_foreign (gimp_dialog_factory_get_singleton (),
+                                       "gimp-controller-action-dialog",
+                                       edit_dialog,
+                                       gimp_widget_get_monitor (button));
+
+      g_signal_connect (edit_dialog, "response",
+                        G_CALLBACK (gimp_controller_editor_edit_response),
+                        editor);
+
+      view = gimp_action_editor_new (gimp_ui_managers_from_name ("<Image>")->data,
+                                     action_name, FALSE);
+      gtk_container_set_border_width (GTK_CONTAINER (view), 12);
+      gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (edit_dialog))),
+                          view, TRUE, TRUE, 0);
+      gtk_widget_show (view);
+
+      g_signal_connect (GIMP_ACTION_EDITOR (view)->view, "row-activated",
+                        G_CALLBACK (gimp_controller_editor_edit_activated),
+                        editor);
+
+      editor->edit_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (GIMP_ACTION_EDITOR (view)->view));
+
+      g_object_add_weak_pointer (G_OBJECT (editor->edit_sel),
+                                 (gpointer) &editor->edit_sel);
+
+      gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
+      gtk_widget_show (edit_dialog);
+
+      g_free (event_name);
+      g_free (event_blurb);
+      g_free (action_name);
+    }
 }


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