Commit 9377b26e authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added help IDs to all actions representing the toplevel popups and menus

2004-05-02  Michael Natterer  <mitch@gimp.org>

	* app/actions/*-actions.c: added help IDs to all actions
	representing the toplevel popups and menus (as fallbacks for the
	still-to-be-written help system intrgration of GimpUIManager).

	* app/display/gimpdisplayshell.c (gimp_display_shell_new): removed
	call to gtk_ui_manager_ensure_update() because that's done by
	gimp_ui_manager_ui_get() now.

	* app/widgets/gimpmenufactory.[ch]: removed API to register and
	create item factories.

	* app/gui/menus.c: changed accordingly.

	* app/gui/dialogs.c
	* app/actions/plug-in-commands.c
	* app/gui/file-dialog-utils.c
	* app/gui/file-save-dialog.c
	* app/widgets/gimpdataeditor.c
	* app/widgets/gimpdockable.c
	* app/widgets/gimpdockbook.[ch]
	* app/widgets/gimpimagedock.c
	* app/widgets/gimpitemtreeview.c: removed leftover item factory
	cruft.

	* app/widgets/widgets-types.h: removed item factory typedefs...

	* app/widgets/gimpitemfactory.h: ...and added them here.

	* app/widgets/gimpactiongroup.[ch]: added new function
	gimp_action_group_add_plug_in_actions().

	* app/actions/plug-in-actions.c: use it here instead of adding
	the actions manually.

	* app/widgets/gimptoolbox.c: ported the code which dynamically
	updates the tool button tooltips on accelerator changes to
	GtkAction. Disabled the whole stuff because GTK+ lacks
	gtk_action_get_accel_closure().
parent 41a9add7
......@@ -35,7 +35,6 @@
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimpdocked.h"
#include "gimpitemfactory.h"
#include "gimpuimanager.h"
#include "gimpwidgets-utils.h"
......
......@@ -37,7 +37,6 @@
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimphelp-ids.h"
#include "gimpitemfactory.h"
#include "gimpmenufactory.h"
#include "gimppreview.h"
......@@ -199,9 +198,8 @@ gimp_dockbook_class_init (GimpDockbookClass *klass)
static void
gimp_dockbook_init (GimpDockbook *dockbook)
{
dockbook->dock = NULL;
dockbook->item_factory = NULL;
dockbook->ui_manager = NULL;
dockbook->dock = NULL;
dockbook->ui_manager = NULL;
gtk_notebook_popup_enable (GTK_NOTEBOOK (dockbook));
gtk_notebook_set_scrollable (GTK_NOTEBOOK (dockbook), TRUE);
......@@ -217,12 +215,6 @@ gimp_dockbook_finalize (GObject *object)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (object);
if (dockbook->item_factory)
{
g_object_unref (dockbook->item_factory);
dockbook->item_factory = NULL;
}
if (dockbook->ui_manager)
{
g_object_unref (dockbook->ui_manager);
......@@ -322,12 +314,6 @@ gimp_dockbook_new (GimpMenuFactory *menu_factory)
dockbook = g_object_new (GIMP_TYPE_DOCKBOOK, NULL);
dockbook->item_factory = gimp_menu_factory_menu_new (menu_factory,
"<Dialogs>",
GTK_TYPE_MENU,
dockbook,
FALSE);
dockbook->ui_manager = gimp_menu_factory_manager_new (menu_factory,
"<Dialogs>",
dockbook,
......
......@@ -38,11 +38,10 @@ typedef struct _GimpDockbookClass GimpDockbookClass;
struct _GimpDockbook
{
GtkNotebook parent_instance;
GtkNotebook parent_instance;
GimpDock *dock;
GimpItemFactory *item_factory;
GimpUIManager *ui_manager;
GimpDock *dock;
GimpUIManager *ui_manager;
};
struct _GimpDockbookClass
......
......@@ -42,7 +42,6 @@
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimphelp-ids.h"
#include "gimpitemfactory.h"
#include "gimpmenufactory.h"
#include "gimpsessioninfo.h"
......
......@@ -22,6 +22,17 @@
G_BEGIN_DECLS
typedef struct _GimpItemFactory GimpItemFactory;
typedef void (* GimpItemFactorySetupFunc) (GimpItemFactory *factory,
gpointer callback_data);
typedef void (* GimpItemFactoryUpdateFunc) (GtkItemFactory *factory,
gpointer update_data);
typedef struct _GimpItemFactoryEntry GimpItemFactoryEntry;
struct _GimpItemFactoryEntry
{
GtkItemFactoryEntry entry;
......@@ -41,7 +52,7 @@ struct _GimpItemFactoryEntry
#define GIMP_ITEM_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ITEM_FACTORY, GimpItemFactoryClass))
typedef struct _GimpItemFactoryClass GimpItemFactoryClass;
typedef struct _GimpItemFactoryClass GimpItemFactoryClass;
struct _GimpItemFactory
{
......
......@@ -45,8 +45,6 @@
#include "gimpcellrenderertoggle.h"
#include "gimpdnd.h"
#include "gimpdocked.h"
#include "gimpitemtreeview.h"
#include "gimpitemfactory.h"
#include "gimplayertreeview.h"
#include "gimpmenufactory.h"
#include "gimppreviewrenderer.h"
......
......@@ -42,7 +42,6 @@
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimphelp-ids.h"
#include "gimpitemfactory.h"
#include "gimpmenufactory.h"
#include "gimpsessioninfo.h"
......
......@@ -33,7 +33,6 @@
#include "gimpactionfactory.h"
#include "gimpmenufactory.h"
#include "gimpitemfactory.h"
#include "gimpuimanager.h"
......@@ -103,8 +102,6 @@ gimp_menu_factory_finalize (GObject *object)
GList *uis;
g_free (entry->identifier);
g_free (entry->title);
g_free (entry->help_id);
g_list_foreach (entry->action_groups, (GFunc) g_free, NULL);
g_list_free (entry->action_groups);
......@@ -147,154 +144,63 @@ gimp_menu_factory_new (Gimp *gimp,
}
void
gimp_menu_factory_menu_register (GimpMenuFactory *factory,
const gchar *identifier,
const gchar *title,
const gchar *help_id,
GimpItemFactorySetupFunc setup_func,
GimpItemFactoryUpdateFunc update_func,
gboolean update_on_popup,
guint n_entries,
GimpItemFactoryEntry *entries)
gimp_menu_factory_manager_register (GimpMenuFactory *factory,
const gchar *identifier,
const gchar *first_group,
...)
{
GimpMenuFactoryEntry *entry;
const gchar *group;
const gchar *ui_path;
va_list args;
g_return_if_fail (GIMP_IS_MENU_FACTORY (factory));
g_return_if_fail (identifier != NULL);
g_return_if_fail (title != NULL);
g_return_if_fail (help_id != NULL);
g_return_if_fail (entries == NULL || n_entries > 0);
g_return_if_fail (first_group != NULL);
entry = g_new0 (GimpMenuFactoryEntry, 1);
entry->identifier = g_strdup (identifier);
entry->title = g_strdup (title);
entry->help_id = g_strdup (help_id);
entry->setup_func = setup_func;
entry->update_func = update_func;
entry->update_on_popup = update_on_popup ? TRUE : FALSE;
entry->n_entries = n_entries;
entry->entries = entries;
entry->identifier = g_strdup (identifier);
factory->registered_menus = g_list_prepend (factory->registered_menus, entry);
}
GimpItemFactory *
gimp_menu_factory_menu_new (GimpMenuFactory *factory,
const gchar *identifier,
GType container_type,
gpointer callback_data,
gboolean create_tearoff)
{
GList *list;
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (factory), NULL);
g_return_val_if_fail (identifier != NULL, NULL);
va_start (args, first_group);
for (list = factory->registered_menus; list; list = g_list_next (list))
for (group = first_group;
group;
group = va_arg (args, const gchar *))
{
GimpMenuFactoryEntry *entry = list->data;
if (! strcmp (entry->identifier, identifier))
{
GimpItemFactory *item_factory;
item_factory = gimp_item_factory_new (factory->gimp,
container_type,
entry->identifier,
entry->title,
entry->help_id,
entry->update_func,
entry->update_on_popup,
entry->n_entries,
entry->entries,
callback_data,
create_tearoff);
if (entry->setup_func)
entry->setup_func (item_factory, callback_data);
return item_factory;
}
entry->action_groups = g_list_prepend (entry->action_groups,
g_strdup (group));
}
g_warning ("%s: no entry registered for \"%s\"",
G_STRFUNC, identifier);
entry->action_groups = g_list_reverse (entry->action_groups);
return NULL;
}
ui_path = va_arg (args, const gchar *);
void
gimp_menu_factory_manager_register (GimpMenuFactory *factory,
const gchar *identifier,
const gchar *first_group,
...)
{
GList *list;
g_return_if_fail (GIMP_IS_MENU_FACTORY (factory));
g_return_if_fail (identifier != NULL);
g_return_if_fail (first_group != NULL);
for (list = factory->registered_menus; list; list = g_list_next (list))
while (ui_path)
{
GimpMenuFactoryEntry *entry = list->data;
const gchar *ui_basename;
GimpUIManagerSetupFunc setup_func;
GimpUIManagerUIEntry *ui_entry;
if (! strcmp (entry->identifier, identifier))
{
const gchar *group;
const gchar *ui_path;
const gchar *ui_basename;
GimpUIManagerSetupFunc setup_func;
va_list args;
ui_basename = va_arg (args, const gchar *);
setup_func = va_arg (args, GimpUIManagerSetupFunc);
g_return_if_fail (entry->action_groups == NULL);
ui_entry = g_new0 (GimpUIManagerUIEntry, 1);
va_start (args, first_group);
ui_entry->ui_path = g_strdup (ui_path);
ui_entry->basename = g_strdup (ui_basename);
ui_entry->setup_func = setup_func;
for (group = first_group;
group;
group = va_arg (args, const gchar *))
{
entry->action_groups = g_list_prepend (entry->action_groups,
g_strdup (group));
}
entry->managed_uis = g_list_prepend (entry->managed_uis, ui_entry);
entry->action_groups = g_list_reverse (entry->action_groups);
ui_path = va_arg (args, const gchar *);
while (ui_path)
{
GimpUIManagerUIEntry *ui_entry;
ui_basename = va_arg (args, const gchar *);
setup_func = va_arg (args, GimpUIManagerSetupFunc);
ui_entry = g_new0 (GimpUIManagerUIEntry, 1);
ui_entry->ui_path = g_strdup (ui_path);
ui_entry->basename = g_strdup (ui_basename);
ui_entry->setup_func = setup_func;
ui_entry->merge_id = 0;
ui_entry->widget = NULL;
entry->managed_uis = g_list_prepend (entry->managed_uis,
ui_entry);
ui_path = va_arg (args, const gchar *);
}
entry->managed_uis = g_list_reverse (entry->managed_uis);
va_end (args);
return;
}
ui_path = va_arg (args, const gchar *);
}
g_warning ("%s: no entry registered for \"%s\"",
G_STRFUNC, identifier);
entry->managed_uis = g_list_reverse (entry->managed_uis);
va_end (args);
}
GimpUIManager *
......
......@@ -30,17 +30,9 @@ typedef struct _GimpMenuFactoryEntry GimpMenuFactoryEntry;
struct _GimpMenuFactoryEntry
{
gchar *identifier;
gchar *title;
gchar *help_id;
GimpItemFactorySetupFunc setup_func;
GimpItemFactoryUpdateFunc update_func;
gboolean update_on_popup;
guint n_entries;
GimpItemFactoryEntry *entries;
GList *action_groups;
GList *managed_uis;
gchar *identifier;
GList *action_groups;
GList *managed_uis;
};
......@@ -74,23 +66,6 @@ GType gimp_menu_factory_get_type (void) G_GNUC_CONST;
GimpMenuFactory * gimp_menu_factory_new (Gimp *gimp,
GimpActionFactory *action_factory);
void gimp_menu_factory_menu_register (GimpMenuFactory *factory,
const gchar *identifier,
const gchar *title,
const gchar *help_id,
GimpItemFactorySetupFunc setup_func,
GimpItemFactoryUpdateFunc update_func,
gboolean update_on_popup,
guint n_entries,
GimpItemFactoryEntry *entries);
GimpItemFactory * gimp_menu_factory_menu_new (GimpMenuFactory *factory,
const gchar *identifier,
GType container_type,
gpointer callback_data,
gboolean create_tearoff);
void gimp_menu_factory_manager_register (GimpMenuFactory *factory,
const gchar *identifier,
const gchar *first_group,
......
......@@ -607,17 +607,13 @@ static void
toolbox_create_tools (GimpToolbox *toolbox,
GimpContext *context)
{
#if 0
FIXME
GimpItemFactory *item_factory;
#endif
GimpToolInfo *active_tool;
GList *list;
GSList *group = NULL;
GimpUIManager *ui_manager;
GimpToolInfo *active_tool;
GList *list;
GSList *group = NULL;
#if 0
item_factory = gimp_item_factory_from_path ("<Image>");
#endif
ui_manager = gimp_ui_managers_from_name ("<Image>")->data;
gimp_ui_manager_ui_get (ui_manager, "/image-popup");
active_tool = gimp_context_get_tool (context);
......@@ -667,54 +663,47 @@ toolbox_create_tools (GimpToolbox *toolbox,
toolbox);
#if 0
if (item_factory)
if (ui_manager)
{
GtkWidget *menu_item;
gchar *menu_path;
menu_path = gimp_strip_uline (tool_info->menu_path);
menu_item =
gtk_item_factory_get_widget (GTK_ITEM_FACTORY (item_factory),
menu_path);
GimpActionGroup *group;
GtkAction *action;
const gchar *identifier;
gchar *tmp;
gchar *name;
GClosure *accel_closure;
GtkAccelGroup *accel_group;
g_free (menu_path);
identifier = gimp_object_get_name (GIMP_OBJECT (tool_info));
if (menu_item)
{
GList *accel_closures;
tmp = g_strndup (identifier + strlen ("gimp-"),
strlen (identifier) - strlen ("gimp--tool"));
name = g_strdup_printf ("tools-%s", tmp);
g_free (tmp);
accel_closures = gtk_widget_list_accel_closures (menu_item);
group = gimp_ui_manager_get_action_group (ui_manager, "tools");
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name);
if (g_list_length (accel_closures) != 1)
{
g_warning (G_STRLOC ": FIXME: g_list_length (accel_closures) != 1");
}
else
{
GClosure *accel_closure;
GtkAccelGroup *accel_group;
g_free (name);
accel_closure = (GClosure *) accel_closures->data;
accel_closure = gtk_action_get_accel_closure (action);
g_object_set_data (G_OBJECT (button), "toolbox-accel-closure",
accel_closure);
g_object_set_data (G_OBJECT (button), "toolbox-accel-closure",
accel_closure);
accel_group = gtk_accel_group_from_accel_closure (accel_closure);
accel_group =
gtk_accel_group_from_accel_closure (accel_closure);
g_signal_connect (accel_group, "accel_changed",
G_CALLBACK (gimp_toolbox_button_accel_changed),
button);
g_signal_connect (accel_group, "accel_changed",
G_CALLBACK (gimp_toolbox_button_accel_changed),
button);
gimp_toolbox_button_accel_changed (accel_group,
0, 0,
accel_closure,
button);
}
g_list_free (accel_closures);
}
gimp_toolbox_button_accel_changed (accel_group,
0, 0,
accel_closure,
button);
}
#else
gimp_help_set_help_data (button, tool_info->help, tool_info->help_id);
#endif
}
}
......
......@@ -137,6 +137,7 @@ typedef struct _GimpToggleActionEntry GimpToggleActionEntry;
typedef struct _GimpRadioActionEntry GimpRadioActionEntry;
typedef struct _GimpEnumActionEntry GimpEnumActionEntry;
typedef struct _GimpStringActionEntry GimpStringActionEntry;
typedef struct _GimpPlugInActionEntry GimpPlugInActionEntry;
typedef struct _GimpDialogFactoryEntry GimpDialogFactoryEntry;
typedef struct _GimpSessionInfo GimpSessionInfo;
typedef struct _GimpSessionInfoBook GimpSessionInfoBook;
......@@ -164,15 +165,4 @@ typedef void (* GimpSelectionToVectorsFunc) (GimpImage *gimage,
gboolean advanced);
/* deprecated stuff, to be removed */
typedef struct _GimpItemFactory GimpItemFactory;
typedef struct _GimpItemFactoryEntry GimpItemFactoryEntry;
typedef void (* GimpItemFactorySetupFunc) (GimpItemFactory *factory,
gpointer callback_data);
typedef void (* GimpItemFactoryUpdateFunc) (GtkItemFactory *factory,
gpointer update_data);
#endif /* __WIDGETS_TYPES_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment