mirror of https://github.com/GNOME/gimp.git
removed "locale_domain" and "help_domain" parameters from
2004-04-26 Michael Natterer <mitch@gimp.org> * app/core/gimp.[ch]: removed "locale_domain" and "help_domain" parameters from GimpMenusCreateFunc. * app/plug-in/plug-ins.c (plug_ins_temp_proc_def_add) * app/actions/plug-in-actions.[ch] (plug_in_actions_add_proc_def): changed accordingly. * app/widgets/gimpactiongroup.[ch]: remember all created action groups is a hash table in GimpActionGroupClass. Added gimp_action_groups_from_name() which returns a GList of all groups with the given name. * app/actions/plug-in-actions.[ch] (plug_in_actions_setup): removed the tree sorting code. Actions don't need to be ordered alphabetically. (plug_in_actions_update): copied & ported plug_in_menus_update(). * app/gui/gui-vtable.c (gui_menus_create,delete_entry): dynamically add/remove plug-in actions in all "plug-in" action groups.
This commit is contained in:
parent
648fd7efad
commit
b69ddb3993
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
2004-04-26 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimp.[ch]: removed "locale_domain" and "help_domain"
|
||||
parameters from GimpMenusCreateFunc.
|
||||
|
||||
* app/plug-in/plug-ins.c (plug_ins_temp_proc_def_add)
|
||||
* app/actions/plug-in-actions.[ch] (plug_in_actions_add_proc_def):
|
||||
changed accordingly.
|
||||
|
||||
* app/widgets/gimpactiongroup.[ch]: remember all created action
|
||||
groups is a hash table in GimpActionGroupClass. Added
|
||||
gimp_action_groups_from_name() which returns a GList of all groups
|
||||
with the given name.
|
||||
|
||||
* app/actions/plug-in-actions.[ch] (plug_in_actions_setup):
|
||||
removed the tree sorting code. Actions don't need to be ordered
|
||||
alphabetically.
|
||||
|
||||
(plug_in_actions_update): copied & ported plug_in_menus_update().
|
||||
|
||||
* app/gui/gui-vtable.c (gui_menus_create,delete_entry):
|
||||
dynamically add/remove plug-in actions in all "plug-in" action
|
||||
groups.
|
||||
|
||||
2004-04-25 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimp.[ch]: changed GimpMenusDeleteFunc to take
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
@ -38,6 +39,10 @@
|
|||
|
||||
#include "widgets/gimpactiongroup.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpitemtreeview.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "plug-in-actions.h"
|
||||
#include "plug-in-commands.h"
|
||||
|
@ -45,26 +50,9 @@
|
|||
#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") },
|
||||
{ "plug-in-menu", NULL, N_("Filte_rs") },
|
||||
{ "plug-in-blur-menu", NULL, N_("_Blur") },
|
||||
{ "plug-in-colors-menu", NULL, N_("_Colors") },
|
||||
{ "plug-in-colors-map-menu", NULL, N_("Ma_p") },
|
||||
|
@ -107,8 +95,7 @@ void
|
|||
plug_in_actions_setup (GimpActionGroup *group,
|
||||
gpointer data)
|
||||
{
|
||||
GSList *procs;
|
||||
GTree *action_entries;
|
||||
GSList *list;
|
||||
|
||||
gimp_action_group_add_actions (group,
|
||||
plug_in_actions,
|
||||
|
@ -121,14 +108,11 @@ plug_in_actions_setup (GimpActionGroup *group,
|
|||
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)
|
||||
for (list = group->gimp->plug_in_proc_defs;
|
||||
list;
|
||||
list = g_slist_next (list))
|
||||
{
|
||||
PlugInProcDef *proc_def = procs->data;
|
||||
PlugInProcDef *proc_def = list->data;
|
||||
|
||||
if (proc_def->prog &&
|
||||
proc_def->menu_path &&
|
||||
|
@ -136,67 +120,177 @@ plug_in_actions_setup (GimpActionGroup *group,
|
|||
! 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);
|
||||
plug_in_actions_add_proc (group, proc_def);
|
||||
}
|
||||
}
|
||||
|
||||
g_tree_foreach (action_entries,
|
||||
(GTraverseFunc) plug_in_actions_tree_traverse_func,
|
||||
group);
|
||||
g_tree_destroy (action_entries);
|
||||
}
|
||||
|
||||
void
|
||||
plug_in_actions_update (GimpActionGroup *group,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage = NULL;
|
||||
GimpImageType type = -1;
|
||||
GList *list;
|
||||
|
||||
if (GIMP_IS_ITEM_TREE_VIEW (data))
|
||||
gimage = GIMP_ITEM_TREE_VIEW (data)->gimage;
|
||||
else if (GIMP_IS_DISPLAY_SHELL (data))
|
||||
gimage = GIMP_DISPLAY_SHELL (data)->gdisp->gimage;
|
||||
else if (GIMP_IS_DISPLAY (data))
|
||||
gimage = GIMP_DISPLAY (data)->gimage;
|
||||
|
||||
if (gimage)
|
||||
{
|
||||
GimpDrawable *drawable = gimp_image_active_drawable (gimage);
|
||||
|
||||
type = gimp_drawable_type (drawable);
|
||||
}
|
||||
|
||||
for (list = group->gimp->plug_in_proc_defs;
|
||||
list;
|
||||
list = g_slist_next (list))
|
||||
{
|
||||
PlugInProcDef *proc_def = list->data;
|
||||
|
||||
if (proc_def->menu_path &&
|
||||
proc_def->image_types_val &&
|
||||
! proc_def->extensions &&
|
||||
! proc_def->prefixes &&
|
||||
! proc_def->magics)
|
||||
{
|
||||
gboolean sensitive;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GIMP_RGB_IMAGE:
|
||||
sensitive = proc_def->image_types_val & PLUG_IN_RGB_IMAGE;
|
||||
break;
|
||||
case GIMP_RGBA_IMAGE:
|
||||
sensitive = proc_def->image_types_val & PLUG_IN_RGBA_IMAGE;
|
||||
break;
|
||||
case GIMP_GRAY_IMAGE:
|
||||
sensitive = proc_def->image_types_val & PLUG_IN_GRAY_IMAGE;
|
||||
break;
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
sensitive = proc_def->image_types_val & PLUG_IN_GRAYA_IMAGE;
|
||||
break;
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
sensitive = proc_def->image_types_val & PLUG_IN_INDEXED_IMAGE;
|
||||
break;
|
||||
case GIMP_INDEXEDA_IMAGE:
|
||||
sensitive = proc_def->image_types_val & PLUG_IN_INDEXEDA_IMAGE;
|
||||
break;
|
||||
default:
|
||||
sensitive = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_action_group_set_action_sensitive (group,
|
||||
proc_def->db_info.name,
|
||||
sensitive);
|
||||
|
||||
if (group->gimp->last_plug_in &&
|
||||
group->gimp->last_plug_in == &proc_def->db_info)
|
||||
{
|
||||
const gchar *progname;
|
||||
const gchar *path;
|
||||
gchar *stripped;
|
||||
gchar *basename;
|
||||
gchar *ellipses;
|
||||
gchar *repeat;
|
||||
gchar *reshow;
|
||||
|
||||
progname = plug_in_proc_def_get_progname (proc_def);
|
||||
|
||||
path = dgettext (plug_ins_locale_domain (group->gimp,
|
||||
progname, NULL),
|
||||
proc_def->menu_path);
|
||||
|
||||
stripped = gimp_strip_uline (path);
|
||||
basename = g_path_get_basename (stripped);
|
||||
|
||||
g_free (stripped);
|
||||
|
||||
ellipses = strstr (basename, "...");
|
||||
|
||||
if (ellipses && ellipses == (basename + strlen (basename) - 3))
|
||||
*ellipses = '\0';
|
||||
|
||||
repeat = g_strdup_printf (_("Re_peat \"%s\""), basename);
|
||||
reshow = g_strdup_printf (_("R_e-show \"%s\""), basename);
|
||||
|
||||
g_free (basename);
|
||||
|
||||
gimp_action_group_set_action_label (group, "plug-in-repeat",
|
||||
repeat);
|
||||
gimp_action_group_set_action_label (group, "plug-in-reshow",
|
||||
reshow);
|
||||
|
||||
g_free (repeat);
|
||||
g_free (reshow);
|
||||
|
||||
gimp_action_group_set_action_sensitive (group, "plug-in-repeat",
|
||||
TRUE);
|
||||
gimp_action_group_set_action_sensitive (group, "plug-in-reshow",
|
||||
TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! group->gimp->last_plug_in)
|
||||
{
|
||||
gimp_action_group_set_action_label (group, "plug-in-repeat",
|
||||
_("Repeat Last"));
|
||||
gimp_action_group_set_action_label (group, "plug-in-reshow",
|
||||
_("Re-Show Last"));
|
||||
|
||||
gimp_action_group_set_action_sensitive (group, "plug-in-repeat", FALSE);
|
||||
gimp_action_group_set_action_sensitive (group, "plug-in-reshow", FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
plug_in_actions_add_proc (GimpActionGroup *group,
|
||||
PlugInProcDef *proc_def,
|
||||
const gchar *locale_domain,
|
||||
const gchar *help_domain)
|
||||
PlugInProcDef *proc_def)
|
||||
{
|
||||
GimpActionEntry entry;
|
||||
const gchar *progname;
|
||||
const gchar *locale_domain;
|
||||
const gchar *help_domain;
|
||||
gchar *label;
|
||||
gchar *help_id;
|
||||
|
||||
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
||||
g_return_if_fail (proc_def != NULL);
|
||||
|
||||
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);
|
||||
|
||||
help_id = plug_in_proc_def_get_help_id (proc_def, help_domain);
|
||||
|
||||
label = g_strdup (strrchr (proc_def->menu_path, '/') + 1);
|
||||
|
||||
entry.name = proc_def->db_info.name;
|
||||
entry.stock_id = NULL;
|
||||
entry.label = strrchr (proc_def->menu_path, '/') + 1;
|
||||
entry.label = label;
|
||||
entry.accelerator = proc_def->accelerator;
|
||||
entry.tooltip = NULL;
|
||||
entry.callback = G_CALLBACK (plug_in_run_cmd_callback);
|
||||
entry.help_id = help_id;
|
||||
|
||||
g_print ("adding plug-in action '%s' (%s)\n",
|
||||
entry.name, label);
|
||||
|
||||
g_object_set (group, "translation-domain", locale_domain, NULL);
|
||||
|
||||
gimp_action_group_add_actions (group, &entry, 1, &proc_def->db_info);
|
||||
|
||||
g_object_set (group, "translation-domain", NULL, NULL);
|
||||
|
||||
g_free (label);
|
||||
g_free (help_id);
|
||||
}
|
||||
|
||||
|
@ -213,21 +307,10 @@ plug_in_actions_remove_proc (GimpActionGroup *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;
|
||||
{
|
||||
g_print ("removing plug-in action '%s'\n",
|
||||
proc_def->db_info.name);
|
||||
|
||||
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,7 @@ 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);
|
||||
PlugInProcDef *proc_def);
|
||||
void plug_in_actions_remove_proc (GimpActionGroup *group,
|
||||
PlugInProcDef *proc_def);
|
||||
|
||||
|
|
|
@ -1074,15 +1074,13 @@ gimp_menus_init (Gimp *gimp,
|
|||
|
||||
void
|
||||
gimp_menus_create_entry (Gimp *gimp,
|
||||
PlugInProcDef *proc_def,
|
||||
const gchar *locale_domain,
|
||||
const gchar *help_domain)
|
||||
PlugInProcDef *proc_def)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (proc_def != NULL);
|
||||
|
||||
if (gimp->gui_menus_create_func)
|
||||
gimp->gui_menus_create_func (gimp, proc_def, locale_domain, help_domain);
|
||||
gimp->gui_menus_create_func (gimp, proc_def);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -36,9 +36,7 @@ typedef void (* GimpMenusInitFunc) (Gimp *gimp,
|
|||
GSList *plug_in_defs,
|
||||
const gchar *std_domain);
|
||||
typedef void (* GimpMenusCreateFunc) (Gimp *gimp,
|
||||
PlugInProcDef *proc_def,
|
||||
const gchar *locale_domain,
|
||||
const gchar *help_domain);
|
||||
PlugInProcDef *proc_def);
|
||||
typedef void (* GimpMenusDeleteFunc) (Gimp *gimp,
|
||||
PlugInProcDef *proc_def);
|
||||
typedef GimpProgress * (* GimpProgressStartFunc) (Gimp *gimp,
|
||||
|
@ -245,9 +243,7 @@ void gimp_menus_init (Gimp *gimp,
|
|||
GSList *plug_in_defs,
|
||||
const gchar *std_plugins_domain);
|
||||
void gimp_menus_create_entry (Gimp *gimp,
|
||||
PlugInProcDef *proc_def,
|
||||
const gchar *locale_domain,
|
||||
const gchar *help_domain);
|
||||
PlugInProcDef *proc_def);
|
||||
void gimp_menus_delete_entry (Gimp *gimp,
|
||||
PlugInProcDef *proc_def);
|
||||
GimpProgress *gimp_start_progress (Gimp *gimp,
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "plug-in/plug-ins.h"
|
||||
#include "plug-in/plug-in-proc.h"
|
||||
|
||||
#include "widgets/gimpactiongroup.h"
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimperrorconsole.h"
|
||||
#include "widgets/gimpitemfactory.h"
|
||||
|
@ -41,6 +45,8 @@
|
|||
#include "display/gimpdisplayshell.h"
|
||||
#include "display/gimpprogress.h"
|
||||
|
||||
#include "actions/plug-in-actions.h"
|
||||
|
||||
#include "brush-select.h"
|
||||
#include "dialogs.h"
|
||||
#include "font-select.h"
|
||||
|
@ -67,9 +73,7 @@ static void gui_menus_init (Gimp *gimp,
|
|||
GSList *plug_in_defs,
|
||||
const gchar *plugins_domain);
|
||||
static void gui_menus_create_entry (Gimp *gimp,
|
||||
PlugInProcDef *proc_def,
|
||||
const gchar *locale_domain,
|
||||
const gchar *help_domain);
|
||||
PlugInProcDef *proc_def);
|
||||
static void gui_menus_delete_entry (Gimp *gimp,
|
||||
PlugInProcDef *proc_def);
|
||||
static GimpProgress * gui_start_progress (Gimp *gimp,
|
||||
|
@ -218,10 +222,25 @@ gui_menus_init (Gimp *gimp,
|
|||
|
||||
static void
|
||||
gui_menus_create_entry (Gimp *gimp,
|
||||
PlugInProcDef *proc_def,
|
||||
const gchar *locale_domain,
|
||||
const gchar *help_domain)
|
||||
PlugInProcDef *proc_def)
|
||||
{
|
||||
const gchar *progname;
|
||||
const gchar *locale_domain;
|
||||
const gchar *help_domain;
|
||||
GList *list;
|
||||
|
||||
for (list = gimp_action_groups_from_name ("plug-in");
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
plug_in_actions_add_proc (list->data, proc_def);
|
||||
}
|
||||
|
||||
progname = plug_in_proc_def_get_progname (proc_def);
|
||||
|
||||
locale_domain = plug_ins_locale_domain (gimp, progname, NULL);
|
||||
help_domain = plug_ins_help_domain (gimp, progname, NULL);
|
||||
|
||||
plug_in_menus_create_entry (NULL, proc_def, locale_domain, help_domain);
|
||||
}
|
||||
|
||||
|
@ -229,7 +248,16 @@ static void
|
|||
gui_menus_delete_entry (Gimp *gimp,
|
||||
PlugInProcDef *proc_def)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
plug_in_menus_delete_entry (proc_def);
|
||||
|
||||
for (list = gimp_action_groups_from_name ("plug-in");
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
plug_in_actions_remove_proc (list->data, proc_def);
|
||||
}
|
||||
}
|
||||
|
||||
static GimpProgress *
|
||||
|
|
|
@ -590,19 +590,7 @@ plug_ins_temp_proc_def_add (Gimp *gimp,
|
|||
if (! gimp->no_interface)
|
||||
{
|
||||
if (proc_def->menu_path)
|
||||
{
|
||||
const gchar *progname;
|
||||
const gchar *locale_domain;
|
||||
const gchar *help_domain;
|
||||
|
||||
progname = plug_in_proc_def_get_progname (proc_def);
|
||||
|
||||
locale_domain = plug_ins_locale_domain (gimp, progname, NULL);
|
||||
help_domain = plug_ins_help_domain (gimp, progname, NULL);
|
||||
|
||||
gimp_menus_create_entry (gimp, proc_def,
|
||||
locale_domain, help_domain);
|
||||
}
|
||||
gimp_menus_create_entry (gimp, proc_def);
|
||||
}
|
||||
|
||||
/* Register the procedural database entry */
|
||||
|
|
|
@ -590,19 +590,7 @@ plug_ins_temp_proc_def_add (Gimp *gimp,
|
|||
if (! gimp->no_interface)
|
||||
{
|
||||
if (proc_def->menu_path)
|
||||
{
|
||||
const gchar *progname;
|
||||
const gchar *locale_domain;
|
||||
const gchar *help_domain;
|
||||
|
||||
progname = plug_in_proc_def_get_progname (proc_def);
|
||||
|
||||
locale_domain = plug_ins_locale_domain (gimp, progname, NULL);
|
||||
help_domain = plug_ins_help_domain (gimp, progname, NULL);
|
||||
|
||||
gimp_menus_create_entry (gimp, proc_def,
|
||||
locale_domain, help_domain);
|
||||
}
|
||||
gimp_menus_create_entry (gimp, proc_def);
|
||||
}
|
||||
|
||||
/* Register the procedural database entry */
|
||||
|
|
|
@ -46,18 +46,22 @@ enum
|
|||
};
|
||||
|
||||
|
||||
static void gimp_action_group_init (GimpActionGroup *group);
|
||||
static void gimp_action_group_class_init (GimpActionGroupClass *klass);
|
||||
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 GObject * gimp_action_group_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
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);
|
||||
|
||||
|
||||
static GtkActionGroupClass *parent_class = NULL;
|
||||
|
@ -98,6 +102,8 @@ gimp_action_group_class_init (GimpActionGroupClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->constructor = gimp_action_group_constructor;
|
||||
object_class->dispose = gimp_action_group_dispose;
|
||||
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;
|
||||
|
@ -115,6 +121,9 @@ gimp_action_group_class_init (GimpActionGroupClass *klass)
|
|||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
|
||||
klass->groups = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -123,6 +132,36 @@ gimp_action_group_init (GimpActionGroup *group)
|
|||
group->translation_domain = NULL;
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_action_group_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
const gchar *name;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_group_finalize (GObject *object)
|
||||
{
|
||||
|
@ -137,6 +176,37 @@ gimp_action_group_finalize (GObject *object)
|
|||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_group_dispose (GObject *object)
|
||||
{
|
||||
const gchar *name;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_group_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
|
@ -213,6 +283,23 @@ gimp_action_group_new (Gimp *gimp,
|
|||
return group;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_action_group_update (GimpActionGroup *group,
|
||||
gpointer update_data)
|
||||
|
@ -688,7 +775,7 @@ gimp_action_group_set_action_important (GimpActionGroup *group,
|
|||
|
||||
if (! action)
|
||||
{
|
||||
g_warning ("%s: Unable to set \"is_important\" of action "
|
||||
g_warning ("%s: Unable to set \"is-important\" of action "
|
||||
"which doesn't exist: %s",
|
||||
G_STRLOC, action_name);
|
||||
return;
|
||||
|
|
|
@ -48,6 +48,8 @@ struct _GimpActionGroup
|
|||
struct _GimpActionGroupClass
|
||||
{
|
||||
GtkActionGroupClass parent_class;
|
||||
|
||||
GHashTable *groups;
|
||||
};
|
||||
|
||||
struct _GimpActionEntry
|
||||
|
@ -115,7 +117,9 @@ struct _GimpStringActionEntry
|
|||
GType gimp_action_group_get_type (void);
|
||||
GimpActionGroup *gimp_action_group_new (Gimp *gimp,
|
||||
const gchar *name,
|
||||
GimpActionGroupUpdateFunc );
|
||||
GimpActionGroupUpdateFunc update_func);
|
||||
|
||||
GList *gimp_action_groups_from_name (const gchar *name);
|
||||
|
||||
void gimp_action_group_update (GimpActionGroup *group,
|
||||
gpointer update_data);
|
||||
|
|
Loading…
Reference in New Issue