[gimp] app: in GimpToolButton, select active tool in menu
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: in GimpToolButton, select active tool in menu
- Date: Thu, 26 Mar 2020 11:33:00 +0000 (UTC)
commit 75435c8e6b5ace24f9b01753660511499382f3d9
Author: Ell <ell_se yahoo com>
Date: Wed Mar 25 20:05:47 2020 +0200
app: in GimpToolButton, select active tool in menu
In a GimpToolButton representing a tool group, select the group's
active-tool item when showing the menu.
app/widgets/gimptoolbutton.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
---
diff --git a/app/widgets/gimptoolbutton.c b/app/widgets/gimptoolbutton.c
index c861d68f75..e4a6250131 100644
--- a/app/widgets/gimptoolbutton.c
+++ b/app/widgets/gimptoolbutton.c
@@ -129,6 +129,9 @@ static void gimp_tool_button_icon_size_notify (GtkToolPalette *p
const GParamSpec *pspec,
GimpToolButton *tool_button);
+static gboolean gimp_tool_button_menu_leave_notify (GtkMenu *menu,
+ GdkEventCrossing *event,
+ GimpToolButton *tool_button);
static void gimp_tool_button_menu_popped_up (GtkMenu *menu,
const GdkRectangle *flipped_rect,
const GdkRectangle *final_rect,
@@ -142,6 +145,7 @@ static gboolean gimp_tool_button_menu_timeout (GimpToolButton *t
static void gimp_tool_button_update (GimpToolButton *tool_button);
static void gimp_tool_button_update_toggled (GimpToolButton *tool_button);
+static void gimp_tool_button_update_menu (GimpToolButton *tool_button);
static void gimp_tool_button_add_menu_item (GimpToolButton *tool_button,
GimpToolInfo *tool_info,
@@ -614,6 +618,20 @@ gimp_tool_button_menu_popped_up (GtkMenu *menu,
tools_select_cmd_block_initialize ();
}
+static gboolean
+gimp_tool_button_menu_leave_notify (GtkMenu *menu,
+ GdkEventCrossing *event,
+ GimpToolButton *tool_button)
+{
+ if (event->mode == GDK_CROSSING_NORMAL &&
+ gtk_widget_get_visible (tool_button->priv->menu))
+ {
+ gimp_tool_button_update_menu (tool_button);
+ }
+
+ return FALSE;
+}
+
static gboolean
gimp_tool_button_menu_deactivate_idle (gpointer data)
{
@@ -680,6 +698,7 @@ gimp_tool_button_update (GimpToolButton *tool_button)
}
gimp_tool_button_update_toggled (tool_button);
+ gimp_tool_button_update_menu (tool_button);
}
static void
@@ -697,6 +716,23 @@ gimp_tool_button_update_toggled (GimpToolButton *tool_button)
tool_info && tool_info == gimp_context_get_tool (context));
}
+static void
+gimp_tool_button_update_menu (GimpToolButton *tool_button)
+{
+ if (tool_button->priv->menu &&
+ gtk_widget_get_visible (tool_button->priv->menu))
+ {
+ GimpToolInfo *tool_info = gimp_tool_button_get_tool_info (tool_button);
+
+ if (tool_info)
+ {
+ gtk_menu_shell_select_item (
+ GTK_MENU_SHELL (tool_button->priv->menu),
+ g_hash_table_lookup (tool_button->priv->menu_items, tool_info));
+ }
+ }
+}
+
static void
gimp_tool_button_add_menu_item (GimpToolButton *tool_button,
GimpToolInfo *tool_info,
@@ -806,6 +842,9 @@ gimp_tool_button_reconstruct_menu (GimpToolButton *tool_button)
gtk_menu_attach_to_widget (GTK_MENU (tool_button->priv->menu),
GTK_WIDGET (tool_button), NULL);
+ g_signal_connect (tool_button->priv->menu, "leave-notify-event",
+ G_CALLBACK (gimp_tool_button_menu_leave_notify),
+ tool_button);
g_signal_connect (tool_button->priv->menu, "popped-up",
G_CALLBACK (gimp_tool_button_menu_popped_up),
tool_button);
@@ -866,6 +905,8 @@ gimp_tool_button_show_menu (GimpToolButton *tool_button,
GDK_GRAVITY_NORTH_WEST,
trigger_event);
+ gimp_tool_button_update_menu (tool_button);
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]