gimp r24635 - in trunk: . app/tools



Author: mitch
Date: Thu Jan 17 12:51:39 2008
New Revision: 24635
URL: http://svn.gnome.org/viewvc/gimp?rev=24635&view=rev

Log:
2008-01-17  Michael Natterer  <mitch gimp org>

	* app/tools/gimpimagemaptool.c: create the operation in
	GObject::constructor() so it's available during the entire tool
	life time (needed soon).



Modified:
   trunk/ChangeLog
   trunk/app/tools/gimpimagemaptool.c

Modified: trunk/app/tools/gimpimagemaptool.c
==============================================================================
--- trunk/app/tools/gimpimagemaptool.c	(original)
+++ trunk/app/tools/gimpimagemaptool.c	Thu Jan 17 12:51:39 2008
@@ -61,57 +61,60 @@
 
 /*  local function prototypes  */
 
-static void     gimp_image_map_tool_finalize   (GObject          *object);
-
-static gboolean gimp_image_map_tool_initialize (GimpTool         *tool,
-                                                GimpDisplay      *display,
-                                                GError          **error);
-static void     gimp_image_map_tool_control    (GimpTool         *tool,
-                                                GimpToolAction    action,
-                                                GimpDisplay      *display);
-static gboolean gimp_image_map_tool_key_press  (GimpTool         *tool,
-                                                GdkEventKey      *kevent,
-                                                GimpDisplay      *display);
-
-static gboolean gimp_image_map_tool_pick_color (GimpColorTool    *color_tool,
-                                                gint              x,
-                                                gint              y,
-                                                GimpImageType    *sample_type,
-                                                GimpRGB          *color,
-                                                gint             *color_index);
-static void     gimp_image_map_tool_map        (GimpImageMapTool *im_tool);
-static void     gimp_image_map_tool_dialog     (GimpImageMapTool *im_tool);
-static void     gimp_image_map_tool_reset      (GimpImageMapTool *im_tool);
-
-static void     gimp_image_map_tool_create_map (GimpImageMapTool *im_tool);
-
-static void     gimp_image_map_tool_flush      (GimpImageMap     *image_map,
-                                                GimpImageMapTool *im_tool);
-
-static void     gimp_image_map_tool_response   (GtkWidget        *widget,
-                                                gint              response_id,
-                                                GimpImageMapTool *im_tool);
-
-static void     gimp_image_map_tool_load_clicked     (GtkWidget        *widget,
-                                                      GimpImageMapTool *tool);
-static void     gimp_image_map_tool_load_ext_clicked (GtkWidget        *widget,
-                                                      GdkModifierType   state,
-                                                      GimpImageMapTool *tool);
-static void     gimp_image_map_tool_save_clicked     (GtkWidget        *widget,
-                                                      GimpImageMapTool *tool);
-static void     gimp_image_map_tool_save_ext_clicked (GtkWidget        *widget,
-                                                      GdkModifierType   state,
-                                                      GimpImageMapTool *tool);
-
-static void     gimp_image_map_tool_settings_dialog  (GimpImageMapTool *im_tool,
-                                                      const gchar      *title,
-                                                      gboolean          save);
-static void     gimp_image_map_tool_notify_preview   (GObject          *config,
-                                                      GParamSpec       *pspec,
-                                                      GimpImageMapTool *im_tool);
-static void     gimp_image_map_tool_gegl_notify      (GObject          *config,
-                                                      const GParamSpec *pspec,
-                                                      GimpImageMapTool *im_tool);
+static GObject * gimp_image_map_tool_constructor (GType             type,
+                                                  guint             n_params,
+                                                  GObjectConstructParam *params);
+static void      gimp_image_map_tool_finalize    (GObject          *object);
+
+static gboolean  gimp_image_map_tool_initialize  (GimpTool         *tool,
+                                                  GimpDisplay      *display,
+                                                  GError          **error);
+static void      gimp_image_map_tool_control     (GimpTool         *tool,
+                                                  GimpToolAction    action,
+                                                  GimpDisplay      *display);
+static gboolean  gimp_image_map_tool_key_press   (GimpTool         *tool,
+                                                  GdkEventKey      *kevent,
+                                                  GimpDisplay      *display);
+
+static gboolean  gimp_image_map_tool_pick_color  (GimpColorTool    *color_tool,
+                                                  gint              x,
+                                                  gint              y,
+                                                  GimpImageType    *sample_type,
+                                                  GimpRGB          *color,
+                                                  gint             *color_index);
+static void      gimp_image_map_tool_map         (GimpImageMapTool *im_tool);
+static void      gimp_image_map_tool_dialog      (GimpImageMapTool *im_tool);
+static void      gimp_image_map_tool_reset       (GimpImageMapTool *im_tool);
+
+static void      gimp_image_map_tool_create_map  (GimpImageMapTool *im_tool);
+
+static void      gimp_image_map_tool_flush       (GimpImageMap     *image_map,
+                                                  GimpImageMapTool *im_tool);
+
+static void      gimp_image_map_tool_response    (GtkWidget        *widget,
+                                                  gint              response_id,
+                                                  GimpImageMapTool *im_tool);
+
+static void      gimp_image_map_tool_load_clicked     (GtkWidget        *widget,
+                                                       GimpImageMapTool *tool);
+static void      gimp_image_map_tool_load_ext_clicked (GtkWidget        *widget,
+                                                       GdkModifierType   state,
+                                                       GimpImageMapTool *tool);
+static void      gimp_image_map_tool_save_clicked     (GtkWidget        *widget,
+                                                       GimpImageMapTool *tool);
+static void      gimp_image_map_tool_save_ext_clicked (GtkWidget        *widget,
+                                                       GdkModifierType   state,
+                                                       GimpImageMapTool *tool);
+
+static void      gimp_image_map_tool_settings_dialog  (GimpImageMapTool *im_tool,
+                                                       const gchar      *title,
+                                                       gboolean          save);
+static void      gimp_image_map_tool_notify_preview   (GObject          *config,
+                                                       GParamSpec       *pspec,
+                                                       GimpImageMapTool *im_tool);
+static void      gimp_image_map_tool_gegl_notify      (GObject          *config,
+                                                       const GParamSpec *pspec,
+                                                       GimpImageMapTool *im_tool);
 
 
 G_DEFINE_TYPE (GimpImageMapTool, gimp_image_map_tool, GIMP_TYPE_COLOR_TOOL)
