Commit 27a2c8c0 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

More unused action stuff:

2004-04-21  Michael Natterer  <mitch@gimp.org>

	More unused action stuff:

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpactionfactory.[ch]: added a simple factory which
	produces GimpActionGroups.

	* app/widgets/gimpactiongroup.[ch]: added an "update_func" member
	to the GimpActionGroup struct. Added it as parameter to
	gimp_action_group_new(). Added function gimp_action_group_update().

	* app/widgets/gimpmenufactory.[ch]: added an "action_factory"
	member and constructor parameter. Added code to create
	GtkUIManagers from registered action group identifiers.

	* app/actions/Makefile.am
	* app/actions/actions.[ch]: new files: create a
	"global_action_factory" and register all action groups with it.

	* app/actions/edit-actions.c: s/edit_action_update/edit_actions_update/

	* app/actions/plug-in-actions.[ch]: added API to add/remove
	plug-in procedure actions dynamically (unfinished).

	* app/gui/menus.c (menus_init): call actions_init().
	(menus_exit): call actions_exit().
parent 732fc05f
2004-04-21 Michael Natterer <mitch@gimp.org>
More unused action stuff:
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpactionfactory.[ch]: added a simple factory which
produces GimpActionGroups.
* app/widgets/gimpactiongroup.[ch]: added an "update_func" member
to the GimpActionGroup struct. Added it as parameter to
gimp_action_group_new(). Added function gimp_action_group_update().
* app/widgets/gimpmenufactory.[ch]: added an "action_factory"
member and constructor parameter. Added code to create
GtkUIManagers from registered action group identifiers.
* app/actions/Makefile.am
* app/actions/actions.[ch]: new files: create a
"global_action_factory" and register all action groups with it.
* app/actions/edit-actions.c: s/edit_action_update/edit_actions_update/
* app/actions/plug-in-actions.[ch]: added API to add/remove
plug-in procedure actions dynamically (unfinished).
* app/gui/menus.c (menus_init): call actions_init().
(menus_exit): call actions_exit().
2004-04-21 Sven Neumann <sven@gimp.org>
* plug-ins/Lighting/lighting_ui.c
......
......@@ -4,6 +4,8 @@ noinst_LIBRARIES = libappactions.a
libappactions_a_SOURCES = \
actions-types.h \
actions.c \
actions.h \
\
brushes-actions.c \
brushes-actions.h \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "core/gimp.h"
#include "widgets/gimpactionfactory.h"
#include "brushes-actions.h"
#include "buffers-actions.h"
#include "channels-actions.h"
#include "colormap-editor-actions.h"
#include "debug-actions.h"
#include "dialogs-actions.h"
#include "dockable-actions.h"
#include "documents-actions.h"
#include "drawable-actions.h"
#include "edit-actions.h"
#include "error-console-actions.h"
#include "file-actions.h"
#include "fonts-actions.h"
#include "gradient-editor-actions.h"
#include "gradients-actions.h"
#include "help-actions.h"
#include "image-actions.h"
#include "images-actions.h"
#include "layers-actions.h"
#include "palette-editor-actions.h"
#include "palettes-actions.h"
#include "patterns-actions.h"
#include "plug-in-actions.h"
#include "qmask-actions.h"
#include "select-actions.h"
#include "templates-actions.h"
#include "tool-options-actions.h"
#include "tools-actions.h"
#include "vectors-actions.h"
#include "view-actions.h"
/* global variables */
GimpActionFactory *global_action_factory = NULL;
/* private variables */
static GimpActionFactoryEntry action_groups[] =
{
{ "brushes",
brushes_actions_setup,
brushes_actions_update },
{ "buffers",
buffers_actions_setup,
buffers_actions_update },
{ "channels",
channels_actions_setup,
channels_actions_update },
{ "colormap-editor",
colormap_editor_actions_setup,
colormap_editor_actions_update },
{ "debug",
debug_actions_setup,
debug_actions_update },
{ "dialogs",
dialogs_actions_setup,
dialogs_actions_update },
{ "dockable",
dockable_actions_setup,
dockable_actions_update },
{ "documents",
documents_actions_setup,
documents_actions_update },
{ "drawable",
drawable_actions_setup,
drawable_actions_update },
{ "edit",
edit_actions_setup,
edit_actions_update },
{ "error-console",
error_console_actions_setup,
error_console_actions_update },
{ "file",
file_actions_setup,
file_actions_update },
{ "fonts",
fonts_actions_setup,
fonts_actions_update },
{ "gradient-editor",
gradient_editor_actions_setup,
gradient_editor_actions_update },
{ "gradients",
gradients_actions_setup,
gradients_actions_update },
{ "help",
help_actions_setup,
help_actions_update },
{ "image",
image_actions_setup,
image_actions_update },
{ "images",
images_actions_setup,
images_actions_update },
{ "layers",
layers_actions_setup,
layers_actions_update },
{ "palette-editor",
palette_editor_actions_setup,
palette_editor_actions_update },
{ "palettes",
palettes_actions_setup,
palettes_actions_update },
{ "plug-in",
plug_in_actions_setup,
plug_in_actions_update },
{ "qmask",
qmask_actions_setup,
qmask_actions_update },
{ "select",
select_actions_setup,
select_actions_update },
{ "templates",
templates_actions_setup,
templates_actions_update },
{ "tool-options",
tool_options_actions_setup,
tool_options_actions_update },
{ "tools",
tools_actions_setup,
tools_actions_update },
{ "vectors",
vectors_actions_setup,
vectors_actions_update },
{ "view",
view_actions_setup,
view_actions_update }
};
static gboolean actions_initialized = FALSE;
/* public functions */
void
actions_init (Gimp *gimp)
{
gint i;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (actions_initialized == FALSE);
actions_initialized = TRUE;
global_action_factory = gimp_action_factory_new (gimp);
for (i = 0; i < G_N_ELEMENTS (action_groups); i++)
gimp_action_factory_group_register (global_action_factory,
action_groups[i].identifier,
action_groups[i].setup_func,
action_groups[i].update_func);
}
void
actions_exit (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_object_unref (global_action_factory);
global_action_factory = NULL;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 __ACTIONS_H__
#define __ACTIONS_H__
extern GimpActionFactory *global_action_factory;
void actions_init (Gimp *gimp);
void actions_exit (Gimp *gimp);
#endif /* __ACTIONS_H__ */
......@@ -187,8 +187,8 @@ edit_actions_setup (GimpActionGroup *group,
}
void
edit_action_update (GimpActionGroup *group,
gpointer data)
edit_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
......
......@@ -18,35 +18,50 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "core/gimpundostack.h"
#include "pdb/procedural_db.h"
#include "plug-in/plug-ins.h"
#include "plug-in/plug-in-proc.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "plug-in-actions.h"
#include "plug-in-commands.h"
#include "gimp-intl.h"
typedef struct _PlugInActionEntry PlugInActionEntry;
struct _PlugInActionEntry
{
PlugInProcDef *proc_def;
const gchar *locale_domain;
const gchar *help_domain;
};
/* local function prototypes */
static gboolean plug_in_actions_tree_traverse_func (gpointer foo,
PlugInActionEntry *entry,
GimpActionGroup *group);
static GimpActionEntry plug_in_actions[] =
{
{ "plug-in-menu", NULL, N_("/Filte_rs") },
......@@ -86,10 +101,15 @@ static GimpEnumActionEntry plug_in_repeat_actions[] =
};
/* public functions */
void
plug_in_actions_setup (GimpActionGroup *group,
gpointer data)
{
GSList *procs;
GTree *action_entries;
gimp_action_group_add_actions (group,
plug_in_actions,
G_N_ELEMENTS (plug_in_actions),
......@@ -100,6 +120,51 @@ plug_in_actions_setup (GimpActionGroup *group,
G_N_ELEMENTS (plug_in_repeat_actions),
G_CALLBACK (plug_in_repeat_cmd_callback),
data);
action_entries = g_tree_new_full ((GCompareDataFunc) g_utf8_collate, NULL,
g_free, g_free);
for (procs = group->gimp->plug_in_proc_defs;
procs;
procs = procs->next)
{
PlugInProcDef *proc_def = procs->data;
if (proc_def->prog &&
proc_def->menu_path &&
! proc_def->extensions &&
! proc_def->prefixes &&
! proc_def->magics)
{
PlugInActionEntry *entry;
const gchar *progname;
const gchar *locale_domain;
const gchar *help_domain;
gchar *key;
progname = plug_in_proc_def_get_progname (proc_def);
locale_domain = plug_ins_locale_domain (group->gimp,
progname, NULL);
help_domain = plug_ins_help_domain (group->gimp,
progname, NULL);
entry = g_new0 (PlugInActionEntry, 1);
entry->proc_def = proc_def;
entry->locale_domain = locale_domain;
entry->help_domain = help_domain;
key = gimp_strip_uline (dgettext (locale_domain,
proc_def->menu_path));
g_tree_insert (action_entries, key, entry);
}
}
g_tree_foreach (action_entries,
(GTraverseFunc) plug_in_actions_tree_traverse_func,
group);
g_tree_destroy (action_entries);
}
void
......@@ -107,3 +172,62 @@ plug_in_actions_update (GimpActionGroup *group,
gpointer data)
{
}
void
plug_in_actions_add_proc (GimpActionGroup *group,
PlugInProcDef *proc_def,
const gchar *locale_domain,
const gchar *help_domain)
{
GimpActionEntry entry;
gchar *help_id;
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
g_return_if_fail (proc_def != NULL);
help_id = plug_in_proc_def_get_help_id (proc_def, help_domain);
entry.name = proc_def->db_info.name;
entry.stock_id = NULL;
entry.label = strrchr (proc_def->menu_path, '/') + 1;
entry.accelerator = proc_def->accelerator;
entry.tooltip = NULL;
entry.callback = G_CALLBACK (plug_in_run_cmd_callback);
entry.help_id = help_id;
gimp_action_group_add_actions (group, &entry, 1, &proc_def->db_info);
g_free (help_id);
}
void
plug_in_actions_remove_proc (GimpActionGroup *group,
PlugInProcDef *proc_def)
{
GtkAction *action;
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
g_return_if_fail (proc_def != NULL);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
proc_def->db_info.name);
if (action)
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
}
/* private functions */
static gboolean
plug_in_actions_tree_traverse_func (gpointer foo,
PlugInActionEntry *entry,
GimpActionGroup *group)
{
plug_in_actions_add_proc (group,
entry->proc_def,
entry->locale_domain,
entry->help_domain);
return FALSE;
}
......@@ -20,10 +20,17 @@
#define __PLUG_IN_ACTIONS_H__
void plug_in_actions_setup (GimpActionGroup *group,
gpointer data);
void plug_in_actions_update (GimpActionGroup *group,
gpointer data);
void plug_in_actions_setup (GimpActionGroup *group,
gpointer data);
void plug_in_actions_update (GimpActionGroup *group,
gpointer data);
void plug_in_actions_add_proc (GimpActionGroup *group,
PlugInProcDef *proc_def,
const gchar *locale_domain,
const gchar *help_domain);
void plug_in_actions_remove_proc (GimpActionGroup *group,
PlugInProcDef *proc_def);
#endif /* __PLUG_IN_ACTIONS_H__ */
......@@ -37,6 +37,7 @@
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpmenufactory.h"
#include "actions/actions.h"
#include "actions/file-commands.h"
#include "brushes-menu.h"
......@@ -100,6 +101,8 @@ menus_init (Gimp *gimp)
menus_initialized = TRUE;
actions_init (gimp);
/* We need to make sure the property is installed before using it */
g_type_class_ref (GTK_TYPE_MENU);
......@@ -108,7 +111,7 @@ menus_init (Gimp *gimp)
g_signal_connect (gimp->config, "notify::can-change-accels",
G_CALLBACK (menu_can_change_accels), NULL);
global_menu_factory = gimp_menu_factory_new (gimp);
global_menu_factory = gimp_menu_factory_new (gimp, global_action_factory);
gimp_menu_factory_menu_register (global_menu_factory, "<Toolbox>",
_("Toolbox Menu"),
......@@ -285,6 +288,8 @@ menus_exit (Gimp *gimp)
g_signal_handlers_disconnect_by_func (gimp->config,
menu_can_change_accels,
NULL);
actions_exit (gimp);
}
void
......
......@@ -37,6 +37,7 @@
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpmenufactory.h"
#include "actions/actions.h"
#include "actions/file-commands.h"
#include "brushes-menu.h"
......@@ -100,6 +101,8 @@ menus_init (Gimp *gimp)
menus_initialized = TRUE;
actions_init (gimp);
/* We need to make sure the property is installed before using it */
g_type_class_ref (GTK_TYPE_MENU);
......@@ -108,7 +111,7 @@ menus_init (Gimp *gimp)
g_signal_connect (gimp->config, "notify::can-change-accels",
G_CALLBACK (menu_can_change_accels), NULL);
global_menu_factory = gimp_menu_factory_new (gimp);
global_menu_factory = gimp_menu_factory_new (gimp, global_action_factory);
gimp_menu_factory_menu_register (global_menu_factory, "<Toolbox>",
_("Toolbox Menu"),
......@@ -285,6 +288,8 @@ menus_exit (Gimp *gimp)
g_signal_handlers_disconnect_by_func (gimp->config,
menu_can_change_accels,
NULL);
actions_exit (gimp);
}
void
......
......@@ -19,6 +19,8 @@ noinst_LIBRARIES = libappwidgets.a
libappwidgets_a_sources = \
widgets-enums.h \
widgets-types.h \
gimpactionfactory.c \
gimpactionfactory.h \
gimpactiongroup.c \
gimpactiongroup.h \
gimpbrusheditor.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpactionfactory.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 <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimp.h"
#include "gimpactionfactory.h"
#include "gimpactiongroup.h"
static void gimp_action_factory_class_init (GimpActionFactoryClass *klass);
static void gimp_action_factory_init (GimpActionFactory *factory);
static void gimp_action_factory_finalize (GObject *object);
static GimpObjectClass *parent_class = NULL;
GType
gimp_action_factory_get_type (void)
{
static GType factory_type = 0;
if (! factory_type)
{
static const GTypeInfo factory_info =
{
sizeof (GimpActionFactoryClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_action_factory_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpActionFactory),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_action_factory_init,
};
factory_type = g_type_register_static (GIMP_TYPE_OBJECT,
"GimpActionFactory",
&factory_info, 0);