[gimp] app: Add GimpContext property to GimpDockWindow
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] app: Add GimpContext property to GimpDockWindow
- Date: Thu, 10 Sep 2009 20:01:33 +0000 (UTC)
commit 81d961423a27e2ce1ffb1a7919cca30dbe80374e
Author: Martin Nordholts <martinn src gnome org>
Date: Thu Sep 10 21:34:49 2009 +0200
app: Add GimpContext property to GimpDockWindow
The GimpDockWindow will need to have a GimpContext so add such a
property but call it "gimp-context" for now to avoid clashing with
"context" of GimpDock.
app/widgets/gimpdockwindow.c | 88 +++++++++++++++++++++++++++++++++++++++++-
app/widgets/gimpmenudock.c | 1 +
app/widgets/gimptoolbox.c | 1 +
3 files changed, 89 insertions(+), 1 deletions(-)
---
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index e173d30..29145be 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -27,17 +27,36 @@
#include "widgets-types.h"
+#include "core/gimpcontext.h"
+
#include "gimpdockwindow.h"
#include "gimpwindow.h"
#include "gimp-intl.h"
+enum
+{
+ PROP_0,
+ PROP_CONTEXT,
+};
+
+
struct _GimpDockWindowPrivate
{
- gint dummy;
+ GimpContext *context;
};
+static void gimp_dock_window_dispose (GObject *object);
+static void gimp_dock_window_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_dock_window_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
G_DEFINE_TYPE (GimpDockWindow, gimp_dock_window, GIMP_TYPE_WINDOW)
@@ -46,6 +65,18 @@ G_DEFINE_TYPE (GimpDockWindow, gimp_dock_window, GIMP_TYPE_WINDOW)
static void
gimp_dock_window_class_init (GimpDockWindowClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = gimp_dock_window_dispose;
+ object_class->set_property = gimp_dock_window_set_property;
+ object_class->get_property = gimp_dock_window_get_property;
+
+ g_object_class_install_property (object_class, PROP_CONTEXT,
+ g_param_spec_object ("gimp-context", NULL, NULL,
+ GIMP_TYPE_CONTEXT,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
g_type_class_add_private (klass, sizeof (GimpDockWindowPrivate));
}
@@ -55,4 +86,59 @@ gimp_dock_window_init (GimpDockWindow *dock_window)
dock_window->p = G_TYPE_INSTANCE_GET_PRIVATE (dock_window,
GIMP_TYPE_DOCK_WINDOW,
GimpDockWindowPrivate);
+ dock_window->p->context = NULL;
+}
+
+static void
+gimp_dock_window_dispose (GObject *object)
+{
+ GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (object);
+
+ if (dock_window->p->context)
+ {
+ g_object_unref (dock_window->p->context);
+ dock_window->p->context = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+gimp_dock_window_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (object);
+
+ switch (property_id)
+ {
+ case PROP_CONTEXT:
+ dock_window->p->context = g_value_dup_object (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_dock_window_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (object);
+
+ switch (property_id)
+ {
+ case PROP_CONTEXT:
+ g_value_set_object (value, dock_window->p->context);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
diff --git a/app/widgets/gimpmenudock.c b/app/widgets/gimpmenudock.c
index 0893243..650b015 100644
--- a/app/widgets/gimpmenudock.c
+++ b/app/widgets/gimpmenudock.c
@@ -385,6 +385,7 @@ gimp_menu_dock_new (GimpDialogFactory *dialog_factory,
"Dock Context", NULL);
menu_dock = g_object_new (GIMP_TYPE_MENU_DOCK,
+ "gimp-context", context,
"context", context,
"dialog-factory", dialog_factory,
NULL);
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index 422294f..7fa4173 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -625,6 +625,7 @@ gimp_toolbox_new (GimpDialogFactory *dialog_factory,
toolbox = g_object_new (GIMP_TYPE_TOOLBOX,
"title", _("Toolbox"),
+ "gimp-context", context,
"context", context,
"dialog-factory", dialog_factory,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]