added a context property and use it when creating GimpViews.

2006-09-01  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpaction.[ch]: added a context property and use
	it when creating GimpViews.

	* app/actions/file-actions.c: set the context on the "Open Recent"
	actions.
This commit is contained in:
Michael Natterer 2006-09-01 17:12:29 +00:00 committed by Michael Natterer
parent cc8553fd1e
commit 7e7e7480a6
4 changed files with 42 additions and 4 deletions

View file

@ -1,3 +1,11 @@
2006-09-01 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpaction.[ch]: added a context property and use
it when creating GimpViews.
* app/actions/file-actions.c: set the context on the "Open Recent"
actions.
2006-09-01 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcontainercombobox.c: implement set_context() and

View file

@ -170,10 +170,17 @@ file_actions_setup (GimpActionGroup *group)
for (i = 0; i < n_entries; i++)
{
GtkAction *action;
gimp_action_group_set_action_visible (group, entries[i].name, FALSE);
g_free ((gchar *) entries[i].name);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
entries[i].name);
g_object_set (action,
"context", gimp_get_user_context (group->gimp),
NULL);
g_free ((gchar *) entries[i].name);
if (i < 9)
g_free ((gchar *) entries[i].accelerator);
}

View file

@ -31,6 +31,7 @@
#include "widgets-types.h"
#include "core/gimpcontext.h"
#include "core/gimpmarshal.h"
#include "core/gimpimagefile.h" /* eek */
#include "core/gimpviewable.h"
@ -43,6 +44,7 @@
enum
{
PROP_0,
PROP_CONTEXT,
PROP_COLOR,
PROP_VIEWABLE
};
@ -83,6 +85,12 @@ gimp_action_class_init (GimpActionClass *klass)
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
g_object_class_install_property (object_class, PROP_CONTEXT,
g_param_spec_object ("context",
NULL, NULL,
GIMP_TYPE_CONTEXT,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_COLOR,
gimp_param_spec_rgb ("color",
NULL, NULL,
@ -108,6 +116,12 @@ gimp_action_finalize (GObject *object)
{
GimpAction *action = GIMP_ACTION (object);
if (action->context)
{
g_object_unref (action->context);
action->context = NULL;
}
if (action->color)
{
g_free (action->color);
@ -133,6 +147,9 @@ gimp_action_get_property (GObject *object,
switch (prop_id)
{
case PROP_CONTEXT:
g_value_set_object (value, action->context);
break;
case PROP_COLOR:
g_value_set_boxed (value, action->color);
break;
@ -156,6 +173,11 @@ gimp_action_set_property (GObject *object,
switch (prop_id)
{
case PROP_CONTEXT:
if (action->context)
g_object_unref (action->context);
action->context = GIMP_CONTEXT (g_value_dup_object (value));
break;
case PROP_COLOR:
if (action->color)
g_free (action->color);
@ -165,7 +187,7 @@ gimp_action_set_property (GObject *object,
case PROP_VIEWABLE:
if (action->viewable)
g_object_unref (action->viewable);
action->viewable = (GimpViewable *) g_value_dup_object (value);
action->viewable = GIMP_VIEWABLE (g_value_dup_object (value));
set_proxy = TRUE;
break;
default:
@ -327,8 +349,7 @@ gimp_action_set_proxy (GimpAction *action,
gtk_icon_size_lookup_for_settings (settings, size, &width, &height);
view = gimp_view_new_full (NULL /* FIXME */,
action->viewable,
view = gimp_view_new_full (action->context, action->viewable,
width, height, border_width,
FALSE, FALSE, FALSE);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), view);

View file

@ -40,6 +40,8 @@ struct _GimpAction
{
GtkAction parent_instance;
GimpContext *context;
GimpRGB *color;
GimpViewable *viewable;
};