2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2004-04-16 20:09:46 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpactiongroup.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-04-16 20:09:46 +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-04-16 20:09:46 +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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-04-16 20:09:46 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-04-22 03:41:36 +08:00
|
|
|
#include <gegl.h>
|
2004-04-16 20:09:46 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2004-07-28 06:17:30 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2004-04-23 00:16:43 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
#include "widgets-types.h"
|
|
|
|
|
2004-04-19 22:54:24 +08:00
|
|
|
#include "core/gimp.h"
|
2004-04-23 00:16:43 +08:00
|
|
|
#include "core/gimpviewable.h"
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
#include "gimpactiongroup.h"
|
2004-05-20 04:56:37 +08:00
|
|
|
#include "gimpaction.h"
|
2004-04-16 20:09:46 +08:00
|
|
|
#include "gimpenumaction.h"
|
2004-05-02 16:56:07 +08:00
|
|
|
#include "gimppluginaction.h"
|
2008-05-20 17:51:04 +08:00
|
|
|
#include "gimpradioaction.h"
|
2004-04-16 20:09:46 +08:00
|
|
|
#include "gimpstringaction.h"
|
2008-05-20 17:51:04 +08:00
|
|
|
#include "gimptoggleaction.h"
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2004-07-21 02:50:20 +08:00
|
|
|
PROP_GIMP,
|
|
|
|
PROP_LABEL,
|
2014-05-07 05:47:38 +08:00
|
|
|
PROP_ICON_NAME
|
2004-04-16 20:09:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
static void gimp_action_group_constructed (GObject *object);
|
|
|
|
static void gimp_action_group_dispose (GObject *object);
|
|
|
|
static void gimp_action_group_finalize (GObject *object);
|
|
|
|
static void gimp_action_group_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_action_group_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpActionGroup, gimp_action_group, GTK_TYPE_ACTION_GROUP)
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
#define parent_class gimp_action_group_parent_class
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_group_class_init (GimpActionGroupClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
object_class->constructed = gimp_action_group_constructed;
|
2004-04-26 23:01:00 +08:00
|
|
|
object_class->dispose = gimp_action_group_dispose;
|
2004-07-21 02:50:20 +08:00
|
|
|
object_class->finalize = gimp_action_group_finalize;
|
2004-04-16 20:09:46 +08:00
|
|
|
object_class->set_property = gimp_action_group_set_property;
|
|
|
|
object_class->get_property = gimp_action_group_get_property;
|
|
|
|
|
2004-04-19 22:54:24 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_GIMP,
|
|
|
|
g_param_spec_object ("gimp",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_GIMP,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
2004-04-19 22:54:24 +08:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2004-07-21 02:50:20 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_LABEL,
|
|
|
|
g_param_spec_string ("label",
|
|
|
|
NULL, NULL,
|
|
|
|
NULL,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
2004-07-21 02:50:20 +08:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2014-05-07 05:47:38 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_ICON_NAME,
|
|
|
|
g_param_spec_string ("icon-name",
|
2004-07-21 02:50:20 +08:00
|
|
|
NULL, NULL,
|
|
|
|
NULL,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
2004-07-21 02:50:20 +08:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2008-12-03 21:20:03 +08:00
|
|
|
klass->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
2004-04-16 20:09:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_group_init (GimpActionGroup *group)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
static void
|
|
|
|
gimp_action_group_constructed (GObject *object)
|
2004-04-26 23:01:00 +08:00
|
|
|
{
|
2011-01-14 16:38:11 +08:00
|
|
|
GimpActionGroup *group = GIMP_ACTION_GROUP (object);
|
2004-07-28 06:17:30 +08:00
|
|
|
const gchar *name;
|
2004-04-26 23:01:00 +08:00
|
|
|
|
2012-11-13 04:51:22 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2004-07-28 06:17:30 +08:00
|
|
|
|
|
|
|
g_assert (GIMP_IS_GIMP (group->gimp));
|
|
|
|
|
2004-04-26 23:01:00 +08:00
|
|
|
name = gtk_action_group_get_name (GTK_ACTION_GROUP (object));
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
GimpActionGroupClass *group_class;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
group_class = GIMP_ACTION_GROUP_GET_CLASS (object);
|
|
|
|
|
|
|
|
list = g_hash_table_lookup (group_class->groups, name);
|
|
|
|
|
|
|
|
list = g_list_append (list, object);
|
|
|
|
|
|
|
|
g_hash_table_replace (group_class->groups,
|
|
|
|
g_strdup (name), list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_group_dispose (GObject *object)
|
|
|
|
{
|
2011-01-14 16:38:11 +08:00
|
|
|
const gchar *name = gtk_action_group_get_name (GTK_ACTION_GROUP (object));
|
2004-04-26 23:01:00 +08:00
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
GimpActionGroupClass *group_class;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
group_class = GIMP_ACTION_GROUP_GET_CLASS (object);
|
|
|
|
|
|
|
|
list = g_hash_table_lookup (group_class->groups, name);
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
list = g_list_remove (list, object);
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
g_hash_table_replace (group_class->groups,
|
|
|
|
g_strdup (name), list);
|
|
|
|
else
|
|
|
|
g_hash_table_remove (group_class->groups, name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2004-07-21 02:50:20 +08:00
|
|
|
static void
|
|
|
|
gimp_action_group_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpActionGroup *group = GIMP_ACTION_GROUP (object);
|
|
|
|
|
|
|
|
if (group->label)
|
|
|
|
{
|
|
|
|
g_free (group->label);
|
|
|
|
group->label = NULL;
|
|
|
|
}
|
|
|
|
|
2014-05-07 05:47:38 +08:00
|
|
|
if (group->icon_name)
|
2004-07-21 02:50:20 +08:00
|
|
|
{
|
2014-05-07 05:47:38 +08:00
|
|
|
g_free (group->icon_name);
|
|
|
|
group->icon_name = NULL;
|
2004-07-21 02:50:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
static void
|
|
|
|
gimp_action_group_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpActionGroup *group = GIMP_ACTION_GROUP (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2004-04-19 22:54:24 +08:00
|
|
|
case PROP_GIMP:
|
|
|
|
group->gimp = g_value_get_object (value);
|
|
|
|
break;
|
2004-07-21 02:50:20 +08:00
|
|
|
case PROP_LABEL:
|
|
|
|
group->label = g_value_dup_string (value);
|
|
|
|
break;
|
2014-05-07 05:47:38 +08:00
|
|
|
case PROP_ICON_NAME:
|
|
|
|
group->icon_name = g_value_dup_string (value);
|
2004-07-21 02:50:20 +08:00
|
|
|
break;
|
2009-07-18 23:51:04 +08:00
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_action_group_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpActionGroup *group = GIMP_ACTION_GROUP (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2004-04-19 22:54:24 +08:00
|
|
|
case PROP_GIMP:
|
|
|
|
g_value_set_object (value, group->gimp);
|
|
|
|
break;
|
2004-07-21 02:50:20 +08:00
|
|
|
case PROP_LABEL:
|
|
|
|
g_value_set_string (value, group->label);
|
|
|
|
break;
|
2014-05-07 05:47:38 +08:00
|
|
|
case PROP_ICON_NAME:
|
|
|
|
g_value_set_string (value, group->icon_name);
|
2004-07-21 02:50:20 +08:00
|
|
|
break;
|
2009-07-18 23:51:04 +08:00
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-03 21:20:03 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_action_group_check_unique_action (GimpActionGroup *group,
|
|
|
|
const gchar *action_name)
|
|
|
|
{
|
|
|
|
if (G_UNLIKELY (gtk_action_group_get_action (GTK_ACTION_GROUP (group),
|
|
|
|
action_name)))
|
|
|
|
{
|
|
|
|
g_warning ("Refusing to add non-unique action '%s' to action group '%s'",
|
|
|
|
action_name,
|
|
|
|
gtk_action_group_get_name (GTK_ACTION_GROUP (group)));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
/**
|
|
|
|
* gimp_action_group_new:
|
2004-05-24 22:51:15 +08:00
|
|
|
* @gimp: the @Gimp instance this action group belongs to
|
|
|
|
* @name: the name of the action group.
|
2004-07-21 02:50:20 +08:00
|
|
|
* @label: the user visible label of the action group.
|
2014-05-07 05:47:38 +08:00
|
|
|
* @icon_name: the icon of the action group.
|
2004-05-24 22:51:15 +08:00
|
|
|
* @user_data: the user_data for #GtkAction callbacks.
|
|
|
|
* @update_func: the function that will be called on
|
|
|
|
* gimp_action_group_update().
|
2004-04-16 20:09:46 +08:00
|
|
|
*
|
|
|
|
* Creates a new #GimpActionGroup object. The name of the action group
|
|
|
|
* is used when associating <link linkend="Action-Accel">keybindings</link>
|
|
|
|
* with the actions.
|
|
|
|
*
|
|
|
|
* Returns: the new #GimpActionGroup
|
|
|
|
*/
|
|
|
|
GimpActionGroup *
|
2004-04-21 07:04:50 +08:00
|
|
|
gimp_action_group_new (Gimp *gimp,
|
|
|
|
const gchar *name,
|
2004-07-21 02:50:20 +08:00
|
|
|
const gchar *label,
|
2014-05-07 05:47:38 +08:00
|
|
|
const gchar *icon_name,
|
2004-04-27 21:55:26 +08:00
|
|
|
gpointer user_data,
|
2004-04-21 07:04:50 +08:00
|
|
|
GimpActionGroupUpdateFunc update_func)
|
2004-04-16 20:09:46 +08:00
|
|
|
{
|
2004-04-21 07:04:50 +08:00
|
|
|
GimpActionGroup *group;
|
|
|
|
|
2004-04-19 22:54:24 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
2004-04-21 07:04:50 +08:00
|
|
|
group = g_object_new (GIMP_TYPE_ACTION_GROUP,
|
2004-07-28 06:17:30 +08:00
|
|
|
"gimp", gimp,
|
|
|
|
"name", name,
|
|
|
|
"label", label,
|
2014-05-07 05:47:38 +08:00
|
|
|
"icon-name", icon_name,
|
2004-04-21 07:04:50 +08:00
|
|
|
NULL);
|
|
|
|
|
2004-04-27 21:55:26 +08:00
|
|
|
group->user_data = user_data;
|
2004-04-21 07:04:50 +08:00
|
|
|
group->update_func = update_func;
|
|
|
|
|
|
|
|
return group;
|
|
|
|
}
|
|
|
|
|
2004-04-26 23:01:00 +08:00
|
|
|
GList *
|
|
|
|
gimp_action_groups_from_name (const gchar *name)
|
|
|
|
{
|
|
|
|
GimpActionGroupClass *group_class;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
|
|
group_class = g_type_class_ref (GIMP_TYPE_ACTION_GROUP);
|
|
|
|
|
|
|
|
list = g_hash_table_lookup (group_class->groups, name);
|
|
|
|
|
|
|
|
g_type_class_unref (group_class);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2004-04-21 07:04:50 +08:00
|
|
|
void
|
|
|
|
gimp_action_group_update (GimpActionGroup *group,
|
|
|
|
gpointer update_data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
|
|
|
|
if (group->update_func)
|
|
|
|
group->update_func (group, update_data);
|
2004-04-16 20:09:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-10 16:06:18 +08:00
|
|
|
gimp_action_group_add_actions (GimpActionGroup *group,
|
2008-12-04 18:32:20 +08:00
|
|
|
const gchar *msg_context,
|
2006-04-10 16:06:18 +08:00
|
|
|
const GimpActionEntry *entries,
|
|
|
|
guint n_entries)
|
2004-04-16 20:09:46 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
|
|
|
|
for (i = 0; i < n_entries; i++)
|
|
|
|
{
|
2004-05-20 04:56:37 +08:00
|
|
|
GimpAction *action;
|
2009-07-18 23:51:04 +08:00
|
|
|
const gchar *label;
|
2008-12-04 18:32:20 +08:00
|
|
|
const gchar *tooltip = NULL;
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2008-12-03 21:20:03 +08:00
|
|
|
if (! gimp_action_group_check_unique_action (group, entries[i].name))
|
|
|
|
continue;
|
|
|
|
|
2008-12-04 18:32:20 +08:00
|
|
|
if (msg_context)
|
|
|
|
{
|
2009-07-18 23:51:04 +08:00
|
|
|
label = g_dpgettext2 (NULL, msg_context, entries[i].label);
|
2008-12-03 23:27:42 +08:00
|
|
|
|
2008-12-04 18:32:20 +08:00
|
|
|
if (entries[i].tooltip)
|
|
|
|
tooltip = g_dpgettext2 (NULL, msg_context, entries[i].tooltip);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
label = gettext (entries[i].label);
|
|
|
|
tooltip = gettext (entries[i].tooltip);
|
|
|
|
}
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
action = gimp_action_new (entries[i].name, label, tooltip,
|
2014-05-07 05:47:38 +08:00
|
|
|
entries[i].icon_name);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
if (entries[i].callback)
|
|
|
|
g_signal_connect (action, "activate",
|
|
|
|
entries[i].callback,
|
2004-04-27 21:55:26 +08:00
|
|
|
group->user_data);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2011-12-01 19:07:43 +08:00
|
|
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
|
|
|
GTK_ACTION (action),
|
|
|
|
entries[i].accelerator);
|
2004-05-03 23:54:54 +08:00
|
|
|
|
|
|
|
if (entries[i].help_id)
|
|
|
|
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
|
|
|
|
g_strdup (entries[i].help_id),
|
|
|
|
(GDestroyNotify) g_free);
|
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
g_object_unref (action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-10 16:06:18 +08:00
|
|
|
gimp_action_group_add_toggle_actions (GimpActionGroup *group,
|
2008-12-04 18:32:20 +08:00
|
|
|
const gchar *msg_context,
|
2006-04-10 16:06:18 +08:00
|
|
|
const GimpToggleActionEntry *entries,
|
|
|
|
guint n_entries)
|
2004-04-16 20:09:46 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
|
|
|
|
for (i = 0; i < n_entries; i++)
|
|
|
|
{
|
|
|
|
GtkToggleAction *action;
|
2009-07-18 23:51:04 +08:00
|
|
|
const gchar *label;
|
2008-12-04 18:32:20 +08:00
|
|
|
const gchar *tooltip = NULL;
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2008-12-03 21:20:03 +08:00
|
|
|
if (! gimp_action_group_check_unique_action (group, entries[i].name))
|
|
|
|
continue;
|
|
|
|
|
2008-12-04 18:32:20 +08:00
|
|
|
if (msg_context)
|
|
|
|
{
|
2009-07-18 23:51:04 +08:00
|
|
|
label = g_dpgettext2 (NULL, msg_context, entries[i].label);
|
2008-12-03 23:27:42 +08:00
|
|
|
|
2008-12-04 18:32:20 +08:00
|
|
|
if (entries[i].tooltip)
|
|
|
|
tooltip = g_dpgettext2 (NULL, msg_context, entries[i].tooltip);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
label = gettext (entries[i].label);
|
|
|
|
tooltip = gettext (entries[i].tooltip);
|
|
|
|
}
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2008-05-20 17:51:04 +08:00
|
|
|
action = gimp_toggle_action_new (entries[i].name, label, tooltip,
|
2014-05-07 05:47:38 +08:00
|
|
|
entries[i].icon_name);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
gtk_toggle_action_set_active (action, entries[i].is_active);
|
|
|
|
|
|
|
|
if (entries[i].callback)
|
|
|
|
g_signal_connect (action, "toggled",
|
|
|
|
entries[i].callback,
|
2004-04-27 21:55:26 +08:00
|
|
|
group->user_data);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2011-12-01 19:07:43 +08:00
|
|
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
|
|
|
GTK_ACTION (action),
|
|
|
|
entries[i].accelerator);
|
2004-05-03 23:54:54 +08:00
|
|
|
|
|
|
|
if (entries[i].help_id)
|
|
|
|
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
|
|
|
|
g_strdup (entries[i].help_id),
|
|
|
|
(GDestroyNotify) g_free);
|
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
g_object_unref (action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-16 04:24:50 +08:00
|
|
|
GSList *
|
2006-04-10 16:06:18 +08:00
|
|
|
gimp_action_group_add_radio_actions (GimpActionGroup *group,
|
2008-12-04 18:32:20 +08:00
|
|
|
const gchar *msg_context,
|
2006-04-10 16:06:18 +08:00
|
|
|
const GimpRadioActionEntry *entries,
|
|
|
|
guint n_entries,
|
|
|
|
GSList *radio_group,
|
|
|
|
gint value,
|
|
|
|
GCallback callback)
|
2004-04-16 20:09:46 +08:00
|
|
|
{
|
|
|
|
GtkRadioAction *first_action = NULL;
|
|
|
|
gint i;
|
|
|
|
|
2005-11-16 04:24:50 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_ACTION_GROUP (group), NULL);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
for (i = 0; i < n_entries; i++)
|
|
|
|
{
|
|
|
|
GtkRadioAction *action;
|
2009-07-18 23:51:04 +08:00
|
|
|
const gchar *label;
|
2008-12-04 18:32:20 +08:00
|
|
|
const gchar *tooltip = NULL;
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2008-12-03 21:20:03 +08:00
|
|
|
if (! gimp_action_group_check_unique_action (group, entries[i].name))
|
|
|
|
continue;
|
|
|
|
|
2008-12-04 18:32:20 +08:00
|
|
|
if (msg_context)
|
|
|
|
{
|
2009-07-18 23:51:04 +08:00
|
|
|
label = g_dpgettext2 (NULL, msg_context, entries[i].label);
|
2008-12-03 23:27:42 +08:00
|
|
|
|
2008-12-04 18:32:20 +08:00
|
|
|
if (entries[i].tooltip)
|
|
|
|
tooltip = g_dpgettext2 (NULL, msg_context, entries[i].tooltip);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
label = gettext (entries[i].label);
|
|
|
|
tooltip = gettext (entries[i].tooltip);
|
|
|
|
}
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2008-05-20 17:51:04 +08:00
|
|
|
action = gimp_radio_action_new (entries[i].name, label, tooltip,
|
2014-05-07 05:47:38 +08:00
|
|
|
entries[i].icon_name,
|
2008-05-20 17:51:04 +08:00
|
|
|
entries[i].value);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
if (i == 0)
|
2006-04-12 20:49:29 +08:00
|
|
|
first_action = action;
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
gtk_radio_action_set_group (action, radio_group);
|
|
|
|
radio_group = gtk_radio_action_get_group (action);
|
|
|
|
|
|
|
|
if (value == entries[i].value)
|
2006-04-12 20:49:29 +08:00
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2011-12-01 19:07:43 +08:00
|
|
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
|
|
|
GTK_ACTION (action),
|
|
|
|
entries[i].accelerator);
|
2004-05-03 23:54:54 +08:00
|
|
|
|
|
|
|
if (entries[i].help_id)
|
|
|
|
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
|
|
|
|
g_strdup (entries[i].help_id),
|
|
|
|
(GDestroyNotify) g_free);
|
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
g_object_unref (action);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (callback && first_action)
|
|
|
|
g_signal_connect (first_action, "changed",
|
|
|
|
callback,
|
2004-04-27 21:55:26 +08:00
|
|
|
group->user_data);
|
2005-11-16 04:24:50 +08:00
|
|
|
|
|
|
|
return radio_group;
|
2004-04-16 20:09:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-10 16:06:18 +08:00
|
|
|
gimp_action_group_add_enum_actions (GimpActionGroup *group,
|
2008-12-04 18:32:20 +08:00
|
|
|
const gchar *msg_context,
|
2006-04-10 16:06:18 +08:00
|
|
|
const GimpEnumActionEntry *entries,
|
|
|
|
guint n_entries,
|
|
|
|
GCallback callback)
|
2004-04-16 20:09:46 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
|
|
|
|
for (i = 0; i < n_entries; i++)
|
|
|
|
{
|
|
|
|
GimpEnumAction *action;
|
2009-07-18 23:51:04 +08:00
|
|
|
const gchar *label;
|
2008-12-04 18:32:20 +08:00
|
|
|
const gchar *tooltip = NULL;
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2008-12-03 21:20:03 +08:00
|
|
|
if (! gimp_action_group_check_unique_action (group, entries[i].name))
|
|
|
|
continue;
|
|
|
|
|
2008-12-04 18:32:20 +08:00
|
|
|
if (msg_context)
|
|
|
|
{
|
2009-07-18 23:51:04 +08:00
|
|
|
label = g_dpgettext2 (NULL, msg_context, entries[i].label);
|
2008-12-03 23:27:42 +08:00
|
|
|
|
2008-12-04 18:32:20 +08:00
|
|
|
if (entries[i].tooltip)
|
|
|
|
tooltip = g_dpgettext2 (NULL, msg_context, entries[i].tooltip);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
label = gettext (entries[i].label);
|
|
|
|
tooltip = gettext (entries[i].tooltip);
|
|
|
|
}
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
action = gimp_enum_action_new (entries[i].name, label, tooltip,
|
2014-05-07 05:47:38 +08:00
|
|
|
entries[i].icon_name,
|
2006-04-12 20:49:29 +08:00
|
|
|
entries[i].value,
|
2004-11-19 00:04:41 +08:00
|
|
|
entries[i].value_variable);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
if (callback)
|
|
|
|
g_signal_connect (action, "selected",
|
|
|
|
callback,
|
2004-04-27 21:55:26 +08:00
|
|
|
group->user_data);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2011-12-01 19:07:43 +08:00
|
|
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
|
|
|
GTK_ACTION (action),
|
|
|
|
entries[i].accelerator);
|
2004-05-03 23:54:54 +08:00
|
|
|
|
|
|
|
if (entries[i].help_id)
|
|
|
|
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
|
|
|
|
g_strdup (entries[i].help_id),
|
|
|
|
(GDestroyNotify) g_free);
|
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
g_object_unref (action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-10 16:06:18 +08:00
|
|
|
gimp_action_group_add_string_actions (GimpActionGroup *group,
|
2008-12-04 18:32:20 +08:00
|
|
|
const gchar *msg_context,
|
2006-04-10 16:06:18 +08:00
|
|
|
const GimpStringActionEntry *entries,
|
|
|
|
guint n_entries,
|
|
|
|
GCallback callback)
|
2004-04-16 20:09:46 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
|
|
|
|
for (i = 0; i < n_entries; i++)
|
|
|
|
{
|
|
|
|
GimpStringAction *action;
|
2009-07-18 23:51:04 +08:00
|
|
|
const gchar *label;
|
2008-12-04 18:32:20 +08:00
|
|
|
const gchar *tooltip = NULL;
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2008-12-03 21:20:03 +08:00
|
|
|
if (! gimp_action_group_check_unique_action (group, entries[i].name))
|
|
|
|
continue;
|
|
|
|
|
2008-12-04 18:32:20 +08:00
|
|
|
if (msg_context)
|
|
|
|
{
|
2009-07-18 23:51:04 +08:00
|
|
|
label = g_dpgettext2 (NULL, msg_context, entries[i].label);
|
2008-12-03 23:27:42 +08:00
|
|
|
|
2008-12-04 18:32:20 +08:00
|
|
|
if (entries[i].tooltip)
|
|
|
|
tooltip = g_dpgettext2 (NULL, msg_context, entries[i].tooltip);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
label = gettext (entries[i].label);
|
|
|
|
tooltip = gettext (entries[i].tooltip);
|
|
|
|
}
|
2004-04-16 20:09:46 +08:00
|
|
|
|
|
|
|
action = gimp_string_action_new (entries[i].name, label, tooltip,
|
2014-05-07 05:47:38 +08:00
|
|
|
entries[i].icon_name,
|
2004-04-16 20:09:46 +08:00
|
|
|
entries[i].value);
|
|
|
|
|
|
|
|
if (callback)
|
|
|
|
g_signal_connect (action, "selected",
|
|
|
|
callback,
|
2004-04-27 21:55:26 +08:00
|
|
|
group->user_data);
|
2004-04-16 20:09:46 +08:00
|
|
|
|
2011-12-01 19:07:43 +08:00
|
|
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
|
|
|
GTK_ACTION (action),
|
|
|
|
entries[i].accelerator);
|
2004-05-03 23:54:54 +08:00
|
|
|
|
|
|
|
if (entries[i].help_id)
|
|
|
|
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
|
|
|
|
g_strdup (entries[i].help_id),
|
|
|
|
(GDestroyNotify) g_free);
|
|
|
|
|
2004-04-16 20:09:46 +08:00
|
|
|
g_object_unref (action);
|
|
|
|
}
|
|
|
|
}
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2004-05-02 16:56:07 +08:00
|
|
|
void
|
2006-04-10 16:06:18 +08:00
|
|
|
gimp_action_group_add_plug_in_actions (GimpActionGroup *group,
|
|
|
|
const GimpPlugInActionEntry *entries,
|
|
|
|
guint n_entries,
|
|
|
|
GCallback callback)
|
2004-05-02 16:56:07 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
|
|
|
|
for (i = 0; i < n_entries; i++)
|
|
|
|
{
|
|
|
|
GimpPlugInAction *action;
|
2004-07-28 06:17:30 +08:00
|
|
|
|
2008-12-03 21:20:03 +08:00
|
|
|
if (! gimp_action_group_check_unique_action (group, entries[i].name))
|
|
|
|
continue;
|
|
|
|
|
2004-05-02 16:56:07 +08:00
|
|
|
action = gimp_plug_in_action_new (entries[i].name,
|
2009-07-18 23:51:04 +08:00
|
|
|
entries[i].label,
|
2004-05-02 16:56:07 +08:00
|
|
|
entries[i].tooltip,
|
2014-05-07 05:47:38 +08:00
|
|
|
entries[i].icon_name,
|
2006-04-05 16:38:33 +08:00
|
|
|
entries[i].procedure);
|
2004-05-02 16:56:07 +08:00
|
|
|
|
|
|
|
if (callback)
|
|
|
|
g_signal_connect (action, "selected",
|
|
|
|
callback,
|
|
|
|
group->user_data);
|
|
|
|
|
2011-12-01 19:07:43 +08:00
|
|
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
|
|
|
GTK_ACTION (action),
|
|
|
|
entries[i].accelerator);
|
2004-05-03 23:54:54 +08:00
|
|
|
|
|
|
|
if (entries[i].help_id)
|
|
|
|
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
|
|
|
|
g_strdup (entries[i].help_id),
|
|
|
|
(GDestroyNotify) g_free);
|
|
|
|
|
2004-05-02 16:56:07 +08:00
|
|
|
g_object_unref (action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-23 21:01:55 +08:00
|
|
|
void
|
|
|
|
gimp_action_group_activate_action (GimpActionGroup *group,
|
|
|
|
const gchar *action_name)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to activate action which doesn't exist: %s",
|
|
|
|
G_STRFUNC, action_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_action_activate (action);
|
|
|
|
}
|
|
|
|
|
2004-04-19 22:54:24 +08:00
|
|
|
void
|
|
|
|
gimp_action_group_set_action_visible (GimpActionGroup *group,
|
|
|
|
const gchar *action_name,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to set visibility of action "
|
|
|
|
"which doesn't exist: %s",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, action_name);
|
2004-04-19 22:54:24 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-03-23 02:51:57 +08:00
|
|
|
gtk_action_set_visible (action, visible);
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_action_group_set_action_sensitive (GimpActionGroup *group,
|
|
|
|
const gchar *action_name,
|
|
|
|
gboolean sensitive)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to set sensitivity of action "
|
|
|
|
"which doesn't exist: %s",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, action_name);
|
2004-04-19 22:54:24 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-03-23 02:51:57 +08:00
|
|
|
gtk_action_set_sensitive (action, sensitive);
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_action_group_set_action_active (GimpActionGroup *group,
|
|
|
|
const gchar *action_name,
|
|
|
|
gboolean active)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to set \"active\" of action "
|
|
|
|
"which doesn't exist: %s",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, action_name);
|
2004-04-19 22:54:24 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-04-23 00:16:43 +08:00
|
|
|
if (! GTK_IS_TOGGLE_ACTION (action))
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to set \"active\" of action "
|
|
|
|
"which is not a GtkToggleAction: %s",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, action_name);
|
2004-04-23 00:16:43 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
|
|
|
|
active ? TRUE : FALSE);
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_action_group_set_action_label (GimpActionGroup *group,
|
|
|
|
const gchar *action_name,
|
|
|
|
const gchar *label)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to set label of action "
|
|
|
|
"which doesn't exist: %s",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, action_name);
|
2004-04-19 22:54:24 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-18 23:51:04 +08:00
|
|
|
gtk_action_set_label (action, label);
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
|
|
|
|
2010-03-07 18:15:16 +08:00
|
|
|
void
|
|
|
|
gimp_action_group_set_action_tooltip (GimpActionGroup *group,
|
|
|
|
const gchar *action_name,
|
|
|
|
const gchar *tooltip)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to set tooltip of action "
|
|
|
|
"which doesn't exist: %s",
|
|
|
|
G_STRFUNC, action_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_action_set_tooltip (action, tooltip);
|
|
|
|
}
|
|
|
|
|
2010-08-18 00:48:05 +08:00
|
|
|
const gchar *
|
|
|
|
gimp_action_group_get_action_tooltip (GimpActionGroup *group,
|
|
|
|
const gchar *action_name)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_ACTION_GROUP (group), NULL);
|
|
|
|
g_return_val_if_fail (action_name != NULL, NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to get tooltip of action "
|
|
|
|
"which doesn't exist: %s",
|
|
|
|
G_STRFUNC, action_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return gtk_action_get_tooltip (action);
|
|
|
|
}
|
|
|
|
|
2004-04-19 22:54:24 +08:00
|
|
|
void
|
|
|
|
gimp_action_group_set_action_color (GimpActionGroup *group,
|
|
|
|
const gchar *action_name,
|
|
|
|
const GimpRGB *color,
|
|
|
|
gboolean set_label)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to set color of action "
|
|
|
|
"which doesn't exist: %s",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, action_name);
|
2004-04-19 22:54:24 +08:00
|
|
|
return;
|
|
|
|
}
|
2004-04-23 00:16:43 +08:00
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
if (! GIMP_IS_ACTION (action))
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to set \"color\" of action "
|
|
|
|
"which is not a GimpAction: %s",
|
|
|
|
G_STRFUNC, action_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-04-23 00:16:43 +08:00
|
|
|
if (set_label)
|
|
|
|
{
|
2004-11-30 08:30:05 +08:00
|
|
|
gchar *label;
|
|
|
|
|
|
|
|
if (color)
|
|
|
|
label = g_strdup_printf (_("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"),
|
|
|
|
color->r, color->g, color->b, color->a);
|
|
|
|
else
|
|
|
|
label = g_strdup (_("(none)"));
|
2004-04-23 00:16:43 +08:00
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
g_object_set (action,
|
|
|
|
"color", color,
|
|
|
|
"label", label,
|
|
|
|
NULL);
|
2004-04-23 00:16:43 +08:00
|
|
|
g_free (label);
|
|
|
|
}
|
2004-05-20 04:56:37 +08:00
|
|
|
else
|
2004-04-23 00:16:43 +08:00
|
|
|
{
|
2004-05-20 04:56:37 +08:00
|
|
|
g_object_set (action, "color", color, NULL);
|
2004-04-23 00:16:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_action_group_set_action_viewable (GimpActionGroup *group,
|
|
|
|
const gchar *action_name,
|
|
|
|
GimpViewable *viewable)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (action_name != NULL);
|
2004-11-30 08:30:05 +08:00
|
|
|
g_return_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable));
|
2004-04-23 00:16:43 +08:00
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to set viewable of action "
|
|
|
|
"which doesn't exist: %s",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, action_name);
|
2004-04-23 00:16:43 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-20 04:56:37 +08:00
|
|
|
if (! GIMP_IS_ACTION (action))
|
2004-04-23 00:16:43 +08:00
|
|
|
{
|
2004-05-20 04:56:37 +08:00
|
|
|
g_warning ("%s: Unable to set \"viewable\" of action "
|
|
|
|
"which is not a GimpAction: %s",
|
|
|
|
G_STRFUNC, action_name);
|
|
|
|
return;
|
2004-04-23 00:16:43 +08:00
|
|
|
}
|
2004-05-20 04:56:37 +08:00
|
|
|
|
|
|
|
g_object_set (action, "viewable", viewable, NULL);
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-09-24 07:41:43 +08:00
|
|
|
gimp_action_group_set_action_hide_empty (GimpActionGroup *group,
|
|
|
|
const gchar *action_name,
|
|
|
|
gboolean hide_empty)
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
2005-09-24 07:41:43 +08:00
|
|
|
g_warning ("%s: Unable to set \"hide-if-empty\" of action "
|
2004-04-19 22:54:24 +08:00
|
|
|
"which doesn't exist: %s",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, action_name);
|
2004-04-19 22:54:24 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-09-24 07:41:43 +08:00
|
|
|
g_object_set (action, "hide-if-empty", hide_empty ? TRUE : FALSE, NULL);
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
2011-04-02 21:38:55 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_action_group_set_action_always_show_image (GimpActionGroup *group,
|
|
|
|
const gchar *action_name,
|
|
|
|
gboolean always_show_image)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Unable to set \"always-show-image\" of action "
|
|
|
|
"which doesn't exist: %s",
|
|
|
|
G_STRFUNC, action_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_action_set_always_show_image (action, always_show_image);
|
|
|
|
}
|