[gimp] app: Move UI manager from GimpImageDock to GimpDockWindow
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] app: Move UI manager from GimpImageDock to GimpDockWindow
- Date: Sun, 13 Sep 2009 07:20:02 +0000 (UTC)
commit 3532acbec66d6cd275d9d062197ee414178d91ea
Author: Martin Nordholts <martinn src gnome org>
Date: Sun Sep 13 09:22:59 2009 +0200
app: Move UI manager from GimpImageDock to GimpDockWindow
Move the GimpUIManager from GimpImageDock to GimpDockWindow. This
includes making the ui_manager_name class-member of GimpImageDock a
normal instance member of GimpDockWindow since the UI manager name no
longer can be configured at the class level.
app/widgets/gimpdockbook.c | 4 +-
app/widgets/gimpdockwindow.c | 126 +++++++++++++++++++++++++++++++++++++-
app/widgets/gimpdockwindow.h | 3 +-
app/widgets/gimpimagedock.c | 139 ------------------------------------------
app/widgets/gimpimagedock.h | 8 +--
app/widgets/gimpmenudock.c | 9 ++-
app/widgets/gimptoolbox.c | 24 +++----
7 files changed, 145 insertions(+), 168 deletions(-)
---
diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c
index f004393..0793f4d 100644
--- a/app/widgets/gimpdockbook.c
+++ b/app/widgets/gimpdockbook.c
@@ -451,7 +451,7 @@ gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
/* EEK */
if (GIMP_IS_IMAGE_DOCK (dockbook->dock) &&
- gimp_image_dock_get_ui_manager (GIMP_IMAGE_DOCK (dockbook->dock)))
+ gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (dockbook->dock)))
{
const gchar *dialog_id;
@@ -463,7 +463,7 @@ gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
GimpActionGroup *group;
group = gimp_ui_manager_get_action_group
- (gimp_image_dock_get_ui_manager (GIMP_IMAGE_DOCK (dockbook->dock)), "dialogs");
+ (gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (dockbook->dock)), "dialogs");
if (group)
{
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index ba278bc..d5f05c8 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -31,8 +31,13 @@
#include "core/gimp.h"
#include "core/gimpcontext.h"
+#include "core/gimpcontainer.h"
+#include "gimpdialogfactory.h"
+#include "gimpdock.h"
#include "gimpdockwindow.h"
+#include "gimpmenufactory.h"
+#include "gimpuimanager.h"
#include "gimpwidgets-utils.h"
#include "gimpwindow.h"
@@ -43,12 +48,17 @@ enum
{
PROP_0,
PROP_CONTEXT,
+ PROP_UI_MANAGER_NAME,
};
struct _GimpDockWindowPrivate
{
- GimpContext *context;
+ GimpContext *context;
+
+ gchar *ui_manager_name;
+ GimpUIManager *ui_manager;
+ GQuark image_flush_handler_id;
};
static GObject * gimp_dock_window_constructor (GType type,
@@ -63,6 +73,15 @@ static void gimp_dock_window_get_property (GObject *obje
guint property_id,
GValue *value,
GParamSpec *pspec);
+static void gimp_dock_window_display_changed (GimpDockWindow *dock_window,
+ GimpObject *display,
+ GimpContext *context);
+static void gimp_dock_window_image_changed (GimpDockWindow *dock_window,
+ GimpImage *image,
+ GimpContext *context);
+static void gimp_dock_window_image_flush (GimpImage *image,
+ gboolean invalidate_preview,
+ GimpDockWindow *dock_window);
G_DEFINE_TYPE (GimpDockWindow, gimp_dock_window, GIMP_TYPE_WINDOW)
@@ -85,6 +104,13 @@ gimp_dock_window_class_init (GimpDockWindowClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_UI_MANAGER_NAME,
+ g_param_spec_string ("ui-manager-name",
+ NULL, NULL,
+ NULL,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
g_type_class_add_private (klass, sizeof (GimpDockWindowPrivate));
}
@@ -94,7 +120,10 @@ 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;
+ dock_window->p->context = NULL;
+ dock_window->p->ui_manager_name = NULL;
+ dock_window->p->ui_manager = NULL;
+ dock_window->p->image_flush_handler_id = 0;
gtk_window_set_resizable (GTK_WINDOW (dock_window), TRUE);
gtk_window_set_focus_on_map (GTK_WINDOW (dock_window), FALSE);
@@ -108,13 +137,44 @@ gimp_dock_window_constructor (GType type,
GObject *object;
GimpDockWindow *dock_window;
GimpGuiConfig *config;
+ GtkAccelGroup *accel_group;
+ /* Init */
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
dock_window = GIMP_DOCK_WINDOW (object);
config = GIMP_GUI_CONFIG (dock_window->p->context->gimp->config);
+ /* Setup hints */
gimp_window_set_hint (GTK_WINDOW (dock_window), config->dock_window_hint);
+ /* Make image window related keyboard shortcuts work also when a
+ * dock window is the focused window
+ */
+ dock_window->p->ui_manager =
+ gimp_menu_factory_manager_new (gimp_dock_get_dialog_factory (GIMP_DOCK (dock_window))->menu_factory,
+ dock_window->p->ui_manager_name,
+ dock_window,
+ config->tearoff_menus);
+ accel_group =
+ gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (dock_window->p->ui_manager));
+
+ gtk_window_add_accel_group (GTK_WINDOW (dock_window), accel_group);
+
+ g_signal_connect_object (dock_window->p->context, "display-changed",
+ G_CALLBACK (gimp_dock_window_display_changed),
+ dock_window,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (dock_window->p->context, "image-changed",
+ G_CALLBACK (gimp_dock_window_image_changed),
+ dock_window,
+ G_CONNECT_SWAPPED);
+
+ dock_window->p->image_flush_handler_id =
+ gimp_container_add_handler (dock_window->p->context->gimp->images, "flush",
+ G_CALLBACK (gimp_dock_window_image_flush),
+ dock_window);
+
+ /* Done! */
return object;
}
@@ -123,6 +183,19 @@ gimp_dock_window_dispose (GObject *object)
{
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (object);
+ if (dock_window->p->image_flush_handler_id)
+ {
+ gimp_container_remove_handler (dock_window->p->context->gimp->images,
+ dock_window->p->image_flush_handler_id);
+ dock_window->p->image_flush_handler_id = 0;
+ }
+
+ if (dock_window->p->ui_manager)
+ {
+ g_object_unref (dock_window->p->ui_manager);
+ dock_window->p->ui_manager = NULL;
+ }
+
if (dock_window->p->context)
{
g_object_unref (dock_window->p->context);
@@ -146,6 +219,11 @@ gimp_dock_window_set_property (GObject *object,
dock_window->p->context = g_value_dup_object (value);
break;
+ case PROP_UI_MANAGER_NAME:
+ g_free (dock_window->p->ui_manager_name);
+ dock_window->p->ui_manager_name = g_value_dup_string (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -166,8 +244,52 @@ gimp_dock_window_get_property (GObject *object,
g_value_set_object (value, dock_window->p->context);
break;
+ case PROP_UI_MANAGER_NAME:
+ g_value_set_string (value, dock_window->p->ui_manager_name);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
+
+static void
+gimp_dock_window_display_changed (GimpDockWindow *dock_window,
+ GimpObject *display,
+ GimpContext *context)
+{
+ gimp_ui_manager_update (dock_window->p->ui_manager,
+ display);
+}
+
+static void
+gimp_dock_window_image_changed (GimpDockWindow *dock_window,
+ GimpImage *image,
+ GimpContext *context)
+{
+ gimp_ui_manager_update (dock_window->p->ui_manager,
+ gimp_context_get_display (context));
+}
+
+static void
+gimp_dock_window_image_flush (GimpImage *image,
+ gboolean invalidate_preview,
+ GimpDockWindow *dock_window)
+{
+ if (image == gimp_context_get_image (dock_window->p->context))
+ {
+ GimpObject *display = gimp_context_get_display (dock_window->p->context);
+
+ if (display)
+ gimp_ui_manager_update (dock_window->p->ui_manager, display);
+ }
+}
+
+GimpUIManager *
+gimp_dock_window_get_ui_manager (GimpDockWindow *dock_window)
+{
+ g_return_val_if_fail (GIMP_IS_DOCK_WINDOW (dock_window), NULL);
+
+ return dock_window->p->ui_manager;
+}
diff --git a/app/widgets/gimpdockwindow.h b/app/widgets/gimpdockwindow.h
index e9e2419..29551ea 100644
--- a/app/widgets/gimpdockwindow.h
+++ b/app/widgets/gimpdockwindow.h
@@ -53,7 +53,8 @@ struct _GimpDockWindowClass
};
-GType gimp_dock_window_get_type (void) G_GNUC_CONST;
+GType gimp_dock_window_get_type (void) G_GNUC_CONST;
+GimpUIManager * gimp_dock_window_get_ui_manager (GimpDockWindow *dock_window);
#endif /* __GIMP_DOCK_WINDOW_H__ */
diff --git a/app/widgets/gimpimagedock.c b/app/widgets/gimpimagedock.c
index f1dade1..c032edc 100644
--- a/app/widgets/gimpimagedock.c
+++ b/app/widgets/gimpimagedock.c
@@ -24,35 +24,7 @@
#include "widgets-types.h"
-#include "config/gimpguiconfig.h"
-
-#include "core/gimp.h"
-#include "core/gimpcontainer.h"
-#include "core/gimpcontext.h"
-
-#include "gimpdialogfactory.h"
#include "gimpimagedock.h"
-#include "gimpmenufactory.h"
-#include "gimpuimanager.h"
-
-#include "gimp-log.h"
-
-
-static GObject * gimp_image_dock_constructor (GType type,
- guint n_params,
- GObjectConstructParam *params);
-
-static void gimp_image_dock_destroy (GtkObject *object);
-
-static void gimp_image_dock_display_changed (GimpContext *context,
- GimpObject *display,
- GimpImageDock *dock);
-static void gimp_image_dock_image_changed (GimpContext *context,
- GimpImage *image,
- GimpImageDock *dock);
-static void gimp_image_dock_image_flush (GimpImage *image,
- gboolean invalidate_preview,
- GimpImageDock *dock);
G_DEFINE_TYPE (GimpImageDock, gimp_image_dock, GIMP_TYPE_DOCK)
@@ -63,120 +35,9 @@ G_DEFINE_TYPE (GimpImageDock, gimp_image_dock, GIMP_TYPE_DOCK)
static void
gimp_image_dock_class_init (GimpImageDockClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
-
- object_class->constructor = gimp_image_dock_constructor;
-
- gtk_object_class->destroy = gimp_image_dock_destroy;
-
- klass->ui_manager_name = "<Dock>";
}
static void
gimp_image_dock_init (GimpImageDock *dock)
{
- dock->ui_manager = NULL;
- dock->image_flush_handler_id = 0;
-}
-
-static GObject *
-gimp_image_dock_constructor (GType type,
- guint n_params,
- GObjectConstructParam *params)
-{
- GObject *object;
- GimpImageDock *dock;
- GimpGuiConfig *config;
- GtkAccelGroup *accel_group;
-
- object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
-
- dock = GIMP_IMAGE_DOCK (object);
-
- config = GIMP_GUI_CONFIG (gimp_dock_get_context (GIMP_DOCK (dock))->gimp->config);
-
- dock->ui_manager =
- gimp_menu_factory_manager_new (gimp_dock_get_dialog_factory (GIMP_DOCK (dock))->menu_factory,
- GIMP_IMAGE_DOCK_GET_CLASS (dock)->ui_manager_name,
- dock,
- config->tearoff_menus);
-
- accel_group =
- gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (dock->ui_manager));
-
- gtk_window_add_accel_group (GTK_WINDOW (object), accel_group);
-
- dock->image_flush_handler_id =
- gimp_container_add_handler (gimp_dock_get_context (GIMP_DOCK (dock))->gimp->images, "flush",
- G_CALLBACK (gimp_image_dock_image_flush),
- dock);
-
- g_signal_connect_object (gimp_dock_get_context (GIMP_DOCK (dock)), "display-changed",
- G_CALLBACK (gimp_image_dock_display_changed),
- dock, 0);
- g_signal_connect_object (gimp_dock_get_context (GIMP_DOCK (dock)), "image-changed",
- G_CALLBACK (gimp_image_dock_image_changed),
- dock, 0);
-
- return object;
-}
-
-static void
-gimp_image_dock_destroy (GtkObject *object)
-{
- GimpImageDock *dock = GIMP_IMAGE_DOCK (object);
-
- if (dock->image_flush_handler_id)
- {
- gimp_container_remove_handler (gimp_dock_get_context (GIMP_DOCK (dock))->gimp->images,
- dock->image_flush_handler_id);
- dock->image_flush_handler_id = 0;
- }
-
- if (dock->ui_manager)
- {
- g_object_unref (dock->ui_manager);
- dock->ui_manager = NULL;
- }
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-gimp_image_dock_display_changed (GimpContext *context,
- GimpObject *display,
- GimpImageDock *dock)
-{
- gimp_ui_manager_update (dock->ui_manager, display);
-}
-
-static void
-gimp_image_dock_image_changed (GimpContext *context,
- GimpImage *image,
- GimpImageDock *dock)
-{
- gimp_ui_manager_update (dock->ui_manager, gimp_context_get_display (context));
-}
-
-static void
-gimp_image_dock_image_flush (GimpImage *image,
- gboolean invalidate_preview,
- GimpImageDock *dock)
-{
- if (image == gimp_context_get_image (gimp_dock_get_context (GIMP_DOCK (dock))))
- {
- GimpObject *display = gimp_context_get_display (gimp_dock_get_context (GIMP_DOCK (dock)));
-
- if (display)
- gimp_ui_manager_update (dock->ui_manager, display);
- }
-}
-
-GimpUIManager *
-gimp_image_dock_get_ui_manager (GimpImageDock *image_dock)
-{
- g_return_val_if_fail (GIMP_IS_IMAGE_DOCK (image_dock), NULL);
-
- return image_dock->ui_manager;
}
diff --git a/app/widgets/gimpimagedock.h b/app/widgets/gimpimagedock.h
index 49d5c90..fbd5cfc 100644
--- a/app/widgets/gimpimagedock.h
+++ b/app/widgets/gimpimagedock.h
@@ -40,22 +40,16 @@ typedef struct _GimpImageDockClass GimpImageDockClass;
*/
struct _GimpImageDock
{
- GimpDock parent_instance;
-
- GimpUIManager *ui_manager;
- GQuark image_flush_handler_id;
+ GimpDock parent_instance;
};
struct _GimpImageDockClass
{
GimpDockClass parent_class;
-
- const gchar *ui_manager_name;
};
GType gimp_image_dock_get_type (void) G_GNUC_CONST;
-GimpUIManager * gimp_image_dock_get_ui_manager (GimpImageDock *image_dock);
#endif /* __GIMP_IMAGE_DOCK_H__ */
diff --git a/app/widgets/gimpmenudock.c b/app/widgets/gimpmenudock.c
index 53078b8..3d0cd3f 100644
--- a/app/widgets/gimpmenudock.c
+++ b/app/widgets/gimpmenudock.c
@@ -389,10 +389,11 @@ gimp_menu_dock_new (GimpDialogFactory *dialog_factory,
"Dock Context", NULL);
menu_dock = g_object_new (GIMP_TYPE_MENU_DOCK,
- "role", "gimp-dock",
- "gimp-context", context,
- "context", context,
- "dialog-factory", dialog_factory,
+ "role", "gimp-dock",
+ "gimp-context", context,
+ "context", context,
+ "dialog-factory", dialog_factory,
+ "ui-manager-name", "<Dock>",
NULL);
g_object_unref (context);
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index c4b40a4..5133851 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -137,10 +137,9 @@ G_DEFINE_TYPE (GimpToolbox, gimp_toolbox, GIMP_TYPE_IMAGE_DOCK)
static void
gimp_toolbox_class_init (GimpToolboxClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GimpDockClass *dock_class = GIMP_DOCK_CLASS (klass);
- GimpImageDockClass *image_dock_class = GIMP_IMAGE_DOCK_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GimpDockClass *dock_class = GIMP_DOCK_CLASS (klass);
object_class->constructor = gimp_toolbox_constructor;
@@ -153,8 +152,6 @@ gimp_toolbox_class_init (GimpToolboxClass *klass)
dock_class->book_added = gimp_toolbox_book_added;
dock_class->book_removed = gimp_toolbox_book_removed;
- image_dock_class->ui_manager_name = "<Toolbox>";
-
gtk_widget_class_install_style_property (widget_class,
g_param_spec_enum ("tool-icon-size",
NULL, NULL,
@@ -620,11 +617,12 @@ gimp_toolbox_new (GimpDialogFactory *dialog_factory,
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
toolbox = g_object_new (GIMP_TYPE_TOOLBOX,
- "title", _("Toolbox"),
- "role", "gimp-toolbox",
- "gimp-context", context,
- "context", context,
- "dialog-factory", dialog_factory,
+ "title", _("Toolbox"),
+ "role", "gimp-toolbox",
+ "gimp-context", context,
+ "context", context,
+ "dialog-factory", dialog_factory,
+ "ui-manager-name", "<Toolbox>",
NULL);
return GTK_WIDGET (toolbox);
@@ -717,7 +715,7 @@ toolbox_create_tools (GimpToolbox *toolbox,
G_CALLBACK (toolbox_tool_button_press),
toolbox);
- if (gimp_image_dock_get_ui_manager (GIMP_IMAGE_DOCK (toolbox)))
+ if (gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (toolbox)))
{
GimpUIManager *ui_manager;
GtkAction *action;
@@ -732,7 +730,7 @@ toolbox_create_tools (GimpToolbox *toolbox,
name = g_strdup_printf ("tools-%s", tmp);
g_free (tmp);
- ui_manager = gimp_image_dock_get_ui_manager (GIMP_IMAGE_DOCK (toolbox));
+ ui_manager = gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (toolbox));
action = gimp_ui_manager_find_action (ui_manager, "tools", name);
g_free (name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]