[gimp] Add menubar_manager member and "menu-factory" construct-only property
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Add menubar_manager member and "menu-factory" construct-only property
- Date: Tue, 29 Sep 2009 18:35:38 +0000 (UTC)
commit dc436b6f86a18a1df80e24e925d4b622464b80ac
Author: Michael Natterer <mitch gimp org>
Date: Wed Sep 23 12:47:25 2009 +0200
Add menubar_manager member and "menu-factory" construct-only property
Create the menubar_manager when the construct property is set, assert
for its presence in constructor(). Pass the newly required construct
property to g_object_new() in gimp_display_shell_new().
app/display/gimpdisplayshell.c | 1 +
app/display/gimpimagewindow.c | 75 ++++++++++++++++++++++++++++++++++-----
app/display/gimpimagewindow.h | 2 +
3 files changed, 68 insertions(+), 10 deletions(-)
---
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index c96ac66..aacc944 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -902,6 +902,7 @@ gimp_display_shell_new (GimpDisplay *display,
/* the toplevel shell */
shell = g_object_new (GIMP_TYPE_DISPLAY_SHELL,
+ "menu-factory", menu_factory,
"unit", unit,
/* The window position will be overridden by the
* dialog factory, it is only really used on first
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 05173d5..33a8b70 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -24,24 +24,37 @@
#include "display-types.h"
+#include "widgets/gimpmenufactory.h"
+#include "widgets/gimpuimanager.h"
+
#include "gimpimagewindow.h"
#include "gimp-intl.h"
+enum
+{
+ PROP_0,
+ PROP_MENU_FACTORY
+};
+
+
/* local function prototypes */
-static void gimp_image_window_finalize (GObject *object);
-static void gimp_image_window_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_image_window_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
+static GObject * gimp_image_window_constructor (GType type,
+ guint n_params,
+ GObjectConstructParam *params);
+static void gimp_image_window_finalize (GObject *object);
+static void gimp_image_window_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_image_window_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
-static void gimp_image_window_destroy (GtkObject *object);
+static void gimp_image_window_destroy (GtkObject *object);
G_DEFINE_TYPE (GimpImageWindow, gimp_image_window, GIMP_TYPE_WINDOW)
@@ -55,11 +68,19 @@ gimp_image_window_class_init (GimpImageWindowClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
+ object_class->constructor = gimp_image_window_constructor;
object_class->finalize = gimp_image_window_finalize;
object_class->set_property = gimp_image_window_set_property;
object_class->get_property = gimp_image_window_get_property;
gtk_object_class->destroy = gimp_image_window_destroy;
+
+ g_object_class_install_property (object_class, PROP_MENU_FACTORY,
+ g_param_spec_object ("menu-factory",
+ NULL, NULL,
+ GIMP_TYPE_MENU_FACTORY,
+ GIMP_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
}
static void
@@ -67,6 +88,23 @@ gimp_image_window_init (GimpImageWindow *window)
{
}
+static GObject *
+gimp_image_window_constructor (GType type,
+ guint n_params,
+ GObjectConstructParam *params)
+{
+ GObject *object;
+ GimpImageWindow *window;
+
+ object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
+
+ window = GIMP_IMAGE_WINDOW (object);
+
+ g_assert (GIMP_IS_UI_MANAGER (window->menubar_manager));
+
+ return object;
+}
+
static void
gimp_image_window_finalize (GObject *object)
{
@@ -85,6 +123,17 @@ gimp_image_window_set_property (GObject *object,
switch (property_id)
{
+ case PROP_MENU_FACTORY:
+ {
+ GimpMenuFactory *factory = g_value_get_object (value);
+
+ window->menubar_manager = gimp_menu_factory_manager_new (factory,
+ "<Image>",
+ window,
+ FALSE);
+ }
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -112,5 +161,11 @@ gimp_image_window_destroy (GtkObject *object)
{
GimpImageWindow *window = GIMP_IMAGE_WINDOW (object);
+ if (window->menubar_manager)
+ {
+ g_object_unref (window->menubar_manager);
+ window->menubar_manager = NULL;
+ }
+
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
diff --git a/app/display/gimpimagewindow.h b/app/display/gimpimagewindow.h
index 5726ef5..e061f50 100644
--- a/app/display/gimpimagewindow.h
+++ b/app/display/gimpimagewindow.h
@@ -35,6 +35,8 @@ typedef struct _GimpImageWindowClass GimpImageWindowClass;
struct _GimpImageWindow
{
GimpWindow parent_instance;
+
+ GimpUIManager *menubar_manager;
};
struct _GimpImageWindowClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]