mirror of https://github.com/GNOME/gimp.git
app: move action/widget sensitivity logic from GimpMenu to GimpAction
This way we handle all kinds of proxies (particularly buttons). Also add a small hack that prevents extended multiline tooltips of GimpButton from being overwritten by gimp_action_update_proxy_tooltip().
This commit is contained in:
parent
c4f71f553c
commit
0532cf31b9
|
@ -98,6 +98,8 @@ static void gimp_action_proxy_destroy (GtkWidget *proxy,
|
|||
static void gimp_action_proxy_button_activate (GtkButton *button,
|
||||
GimpAction *action);
|
||||
|
||||
static void gimp_action_update_proxy_sensitive (GimpAction *action,
|
||||
GtkWidget *proxy);
|
||||
static void gimp_action_update_proxy_tooltip (GimpAction *action,
|
||||
GtkWidget *proxy);
|
||||
|
||||
|
@ -486,7 +488,7 @@ gimp_action_set_sensitive (GimpAction *action,
|
|||
|
||||
g_object_notify (G_OBJECT (action), "sensitive");
|
||||
|
||||
gimp_action_update_proxy_tooltip (action, NULL);
|
||||
gimp_action_update_proxy_sensitive (action, NULL);
|
||||
|
||||
g_object_notify (G_OBJECT (action), "enabled");
|
||||
}
|
||||
|
@ -1139,7 +1141,7 @@ gimp_action_set_proxy (GimpAction *action,
|
|||
(GCallback) gimp_action_proxy_button_activate,
|
||||
action);
|
||||
|
||||
gimp_action_update_proxy_tooltip (action, proxy);
|
||||
gimp_action_update_proxy_sensitive (action, proxy);
|
||||
}
|
||||
|
||||
g_clear_object (&pixbuf);
|
||||
|
@ -1331,6 +1333,27 @@ gimp_action_proxy_button_activate (GtkButton *button,
|
|||
gimp_action_activate (action);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_update_proxy_sensitive (GimpAction *action,
|
||||
GtkWidget *proxy)
|
||||
{
|
||||
GimpActionPrivate *priv = GET_PRIVATE (action);
|
||||
gboolean sensitive = gimp_action_is_sensitive (action, NULL);
|
||||
|
||||
if (proxy)
|
||||
{
|
||||
gtk_widget_set_sensitive (proxy, sensitive);
|
||||
gimp_action_update_proxy_tooltip (action, proxy);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GList *list = priv->proxies; list; list = list->next)
|
||||
gtk_widget_set_sensitive (list->data, sensitive);
|
||||
|
||||
gimp_action_update_proxy_tooltip (action, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_update_proxy_tooltip (GimpAction *action,
|
||||
GtkWidget *proxy)
|
||||
|
@ -1358,13 +1381,23 @@ gimp_action_update_proxy_tooltip (GimpAction *action,
|
|||
escaped_reason && tooltip ? "\n" : "",
|
||||
escaped_reason ? escaped_reason : "");
|
||||
|
||||
/* This hack makes sure we don't replace the tooltips of GimpButtons
|
||||
* with extended callbacks (for Shift+Click etc.), because these
|
||||
* buttons already have customly constructed multi-line tooltips
|
||||
* which we want to keep.
|
||||
*/
|
||||
#define HAS_EXTENDED_ACTIONS(widget) \
|
||||
(g_object_get_data (G_OBJECT (widget), "extended-actions") != NULL)
|
||||
|
||||
if (proxy != NULL)
|
||||
{
|
||||
if (! HAS_EXTENDED_ACTIONS (proxy))
|
||||
gimp_help_set_help_data_with_markup (proxy, markup, help_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (GList *list = priv->proxies; list; list = list->next)
|
||||
if (! HAS_EXTENDED_ACTIONS (list->data))
|
||||
gimp_help_set_help_data_with_markup (list->data, markup, help_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -116,9 +116,6 @@ static void gimp_menu_toggle_item_toggled (GtkWidget *item
|
|||
|
||||
static void gimp_menu_toggle_action_toggled (GimpAction *action,
|
||||
GtkCheckMenuItem *item);
|
||||
static void gimp_menu_action_notify_sensitive (GimpAction *action,
|
||||
const GParamSpec *pspec,
|
||||
GtkCheckMenuItem *item);
|
||||
static void gimp_menu_action_notify_visible (GimpAction *action,
|
||||
const GParamSpec *pspec,
|
||||
GtkWidget *item);
|
||||
|
@ -520,12 +517,6 @@ gimp_menu_add_action (GimpMenu *menu,
|
|||
gimp_action_set_proxy (action, item);
|
||||
g_object_set_data (G_OBJECT (item), GIMP_MENU_ACTION_KEY, action);
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (item),
|
||||
gimp_action_is_sensitive (action, NULL));
|
||||
g_signal_connect_object (action, "notify::sensitive",
|
||||
G_CALLBACK (gimp_menu_action_notify_sensitive),
|
||||
item, 0);
|
||||
|
||||
if (sibling)
|
||||
{
|
||||
GList *children;
|
||||
|
@ -782,15 +773,6 @@ gimp_menu_toggle_action_toggled (GimpAction *action,
|
|||
action);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_menu_action_notify_sensitive (GimpAction *action,
|
||||
const GParamSpec *pspec,
|
||||
GtkCheckMenuItem *item)
|
||||
{
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (item),
|
||||
gimp_action_is_sensitive (action, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_menu_action_notify_visible (GimpAction *action,
|
||||
const GParamSpec *pspec,
|
||||
|
|
Loading…
Reference in New Issue