new marshaller VOID:STRING
2004-04-16 Michael Natterer <mitch@gimp.org> * app/core/gimpmarshal.list: new marshaller VOID:STRING * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpenumaction.[ch] * app/widgets/gimpstringaction.[ch]: added some completely unused GtkAction infrastructure.
This commit is contained in:

committed by
Michael Natterer

parent
361b1f5677
commit
537b874750
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2004-04-16 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/core/gimpmarshal.list: new marshaller VOID:STRING
|
||||||
|
|
||||||
|
* app/widgets/Makefile.am
|
||||||
|
* app/widgets/widgets-types.h
|
||||||
|
* app/widgets/gimpactiongroup.[ch]
|
||||||
|
* app/widgets/gimpenumaction.[ch]
|
||||||
|
* app/widgets/gimpstringaction.[ch]: added some completely unused
|
||||||
|
GtkAction infrastructure.
|
||||||
|
|
||||||
2004-04-15 Tor Lillqvist <tml@iki.fi>
|
2004-04-15 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* app/plug-in/plug-in-message.c (plug_in_handle_proc_install)
|
* app/plug-in/plug-in-message.c (plug_in_handle_proc_install)
|
||||||
|
@ -41,5 +41,6 @@ VOID: OBJECT
|
|||||||
VOID: OBJECT, INT
|
VOID: OBJECT, INT
|
||||||
VOID: OBJECT, POINTER
|
VOID: OBJECT, POINTER
|
||||||
VOID: POINTER
|
VOID: POINTER
|
||||||
|
VOID: STRING
|
||||||
VOID: STRING, FLAGS
|
VOID: STRING, FLAGS
|
||||||
VOID: VOID
|
VOID: VOID
|
||||||
|
@ -19,6 +19,8 @@ noinst_LIBRARIES = libappwidgets.a
|
|||||||
libappwidgets_a_sources = \
|
libappwidgets_a_sources = \
|
||||||
widgets-enums.h \
|
widgets-enums.h \
|
||||||
widgets-types.h \
|
widgets-types.h \
|
||||||
|
gimpactiongroup.c \
|
||||||
|
gimpactiongroup.h \
|
||||||
gimpbrusheditor.c \
|
gimpbrusheditor.c \
|
||||||
gimpbrusheditor.h \
|
gimpbrusheditor.h \
|
||||||
gimpbrushfactoryview.c \
|
gimpbrushfactoryview.c \
|
||||||
@ -95,6 +97,8 @@ libappwidgets_a_sources = \
|
|||||||
gimpdrawabletreeview.h \
|
gimpdrawabletreeview.h \
|
||||||
gimpeditor.c \
|
gimpeditor.c \
|
||||||
gimpeditor.h \
|
gimpeditor.h \
|
||||||
|
gimpenumaction.c \
|
||||||
|
gimpenumaction.h \
|
||||||
gimpenummenu.c \
|
gimpenummenu.c \
|
||||||
gimpenummenu.h \
|
gimpenummenu.h \
|
||||||
gimperrorconsole.c \
|
gimperrorconsole.c \
|
||||||
@ -166,6 +170,8 @@ libappwidgets_a_sources = \
|
|||||||
gimpselectioneditor.h \
|
gimpselectioneditor.h \
|
||||||
gimpsessioninfo.c \
|
gimpsessioninfo.c \
|
||||||
gimpsessioninfo.h \
|
gimpsessioninfo.h \
|
||||||
|
gimpstringaction.c \
|
||||||
|
gimpstringaction.h \
|
||||||
gimpstrokeeditor.c \
|
gimpstrokeeditor.c \
|
||||||
gimpstrokeeditor.h \
|
gimpstrokeeditor.h \
|
||||||
gimptemplateeditor.c \
|
gimptemplateeditor.c \
|
||||||
|
371
app/widgets/gimpactiongroup.c
Normal file
371
app/widgets/gimpactiongroup.c
Normal file
@ -0,0 +1,371 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpactiongroup.c
|
||||||
|
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (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
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "widgets-types.h"
|
||||||
|
|
||||||
|
#include "gimpactiongroup.h"
|
||||||
|
#include "gimpenumaction.h"
|
||||||
|
#include "gimpstringaction.h"
|
||||||
|
|
||||||
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_TRANSLATION_DOMAIN
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void gimp_action_group_init (GimpActionGroup *group);
|
||||||
|
static void gimp_action_group_class_init (GimpActionGroupClass *klass);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
static GtkActionGroupClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
GType
|
||||||
|
gimp_action_group_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (!type)
|
||||||
|
{
|
||||||
|
static const GTypeInfo type_info =
|
||||||
|
{
|
||||||
|
sizeof (GimpActionGroupClass),
|
||||||
|
NULL, /* base_init */
|
||||||
|
NULL, /* base_finalize */
|
||||||
|
(GClassInitFunc) gimp_action_group_class_init,
|
||||||
|
NULL, /* class_finalize */
|
||||||
|
NULL, /* class_data */
|
||||||
|
sizeof (GimpActionGroup),
|
||||||
|
0, /* n_preallocs */
|
||||||
|
(GInstanceInitFunc) gimp_action_group_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
type = g_type_register_static (GTK_TYPE_ACTION_GROUP,
|
||||||
|
"GimpActionGroup",
|
||||||
|
&type_info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_action_group_class_init (GimpActionGroupClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
|
object_class->finalize = gimp_action_group_finalize;
|
||||||
|
object_class->set_property = gimp_action_group_set_property;
|
||||||
|
object_class->get_property = gimp_action_group_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_TRANSLATION_DOMAIN,
|
||||||
|
g_param_spec_string ("translation-domain",
|
||||||
|
NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_action_group_init (GimpActionGroup *group)
|
||||||
|
{
|
||||||
|
group->translation_domain = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_action_group_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GimpActionGroup *group = GIMP_ACTION_GROUP (object);
|
||||||
|
|
||||||
|
if (group->translation_domain)
|
||||||
|
{
|
||||||
|
g_free (group->translation_domain);
|
||||||
|
group->translation_domain = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
case PROP_TRANSLATION_DOMAIN:
|
||||||
|
g_free (group->translation_domain);
|
||||||
|
group->translation_domain = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
case PROP_TRANSLATION_DOMAIN:
|
||||||
|
g_value_set_string (value, group->translation_domain);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_action_group_new:
|
||||||
|
* @name: the name of the action group.
|
||||||
|
*
|
||||||
|
* 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 *
|
||||||
|
gimp_action_group_new (const gchar *name)
|
||||||
|
{
|
||||||
|
return g_object_new (GIMP_TYPE_ACTION_GROUP,
|
||||||
|
"name", name,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_action_group_add_actions (GimpActionGroup *group,
|
||||||
|
GimpActionEntry *entries,
|
||||||
|
guint n_entries,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
||||||
|
|
||||||
|
for (i = 0; i < n_entries; i++)
|
||||||
|
{
|
||||||
|
GtkAction *action;
|
||||||
|
const gchar *label;
|
||||||
|
const gchar *tooltip;
|
||||||
|
|
||||||
|
label = dgettext (group->translation_domain, entries[i].label);
|
||||||
|
tooltip = dgettext (group->translation_domain, entries[i].tooltip);
|
||||||
|
|
||||||
|
action = gtk_action_new (entries[i].name, label, tooltip,
|
||||||
|
entries[i].stock_id);
|
||||||
|
|
||||||
|
if (entries[i].callback)
|
||||||
|
g_signal_connect (action, "activate",
|
||||||
|
entries[i].callback,
|
||||||
|
user_data);
|
||||||
|
|
||||||
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
||||||
|
action,
|
||||||
|
entries[i].accelerator);
|
||||||
|
g_object_unref (action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_action_group_add_toggle_actions (GimpActionGroup *group,
|
||||||
|
GimpToggleActionEntry *entries,
|
||||||
|
guint n_entries,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
||||||
|
|
||||||
|
for (i = 0; i < n_entries; i++)
|
||||||
|
{
|
||||||
|
GtkToggleAction *action;
|
||||||
|
const gchar *label;
|
||||||
|
const gchar *tooltip;
|
||||||
|
|
||||||
|
label = dgettext (group->translation_domain, entries[i].label);
|
||||||
|
tooltip = dgettext (group->translation_domain, entries[i].tooltip);
|
||||||
|
|
||||||
|
action = gtk_toggle_action_new (entries[i].name, label, tooltip,
|
||||||
|
entries[i].stock_id);
|
||||||
|
|
||||||
|
gtk_toggle_action_set_active (action, entries[i].is_active);
|
||||||
|
|
||||||
|
if (entries[i].callback)
|
||||||
|
g_signal_connect (action, "toggled",
|
||||||
|
entries[i].callback,
|
||||||
|
user_data);
|
||||||
|
|
||||||
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
||||||
|
GTK_ACTION (action),
|
||||||
|
entries[i].accelerator);
|
||||||
|
g_object_unref (action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_action_group_add_radio_actions (GimpActionGroup *group,
|
||||||
|
GimpRadioActionEntry *entries,
|
||||||
|
guint n_entries,
|
||||||
|
gint value,
|
||||||
|
GCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkRadioAction *first_action = NULL;
|
||||||
|
GSList *radio_group = NULL;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
||||||
|
|
||||||
|
for (i = 0; i < n_entries; i++)
|
||||||
|
{
|
||||||
|
GtkRadioAction *action;
|
||||||
|
const gchar *label;
|
||||||
|
const gchar *tooltip;
|
||||||
|
|
||||||
|
label = dgettext (group->translation_domain, entries[i].label);
|
||||||
|
tooltip = dgettext (group->translation_domain, entries[i].tooltip);
|
||||||
|
|
||||||
|
action = gtk_radio_action_new (entries[i].name, label, tooltip,
|
||||||
|
entries[i].stock_id,
|
||||||
|
entries[i].value);
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
first_action = action;
|
||||||
|
|
||||||
|
gtk_radio_action_set_group (action, radio_group);
|
||||||
|
radio_group = gtk_radio_action_get_group (action);
|
||||||
|
|
||||||
|
if (value == entries[i].value)
|
||||||
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
|
||||||
|
|
||||||
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
||||||
|
GTK_ACTION (action),
|
||||||
|
entries[i].accelerator);
|
||||||
|
g_object_unref (action);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback && first_action)
|
||||||
|
g_signal_connect (first_action, "changed",
|
||||||
|
callback,
|
||||||
|
user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_action_group_add_enum_actions (GimpActionGroup *group,
|
||||||
|
GimpEnumActionEntry *entries,
|
||||||
|
guint n_entries,
|
||||||
|
GCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
||||||
|
|
||||||
|
for (i = 0; i < n_entries; i++)
|
||||||
|
{
|
||||||
|
GimpEnumAction *action;
|
||||||
|
const gchar *label;
|
||||||
|
const gchar *tooltip;
|
||||||
|
|
||||||
|
label = dgettext (group->translation_domain, entries[i].label);
|
||||||
|
tooltip = dgettext (group->translation_domain, entries[i].tooltip);
|
||||||
|
|
||||||
|
action = gimp_enum_action_new (entries[i].name, label, tooltip,
|
||||||
|
entries[i].stock_id,
|
||||||
|
entries[i].value);
|
||||||
|
|
||||||
|
if (callback)
|
||||||
|
g_signal_connect (action, "selected",
|
||||||
|
callback,
|
||||||
|
user_data);
|
||||||
|
|
||||||
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
||||||
|
GTK_ACTION (action),
|
||||||
|
entries[i].accelerator);
|
||||||
|
g_object_unref (action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_action_group_add_string_actions (GimpActionGroup *group,
|
||||||
|
GimpStringActionEntry *entries,
|
||||||
|
guint n_entries,
|
||||||
|
GCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
||||||
|
|
||||||
|
for (i = 0; i < n_entries; i++)
|
||||||
|
{
|
||||||
|
GimpStringAction *action;
|
||||||
|
const gchar *label;
|
||||||
|
const gchar *tooltip;
|
||||||
|
|
||||||
|
label = dgettext (group->translation_domain, entries[i].label);
|
||||||
|
tooltip = dgettext (group->translation_domain, entries[i].tooltip);
|
||||||
|
|
||||||
|
action = gimp_string_action_new (entries[i].name, label, tooltip,
|
||||||
|
entries[i].stock_id,
|
||||||
|
entries[i].value);
|
||||||
|
|
||||||
|
if (callback)
|
||||||
|
g_signal_connect (action, "selected",
|
||||||
|
callback,
|
||||||
|
user_data);
|
||||||
|
|
||||||
|
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
||||||
|
GTK_ACTION (action),
|
||||||
|
entries[i].accelerator);
|
||||||
|
g_object_unref (action);
|
||||||
|
}
|
||||||
|
}
|
142
app/widgets/gimpactiongroup.h
Normal file
142
app/widgets/gimpactiongroup.h
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpactiongroup.h
|
||||||
|
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (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
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_ACTION_GROUP_H__
|
||||||
|
#define __GIMP_ACTION_GROUP_H__
|
||||||
|
|
||||||
|
#include <gtk/gtkactiongroup.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define GIMP_TYPE_ACTION_GROUP (gimp_action_group_get_type ())
|
||||||
|
#define GIMP_ACTION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ACTION_GROUP, GimpActionGroup))
|
||||||
|
#define GIMP_ACTION_GROUP_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GIMP_TYPE_ACTION_GROUP, GimpActionGroupClass))
|
||||||
|
#define GIMP_IS_ACTION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ACTION_GROUP))
|
||||||
|
#define GIMP_IS_ACTION_GROUP_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GIMP_TYPE_ACTION_GROUP))
|
||||||
|
#define GIMP_ACTION_GROUP_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GIMP_TYPE_ACTION_GROUP, GimpActionGroupClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpActionGroupClass GimpActionGroupClass;
|
||||||
|
|
||||||
|
struct _GimpActionGroup
|
||||||
|
{
|
||||||
|
GtkActionGroup parent_instance;
|
||||||
|
|
||||||
|
gchar *translation_domain;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpActionGroupClass
|
||||||
|
{
|
||||||
|
GtkActionGroupClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpActionEntry
|
||||||
|
{
|
||||||
|
const gchar *name;
|
||||||
|
const gchar *stock_id;
|
||||||
|
const gchar *label;
|
||||||
|
const gchar *accelerator;
|
||||||
|
const gchar *tooltip;
|
||||||
|
GCallback callback;
|
||||||
|
|
||||||
|
const gchar *help_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpToggleActionEntry
|
||||||
|
{
|
||||||
|
const gchar *name;
|
||||||
|
const gchar *stock_id;
|
||||||
|
const gchar *label;
|
||||||
|
const gchar *accelerator;
|
||||||
|
const gchar *tooltip;
|
||||||
|
GCallback callback;
|
||||||
|
gboolean is_active;
|
||||||
|
|
||||||
|
const gchar *help_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpRadioActionEntry
|
||||||
|
{
|
||||||
|
const gchar *name;
|
||||||
|
const gchar *stock_id;
|
||||||
|
const gchar *label;
|
||||||
|
const gchar *accelerator;
|
||||||
|
const gchar *tooltip;
|
||||||
|
gint value;
|
||||||
|
|
||||||
|
const gchar *help_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpEnumActionEntry
|
||||||
|
{
|
||||||
|
const gchar *name;
|
||||||
|
const gchar *stock_id;
|
||||||
|
const gchar *label;
|
||||||
|
const gchar *accelerator;
|
||||||
|
const gchar *tooltip;
|
||||||
|
gint value;
|
||||||
|
|
||||||
|
const gchar *help_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpStringActionEntry
|
||||||
|
{
|
||||||
|
const gchar *name;
|
||||||
|
const gchar *stock_id;
|
||||||
|
const gchar *label;
|
||||||
|
const gchar *accelerator;
|
||||||
|
const gchar *tooltip;
|
||||||
|
const gchar *value;
|
||||||
|
|
||||||
|
const gchar *help_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GType gimp_action_group_get_type (void);
|
||||||
|
GimpActionGroup *gimp_action_group_new (const gchar *name);
|
||||||
|
|
||||||
|
void gimp_action_group_add_actions (GimpActionGroup *action_group,
|
||||||
|
GimpActionEntry *entries,
|
||||||
|
guint n_entries,
|
||||||
|
gpointer user_data);
|
||||||
|
void gimp_action_group_add_toggle_actions (GimpActionGroup *action_group,
|
||||||
|
GimpToggleActionEntry *entries,
|
||||||
|
guint n_entries,
|
||||||
|
gpointer user_data);
|
||||||
|
void gimp_action_group_add_radio_actions (GimpActionGroup *action_group,
|
||||||
|
GimpRadioActionEntry *entries,
|
||||||
|
guint n_entries,
|
||||||
|
gint value,
|
||||||
|
GCallback on_change,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void gimp_action_group_add_enum_actions (GimpActionGroup *action_group,
|
||||||
|
GimpEnumActionEntry *entries,
|
||||||
|
guint n_entries,
|
||||||
|
GCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
void gimp_action_group_add_string_actions (GimpActionGroup *action_group,
|
||||||
|
GimpStringActionEntry *entries,
|
||||||
|
guint n_entries,
|
||||||
|
GCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_ACTION_GROUP_H__ */
|
197
app/widgets/gimpenumaction.c
Normal file
197
app/widgets/gimpenumaction.c
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpenumaction.c
|
||||||
|
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (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
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "widgets-types.h"
|
||||||
|
|
||||||
|
#include "core/gimpmarshal.h"
|
||||||
|
|
||||||
|
#include "gimpenumaction.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SELECTED,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void gimp_enum_action_init (GimpEnumAction *action);
|
||||||
|
static void gimp_enum_action_class_init (GimpEnumActionClass *klass);
|
||||||
|
|
||||||
|
static void gimp_enum_action_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
static void gimp_enum_action_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
|
||||||
|
static void gimp_enum_action_activate (GtkAction *action);
|
||||||
|
|
||||||
|
|
||||||
|
static GtkActionClass *parent_class = NULL;
|
||||||
|
static guint action_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
|
|
||||||
|
GType
|
||||||
|
gimp_enum_action_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (!type)
|
||||||
|
{
|
||||||
|
static const GTypeInfo type_info =
|
||||||
|
{
|
||||||
|
sizeof (GimpEnumActionClass),
|
||||||
|
(GBaseInitFunc) NULL,
|
||||||
|
(GBaseFinalizeFunc) NULL,
|
||||||
|
(GClassInitFunc) gimp_enum_action_class_init,
|
||||||
|
(GClassFinalizeFunc) NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (GimpEnumAction),
|
||||||
|
0, /* n_preallocs */
|
||||||
|
(GInstanceInitFunc) gimp_enum_action_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
type = g_type_register_static (GTK_TYPE_ACTION,
|
||||||
|
"GimpEnumAction",
|
||||||
|
&type_info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_enum_action_class_init (GimpEnumActionClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
|
||||||
|
|
||||||
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
|
object_class->set_property = gimp_enum_action_set_property;
|
||||||
|
object_class->get_property = gimp_enum_action_get_property;
|
||||||
|
|
||||||
|
action_class->activate = gimp_enum_action_activate;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_VALUE,
|
||||||
|
g_param_spec_int ("value",
|
||||||
|
NULL, NULL,
|
||||||
|
0, G_MININT, G_MAXINT,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
action_signals[SELECTED] =
|
||||||
|
g_signal_new ("selected",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
G_STRUCT_OFFSET (GimpEnumActionClass, selected),
|
||||||
|
NULL, NULL,
|
||||||
|
gimp_marshal_VOID__INT,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
G_TYPE_INT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_enum_action_init (GimpEnumAction *action)
|
||||||
|
{
|
||||||
|
action->value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_enum_action_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GimpEnumAction *action = GIMP_ENUM_ACTION (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_VALUE:
|
||||||
|
g_value_set_int (value, action->value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_enum_action_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GimpEnumAction *action = GIMP_ENUM_ACTION (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_VALUE:
|
||||||
|
action->value = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GimpEnumAction *
|
||||||
|
gimp_enum_action_new (const gchar *name,
|
||||||
|
const gchar *label,
|
||||||
|
const gchar *tooltip,
|
||||||
|
const gchar *stock_id,
|
||||||
|
gint value)
|
||||||
|
{
|
||||||
|
return g_object_new (GIMP_TYPE_ENUM_ACTION,
|
||||||
|
"name", name,
|
||||||
|
"label", label,
|
||||||
|
"tooltip", tooltip,
|
||||||
|
"stock_id", stock_id,
|
||||||
|
"value", value,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_enum_action_activate (GtkAction *action)
|
||||||
|
{
|
||||||
|
GimpEnumAction *enum_action = GIMP_ENUM_ACTION (action);
|
||||||
|
|
||||||
|
gimp_enum_action_selected (enum_action);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_enum_action_selected (GimpEnumAction *action)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_ENUM_ACTION (action));
|
||||||
|
|
||||||
|
g_signal_emit (action, action_signals[SELECTED], 0, action->value);
|
||||||
|
}
|
64
app/widgets/gimpenumaction.h
Normal file
64
app/widgets/gimpenumaction.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpenumaction.h
|
||||||
|
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (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
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_ENUM_ACTION_H__
|
||||||
|
#define __GIMP_ENUM_ACTION_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include <gtk/gtkaction.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define GIMP_TYPE_ENUM_ACTION (gimp_enum_action_get_type ())
|
||||||
|
#define GIMP_ENUM_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ENUM_ACTION, GimpEnumAction))
|
||||||
|
#define GIMP_ENUM_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ENUM_ACTION, GimpEnumActionClass))
|
||||||
|
#define GIMP_IS_ENUM_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ENUM_ACTION))
|
||||||
|
#define GIMP_IS_ENUM_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GIMP_TYPE_ENUM_ACTION))
|
||||||
|
#define GIMP_ENUM_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GIMP_TYPE_ENUM_ACTION, GimpEnumActionClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpEnumActionClass GimpEnumActionClass;
|
||||||
|
|
||||||
|
struct _GimpEnumAction
|
||||||
|
{
|
||||||
|
GtkAction parent_instance;
|
||||||
|
|
||||||
|
gint value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpEnumActionClass
|
||||||
|
{
|
||||||
|
GtkActionClass parent_class;
|
||||||
|
|
||||||
|
void (* selected) (GimpEnumAction *action,
|
||||||
|
gint value);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GType gimp_enum_action_get_type (void);
|
||||||
|
GimpEnumAction * gimp_enum_action_new (const gchar *name,
|
||||||
|
const gchar *label,
|
||||||
|
const gchar *tooltip,
|
||||||
|
const gchar *stock_id,
|
||||||
|
gint value);
|
||||||
|
void gimp_enum_action_selected (GimpEnumAction *action);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_ENUM_ACTION_H__ */
|
214
app/widgets/gimpstringaction.c
Normal file
214
app/widgets/gimpstringaction.c
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpstringaction.c
|
||||||
|
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (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
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "widgets-types.h"
|
||||||
|
|
||||||
|
#include "core/gimpmarshal.h"
|
||||||
|
|
||||||
|
#include "gimpstringaction.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SELECTED,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void gimp_string_action_init (GimpStringAction *action);
|
||||||
|
static void gimp_string_action_class_init (GimpStringActionClass *klass);
|
||||||
|
|
||||||
|
static void gimp_string_action_finalize (GObject *object);
|
||||||
|
static void gimp_string_action_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
static void gimp_string_action_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
|
||||||
|
static void gimp_string_action_activate (GtkAction *action);
|
||||||
|
|
||||||
|
|
||||||
|
static GtkActionClass *parent_class = NULL;
|
||||||
|
static guint action_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
|
|
||||||
|
GType
|
||||||
|
gimp_string_action_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (!type)
|
||||||
|
{
|
||||||
|
static const GTypeInfo type_info =
|
||||||
|
{
|
||||||
|
sizeof (GimpStringActionClass),
|
||||||
|
(GBaseInitFunc) NULL,
|
||||||
|
(GBaseFinalizeFunc) NULL,
|
||||||
|
(GClassInitFunc) gimp_string_action_class_init,
|
||||||
|
(GClassFinalizeFunc) NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (GimpStringAction),
|
||||||
|
0, /* n_preallocs */
|
||||||
|
(GInstanceInitFunc) gimp_string_action_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
type = g_type_register_static (GTK_TYPE_ACTION,
|
||||||
|
"GimpStringAction",
|
||||||
|
&type_info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_string_action_class_init (GimpStringActionClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
|
||||||
|
|
||||||
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
|
object_class->finalize = gimp_string_action_finalize;
|
||||||
|
object_class->set_property = gimp_string_action_set_property;
|
||||||
|
object_class->get_property = gimp_string_action_get_property;
|
||||||
|
|
||||||
|
action_class->activate = gimp_string_action_activate;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_VALUE,
|
||||||
|
g_param_spec_string ("value",
|
||||||
|
NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
action_signals[SELECTED] =
|
||||||
|
g_signal_new ("selected",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
G_STRUCT_OFFSET (GimpStringActionClass, selected),
|
||||||
|
NULL, NULL,
|
||||||
|
gimp_marshal_VOID__STRING,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
G_TYPE_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_string_action_init (GimpStringAction *action)
|
||||||
|
{
|
||||||
|
action->value = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_string_action_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GimpStringAction *action = GIMP_STRING_ACTION (object);
|
||||||
|
|
||||||
|
if (action->value)
|
||||||
|
{
|
||||||
|
g_free (action->value);
|
||||||
|
action->value = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_string_action_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GimpStringAction *action = GIMP_STRING_ACTION (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_VALUE:
|
||||||
|
g_value_set_string (value, action->value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_string_action_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GimpStringAction *action = GIMP_STRING_ACTION (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_VALUE:
|
||||||
|
g_free (action->value);
|
||||||
|
action->value = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GimpStringAction *
|
||||||
|
gimp_string_action_new (const gchar *name,
|
||||||
|
const gchar *label,
|
||||||
|
const gchar *tooltip,
|
||||||
|
const gchar *stock_id,
|
||||||
|
const gchar *value)
|
||||||
|
{
|
||||||
|
return g_object_new (GIMP_TYPE_STRING_ACTION,
|
||||||
|
"name", name,
|
||||||
|
"label", label,
|
||||||
|
"tooltip", tooltip,
|
||||||
|
"stock_id", stock_id,
|
||||||
|
"value", value,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_string_action_activate (GtkAction *action)
|
||||||
|
{
|
||||||
|
GimpStringAction *string_action = GIMP_STRING_ACTION (action);
|
||||||
|
|
||||||
|
gimp_string_action_selected (string_action);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_string_action_selected (GimpStringAction *action)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_STRING_ACTION (action));
|
||||||
|
|
||||||
|
g_signal_emit (action, action_signals[SELECTED], 0, action->value);
|
||||||
|
}
|
64
app/widgets/gimpstringaction.h
Normal file
64
app/widgets/gimpstringaction.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpstringaction.h
|
||||||
|
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (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
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_STRING_ACTION_H__
|
||||||
|
#define __GIMP_STRING_ACTION_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include <gtk/gtkaction.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define GIMP_TYPE_STRING_ACTION (gimp_string_action_get_type ())
|
||||||
|
#define GIMP_STRING_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_STRING_ACTION, GimpStringAction))
|
||||||
|
#define GIMP_STRING_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_STRING_ACTION, GimpStringActionClass))
|
||||||
|
#define GIMP_IS_STRING_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_STRING_ACTION))
|
||||||
|
#define GIMP_IS_STRING_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GIMP_TYPE_STRING_ACTION))
|
||||||
|
#define GIMP_STRING_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GIMP_TYPE_STRING_ACTION, GimpStringActionClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpStringActionClass GimpStringActionClass;
|
||||||
|
|
||||||
|
struct _GimpStringAction
|
||||||
|
{
|
||||||
|
GtkAction parent_instance;
|
||||||
|
|
||||||
|
gchar *value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpStringActionClass
|
||||||
|
{
|
||||||
|
GtkActionClass parent_class;
|
||||||
|
|
||||||
|
void (* selected) (GimpStringAction *action,
|
||||||
|
const gchar *value);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GType gimp_string_action_get_type (void);
|
||||||
|
GimpStringAction * gimp_string_action_new (const gchar *name,
|
||||||
|
const gchar *label,
|
||||||
|
const gchar *tooltip,
|
||||||
|
const gchar *stock_id,
|
||||||
|
const gchar *value);
|
||||||
|
void gimp_string_action_selected (GimpStringAction *action);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_STRING_ACTION_H__ */
|
@ -34,6 +34,10 @@ typedef struct _GimpDialogFactory GimpDialogFactory;
|
|||||||
typedef struct _GimpItemFactory GimpItemFactory;
|
typedef struct _GimpItemFactory GimpItemFactory;
|
||||||
typedef struct _GimpMenuFactory GimpMenuFactory;
|
typedef struct _GimpMenuFactory GimpMenuFactory;
|
||||||
|
|
||||||
|
typedef struct _GimpActionGroup GimpActionGroup;
|
||||||
|
typedef struct _GimpEnumAction GimpEnumAction;
|
||||||
|
typedef struct _GimpStringAction GimpStringAction;
|
||||||
|
|
||||||
typedef struct _GimpCellRendererToggle GimpCellRendererToggle;
|
typedef struct _GimpCellRendererToggle GimpCellRendererToggle;
|
||||||
typedef struct _GimpCellRendererViewable GimpCellRendererViewable;
|
typedef struct _GimpCellRendererViewable GimpCellRendererViewable;
|
||||||
|
|
||||||
@ -123,6 +127,12 @@ typedef struct _GimpColorDisplayEditor GimpColorDisplayEditor;
|
|||||||
|
|
||||||
/* structs */
|
/* structs */
|
||||||
|
|
||||||
|
typedef struct _GimpActionEntry GimpActionEntry;
|
||||||
|
typedef struct _GimpToggleActionEntry GimpToggleActionEntry;
|
||||||
|
typedef struct _GimpRadioActionEntry GimpRadioActionEntry;
|
||||||
|
typedef struct _GimpEnumActionEntry GimpEnumActionEntry;
|
||||||
|
typedef struct _GimpStringActionEntry GimpStringActionEntry;
|
||||||
|
|
||||||
typedef struct _GimpItemFactoryEntry GimpItemFactoryEntry;
|
typedef struct _GimpItemFactoryEntry GimpItemFactoryEntry;
|
||||||
typedef struct _GimpDialogFactoryEntry GimpDialogFactoryEntry;
|
typedef struct _GimpDialogFactoryEntry GimpDialogFactoryEntry;
|
||||||
typedef struct _GimpSessionInfo GimpSessionInfo;
|
typedef struct _GimpSessionInfo GimpSessionInfo;
|
||||||
|
Reference in New Issue
Block a user