@@ -126,27 +129,28 @@
   GimpToolClass      *tool_class       = GIMP_TOOL_CLASS (klass);
   GimpColorToolClass *color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
 
-  object_class->finalize   = gimp_image_map_tool_finalize;
+  object_class->constructor = gimp_image_map_tool_constructor;
+  object_class->finalize    = gimp_image_map_tool_finalize;
 
-  tool_class->initialize   = gimp_image_map_tool_initialize;
-  tool_class->control      = gimp_image_map_tool_control;
-  tool_class->key_press    = gimp_image_map_tool_key_press;
-
-  color_tool_class->pick   = gimp_image_map_tool_pick_color;
-
-  klass->shell_desc        = NULL;
-  klass->settings_name     = NULL;
-  klass->load_dialog_title = NULL;
-  klass->load_button_tip   = NULL;
-  klass->save_dialog_title = NULL;
-  klass->save_button_tip   = NULL;
-
-  klass->get_operation     = NULL;
-  klass->map               = NULL;
-  klass->dialog            = NULL;
-  klass->reset             = NULL;
-  klass->settings_load     = NULL;
-  klass->settings_save     = NULL;
+  tool_class->initialize    = gimp_image_map_tool_initialize;
+  tool_class->control       = gimp_image_map_tool_control;
+  tool_class->key_press     = gimp_image_map_tool_key_press;
+
+  color_tool_class->pick    = gimp_image_map_tool_pick_color;
+
+  klass->shell_desc         = NULL;
+  klass->settings_name      = NULL;
+  klass->load_dialog_title  = NULL;
+  klass->load_button_tip    = NULL;
+  klass->save_dialog_title  = NULL;
+  klass->save_button_tip    = NULL;
+
+  klass->get_operation      = NULL;
+  klass->map                = NULL;
+  klass->dialog             = NULL;
+  klass->reset              = NULL;
+  klass->settings_load      = NULL;
+  klass->settings_save      = NULL;
 }
 
 static void
@@ -173,6 +177,26 @@
   image_map_tool->settings_dialog = NULL;
 }
 
+static GObject *
+gimp_image_map_tool_constructor (GType                  type,
+                                 guint                  n_params,
+                                 GObjectConstructParam *params)
+{
+  GObject               *object;
+  GimpImageMapTool      *image_map_tool;
+  GimpImageMapToolClass *klass;
+
+  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
+
+  image_map_tool = GIMP_IMAGE_MAP_TOOL (object);
+  klass          = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
+
+  if (klass->get_operation)
+    image_map_tool->operation = klass->get_operation (image_map_tool);
+
+  return object;
+}
+
 static void
 gimp_image_map_tool_finalize (GObject *object)
 {
@@ -323,7 +347,7 @@
 
       gtk_widget_show (vbox);
 
-      if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool)->get_operation)
+      if (image_map_tool->operation)
         g_signal_connect_object (tool_info->gimp->config, "notify::use-gegl",
                                  G_CALLBACK (gimp_image_map_tool_gegl_notify),
                                  image_map_tool, 0);
@@ -476,9 +500,6 @@
       g_object_unref (tool->image_map);
     }
 
-  if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->get_operation)
-    tool->operation = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->get_operation (tool);
-
   g_assert (tool->operation || tool->apply_func);
 
   use_gegl = (config->use_gegl || ! tool->apply_func);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]