2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2004-05-20 04:56:37 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpaction.c
|
|
|
|
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2004-05-20 04:56:37 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-05-20 04:56:37 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2004-05-20 04:56:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2004-07-21 02:50:20 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-03-30 01:19:01 +08:00
|
|
|
#include <gegl.h>
|
2004-05-20 04:56:37 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2005-01-22 08:43:31 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2004-05-20 04:56:37 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
2016-05-28 09:01:37 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2006-09-02 01:12:29 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2004-05-20 04:56:37 +08:00
|
|
|
#include "core/gimpmarshal.h"
|
2004-09-28 07:31:46 +08:00
|
|
|
#include "core/gimpimagefile.h" /* eek */
|
2004-05-20 04:56:37 +08:00
|
|
|
#include "core/gimpviewable.h"
|
|
|
|
|
|
|
|
#include "gimpaction.h"
|
2013-09-26 02:02:59 +08:00
|
|
|
#include "gimpaction-history.h"
|
2004-08-25 01:16:46 +08:00
|
|
|
#include "gimpview.h"
|
2006-05-17 03:55:01 +08:00
|
|
|
#include "gimpviewrenderer.h"
|
2018-05-02 20:53:56 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2004-05-20 04:56:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2006-09-02 01:12:29 +08:00
|
|
|
PROP_CONTEXT,
|
2004-05-20 04:56:37 +08:00
|
|
|
PROP_COLOR,
|
2008-05-11 17:26:17 +08:00
|
|
|
PROP_VIEWABLE,
|
2008-05-17 00:06:42 +08:00
|
|
|
PROP_ELLIPSIZE,
|
|
|
|
PROP_MAX_WIDTH_CHARS
|
2004-05-20 04:56:37 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-17 20:53:07 +08:00
|
|
|
static void gimp_action_finalize (GObject *object);
|
|
|
|
static void gimp_action_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_action_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2018-07-06 12:00:16 +08:00
|
|
|
static void gimp_action_activate (GtkAction *action);
|
2008-05-17 20:53:07 +08:00
|
|
|
static void gimp_action_connect_proxy (GtkAction *action,
|
|
|
|
GtkWidget *proxy);
|
|
|
|
static void gimp_action_set_proxy (GimpAction *action,
|
|
|
|
GtkWidget *proxy);
|
|
|
|
static void gimp_action_set_proxy_tooltip (GimpAction *action,
|
|
|
|
GtkWidget *proxy);
|
2019-05-05 22:17:50 +08:00
|
|
|
static void gimp_action_label_notify (GimpAction *action,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
gpointer data);
|
2008-05-17 20:53:07 +08:00
|
|
|
static void gimp_action_tooltip_notify (GimpAction *action,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
gpointer data);
|
2004-05-20 04:56:37 +08:00
|
|
|
|
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpAction, gimp_action, GTK_TYPE_ACTION)
|
2004-05-20 04:56:37 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
#define parent_class gimp_action_parent_class
|
2004-05-20 04:56:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_class_init (GimpActionClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
|
|
|
|
GimpRGB black;
|
|
|
|
|
|
|
|
object_class->finalize = gimp_action_finalize;
|
|
|
|
object_class->set_property = gimp_action_set_property;
|
|
|
|
object_class->get_property = gimp_action_get_property;
|
|
|
|
|
2018-07-06 12:00:16 +08:00
|
|
|
action_class->activate = gimp_action_activate;
|
2004-05-20 04:56:37 +08:00
|
|
|
action_class->connect_proxy = gimp_action_connect_proxy;
|
|
|
|
|
|
|
|
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
|
|
|
|
2006-09-02 01:12:29 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_CONTEXT,
|
|
|
|
g_param_spec_object ("context",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_CONTEXT,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_COLOR,
|
2004-07-27 03:56:47 +08:00
|
|
|
gimp_param_spec_rgb ("color",
|
|
|
|
NULL, NULL,
|
2006-04-27 23:19:59 +08:00
|
|
|
TRUE, &black,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE));
|
2004-05-20 04:56:37 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_VIEWABLE,
|
|
|
|
g_param_spec_object ("viewable",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_VIEWABLE,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE));
|
2008-05-11 17:26:17 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_ELLIPSIZE,
|
|
|
|
g_param_spec_enum ("ellipsize",
|
|
|
|
NULL, NULL,
|
|
|
|
PANGO_TYPE_ELLIPSIZE_MODE,
|
|
|
|
PANGO_ELLIPSIZE_NONE,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2008-05-17 00:06:42 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_MAX_WIDTH_CHARS,
|
|
|
|
g_param_spec_int ("max-width-chars",
|
|
|
|
NULL, NULL,
|
|
|
|
-1, G_MAXINT, -1,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2004-05-20 04:56:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_init (GimpAction *action)
|
|
|
|
{
|
2008-06-28 09:54:05 +08:00
|
|
|
action->color = NULL;
|
|
|
|
action->viewable = NULL;
|
|
|
|
action->ellipsize = PANGO_ELLIPSIZE_NONE;
|
|
|
|
action->max_width_chars = -1;
|
2008-05-17 20:53:07 +08:00
|
|
|
|
2019-05-05 22:17:50 +08:00
|
|
|
g_signal_connect (action, "notify::label",
|
|
|
|
G_CALLBACK (gimp_action_label_notify),
|
|
|
|
NULL);
|
2008-05-17 20:53:07 +08:00
|
|
|
g_signal_connect (action, "notify::tooltip",
|
|
|
|
G_CALLBACK (gimp_action_tooltip_notify),
|
|
|
|
NULL);
|
2004-05-20 04:56:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpAction *action = GIMP_ACTION (object);
|
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&action->context);
|
|
|
|
g_clear_pointer (&action->color, g_free);
|
|
|
|
g_clear_object (&action->viewable);
|
2004-05-20 04:56:37 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpAction *action = GIMP_ACTION (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2006-09-02 01:12:29 +08:00
|
|
|
case PROP_CONTEXT:
|
|
|
|
g_value_set_object (value, action->context);
|
|
|
|
break;
|
2008-07-23 14:47:23 +08:00
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
case PROP_COLOR:
|
|
|
|
g_value_set_boxed (value, action->color);
|
|
|
|
break;
|
2008-07-23 14:47:23 +08:00
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
case PROP_VIEWABLE:
|
|
|
|
g_value_set_object (value, action->viewable);
|
|
|
|
break;
|
2008-07-23 14:47:23 +08:00
|
|
|
|
2008-05-11 17:26:17 +08:00
|
|
|
case PROP_ELLIPSIZE:
|
|
|
|
g_value_set_enum (value, action->ellipsize);
|
|
|
|
break;
|
2008-07-23 14:47:23 +08:00
|
|
|
|
2008-05-17 00:06:42 +08:00
|
|
|
case PROP_MAX_WIDTH_CHARS:
|
|
|
|
g_value_set_int (value, action->max_width_chars);
|
|
|
|
break;
|
2008-05-11 17:26:17 +08:00
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpAction *action = GIMP_ACTION (object);
|
|
|
|
gboolean set_proxy = FALSE;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2006-09-02 01:12:29 +08:00
|
|
|
case PROP_CONTEXT:
|
|
|
|
if (action->context)
|
|
|
|
g_object_unref (action->context);
|
2008-07-23 14:47:23 +08:00
|
|
|
action->context = g_value_dup_object (value);
|
2006-09-02 01:12:29 +08:00
|
|
|
break;
|
2008-07-23 14:47:23 +08:00
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
case PROP_COLOR:
|
|
|
|
if (action->color)
|
|
|
|
g_free (action->color);
|
|
|
|
action->color = g_value_dup_boxed (value);
|
|
|
|
set_proxy = TRUE;
|
|
|
|
break;
|
2008-07-23 14:47:23 +08:00
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
case PROP_VIEWABLE:
|
|
|
|
if (action->viewable)
|
|
|
|
g_object_unref (action->viewable);
|
2008-07-23 14:47:23 +08:00
|
|
|
action->viewable = g_value_dup_object (value);
|
2004-05-20 04:56:37 +08:00
|
|
|
set_proxy = TRUE;
|
|
|
|
break;
|
2008-07-23 14:47:23 +08:00
|
|
|
|
2008-05-11 17:26:17 +08:00
|
|
|
case PROP_ELLIPSIZE:
|
|
|
|
action->ellipsize = g_value_get_enum (value);
|
|
|
|
set_proxy = TRUE;
|
|
|
|
break;
|
2008-07-23 14:47:23 +08:00
|
|
|
|
2008-05-17 00:06:42 +08:00
|
|
|
case PROP_MAX_WIDTH_CHARS:
|
|
|
|
action->max_width_chars = g_value_get_int (value);
|
|
|
|
set_proxy = TRUE;
|
|
|
|
break;
|
2008-05-11 17:26:17 +08:00
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (set_proxy)
|
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
for (list = gtk_action_get_proxies (GTK_ACTION (action));
|
|
|
|
list;
|
|
|
|
list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
gimp_action_set_proxy (action, list->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-06 12:00:16 +08:00
|
|
|
static void
|
|
|
|
gimp_action_activate (GtkAction *action)
|
|
|
|
{
|
|
|
|
if (GTK_ACTION_CLASS (parent_class)->activate)
|
|
|
|
GTK_ACTION_CLASS (parent_class)->activate (action);
|
|
|
|
|
|
|
|
gimp_action_history_action_activated (action);
|
|
|
|
}
|
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
static void
|
|
|
|
gimp_action_connect_proxy (GtkAction *action,
|
|
|
|
GtkWidget *proxy)
|
|
|
|
{
|
|
|
|
GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
|
|
|
|
|
|
|
|
gimp_action_set_proxy (GIMP_ACTION (action), proxy);
|
2008-05-17 20:53:07 +08:00
|
|
|
gimp_action_set_proxy_tooltip (GIMP_ACTION (action), proxy);
|
2004-05-20 04:56:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GimpAction *
|
|
|
|
gimp_action_new (const gchar *name,
|
|
|
|
const gchar *label,
|
|
|
|
const gchar *tooltip,
|
2014-05-07 05:47:38 +08:00
|
|
|
const gchar *icon_name)
|
2004-05-20 04:56:37 +08:00
|
|
|
{
|
2008-08-22 16:57:11 +08:00
|
|
|
GimpAction *action;
|
|
|
|
|
|
|
|
action = g_object_new (GIMP_TYPE_ACTION,
|
2014-05-07 05:47:38 +08:00
|
|
|
"name", name,
|
|
|
|
"label", label,
|
|
|
|
"tooltip", tooltip,
|
|
|
|
"icon-name", icon_name,
|
2008-08-22 16:57:11 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
return action;
|
2004-05-20 04:56:37 +08:00
|
|
|
}
|
|
|
|
|
2004-07-21 02:50:20 +08:00
|
|
|
gint
|
|
|
|
gimp_action_name_compare (GimpAction *action1,
|
|
|
|
GimpAction *action2)
|
|
|
|
{
|
|
|
|
return strcmp (gtk_action_get_name ((GtkAction *) action1),
|
|
|
|
gtk_action_get_name ((GtkAction *) action2));
|
|
|
|
}
|
|
|
|
|
2014-04-20 21:57:57 +08:00
|
|
|
gboolean
|
|
|
|
gimp_action_is_gui_blacklisted (const gchar *action_name)
|
|
|
|
{
|
|
|
|
static const gchar *suffixes[] =
|
|
|
|
{
|
|
|
|
"-menu",
|
|
|
|
"-popup"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const gchar *prefixes[] =
|
|
|
|
{
|
|
|
|
"<",
|
|
|
|
"tools-color-average-radius-",
|
2014-05-04 04:55:05 +08:00
|
|
|
"tools-paintbrush-size-",
|
|
|
|
"tools-paintbrush-aspect-ratio-",
|
2016-03-23 06:51:32 +08:00
|
|
|
"tools-paintbrush-angle-",
|
|
|
|
"tools-paintbrush-spacing-",
|
|
|
|
"tools-paintbrush-hardness-",
|
|
|
|
"tools-paintbrush-force-",
|
2014-04-20 21:57:57 +08:00
|
|
|
"tools-ink-blob-size-",
|
|
|
|
"tools-ink-blob-aspect-",
|
|
|
|
"tools-ink-blob-angle-",
|
2015-12-23 02:39:11 +08:00
|
|
|
"tools-mypaint-brush-radius-",
|
2016-03-23 06:51:32 +08:00
|
|
|
"tools-mypaint-brush-hardness-",
|
2014-04-20 21:57:57 +08:00
|
|
|
"tools-foreground-select-brush-size-",
|
2014-05-04 04:56:46 +08:00
|
|
|
"tools-transform-preview-opacity-",
|
2018-02-17 17:21:06 +08:00
|
|
|
"tools-warp-effect-size-",
|
2016-03-23 06:51:32 +08:00
|
|
|
"tools-warp-effect-hardness-"
|
2014-04-20 21:57:57 +08:00
|
|
|
};
|
|
|
|
|
2018-01-14 22:42:29 +08:00
|
|
|
static const gchar *actions[] =
|
|
|
|
{
|
|
|
|
"tools-brightness-contrast",
|
|
|
|
"tools-curves",
|
|
|
|
"tools-levels",
|
2019-06-06 16:47:46 +08:00
|
|
|
"tools-offset",
|
2018-01-14 22:42:29 +08:00
|
|
|
"tools-threshold"
|
|
|
|
};
|
|
|
|
|
2014-04-20 21:57:57 +08:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
if (! (action_name && *action_name))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (suffixes); i++)
|
|
|
|
{
|
|
|
|
if (g_str_has_suffix (action_name, suffixes[i]))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (prefixes); i++)
|
|
|
|
{
|
|
|
|
if (g_str_has_prefix (action_name, prefixes[i]))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-01-14 22:42:29 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (actions); i++)
|
|
|
|
{
|
|
|
|
if (! strcmp (action_name, actions[i]))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-04-20 21:57:57 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_set_proxy (GimpAction *action,
|
|
|
|
GtkWidget *proxy)
|
|
|
|
{
|
2018-05-02 20:53:56 +08:00
|
|
|
if (! GTK_IS_MENU_ITEM (proxy))
|
2004-05-20 04:56:37 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (action->color)
|
|
|
|
{
|
|
|
|
GtkWidget *area;
|
|
|
|
|
2018-05-02 20:53:56 +08:00
|
|
|
area = gimp_menu_item_get_image (GTK_MENU_ITEM (proxy));
|
2004-05-20 04:56:37 +08:00
|
|
|
|
2008-06-28 09:54:05 +08:00
|
|
|
if (GIMP_IS_COLOR_AREA (area))
|
2004-05-20 04:56:37 +08:00
|
|
|
{
|
2008-06-28 09:54:05 +08:00
|
|
|
gimp_color_area_set_color (GIMP_COLOR_AREA (area), action->color);
|
2004-05-20 04:56:37 +08:00
|
|
|
}
|
2008-06-28 09:54:05 +08:00
|
|
|
else
|
2004-05-20 04:56:37 +08:00
|
|
|
{
|
2008-06-28 09:54:05 +08:00
|
|
|
gint width, height;
|
2004-05-20 04:56:37 +08:00
|
|
|
|
|
|
|
area = gimp_color_area_new (action->color,
|
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS, 0);
|
|
|
|
gimp_color_area_set_draw_border (GIMP_COLOR_AREA (area), TRUE);
|
|
|
|
|
2016-05-28 09:01:37 +08:00
|
|
|
if (action->context)
|
|
|
|
gimp_color_area_set_color_config (GIMP_COLOR_AREA (area),
|
|
|
|
action->context->gimp->config->color_management);
|
|
|
|
|
2018-04-29 08:53:51 +08:00
|
|
|
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
|
2004-05-20 04:56:37 +08:00
|
|
|
gtk_widget_set_size_request (area, width, height);
|
2018-05-02 20:53:56 +08:00
|
|
|
gimp_menu_item_set_image (GTK_MENU_ITEM (proxy), area);
|
2004-05-20 04:56:37 +08:00
|
|
|
gtk_widget_show (area);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (action->viewable)
|
|
|
|
{
|
2004-08-25 01:16:46 +08:00
|
|
|
GtkWidget *view;
|
2004-05-20 04:56:37 +08:00
|
|
|
|
2018-05-02 20:53:56 +08:00
|
|
|
view = gimp_menu_item_get_image (GTK_MENU_ITEM (proxy));
|
2004-05-20 04:56:37 +08:00
|
|
|
|
2008-06-28 09:54:05 +08:00
|
|
|
if (GIMP_IS_VIEW (view) &&
|
|
|
|
g_type_is_a (G_TYPE_FROM_INSTANCE (action->viewable),
|
|
|
|
GIMP_VIEW (view)->renderer->viewable_type))
|
2004-05-20 04:56:37 +08:00
|
|
|
{
|
2008-06-28 09:54:05 +08:00
|
|
|
gimp_view_set_viewable (GIMP_VIEW (view), action->viewable);
|
2004-05-20 04:56:37 +08:00
|
|
|
}
|
2008-06-28 09:54:05 +08:00
|
|
|
else
|
2004-05-20 04:56:37 +08:00
|
|
|
{
|
2008-06-28 09:54:05 +08:00
|
|
|
GtkIconSize size;
|
|
|
|
gint width, height;
|
|
|
|
gint border_width;
|
2004-05-20 04:56:37 +08:00
|
|
|
|
2004-10-12 18:37:11 +08:00
|
|
|
if (GIMP_IS_IMAGEFILE (action->viewable))
|
|
|
|
{
|
|
|
|
size = GTK_ICON_SIZE_LARGE_TOOLBAR;
|
|
|
|
border_width = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size = GTK_ICON_SIZE_MENU;
|
|
|
|
border_width = 1;
|
|
|
|
}
|
2004-05-20 04:56:37 +08:00
|
|
|
|
2018-04-29 08:53:51 +08:00
|
|
|
gtk_icon_size_lookup (size, &width, &height);
|
2006-09-02 01:12:29 +08:00
|
|
|
view = gimp_view_new_full (action->context, action->viewable,
|
2004-10-12 18:37:11 +08:00
|
|
|
width, height, border_width,
|
2004-09-28 07:31:46 +08:00
|
|
|
FALSE, FALSE, FALSE);
|
2018-05-02 20:53:56 +08:00
|
|
|
gimp_menu_item_set_image (GTK_MENU_ITEM (proxy), view);
|
2004-08-25 01:16:46 +08:00
|
|
|
gtk_widget_show (view);
|
2004-05-20 04:56:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkWidget *image;
|
|
|
|
|
2018-05-02 20:53:56 +08:00
|
|
|
image = gimp_menu_item_get_image (GTK_MENU_ITEM (proxy));
|
2004-05-20 04:56:37 +08:00
|
|
|
|
2008-05-11 16:55:13 +08:00
|
|
|
if (GIMP_IS_VIEW (image) || GIMP_IS_COLOR_AREA (image))
|
2004-05-20 04:56:37 +08:00
|
|
|
{
|
2018-05-02 20:53:56 +08:00
|
|
|
gimp_menu_item_set_image (GTK_MENU_ITEM (proxy), NULL);
|
2014-05-07 05:47:38 +08:00
|
|
|
g_object_notify (G_OBJECT (action), "icon-name");
|
2004-05-20 04:56:37 +08:00
|
|
|
}
|
|
|
|
}
|
2008-05-11 17:26:17 +08:00
|
|
|
|
|
|
|
{
|
2008-05-17 00:06:42 +08:00
|
|
|
GtkWidget *child = gtk_bin_get_child (GTK_BIN (proxy));
|
2008-05-11 17:26:17 +08:00
|
|
|
|
2018-05-02 20:53:56 +08:00
|
|
|
if (GTK_IS_BOX (child))
|
|
|
|
child = g_object_get_data (G_OBJECT (proxy), "gimp-menu-item-label");
|
|
|
|
|
2008-05-17 00:06:42 +08:00
|
|
|
if (GTK_IS_LABEL (child))
|
2008-05-11 17:26:17 +08:00
|
|
|
{
|
2008-05-17 00:06:42 +08:00
|
|
|
GtkLabel *label = GTK_LABEL (child);
|
|
|
|
|
|
|
|
gtk_label_set_ellipsize (label, action->ellipsize);
|
|
|
|
gtk_label_set_max_width_chars (label, action->max_width_chars);
|
2008-05-11 17:26:17 +08:00
|
|
|
}
|
|
|
|
}
|
2004-05-20 04:56:37 +08:00
|
|
|
}
|
2008-05-17 20:53:07 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_set_proxy_tooltip (GimpAction *action,
|
|
|
|
GtkWidget *proxy)
|
|
|
|
{
|
2009-05-25 04:29:18 +08:00
|
|
|
const gchar *tooltip = gtk_action_get_tooltip (GTK_ACTION (action));
|
2008-05-17 20:53:07 +08:00
|
|
|
|
|
|
|
if (tooltip)
|
2009-05-25 04:29:18 +08:00
|
|
|
gimp_help_set_help_data (proxy, tooltip,
|
|
|
|
g_object_get_qdata (G_OBJECT (proxy),
|
|
|
|
GIMP_HELP_ID));
|
2008-05-17 20:53:07 +08:00
|
|
|
}
|
|
|
|
|
2019-05-05 22:17:50 +08:00
|
|
|
static void
|
|
|
|
gimp_action_label_notify (GimpAction *action,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
for (list = gtk_action_get_proxies (GTK_ACTION (action));
|
|
|
|
list;
|
|
|
|
list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
if (GTK_IS_MENU_ITEM (list->data))
|
|
|
|
{
|
|
|
|
GtkWidget *child = gtk_bin_get_child (GTK_BIN (list->data));
|
|
|
|
|
|
|
|
if (GTK_IS_BOX (child))
|
|
|
|
{
|
|
|
|
child = g_object_get_data (G_OBJECT (list->data),
|
|
|
|
"gimp-menu-item-label");
|
|
|
|
|
|
|
|
if (GTK_IS_LABEL (child))
|
|
|
|
gtk_label_set_text (GTK_LABEL (child),
|
|
|
|
gtk_action_get_label (GTK_ACTION (action)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-17 20:53:07 +08:00
|
|
|
static void
|
|
|
|
gimp_action_tooltip_notify (GimpAction *action,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
for (list = gtk_action_get_proxies (GTK_ACTION (action));
|
|
|
|
list;
|
|
|
|
list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
gimp_action_set_proxy_tooltip (action, list->data);
|
|
|
|
}
|
|
|
|
}
|