Commit 1437f52d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

make sure that all actions, even if they have no menu proxy, can be

2004-08-12  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpmenufactory.c (gimp_menu_factory_manager_new):
	make sure that all actions, even if they have no menu proxy, can
	be invoked by their accelerators. Fixes bug #149938.

	* app/widgets/gimpimagedock.c (gimp_image_dock_constructor):
	removed the same code here.

	* app/widgets/gimpactionview.[ch] (gimp_action_view_dispose): new
	function which disconnects from "accel_changed" of the accel_group
	before upchaining (== before emitting "destroy").

	The above changes make this one redundant, but since the crash in
	bug #149938 was triggered by "accel_changed" emitted in the middle
	of g_object_unref(tree_model), it feels better to be paranoic here
	(fiddling with objects in destruction is no fun).

	(gimp_action_view_accel_edited): don't warn if assigning the same
	accel to the same action again.

	(gimp_action_view_new): don't leak all accel_closures.
parent 6b4d16e0
2004-08-12 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpmenufactory.c (gimp_menu_factory_manager_new):
make sure that all actions, even if they have no menu proxy, can
be invoked by their accelerators. Fixes bug #149938.
* app/widgets/gimpimagedock.c (gimp_image_dock_constructor):
removed the same code here.
* app/widgets/gimpactionview.[ch] (gimp_action_view_dispose): new
function which disconnects from "accel_changed" of the accel_group
before upchaining (== before emitting "destroy").
The above changes make this one redundant, but since the crash in
bug #149938 was triggered by "accel_changed" emitted in the middle
of g_object_unref(tree_model), it feels better to be paranoic here
(fiddling with objects in destruction is no fun).
(gimp_action_view_accel_edited): don't warn if assigning the same
accel to the same action again.
(gimp_action_view_new): don't leak all accel_closures.
2004-08-12 DindinX <david@dindinx.org>
* plug-ins/common/edge.c: added a preview.
......
......@@ -58,6 +58,8 @@ enum
static void gimp_action_view_class_init (GimpActionViewClass *klass);
static void gimp_action_view_init (GimpActionView *view);
static void gimp_action_view_dispose (GObject *object);
static gboolean gimp_action_view_accel_find_func (GtkAccelKey *key,
GClosure *closure,
gpointer data);
......@@ -74,6 +76,8 @@ static void gimp_action_view_accel_edited (GimpCellRendererAccel *accel,
GimpActionView *view);
static GtkTreeViewClass *parent_class = NULL;
GType
gimp_action_view_get_type (void)
......@@ -106,6 +110,11 @@ gimp_action_view_get_type (void)
static void
gimp_action_view_class_init (GimpActionViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->dispose = gimp_action_view_dispose;
}
static void
......@@ -113,6 +122,31 @@ gimp_action_view_init (GimpActionView *view)
{
}
static void
gimp_action_view_dispose (GObject *object)
{
GimpActionView *view = GIMP_ACTION_VIEW (object);
if (view->manager)
{
if (view->show_shortcuts)
{
GtkAccelGroup *group;
group = gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (view->manager));
g_signal_handlers_disconnect_by_func (group,
gimp_action_view_accel_changed,
view);
}
g_object_unref (view->manager);
view->manager = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
GtkWidget *
gimp_action_view_new (GimpUIManager *manager,
gboolean show_shortcuts)
......@@ -182,8 +216,6 @@ gimp_action_view_new (GimpUIManager *manager,
if (show_shortcuts)
{
gtk_action_set_accel_group (action, accel_group);
menu_item = gtk_action_create_menu_item (action);
if (GTK_IS_MENU_ITEM (menu_item) &&
......@@ -211,6 +243,8 @@ gimp_action_view_new (GimpUIManager *manager,
accel_key = key->accel_key;
accel_mask = key->accel_mods;
}
g_closure_unref (accel_closure);
}
g_object_ref (menu_item);
......@@ -254,6 +288,9 @@ gimp_action_view_new (GimpUIManager *manager,
g_object_unref (store);
GIMP_ACTION_VIEW (view)->manager = g_object_ref (manager);
GIMP_ACTION_VIEW (view)->show_shortcuts = show_shortcuts;
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("Action"));
......@@ -273,9 +310,9 @@ gimp_action_view_new (GimpUIManager *manager,
if (show_shortcuts)
{
g_signal_connect_object (accel_group, "accel-changed",
G_CALLBACK (gimp_action_view_accel_changed),
view, 0);
g_signal_connect (accel_group, "accel-changed",
G_CALLBACK (gimp_action_view_accel_changed),
view);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("Shortcut"));
......@@ -529,7 +566,7 @@ gimp_action_view_accel_edited (GimpCellRendererAccel *accel,
break;
}
if (conflict_action)
if (conflict_action && conflict_action != action)
{
GimpActionGroup *conflict_group;
gchar *label;
......@@ -595,7 +632,7 @@ gimp_action_view_accel_edited (GimpCellRendererAccel *accel,
gtk_widget_show (query_box);
}
else
else if (conflict_action != action)
{
g_message (_("Changing shortcut failed."));
}
......
......@@ -38,7 +38,10 @@ typedef struct _GimpActionViewClass GimpActionViewClass;
struct _GimpActionView
{
GtkTreeView parent_instance;
GtkTreeView parent_instance;
GimpUIManager *manager;
gboolean show_shortcuts;
};
struct _GimpActionViewClass
......
......@@ -226,7 +226,6 @@ gimp_image_dock_constructor (GType type,
GimpMenuFactory *menu_factory;
GtkUIManager *ui_manager;
GtkAccelGroup *accel_group;
GList *groups;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
......@@ -241,26 +240,6 @@ gimp_image_dock_constructor (GType type,
accel_group = gtk_ui_manager_get_accel_group (ui_manager);
for (groups = gtk_ui_manager_get_action_groups (ui_manager);
groups;
groups = g_list_next (groups))
{
GList *actions;
GList *list;
actions = gtk_action_group_list_actions (groups->data);
for (list = actions; list; list = g_list_next (list))
{
GtkAction *action = list->data;
gtk_action_set_accel_group (action, accel_group);
gtk_action_connect_accelerator (action);
}
g_list_free (actions);
}
gtk_window_add_accel_group (GTK_WINDOW (object), accel_group);
return object;
......
......@@ -226,7 +226,6 @@ gimp_image_dock_constructor (GType type,
GimpMenuFactory *menu_factory;
GtkUIManager *ui_manager;
GtkAccelGroup *accel_group;
GList *groups;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
......@@ -241,26 +240,6 @@ gimp_image_dock_constructor (GType type,
accel_group = gtk_ui_manager_get_accel_group (ui_manager);
for (groups = gtk_ui_manager_get_action_groups (ui_manager);
groups;
groups = g_list_next (groups))
{
GList *actions;
GList *list;
actions = gtk_action_group_list_actions (groups->data);
for (list = actions; list; list = g_list_next (list))
{
GtkAction *action = list->data;
gtk_action_set_accel_group (action, accel_group);
gtk_action_connect_accelerator (action);
}
g_list_free (actions);
}
gtk_window_add_accel_group (GTK_WINDOW (object), accel_group);
return object;
......
......@@ -221,22 +221,41 @@ gimp_menu_factory_manager_new (GimpMenuFactory *factory,
if (! strcmp (entry->identifier, identifier))
{
GimpUIManager *manager;
GtkAccelGroup *accel_group;
GList *list;
manager = gimp_ui_manager_new (factory->gimp, entry->identifier);
gtk_ui_manager_set_add_tearoffs (GTK_UI_MANAGER (manager),
create_tearoff);
accel_group = gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (manager));
for (list = entry->action_groups; list; list = g_list_next (list))
{
GimpActionGroup *group;
GList *actions;
GList *list2;
group = gimp_action_factory_group_new (factory->action_factory,
(const gchar *) list->data,
callback_data);
actions = gtk_action_group_list_actions (GTK_ACTION_GROUP (group));
for (list2 = actions; list2; list2 = g_list_next (list2))
{
GtkAction *action = list2->data;
gtk_action_set_accel_group (action, accel_group);
gtk_action_connect_accelerator (action);
}
g_list_free (actions);
gtk_ui_manager_insert_action_group (GTK_UI_MANAGER (manager),
GTK_ACTION_GROUP (group),
-1);
g_object_unref (group);
}
......
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