[gimp] app: reparenting GimpSymmetryEditor to GimpImageEditor.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: reparenting GimpSymmetryEditor to GimpImageEditor.
- Date: Thu, 4 Feb 2016 16:06:50 +0000 (UTC)
commit 66ead15f69ef72db2bbba9bbfc3a082f1b566ded
Author: Jehan <jehan girinstud io>
Date: Thu Feb 4 17:05:27 2016 +0100
app: reparenting GimpSymmetryEditor to GimpImageEditor.
app/dialogs/dialogs-constructors.c | 3 +-
app/widgets/gimpsymmetryeditor.c | 171 ++++++++++--------------------------
app/widgets/gimpsymmetryeditor.h | 11 +--
3 files changed, 51 insertions(+), 134 deletions(-)
---
diff --git a/app/dialogs/dialogs-constructors.c b/app/dialogs/dialogs-constructors.c
index 8db0e64..e0fdbc4 100644
--- a/app/dialogs/dialogs-constructors.c
+++ b/app/dialogs/dialogs-constructors.c
@@ -743,8 +743,7 @@ dialogs_symmetry_editor_new (GimpDialogFactory *factory,
GimpUIManager *ui_manager,
gint view_size)
{
- return gimp_symmetry_editor_new (context->gimp,
- gimp_context_get_image (context),
+ return gimp_symmetry_editor_new (gimp_context_get_image (context),
gimp_dialog_factory_get_menu_factory (factory));
}
diff --git a/app/widgets/gimpsymmetryeditor.c b/app/widgets/gimpsymmetryeditor.c
index 4a1b9c3..1dd0975 100644
--- a/app/widgets/gimpsymmetryeditor.c
+++ b/app/widgets/gimpsymmetryeditor.c
@@ -44,40 +44,24 @@
#include "gimp-intl.h"
-enum
-{
- PROP_0,
- PROP_GIMP
-};
-
-
struct _GimpSymmetryEditorPrivate
{
- Gimp *gimp;
- GimpImage *image;
+ GimpContext *context;
- GtkWidget *menu;
- GtkWidget *options_frame;
+ GtkWidget *menu;
+ GtkWidget *options_frame;
};
static void gimp_symmetry_editor_docked_iface_init (GimpDockedInterface *iface);
-static void gimp_symmetry_editor_constructed (GObject *object);
-static void gimp_symmetry_editor_dispose (GObject *object);
-static void gimp_symmetry_editor_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_symmetry_editor_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-/* Signal handlers on the context. */
-static void gimp_symmetry_editor_image_changed (GimpContext *context,
- GimpImage *image,
- GimpSymmetryEditor *editor);
+/* GimpDockedInterface handlers. */
+static void gimp_symmetry_editor_set_context (GimpDocked *docked,
+ GimpContext *context);
+
+/* GimpImageEditor handlers. */
+static void gimp_symmetry_editor_set_image (GimpImageEditor *editor,
+ GimpImage *image);
/* Signal handlers on the contextual image. */
static void gimp_symmetry_editor_symmetry_notify (GimpImage *image,
@@ -95,28 +79,20 @@ static void gimp_symmetry_editor_set_options (GimpSymmetryEditor
G_DEFINE_TYPE_WITH_CODE (GimpSymmetryEditor, gimp_symmetry_editor,
- GIMP_TYPE_EDITOR,
+ GIMP_TYPE_IMAGE_EDITOR,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
gimp_symmetry_editor_docked_iface_init))
#define parent_class gimp_symmetry_editor_parent_class
+static GimpDockedInterface *parent_docked_iface = NULL;
+
static void
gimp_symmetry_editor_class_init (GimpSymmetryEditorClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructed = gimp_symmetry_editor_constructed;
- object_class->dispose = gimp_symmetry_editor_dispose;
- object_class->set_property = gimp_symmetry_editor_set_property;
- object_class->get_property = gimp_symmetry_editor_get_property;
+ GimpImageEditorClass *image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
- g_object_class_install_property (object_class, PROP_GIMP,
- g_param_spec_object ("gimp",
- NULL, NULL,
- GIMP_TYPE_GIMP,
- GIMP_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
+ image_editor_class->set_image = gimp_symmetry_editor_set_image;
g_type_class_add_private (klass, sizeof (GimpSymmetryEditorPrivate));
}
@@ -124,6 +100,12 @@ gimp_symmetry_editor_class_init (GimpSymmetryEditorClass *klass)
static void
gimp_symmetry_editor_docked_iface_init (GimpDockedInterface *docked_iface)
{
+ parent_docked_iface = g_type_interface_peek_parent (docked_iface);
+
+ if (! parent_docked_iface)
+ parent_docked_iface = g_type_default_interface_peek (GIMP_TYPE_DOCKED);
+
+ docked_iface->set_context = gimp_symmetry_editor_set_context;
}
static void
@@ -156,103 +138,47 @@ gimp_symmetry_editor_init (GimpSymmetryEditor *editor)
}
static void
-gimp_symmetry_editor_constructed (GObject *object)
+gimp_symmetry_editor_set_context (GimpDocked *docked,
+ GimpContext *context)
{
- GimpSymmetryEditor *editor = GIMP_SYMMETRY_EDITOR (object);
- GimpContext *user_context;
-
- G_OBJECT_CLASS (parent_class)->constructed (object);
-
- user_context = gimp_get_user_context (editor->p->gimp);
-
- g_signal_connect_object (user_context, "image-changed",
- G_CALLBACK (gimp_symmetry_editor_image_changed),
- editor,
- 0);
+ GimpSymmetryEditor *editor = GIMP_SYMMETRY_EDITOR (docked);
- gimp_symmetry_editor_image_changed (user_context,
- gimp_context_get_image (user_context),
- editor);
-}
+ if (editor->p->context)
+ g_object_unref (editor->p->context);
-static void
-gimp_symmetry_editor_dispose (GObject *object)
-{
- GimpSymmetryEditor *editor = GIMP_SYMMETRY_EDITOR (object);
+ editor->p->context = context;
- g_clear_object (&editor->p->image);
+ if (editor->p->context)
+ g_object_ref (editor->p->context);
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ parent_docked_iface->set_context (docked, context);
}
static void
-gimp_symmetry_editor_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+gimp_symmetry_editor_set_image (GimpImageEditor *image_editor,
+ GimpImage *image)
{
- GimpSymmetryEditor *editor = GIMP_SYMMETRY_EDITOR (object);
+ GimpSymmetryEditor *editor = GIMP_SYMMETRY_EDITOR (image_editor);
+ GimpGuiConfig *guiconfig;
- switch (property_id)
- {
- case PROP_GIMP:
- editor->p->gimp = g_value_get_object (value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-gimp_symmetry_editor_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GimpSymmetryEditor *editor = GIMP_SYMMETRY_EDITOR (object);
-
- switch (property_id)
- {
- case PROP_GIMP:
- g_value_set_object (value, editor->p->gimp);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-gimp_symmetry_editor_image_changed (GimpContext *context,
- GimpImage *image,
- GimpSymmetryEditor *editor)
-{
- GimpGuiConfig *guiconfig;
-
- if (image == editor->p->image)
- return;
-
- guiconfig = GIMP_GUI_CONFIG (editor->p->gimp->config);
+ guiconfig = GIMP_GUI_CONFIG (editor->p->context->gimp->config);
/* Disconnect and unref the previous image. */
- if (editor->p->image)
+ if (image_editor->image)
{
- g_signal_handlers_disconnect_by_func (editor->p->image,
+ g_signal_handlers_disconnect_by_func (image_editor->image,
G_CALLBACK (gimp_symmetry_editor_symmetry_notify),
editor);
- g_object_unref (editor->p->image);
- editor->p->image = NULL;
}
+ GIMP_IMAGE_EDITOR_CLASS (parent_class)->set_image (image_editor, image);
+
/* Destroy the previous menu. */
if (editor->p->menu)
gtk_widget_destroy (editor->p->menu);
editor->p->menu = NULL;
- if (image && guiconfig->playground_symmetry)
+ if (image_editor->image && guiconfig->playground_symmetry)
{
GtkListStore *store;
GtkTreeIter iter;
@@ -288,7 +214,7 @@ gimp_symmetry_editor_image_changed (GimpContext *context,
GIMP_INT_STORE_LABEL, _("None"),
GIMP_INT_STORE_USER_DATA, GIMP_TYPE_SYMMETRY,
-1);
- editor->p->menu = gimp_prop_pointer_combo_box_new (G_OBJECT (image),
+ editor->p->menu = gimp_prop_pointer_combo_box_new (G_OBJECT (image_editor->image),
"symmetry",
GIMP_INT_STORE (store));
g_object_unref (store);
@@ -303,14 +229,13 @@ gimp_symmetry_editor_image_changed (GimpContext *context,
gtk_widget_show (editor->p->menu);
/* Connect to symmetry change. */
- g_signal_connect (image, "notify::symmetry",
+ g_signal_connect (image_editor->image, "notify::symmetry",
G_CALLBACK (gimp_symmetry_editor_symmetry_notify),
editor);
/* Update the symmetry options. */
- symmetry = gimp_image_get_active_symmetry (image);
+ symmetry = gimp_image_get_active_symmetry (image_editor->image);
gimp_symmetry_editor_set_options (editor, symmetry);
- editor->p->image = g_object_ref (image);
}
else if (! guiconfig->playground_symmetry)
{
@@ -354,12 +279,9 @@ gimp_symmetry_editor_symmetry_updated (GimpSymmetry *symmetry,
GimpImage *image,
GimpSymmetryEditor *editor)
{
- GimpContext *context;
-
g_return_if_fail (GIMP_IS_SYMMETRY (symmetry));
- context = gimp_get_user_context (editor->p->gimp);
- if (image != context->image ||
+ if (image != editor->p->context->image ||
symmetry != gimp_image_get_active_symmetry (image))
{
g_signal_handlers_disconnect_by_func (symmetry,
@@ -486,16 +408,13 @@ gimp_symmetry_editor_set_options (GimpSymmetryEditor *editor,
/* public functions */
GtkWidget *
-gimp_symmetry_editor_new (Gimp *gimp,
- GimpImage *image,
+gimp_symmetry_editor_new (GimpImage *image,
GimpMenuFactory *menu_factory)
{
- g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
g_return_val_if_fail (image == NULL || GIMP_IS_IMAGE (image), NULL);
return g_object_new (GIMP_TYPE_SYMMETRY_EDITOR,
- "gimp", gimp,
"menu-factory", menu_factory,
NULL);
}
diff --git a/app/widgets/gimpsymmetryeditor.h b/app/widgets/gimpsymmetryeditor.h
index d53364c..c434147 100644
--- a/app/widgets/gimpsymmetryeditor.h
+++ b/app/widgets/gimpsymmetryeditor.h
@@ -22,7 +22,7 @@
#define __GIMP_SYMMETRY_EDITOR_H__
-#include "gimpeditor.h"
+#include "gimpimageeditor.h"
#define GIMP_TYPE_SYMMETRY_EDITOR (gimp_symmetry_editor_get_type ())
@@ -38,21 +38,20 @@ typedef struct _GimpSymmetryEditorClass GimpSymmetryEditorClass;
struct _GimpSymmetryEditor
{
- GimpEditor parent_instance;
+ GimpImageEditor parent_instance;
GimpSymmetryEditorPrivate *p;
};
struct _GimpSymmetryEditorClass
{
- GimpEditorClass parent_class;
+ GimpImageEditorClass parent_class;
};
GType gimp_symmetry_editor_get_type (void) G_GNUC_CONST;
-GtkWidget * gimp_symmetry_editor_new (Gimp *gimp,
- GimpImage *image,
- GimpMenuFactory *menu_factory);
+GtkWidget * gimp_symmetry_editor_new (GimpImage *image,
+ GimpMenuFactory *menu_factory);
#endif /* __GIMP_SYMMETRY_EDITOR_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]