Commit 537b8747 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

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.
parent 361b1f56
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>
* app/plug-in/plug-in-message.c (plug_in_handle_proc_install)
......
......@@ -41,5 +41,6 @@ VOID: OBJECT
VOID: OBJECT, INT
VOID: OBJECT, POINTER
VOID: POINTER
VOID: STRING
VOID: STRING, FLAGS
VOID: VOID
......@@ -19,6 +19,8 @@ noinst_LIBRARIES = libappwidgets.a
libappwidgets_a_sources = \
widgets-enums.h \
widgets-types.h \
gimpactiongroup.c \
gimpactiongroup.h \
gimpbrusheditor.c \
gimpbrusheditor.h \
gimpbrushfactoryview.c \
......@@ -95,6 +97,8 @@ libappwidgets_a_sources = \
gimpdrawabletreeview.h \
gimpeditor.c \
gimpeditor.h \
gimpenumaction.c \
gimpenumaction.h \
gimpenummenu.c \
gimpenummenu.h \
gimperrorconsole.c \
......@@ -166,6 +170,8 @@ libappwidgets_a_sources = \
gimpselectioneditor.h \
gimpsessioninfo.c \
gimpsessioninfo.h \
gimpstringaction.c \
gimpstringaction.h \
gimpstrokeeditor.c \
gimpstrokeeditor.h \
gimptemplateeditor.c \
......
/* 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);
}
}
/* 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__ */
/* 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);
}