Re: [g-a-devel]Re: gnome-mag fixage (patch)
- From: Michael Meeks <michael ximian com>
- To: Bill Haneman <bill haneman sun com>
- Cc: accessibility mailing list <gnome-accessibility-devel gnome org>
- Subject: Re: [g-a-devel]Re: gnome-mag fixage (patch)
- Date: 10 Dec 2002 10:31:07 +0000
Hi Bill,
On Mon, 2002-12-09 at 17:43, Bill Haneman wrote:
> Thanks for the patch. It looks good overall. However there are a
> couple of issues, I'll mention them below [BH]. If you don't mind
> making the changes I mention below, than feel free to commit.
I've committed - I attach the patch I committed - I did a few things
slightly differently - but at least this will give us smaller diffs next
time:
> * copyright; LGPL please
Doh - didn't read the patch; someone added COPYING to CVS without CVS
noticing (for me).
> * please let's use bonobo_object_from_servant throughout
Whatever - it's longer and no better, but if you insist.
> * some typos (I mention them in comments [BH]).
I saw only one, fixed that.
> [BH] Ah, no, since a single unref is not guaranteed to dispose the region.
> This method is probably bogus, but still...
I re-wrote these two methods so they do actually do 'dispose-like'
things, splitting the code from the GObject dispose. It's totally
unacceptable to have a loop that unrefs to 0, especially when it relies
on trampling on undefined memory to see if it's finished:
- while (IS_MAGNIFIER(magnifier) &&
- G_OBJECT (magnifier)->ref_count)
- bonobo_object_unref (BONOBO_OBJECT (magnifier));
may well be (one) of the crasher bugs now gone that was killing my
magnification experience.
> [BH] This looks like pointless churn, except for the removal of
> 'dirty-bounds-any'. Honestly, we need a better diff ;-)
Ah - but it makes the code look beautiful - and there is great merit in
it being a joy to read - then perhaps more people will read / fix it ;-)
apologies for the noise though. I didn't anticipate such a re-working.
> [BH] Should be else if, not 'if'.
fixed.
> [BH] Typo, regression.
fixed.
> [BH] This was BONOBO_ARG_INT, not BONOBO_ARG_LONG.
No difference - BONOBO_ARG_INT is an imaginary type for long term
suffering C programmers ;-) it's actually a CORBA_tk_long.
> [BH] Odd, I thought we were using lone-brackets (i.e. bracket on its own
> line).
The style was fairly grotesquely eclectic - it's now I think less so on
the whole.
> [BH] Why are we not using the standard bonobo_object_from_servant()
> here?
Fixed all of those.
> [BH] object_from_servant again. Also, I think we should retain the old
> behavior of un-reffing to zero, even though I agree that it's quite a
> nasty thing to do to a client. I think this method is marked deprecated
> in the docs, if not, we'll do that straightaway.
I re-wrote that; at least now the dispose method is safe and does
something useful [ for those too lazy to get ref counting right ;-].
HTH,
Michael.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-mag/ChangeLog,v
retrieving revision 1.30
diff -u -p -u -r1.30 ChangeLog
--- ChangeLog 12 Nov 2002 18:57:01 -0000 1.30
+++ ChangeLog 10 Dec 2002 10:28:39 -0000
@@ -1,3 +1,55 @@
+2002-12-10 Michael Meeks <michael ximian com>
+
+ * magnifier/magnifier.c (magnifier_do_dispose): split.
+ (magnifier_gobject_dispose, impl_magnifier_dispose): upd.
+
+ * magnifier/zoom-region.c (zoom_region_do_dispose):
+ split & protect from double disposes.
+ (impl_zoom_region_dispose, zoom_region_dispose): use it.
+
+2002-12-09 Michael Meeks <michael ximian com>
+
+ * magnifier/zoom-region.c (zoom_region_paint_cursor),
+ (zoom_region_calculate_scroll_rects),
+ (zoom_region_scroll_smooth): exit if we don't have drawable.
+
+ * magnifier/magnifier.c (magnifier_get_type): kill.
+ (magnifier_new): upd.
+ (impl_magnifier_dispose): upd.
+ (impl_magnifier_create_zoom_region): plug leak.
+ (magnifier_properties_init): don't leak default args
+ on properties that are non-writeable.
+
+ * magnifier/magnifier-main.c
+ (magnifier_main_test_image): make test_i_foo a
+ local static at least.
+
+ * magnifier/zoom-region.c
+ (impl_zoom_region_set_mag_factor): dup/ref pb.
+ (zoom_region_update_pointer_timeout): remove evil
+ check for ->priv == 0xaaaaaaa ie. what might be
+ in freed memory if you're lucky.
+ (zoom_region_class_init): use GObject dispose,
+ not the epv version.
+ (zoom_region_dispose): fix several evilnesses.
+ (zoom_region_get_type): kill.
+ (zoom_region_finalize): chain to parent.
+ (zoom_region_get_source_subwindow): bin ugly static we
+ re-allocate each time anyway.
+ (impl_zoom_region_dispose): for compat, just do
+ an unref.
+ calm compile warnings, kill PropData, PropIdx
+
+ * magnifier/magnifier.c (impl_magnifier_create_zoom_region),
+ (impl_magnifier_get_properties): dup/ref/rel/unref the pb.
+
+ * magnifier/magnifier-main.c (main): re-write to
+ use bonobo_pbclient stuff.
+ (magnifier_main_refresh_all): release/unref the pb.
+
+ * magnifier/zoom-region.c (impl_zoom_region_dispose):
+ don't g_idle_remove_by_data 3 times.
+
2002-11-12 Bill Haneman <bill haneman sun com>
Fixes for bugzilla 95942 and 98236.
Index: magnifier/magnifier-main.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier-main.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 magnifier-main.c
--- magnifier/magnifier-main.c 12 Nov 2002 18:57:05 -0000 1.12
+++ magnifier/magnifier-main.c 10 Dec 2002 10:28:39 -0000
@@ -120,44 +120,39 @@ init_rect_bounds (GNOME_Magnifier_RectBo
bounds->y2 = y2;
}
-static int test_i_foo = 0;
-
static int
magnifier_main_test_image (gpointer data)
{
- Magnifier *magnifier = (Magnifier *) data;
- GNOME_Magnifier_ZoomRegionList *zoom_regions;
- GNOME_Magnifier_ZoomRegion zoom_region;
- CORBA_Environment ev;
- GNOME_Magnifier_RectBounds roi;
+ static int test_i_foo = 0;
+ Magnifier *magnifier = (Magnifier *) data;
+ GNOME_Magnifier_ZoomRegionList *zoom_regions;
+ CORBA_Environment ev;
+ GNOME_Magnifier_RectBounds roi;
+ CORBA_exception_init (&ev);
- CORBA_exception_init (&ev);
+ roi.x1 = 10 * test_i_foo;
+ roi.y1 = 10 * test_i_foo;
+ roi.x2 = 200 + 10 * test_i_foo;
+ roi.y2 = 200 + 10 * test_i_foo;
+ ++test_i_foo;
+
+ if (!IS_MAGNIFIER (magnifier))
+ return FALSE;
+ magnifier->priv->cursor_x = (roi.x2 + roi.x1) / 2;
+ magnifier->priv->cursor_y = (roi.y2 + roi.y1) / 2;
+ zoom_regions =
+ GNOME_Magnifier_Magnifier_getZoomRegions (
+ BONOBO_OBJREF (magnifier),
+ &ev);
- roi.x1 = 10 * test_i_foo;
- roi.y1 = 10 * test_i_foo;
- roi.x2 = 200 + 10 * test_i_foo;
- roi.y2 = 200 + 10 * test_i_foo;
- ++test_i_foo;
-
- if (!IS_MAGNIFIER (magnifier)) return FALSE;
- magnifier->priv->cursor_x = (roi.x2 + roi.x1) / 2;
- magnifier->priv->cursor_y = (roi.y2 + roi.y1) / 2;
- zoom_regions =
- GNOME_Magnifier_Magnifier_getZoomRegions (
- BONOBO_OBJREF (magnifier),
- &ev);
- if (zoom_regions && (zoom_regions->_length > 0)) {
- zoom_region = CORBA_Object_duplicate (
- ( (CORBA_Object *) (zoom_regions->_buffer))[0], &ev);
- if (zoom_region != CORBA_OBJECT_NIL) {
- GNOME_Magnifier_ZoomRegion_setROI (zoom_region,
- &roi,
- &ev);
- } else fprintf (stderr, "nil region!\n");
- }
+ if (zoom_regions && (zoom_regions->_length > 0))
+ GNOME_Magnifier_ZoomRegion_setROI (
+ zoom_regions->_buffer[0], &roi, &ev);
- if (test_i_foo < 50) return TRUE;
- return FALSE;
+ if (test_i_foo < 50)
+ return TRUE;
+
+ return FALSE;
}
static int last_x = 0, last_y = 0;
@@ -175,7 +170,7 @@ magnifier_main_pan_image (gpointer data)
GdkModifierType mask_return;
CORBA_exception_init (&ev);
-
+
if (global_options.mouse_follow && IS_MAGNIFIER (magnifier))
{
gdk_window_get_pointer (
@@ -226,39 +221,46 @@ magnifier_main_pan_image (gpointer data)
static int
magnifier_main_refresh_all (gpointer data)
{
+ int i;
Magnifier *magnifier = data;
- CORBA_Environment ev;
CORBA_any *dirty_bounds_any;
- GNOME_Magnifier_ZoomRegionList *regions;
- GNOME_Magnifier_RectBounds *dirty_bounds;
- GNOME_Magnifier_ZoomRegion region;
+ CORBA_Environment ev;
Bonobo_PropertyBag properties;
- int i;
+ GNOME_Magnifier_RectBounds *dirty_bounds;
+ GNOME_Magnifier_ZoomRegionList *regions;
CORBA_exception_init (&ev);
- if (!IS_MAGNIFIER (magnifier)) return FALSE;
+ if (!IS_MAGNIFIER (magnifier))
+ return FALSE;
regions = GNOME_Magnifier_Magnifier_getZoomRegions (
BONOBO_OBJREF (magnifier),
&ev);
+#ifdef DEBUG
fprintf (stderr, "refreshing %d regions\n", regions->_length);
+#endif
properties = GNOME_Magnifier_Magnifier_getProperties (BONOBO_OBJREF
(magnifier), &ev);
+
dirty_bounds_any = Bonobo_PropertyBag_getValue (properties,
"source-display-size", &ev);
+ if (BONOBO_EX (&ev)) {
+ g_warning ("Error getting source-display-size");
+ bonobo_main_quit ();
+ return FALSE;
+ }
+
dirty_bounds = (GNOME_Magnifier_RectBounds *)
dirty_bounds_any->_value;
/*
fprintf (stderr, "region to update: %d %d %d %d\n",
dirty_bounds->x1, dirty_bounds->y1, dirty_bounds->x2,
dirty_bounds->y2);
*/
- for (i = 0; i < regions->_length; ++i) {
- region = CORBA_Object_duplicate (regions->_buffer[i], &ev);
+ for (i = 0; i < regions->_length; ++i)
GNOME_Magnifier_ZoomRegion_markDirty (
- region,
- ORBit_copy_value (dirty_bounds,
- TC_GNOME_Magnifier_RectBounds),
- &ev);
- }
+ regions->_buffer [i], dirty_bounds, &ev);
+
+ bonobo_object_release_unref (properties, NULL);
+
return TRUE;
}
@@ -302,56 +304,24 @@ main (int argc, char** argv)
if (ev._major != CORBA_NO_EXCEPTION) fprintf (stderr, "EXCEPTION\n");
if (global_options.source_display)
- {
- BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
- /* TODO: do we need to free the bonobo arg after this call? */
- BONOBO_ARG_SET_STRING (arg, global_options.source_display);
- Bonobo_PropertyBag_setValue (properties, "source-display-screen",
- arg,
- &ev);
- }
- if (global_options.target_display)
- {
- BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
- /* TODO: do we need to free the bonobo arg after this call? */
- BONOBO_ARG_SET_STRING (arg, global_options.target_display);
- Bonobo_PropertyBag_setValue (properties, "target-display-screen",
- arg,
- &ev);
- }
+ bonobo_pbclient_set_string (properties, "source-display-screen",
+ global_options.source_display, NULL);
+
if (global_options.target_display)
- {
- BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
- /* TODO: do we need to free the bonobo arg after this call? */
- BONOBO_ARG_SET_STRING (arg, global_options.cursor_set);
- Bonobo_PropertyBag_setValue (properties, "cursor-set",
- arg,
- &ev);
- }
+ bonobo_pbclient_set_string (properties, "target-display-screen",
+ global_options.target_display, NULL);
+
if (global_options.cursor_size)
- {
- BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_INT);
- BONOBO_ARG_SET_INT (arg, global_options.cursor_size);
- Bonobo_PropertyBag_setValue (properties, "cursor-size",
- arg,
- &ev);
- }
+ bonobo_pbclient_set_long (properties, "cursor-size",
+ global_options.cursor_size, NULL);
+
else if (global_options.cursor_scale_factor != 1.0F)
- {
- BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_FLOAT);
- BONOBO_ARG_SET_FLOAT (arg, global_options.cursor_scale_factor);
- Bonobo_PropertyBag_setValue (properties, "cursor-scale-factor",
- arg,
- &ev);
- }
+ bonobo_pbclient_set_float (properties, "cursor-scale-factor",
+ global_options.cursor_scale_factor, NULL);
+
if (global_options.cursor_color)
- {
- BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_LONG);
- BONOBO_ARG_SET_LONG (arg, global_options.cursor_color);
- Bonobo_PropertyBag_setValue (properties, "cursor-color",
- arg,
- &ev);
- }
+ bonobo_pbclient_set_long (properties, "cursor-color",
+ global_options.cursor_color, NULL);
w = gdk_screen_get_width (
gdk_display_get_screen (magnifier->target_display,
magnifier->target_screen_num));
@@ -380,12 +350,15 @@ main (int argc, char** argv)
viewport_any,
&ev);
+ bonobo_object_release_unref (properties, NULL);
+ properties = NULL;
+
if (global_options.vertical_split ||
global_options.horizontal_split ||
global_options.fullscreen)
{
- GNOME_Magnifier_ZoomRegion zoom_region;
int scroll_policy;
+ GNOME_Magnifier_ZoomRegion zoom_region;
fprintf (stderr, "creating an initial zoom region.\n");
init_rect_bounds (roi, 0, 0, 100, 100);
@@ -404,55 +377,52 @@ main (int argc, char** argv)
scroll_policy = global_options.smooth_scroll ?
GNOME_Magnifier_ZoomRegion_SCROLL_SMOOTHEST :
GNOME_Magnifier_ZoomRegion_SCROLL_FASTEST;
- if (ev._major != CORBA_NO_EXCEPTION) fprintf (stderr,
"EXCEPTION\n");
- Bonobo_PropertyBag_setValue (properties, "smooth-scroll-policy",
- bonobo_arg_new_from (
- BONOBO_ARG_INT, &scroll_policy),
- &ev);
- Bonobo_PropertyBag_setValue (properties, "border-size",
- bonobo_arg_new_from (
- BONOBO_ARG_INT, &global_options.border_width),
- &ev);
- Bonobo_PropertyBag_setValue (properties, "border-color",
- bonobo_arg_new_from (
- BONOBO_ARG_LONG, &global_options.border_color),
- &ev);
- Bonobo_PropertyBag_setValue (properties, "use-test-pattern",
- bonobo_arg_new_from (
- BONOBO_ARG_BOOLEAN, &global_options.test_pattern),
- &ev);
+ if (BONOBO_EX (&ev))
+ fprintf (stderr, "EXCEPTION\n");
+
+ bonobo_pbclient_set_boolean (properties, "smooth-scroll-policy",
+ scroll_policy, &ev);
+ bonobo_pbclient_set_long (properties, "border_size",
+ global_options.border_width, &ev);
+ bonobo_pbclient_set_long (properties, "border-color",
+ global_options.border_color, &ev);
+ bonobo_pbclient_set_boolean (properties, "use-test-pattern",
+ global_options.test_pattern, &ev);
+
if (strcmp (global_options.smoothing_type, "none"))
- {
- BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
- /* TODO: do we need to free the bonobo arg after this call? */
- BONOBO_ARG_SET_STRING (arg, global_options.smoothing_type);
- Bonobo_PropertyBag_setValue (properties, "smoothing-type",
- arg,
- &ev);
- }
+ bonobo_pbclient_set_string (properties, "smoothing-type",
+ global_options.smoothing_type, &ev);
+
if (global_options.invert_image)
- Bonobo_PropertyBag_setValue (properties, "inverse-video",
- bonobo_arg_new_from (
- BONOBO_ARG_BOOLEAN,
- &global_options.invert_image),
- &ev);
+ bonobo_pbclient_set_boolean (properties, "inverse-video",
+ global_options.invert_image, NULL);
+
GNOME_Magnifier_Magnifier_addZoomRegion (
BONOBO_OBJREF (magnifier),
zoom_region,
&ev);
- }
- if (!global_options.timing_test)
- {
- refresh_handle = gtk_timeout_add(global_options.refresh_time,
magnifier_main_refresh_all, magnifier);
- pan_handle = gtk_timeout_add(global_options.mouse_poll_time,
magnifier_main_pan_image, magnifier);
+ bonobo_object_release_unref (properties, &ev);
+ properties = NULL;
}
- else
- refresh_handle = gtk_timeout_add(global_options.refresh_time,
magnifier_main_test_image, magnifier);
+
+ if (!global_options.timing_test) {
+ refresh_handle = gtk_timeout_add (
+ global_options.refresh_time,
+ magnifier_main_refresh_all, magnifier);
+
+ pan_handle = gtk_timeout_add (
+ global_options.mouse_poll_time,
+ magnifier_main_pan_image, magnifier);
+ } else
+ refresh_handle = gtk_timeout_add (
+ global_options.refresh_time,
+ magnifier_main_test_image, magnifier);
bonobo_main ();
gtk_timeout_remove (refresh_handle);
+
if (pan_handle)
gtk_timeout_remove (pan_handle);
Index: magnifier/magnifier.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier.c,v
retrieving revision 1.22
diff -u -p -u -r1.22 magnifier.c
--- magnifier/magnifier.c 12 Nov 2002 18:57:05 -0000 1.22
+++ magnifier/magnifier.c 10 Dec 2002 10:28:40 -0000
@@ -34,10 +34,7 @@
#include "zoom-region-private.h"
#include "GNOME_Magnifier.h"
-/*
- * Our parent GObject type
- */
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
+static GObjectClass *parent_class = NULL;
enum {
MAGNIFIER_SOURCE_DISPLAY_PROP,
@@ -55,8 +52,6 @@ enum {
MAGNIFIER_CROSSWIRE_COLOR_PROP
} PropIdx;
-static BonoboObjectClass *parent_class;
-
static void
magnifier_realize (GtkWidget *widget)
{
@@ -66,8 +61,7 @@ magnifier_realize (GtkWidget *widget)
static gboolean initialized = FALSE;
- if (!initialized)
- {
+ if (!initialized) {
wm_window_protocols[0] = gdk_x11_get_xatom_by_name
("WM_DELETE_WINDOW");
wm_window_protocols[1] = gdk_x11_get_xatom_by_name ("_NET_WM_PING");
/* use DOCK until Metacity RFE for new window type goes in */
@@ -94,9 +88,9 @@ magnifier_realize (GtkWidget *widget)
}
static void
-magnifier_exit()
+magnifier_exit (GtkObject *object)
{
- gtk_exit(0);
+ gtk_exit (0);
}
static gint
@@ -466,9 +460,9 @@ magnifier_set_property (BonoboPropertyBa
}
static void
-magnifier_gobject_dispose (GObject *object)
+magnifier_do_dispose (Magnifier *magnifier)
{
- Magnifier *magnifier = MAGNIFIER (object);
+ /* FIXME: this is dead ropey code structuring */
bonobo_activation_active_server_unregister (
MAGNIFIER_OAFIID, BONOBO_OBJREF (magnifier));
@@ -476,27 +470,34 @@ magnifier_gobject_dispose (GObject *obje
if (magnifier->zoom_regions)
g_list_free (magnifier->zoom_regions);
magnifier->zoom_regions = NULL;
- G_OBJECT_CLASS (parent_class)->dispose (object);
+
bonobo_main_quit ();
}
static void
+magnifier_gobject_dispose (GObject *object)
+{
+ magnifier_do_dispose (MAGNIFIER (object));
+
+ BONOBO_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
+}
+
+static void
impl_magnifier_set_source_display (PortableServer_Servant servant,
const CORBA_char *display,
CORBA_Environment *ev)
{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant
(servant));
- BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
- BONOBO_ARG_SET_STRING (arg, display);
-
- magnifier_set_property (magnifier->property_bag,
- arg,
- MAGNIFIER_SOURCE_DISPLAY_PROP,
- ev,
- magnifier);
+ Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant
(servant));
+ BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
+ BONOBO_ARG_SET_STRING (arg, display);
+
+ magnifier_set_property (magnifier->property_bag,
+ arg,
+ MAGNIFIER_SOURCE_DISPLAY_PROP,
+ ev,
+ magnifier);
- bonobo_arg_release (arg);
-
+ bonobo_arg_release (arg);
}
static void
@@ -504,18 +505,17 @@ impl_magnifier_set_target_display (Porta
const CORBA_char *display,
CORBA_Environment *ev)
{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant
(servant));
- BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
- BONOBO_ARG_SET_STRING (arg, display);
-
- magnifier_set_property (magnifier->property_bag,
- arg,
- MAGNIFIER_TARGET_DISPLAY_PROP,
- ev,
- magnifier);
+ Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant
(servant));
+ BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
+ BONOBO_ARG_SET_STRING (arg, display);
+
+ magnifier_set_property (magnifier->property_bag,
+ arg,
+ MAGNIFIER_TARGET_DISPLAY_PROP,
+ ev,
+ magnifier);
- bonobo_arg_release (arg);
-
+ bonobo_arg_release (arg);
}
static GNOME_Magnifier_ZoomRegion
@@ -526,13 +526,11 @@ impl_magnifier_create_zoom_region (Porta
const GNOME_Magnifier_RectBounds *viewport,
CORBA_Environment *ev)
{
- Magnifier *magnifier =
- MAGNIFIER (bonobo_object_from_servant (servant));
- GNOME_Magnifier_ZoomRegion retval;
- CORBA_any *viewport_any =
- CORBA_any__alloc ();
- Bonobo_PropertyBag properties;
+ Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant
(servant));
+ CORBA_any viewport_any;
ZoomRegion *zoom_region = zoom_region_new ();
+ Bonobo_PropertyBag properties;
+ GNOME_Magnifier_ZoomRegion retval;
/* FIXME:
* shouldn't do this here, since it causes the region to get
@@ -544,20 +542,24 @@ impl_magnifier_create_zoom_region (Porta
/* XXX: should check ev after each call, below */
CORBA_exception_init (ev);
GNOME_Magnifier_ZoomRegion_setMagFactor (retval, zx, zy, ev);
- if (ev->_major != CORBA_NO_EXCEPTION) fprintf (stderr, "EXCEPTION
setMagFactor\n");
+
+ if (ev->_major != CORBA_NO_EXCEPTION)
+ fprintf (stderr, "EXCEPTION setMagFactor\n");
+
CORBA_exception_init (ev);
properties = GNOME_Magnifier_ZoomRegion_getProperties (retval, ev);
- if (ev->_major != CORBA_NO_EXCEPTION) fprintf (stderr, "EXCEPTION
getProperties\n");
- viewport_any->_type = TC_GNOME_Magnifier_RectBounds;
- viewport_any->_value = ORBit_copy_value (viewport,
- TC_GNOME_Magnifier_RectBounds);
+ if (ev->_major != CORBA_NO_EXCEPTION)
+ fprintf (stderr, "EXCEPTION getProperties\n");
+
+ viewport_any._type = TC_GNOME_Magnifier_RectBounds;
+ viewport_any._value = (gpointer) viewport;
Bonobo_PropertyBag_setValue (
- properties,
- "viewport",
- viewport_any,
- ev);
+ properties, "viewport", &viewport_any, ev);
+
GNOME_Magnifier_ZoomRegion_setROI (retval, roi, ev);
- if (ev->_major != CORBA_NO_EXCEPTION) fprintf (stderr, "EXCEPTION
setROI\n");
+ if (ev->_major != CORBA_NO_EXCEPTION)
+ fprintf (stderr, "EXCEPTION setROI\n");
+
CORBA_exception_init (ev);
gtk_widget_set_size_request (magnifier->priv->canvas,
@@ -565,6 +567,8 @@ impl_magnifier_create_zoom_region (Porta
viewport->y2 - viewport->y1);
gtk_widget_show (magnifier->priv->canvas);
gtk_widget_show (magnifier->priv->w);
+
+ bonobo_object_release_unref (properties, ev);
return CORBA_Object_duplicate (retval, ev);
}
@@ -575,9 +579,11 @@ impl_magnifier_add_zoom_region (Portable
const GNOME_Magnifier_ZoomRegion region,
CORBA_Environment * ev)
{
- Magnifier *magnifier =
- MAGNIFIER (bonobo_object_from_servant (servant));
+ Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant
(servant));
+
+ /* FIXME: this needs proper lifecycle management */
magnifier->zoom_regions = g_list_append (magnifier->zoom_regions,
region);
+
return CORBA_TRUE;
}
@@ -585,10 +591,9 @@ static Bonobo_PropertyBag
impl_magnifier_get_properties (PortableServer_Servant servant,
CORBA_Environment *ev)
{
- Magnifier *magnifier =
- MAGNIFIER (bonobo_object_from_servant (servant));
+ Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant
(servant));
- return CORBA_Object_duplicate (
+ return bonobo_object_dup_ref (
BONOBO_OBJREF (magnifier->property_bag), ev);
}
@@ -609,7 +614,7 @@ impl_magnifier_get_zoom_regions (Portabl
list->_buffer =
GNOME_Magnifier_ZoomRegionList_allocbuf (list->_length);
for (i = 0; i < len; ++i) {
- objref = g_list_nth_data (magnifier->zoom_regions, i);
+ objref = g_list_nth_data (magnifier->zoom_regions, i);
list->_buffer [i] =
CORBA_Object_duplicate (objref, ev);
}
@@ -622,21 +627,21 @@ static void
impl_magnifier_clear_all_zoom_regions (PortableServer_Servant servant,
CORBA_Environment * ev)
{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant
(servant));
- fprintf (stderr, "Destroying all zoom regions!\n");
- g_list_foreach (magnifier->zoom_regions, magnifier_unref_zoom_region,
magnifier);
- g_list_free (magnifier->zoom_regions);
- magnifier->zoom_regions = NULL;
+ Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant
(servant));
+
+ fprintf (stderr, "Destroying all zoom regions!\n");
+ g_list_foreach (magnifier->zoom_regions,
+ magnifier_unref_zoom_region, magnifier);
+ g_list_free (magnifier->zoom_regions);
+ magnifier->zoom_regions = NULL;
}
static void
impl_magnifier_dispose (PortableServer_Servant servant,
CORBA_Environment *ev)
{
- Magnifier *magnifier =
- MAGNIFIER (bonobo_object_from_servant (servant));
- while (IS_MAGNIFIER(magnifier) && G_OBJECT (magnifier)->ref_count)
- bonobo_object_unref (BONOBO_OBJECT (magnifier));
+ magnifier_do_dispose (
+ MAGNIFIER (bonobo_object_from_servant (servant)));
}
static void
@@ -645,9 +650,7 @@ magnifier_class_init (MagnifierClass *kl
GObjectClass * object_class = (GObjectClass *) klass;
POA_GNOME_Magnifier_Magnifier__epv *epv = &klass->epv;
- object_class->dispose = magnifier_gobject_dispose;
-
- parent_class = g_type_class_ref (BONOBO_OBJECT_TYPE);
+ object_class->dispose = magnifier_gobject_dispose;
epv->_set_SourceDisplay = impl_magnifier_set_source_display;
epv->_set_TargetDisplay = impl_magnifier_set_target_display;
@@ -677,25 +680,19 @@ magnifier_properties_init (Magnifier *ma
bonobo_object_add_interface (BONOBO_OBJECT (magnifier),
BONOBO_OBJECT (magnifier->property_bag));
- def = bonobo_arg_new (BONOBO_ARG_STRING);
- BONOBO_ARG_SET_STRING (def, getenv ("DISPLAY"));
-
bonobo_property_bag_add (magnifier->property_bag,
"source-display-screen",
MAGNIFIER_SOURCE_DISPLAY_PROP,
BONOBO_ARG_STRING,
- def,
+ NULL,
"source display screen",
Bonobo_PROPERTY_WRITEABLE);
- def = bonobo_arg_new (BONOBO_ARG_STRING);
- BONOBO_ARG_SET_STRING (def, getenv ("DISPLAY"));
-
bonobo_property_bag_add (magnifier->property_bag,
"target-display-screen",
MAGNIFIER_TARGET_DISPLAY_PROP,
BONOBO_ARG_STRING,
- def,
+ NULL,
"target display screen",
Bonobo_PROPERTY_WRITEABLE);
@@ -800,7 +797,6 @@ magnifier_properties_init (Magnifier *ma
Bonobo_PROPERTY_WRITEABLE);
}
-
static void
magnifier_init (Magnifier *magnifier)
{
@@ -855,53 +851,18 @@ GdkDrawable *
magnifier_get_cursor (Magnifier *magnifier)
{
if (!magnifier->priv->cursor)
- {
magnifier_init_cursor (magnifier);
- }
- return magnifier->priv->cursor;
-}
-GType
-magnifier_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (MagnifierClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) magnifier_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (Magnifier),
- 0, /* n preallocs */
- (GInstanceInitFunc) magnifier_init,
- NULL /* value table */
- };
- /*
- * Here we use bonobo_type_unique instead of
- * gtk_type_unique, this auto-generates a load of
- * CORBA structures for us. All derived types must
- * use bonobo_type_unique.
- */
- type = bonobo_type_unique (
- PARENT_TYPE,
- POA_GNOME_Magnifier_Magnifier__init,
- NULL,
- G_STRUCT_OFFSET (MagnifierClass, epv),
- &tinfo,
- "Magnifier");
- }
-
- return type;
+ return magnifier->priv->cursor;
}
Magnifier *
magnifier_new (int argc, char **argv)
{
- Magnifier *magnifier =
- MAGNIFIER (g_object_new (magnifier_get_type(), NULL));
-
- return magnifier;
+ return g_object_new (magnifier_get_type(), NULL);
}
+
+BONOBO_TYPE_FUNC_FULL (Magnifier,
+ GNOME_Magnifier_Magnifier,
+ BONOBO_TYPE_OBJECT,
+ magnifier);
Index: magnifier/zoom-region.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/zoom-region.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 zoom-region.c
--- magnifier/zoom-region.c 12 Nov 2002 18:57:05 -0000 1.12
+++ magnifier/zoom-region.c 10 Dec 2002 10:28:41 -0000
@@ -36,10 +36,7 @@
#include "magnifier.h" /* needed to access parent data */
#include "magnifier-private.h" /* needed to access parent data */
-/*
- * Our parent GObject type
- */
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
+static GObjectClass *parent_class = NULL;
enum {
ZOOM_REGION_MANAGED_PROP,
@@ -57,20 +54,12 @@ enum {
ZOOM_REGION_TESTPATTERN_PROP
} PropIdx;
-typedef union {
- gint i;
- glong l;
- gboolean b;
- gfloat f;
- gdouble d;
- char *s;
- GNOME_Magnifier_RectBounds r;
-} PropData;
-
+#ifdef TEST_XTST_CURSOR
static Cursor *x_cursors;
static Window cursor_window = None;
+#endif
-static gboolean can_coalesce = True; /* change this when event
coalescing is working */
+static gboolean can_coalesce = TRUE ; /* change this when event
coalescing is working */
static void zoom_region_sync (ZoomRegion *region);
static void zoom_region_finalize (GObject *object);
@@ -99,6 +88,7 @@ _debug_announce_rect (char *msg, GdkRect
msg, rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);
}
+#ifdef TEST_XTST_CURSOR
/** util stuff **/
static Cursor *
_get_x_cursors (Display *display)
@@ -120,6 +110,7 @@ _get_x_cursors (Display *display)
}
return x_cursors;
}
+#endif
static gboolean
_diff_pixbufs (const GdkPixbuf *a, const GdkPixbuf *b)
@@ -136,8 +127,10 @@ _diff_pixbufs (const GdkPixbuf *a, const
gdk_pixbuf_get_n_channels (a)/ bits_per_byte;
long n_rows = gdk_pixbuf_get_height (a);
- if (gdk_pixbuf_get_height (b) != n_rows) return True;
- if (gdk_pixbuf_get_width (b) != gdk_pixbuf_get_width (a)) return True;
+ if (gdk_pixbuf_get_height (b) != n_rows)
+ return TRUE;
+ if (gdk_pixbuf_get_width (b) != gdk_pixbuf_get_width (a))
+ return TRUE;
for (j = 0; j < n_rows; ++j)
{
cpa = pa + j * rsa;
@@ -146,13 +139,13 @@ _diff_pixbufs (const GdkPixbuf *a, const
{
if (*cpa != *cpb)
{
- return True;
+ return TRUE;
}
cpa++;
cpb++;
}
}
- return False;
+ return FALSE;
}
/** EVENT COALESCING **/
@@ -165,19 +158,19 @@ _diff_pixbufs (const GdkPixbuf *a, const
* a: the first GdkRectangle, which will be changed to the new bounds
if
* coalesce operation can be performed, otherwise unchanged.
* b: the second GdkRectangle.
- * returns: True if the two are coalesced, False otherwise.
+ * returns: True if the two are coalesced, FALSE otherwise.
**/
static gboolean
_combine_rects (GdkRectangle *a, GdkRectangle *b)
{
- gboolean can_combine = False;
+ gboolean can_combine = FALSE;
if ((a->x == b->x) && (a->x + a->width == b->x + b->width))
{
- can_combine = True;
+ can_combine = TRUE;
}
else if ((a->y == b->y) && (a->y + a->height == b->y + b->height))
{
- can_combine = True;
+ can_combine = TRUE;
}
if (can_combine)
{
@@ -187,11 +180,11 @@ _combine_rects (GdkRectangle *a, GdkRect
{
gdk_rectangle_union (a, b, &c);
*a = c;
- can_combine = True;
+ can_combine = TRUE;
}
else
{
- can_combine = False;
+ can_combine = FALSE;
}
}
return can_combine;
@@ -207,13 +200,13 @@ _combine_rects (GdkRectangle *a, GdkRect
* oooooo into oooxxx
* oooooo oooxxx
*
- * returns: True if the refactor was performed, False if it could not
be
+ * returns: TRUE if the refactor was performed, FALSE if it could not
be
* completed (i.e. if the rectangles did not form a suitable
union).
**/
static gboolean
_refactor_rects (GdkRectangle *p, GdkRectangle *n)
{
- gboolean refactored = False;
+ gboolean refactored = FALSE;
GdkRectangle *a, *b;
if (p->x == n->x)
{
@@ -233,14 +226,14 @@ _refactor_rects (GdkRectangle *p, GdkRec
a->height += b->height;
b->x += a->width;
b->width -= a->width;
- refactored = True;
+ refactored = TRUE;
}
else if (a->y + a->height == b->y)
{
a->height += b->height;
b->x += a->width;
b->width -= a->width;
- refactored = True;
+ refactored = TRUE;
}
if (refactored) fprintf (stderr, "REFACTOR 1\n");
}
@@ -262,14 +255,14 @@ _refactor_rects (GdkRectangle *p, GdkRec
a->width += b->width;
b->y += a->height;
b->height -= a->height;
- refactored = True;
+ refactored = TRUE;
}
else if (a->x + a->width == b->x)
{
a->width += b->width;
b->y += a->height;
b->height -= a->height;
- refactored = True;
+ refactored = TRUE;
}
if (refactored) fprintf (stderr, "REFACTOR 2\n");
}
@@ -290,13 +283,13 @@ _refactor_rects (GdkRectangle *p, GdkRec
a->y -= b->height;
a->height += b->height;
b->width -= a->width;
- refactored = True;
+ refactored = TRUE;
}
else if (a->y + a->height == b->y)
{
a->height += b->height;
b->width -= a->width;
- refactored = True;
+ refactored = TRUE;
}
if (refactored) fprintf (stderr, "REFACTOR 3\n");
}
@@ -317,13 +310,13 @@ _refactor_rects (GdkRectangle *p, GdkRec
a->x -= b->width;
a->width += b->width;
b->height -= a->height;
- refactored = True;
+ refactored = TRUE;
}
else if (a->x + a->width == b->x)
{
a->width += b->width;
b->height -= a->height;
- refactored = True;
+ refactored = TRUE;
}
if (refactored) fprintf (stderr, "REFACTOR 4\n");
}
@@ -601,7 +594,7 @@ zoom_region_cursor_rect (ZoomRegion *zoo
rect = zoom_region_view_rect_from_source_rect (zoom_region, rect);
rect.x -= magnifier->cursor_hotspot.x;
rect.y -= magnifier->cursor_hotspot.y;
- gdk_drawable_get_size (magnifier->priv->cursor, &rect.width,
&rect.height);
+ gdk_drawable_get_size (cursor, &rect.width, &rect.height);
}
return rect;
}
@@ -642,6 +635,7 @@ zoom_region_paint_crosswire_cursor (Zoom
int x_left_clip, x_right_clip = 0, y_top_clip, y_bottom_clip = 0;
int csize;
GdkRectangle rect;
+ GdkDrawable *cursor;
if (!(magnifier && zoom_region->priv->w &&
zoom_region->priv->w->window &&
@@ -670,10 +664,10 @@ zoom_region_paint_crosswire_cursor (Zoom
rect = zoom_region_view_rect_from_source_rect (zoom_region, rect);
if (clip_rect) gdk_gc_set_clip_rectangle (gc, clip_rect);
- if (magnifier->crosswire_clip)
+ if (magnifier->crosswire_clip &&
+ (cursor = magnifier_get_cursor (magnifier)))
{
- gdk_drawable_get_size (magnifier_get_cursor (magnifier),
- &csize, &csize);
+ gdk_drawable_get_size (cursor, &csize, &csize);
y_top_clip = rect.y - magnifier->cursor_hotspot.y -
magnifier->crosswire_size;
y_bottom_clip = rect.y +
@@ -703,17 +697,17 @@ zoom_region_paint_crosswire_cursor (Zoom
{
if (magnifier->crosswire_clip )
{
- gdk_draw_rectangle (zoom_region->priv->w->window, gc, True,
+ gdk_draw_rectangle (zoom_region->priv->w->window, gc, TRUE,
rect.x - magnifier->crosswire_size / 2,
0, magnifier->crosswire_size, y_top_clip);
- gdk_draw_rectangle (zoom_region->priv->w->window, gc, True, 0,
+ gdk_draw_rectangle (zoom_region->priv->w->window, gc, TRUE, 0,
rect.y - magnifier->crosswire_size / 2,
x_left_clip, magnifier->crosswire_size);
}
- gdk_draw_rectangle (zoom_region->priv->w->window, gc, True,
+ gdk_draw_rectangle (zoom_region->priv->w->window, gc, TRUE,
rect.x - magnifier->crosswire_size / 2,
x_right_clip, magnifier->crosswire_size, 4096);
- gdk_draw_rectangle (zoom_region->priv->w->window, gc, True,
y_bottom_clip,
+ gdk_draw_rectangle (zoom_region->priv->w->window, gc, TRUE,
y_bottom_clip,
rect.y - magnifier->crosswire_size / 2,
4096, magnifier->crosswire_size);
}
@@ -744,6 +738,8 @@ zoom_region_paint_cursor (ZoomRegion *zo
int width, height;
GdkGC *gc = gdk_gc_new (zoom_region->priv->w->window);
GdkDrawable *cursor = magnifier_get_cursor (magnifier);
+ if (!cursor)
+ return;
zoom_region->priv->cursor_backing_rect = rect;
gdk_drawable_get_size (zoom_region->priv->cursor_backing_pixels,
&width, &height);
@@ -831,14 +827,16 @@ zoom_region_paint_border (ZoomRegion *zo
color.red = (zoom_region->border_color & 0xFF0000) >> 16;
color.green = (zoom_region->border_color & 0xFF00) >> 8;
color.blue = zoom_region->border_color & 0xFF;
+#ifdef DEBUG
fprintf (stderr, "border color triple RGB=%d|%d|%d",
color.red, color.green, color.blue);
+#endif
gdk_gc_set_foreground (zoom_region->priv->border_gc, &color);
}
/*
gdk_draw_rectangle (zoom_region->priv->w->window,
zoom_region->priv->border_gc,
- True,
+ TRUE,
area->x,
area->y,
area->width,
@@ -943,7 +941,10 @@ zoom_region_calculate_scroll_rects (Zoom
zoom_region->priv->w->window)
window = zoom_region->priv->w->window;
else
- return False;
+ return FALSE;
+ if (!window)
+ return FALSE;
+
gdk_drawable_get_size (GDK_DRAWABLE (window),
&rect.width,
&rect.height);
@@ -1000,6 +1001,9 @@ zoom_region_scroll_smooth (ZoomRegion *z
{
GdkWindow *window = zoom_region->priv->w->window;
GdkRectangle window_rect;
+
+ if (!window)
+ return;
window_rect.x = 0;
window_rect.y = 0;
gdk_drawable_get_size (GDK_DRAWABLE (window),
@@ -1080,6 +1084,7 @@ zoom_region_set_cursor_pos (ZoomRegion *
}
}
+#ifdef TEST_XTST_CURSOR
static GdkWindow *
zoom_region_source_root (ZoomRegion *zoom_region)
{
@@ -1091,6 +1096,7 @@ zoom_region_source_root (ZoomRegion *zoo
return gdk_screen_get_root_window (source_screen);
else return NULL;
}
+#endif
static gboolean
zoom_region_update_pointer (ZoomRegion *zoom_region, gboolean
draw_cursor)
@@ -1160,7 +1166,7 @@ zoom_region_update_pointer (ZoomRegion *
magnifier->target_display));
XSync (GDK_DISPLAY_XDISPLAY (
magnifier->target_display),
- False);
+ FALSE);
}
XSynchronize (display, FALSE);
if (cursor_id >= max_cursors) cursor_id = -1;
@@ -1211,16 +1217,15 @@ static int
zoom_region_update_pointer_timeout (gpointer data)
{
ZoomRegion *zoom_region = data;
- /* FIXME: test below is a hack */
- if (!zoom_region->priv == 0xaaaaaaaa) return FALSE;
+
if (zoom_region_update_pointer (zoom_region, TRUE)) {
g_idle_add_full (G_PRIORITY_HIGH_IDLE,
zoom_region_update_pointer_idle,
data,
NULL);
return FALSE;
- }
- else return TRUE;
+ } else
+ return TRUE;
}
static void
@@ -1285,9 +1290,6 @@ zoom_region_post_process_pixbuf (ZoomReg
**/
}
-
-static GdkImage *__image = NULL; /* TESTING ONLY */
-
static GdkPixbuf *
zoom_region_get_source_subwindow (ZoomRegion *zoom_region,
const GdkRectangle bounds)
@@ -1309,19 +1311,21 @@ zoom_region_get_source_subwindow (ZoomRe
if (!zoom_region->priv->source_drawable)
{
if (zoom_region->priv->test) {
- __image = gdk_image_new (GDK_IMAGE_FASTEST,
- gdk_visual_get_system (),
- width,
- height);
+ GdkImage *test_image = NULL;
+
+ test_image = gdk_image_new (GDK_IMAGE_FASTEST,
+ gdk_visual_get_system (),
+ width,
+ height);
for (i = 0; i < width; ++i)
for (j = 0; j < height; ++j)
- gdk_image_put_pixel (__image, i, j, i*j);
+ gdk_image_put_pixel (test_image, i, j, i*j);
zoom_region->priv->source_drawable = gdk_pixmap_new (NULL, width,
height, 24);
gdk_draw_image (zoom_region->priv->source_drawable,
gdk_gc_new (zoom_region->priv->source_drawable),
- __image,
+ test_image,
0, 0,
0, 0,
width, height);
@@ -1338,7 +1342,7 @@ zoom_region_get_source_subwindow (ZoomRe
{
zoom_region->priv->source_pixbuf_cache =
gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- False,
+ FALSE,
8, /* FIXME: not always 8? */
width, height);
}
@@ -1555,9 +1559,11 @@ zoom_region_set_viewport (ZoomRegion *zo
const GNOME_Magnifier_RectBounds *viewport)
{
zoom_region->viewport = *viewport;
+#ifdef DEBUG
fprintf (stderr, "setting viewport %d,%d - %d,%d\n",
(int) viewport->x1, (int) viewport->y1,
(int) viewport->x2, (int) viewport->y2);
+#endif
zoom_region_recompute_exposed_viewport (zoom_region);
zoom_region_align (zoom_region);
if (!zoom_region->priv->w) {
@@ -1740,7 +1746,6 @@ impl_zoom_region_set_mag_factor (Portabl
{
ZoomRegion *zoom_region =
ZOOM_REGION (bonobo_object_from_servant (servant));
- GNOME_Magnifier_RectBounds *source_bounds;
CORBA_any *any;
/* TODO: assert that parent is magnifier object */
Bonobo_PropertyBag properties =
@@ -1749,27 +1754,30 @@ impl_zoom_region_set_mag_factor (Portabl
(Magnifier *) zoom_region->priv->parent), ev);
any = Bonobo_PropertyBag_getValue (
properties, "source-display-size", ev);
- source_bounds = (GNOME_Magnifier_RectBounds *) any->_value;
+ if (!BONOBO_EX (ev))
+ zoom_region->priv->source_area =
+ *((GNOME_Magnifier_RectBounds *) any->_value);
zoom_region->xscale = mag_factor_x;
zoom_region->yscale = mag_factor_y;
- zoom_region->priv->source_area = *source_bounds;
-
if (zoom_region->priv->scaled_pixbuf)
g_object_unref (zoom_region->priv->scaled_pixbuf);
+
zoom_region->priv->scaled_pixbuf = gdk_pixbuf_new (
GDK_COLORSPACE_RGB, FALSE, 8,
zoom_region->priv->source_area.x2 -
zoom_region->priv->source_area.x1 * zoom_region->xscale + 1,
zoom_region->priv->source_area.y2 -
zoom_region->priv->source_area.y1 * zoom_region->yscale + 1);
- if (zoom_region->priv->pixmap)
- {
+
+ if (zoom_region->priv->pixmap) {
g_object_unref (zoom_region->priv->pixmap);
zoom_region->priv->pixmap = NULL;
}
zoom_region_update_current (zoom_region);
zoom_region_sync (zoom_region);
+
+ bonobo_object_release_unref (properties, NULL);
}
static void
@@ -1790,8 +1798,7 @@ impl_zoom_region_get_properties (Portabl
{
ZoomRegion *zoom_region =
ZOOM_REGION (bonobo_object_from_servant (servant));
- fprintf (stderr, "getting zoom region property-bag\n");
- return CORBA_Object_duplicate (
+ return bonobo_object_dup_ref (
BONOBO_OBJREF (zoom_region->properties), ev);
}
@@ -1811,7 +1818,7 @@ impl_zoom_region_mark_dirty (PortableSer
static GNOME_Magnifier_RectBounds
impl_zoom_region_get_roi (PortableServer_Servant servant,
- CORBA_Environment * ev)
+ CORBA_Environment *ev)
{
ZoomRegion *zoom_region =
ZOOM_REGION (bonobo_object_from_servant (servant));
@@ -1819,9 +1826,9 @@ impl_zoom_region_get_roi (PortableServer
}
static void
-impl_zoom_region_move_resize (PortableServer_Servant servant,
+impl_zoom_region_move_resize (PortableServer_Servant
servant,
const GNOME_Magnifier_RectBounds *viewport_bounds,
- CORBA_Environment * ev)
+ CORBA_Environment *ev)
{
ZoomRegion *zoom_region =
ZOOM_REGION (bonobo_object_from_servant (servant));
@@ -1829,19 +1836,34 @@ impl_zoom_region_move_resize (PortableSe
}
static void
+zoom_region_do_dispose (ZoomRegion *zoom_region)
+{
+ if (zoom_region->priv->expose_handler_id) {
+ g_signal_handler_disconnect (
+ zoom_region->priv->w,
+ zoom_region->priv->expose_handler_id);
+ zoom_region->priv->expose_handler_id = 0;
+ }
+ g_idle_remove_by_data (zoom_region);
+}
+
+static void
impl_zoom_region_dispose (PortableServer_Servant servant,
- CORBA_Environment * ev)
+ CORBA_Environment *ev)
{
ZoomRegion *zoom_region =
ZOOM_REGION (bonobo_object_from_servant (servant));
- fprintf (stderr, "zoom region destroyed!\n");
- gtk_signal_disconnect (GTK_OBJECT (zoom_region->priv->w),
- zoom_region->priv->expose_handler_id);
- g_idle_remove_by_data (zoom_region); /* 3 times? well, we have
several...*/
- g_idle_remove_by_data (zoom_region);
- g_idle_remove_by_data (zoom_region);
- g_idle_remove_by_data (zoom_region);
- bonobo_object_unref (BONOBO_OBJECT (zoom_region));
+ zoom_region_do_dispose (zoom_region);
+}
+
+static void
+zoom_region_dispose (GObject *object)
+{
+ ZoomRegion *zoom_region = ZOOM_REGION (object);
+
+ zoom_region_do_dispose (zoom_region);
+
+ BONOBO_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
}
static void
@@ -1849,8 +1871,9 @@ zoom_region_class_init (ZoomRegionClass
{
GObjectClass * object_class = (GObjectClass *) klass;
POA_GNOME_Magnifier_ZoomRegion__epv *epv = &klass->epv;
-
- object_class->finalize = zoom_region_finalize; /* TODO */
+
+ object_class->dispose = zoom_region_dispose;
+ object_class->finalize = zoom_region_finalize;
epv->setMagFactor = impl_zoom_region_set_mag_factor;
epv->getMagFactor = impl_zoom_region_get_mag_factor;
@@ -2047,7 +2070,7 @@ zoom_region_private_init (ZoomRegionPriv
priv->border_gc = NULL;
priv->gdk_interp_type = GDK_INTERP_NEAREST;
priv->expose_handler_id = 0;
- priv->test = False;
+ priv->test = FALSE;
}
static void
@@ -2056,8 +2079,8 @@ zoom_region_init (ZoomRegion *zoom_regio
zoom_region_properties_init (zoom_region);
zoom_region->smooth_scroll_policy =
GNOME_Magnifier_ZoomRegion_SCROLL_FASTEST;
- zoom_region->invert = False;
- zoom_region->cache_source = False;
+ zoom_region->invert = FALSE;
+ zoom_region->cache_source = FALSE;
zoom_region->border_size = 0;
zoom_region->border_color = 0;
zoom_region->roi.x1 = 0;
@@ -2078,65 +2101,35 @@ zoom_region_init (ZoomRegion *zoom_regio
NULL);
}
-GType
-zoom_region_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (ZoomRegionClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) zoom_region_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (ZoomRegion),
- 0, /* n preallocs */
- (GInstanceInitFunc) zoom_region_init,
- NULL /* value table */
- };
- /*
- * Here we use bonobo_type_unique instead of
- * gtk_type_unique, this auto-generates a load of
- * CORBA structures for us. All derived types must
- * use bonobo_type_unique.
- */
- type = bonobo_type_unique (
- PARENT_TYPE,
- POA_GNOME_Magnifier_ZoomRegion__init,
- NULL,
- G_STRUCT_OFFSET (ZoomRegionClass, epv),
- &tinfo,
- "ZoomRegion");
- }
-
- return type;
-}
-
ZoomRegion *
-zoom_region_new ()
+zoom_region_new (void)
{
- ZoomRegion *zoom_region =
- ZOOM_REGION (g_object_new (zoom_region_get_type(), NULL));
- return zoom_region;
+ return g_object_new (zoom_region_get_type(), NULL);
}
static void
zoom_region_finalize (GObject *region)
{
- ZoomRegion *zoom_region = (ZoomRegion *) region;
- g_list_free (zoom_region->priv->q);
- gtk_container_remove (GTK_CONTAINER (zoom_region->priv->border),
- GTK_WIDGET (zoom_region->priv->w));
- gtk_container_remove (GTK_CONTAINER (((Magnifier *)
- zoom_region->priv->parent)->priv->canvas),
- GTK_WIDGET (zoom_region->priv->border));
- g_object_unref (G_OBJECT (zoom_region->priv->source_pixbuf_cache));
- g_object_unref (G_OBJECT (zoom_region->priv->scaled_pixbuf));
- g_object_unref (G_OBJECT (zoom_region->priv->pixmap));
- g_object_unref (G_OBJECT (zoom_region->priv->cursor_backing_pixels));
- g_object_unref (G_OBJECT (zoom_region->priv->border_gc));
- g_free (zoom_region->priv);
- zoom_region->priv = NULL;
-}
+ ZoomRegion *zoom_region = (ZoomRegion *) region;
+
+ g_list_free (zoom_region->priv->q);
+ gtk_container_remove (GTK_CONTAINER (zoom_region->priv->border),
+ GTK_WIDGET (zoom_region->priv->w));
+ gtk_container_remove (GTK_CONTAINER (((Magnifier *)
+ zoom_region->priv->parent)->priv->canvas),
+ GTK_WIDGET (zoom_region->priv->border));
+ g_object_unref (zoom_region->priv->source_pixbuf_cache);
+ g_object_unref (zoom_region->priv->scaled_pixbuf);
+ g_object_unref (zoom_region->priv->pixmap);
+ g_object_unref (zoom_region->priv->cursor_backing_pixels);
+ g_object_unref (zoom_region->priv->border_gc);
+ g_free (zoom_region->priv);
+ zoom_region->priv = NULL;
+
+ BONOBO_CALL_PARENT (G_OBJECT_CLASS, finalize, (region));
+}
+
+BONOBO_TYPE_FUNC_FULL (ZoomRegion,
+ GNOME_Magnifier_ZoomRegion,
+ BONOBO_TYPE_OBJECT,
+ zoom_region);
--
mmeeks gnu org <><, Pseudo Engineer, itinerant idiot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]