summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Haneman <billh@src.gnome.org>2002-09-24 16:54:51 +0000
committerBill Haneman <billh@src.gnome.org>2002-09-24 16:54:51 +0000
commitb4d6a1388a8c57c21192b658ac70603645554de4 (patch)
tree3dea8bb112c4122c6cf0d3f62245ef6f03bfe814
parent002ec345ce7a47f6cb2b9859ecbce078efddce71 (diff)
New version of Magnifier that uses new IDL.
-rw-r--r--ChangeLog89
-rw-r--r--idl/GNOME_Magnifier.idl168
-rw-r--r--magnifier/Makefile.am4
-rw-r--r--magnifier/mag_image.c12
-rw-r--r--magnifier/magnifier.c482
-rw-r--r--magnifier/magnifier.h13
-rw-r--r--magnifier/zoom-region.c489
-rw-r--r--magnifier/zoom-region.h69
8 files changed, 1050 insertions, 276 deletions
diff --git a/ChangeLog b/ChangeLog
index d65ba67..7d0c1d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,92 @@
+2002-09-24 Bill Haneman <bill.haneman@sun.com>
+
+ * idl/GNOME_Magnifier.idl:
+ Major revision of Magnifier API.
+ (#includes):
+ Now we include (and thus depend on) Bonobo_Property.idl.
+ (namespace):
+ Now our interfaces are in the GNOME/Magnifier namespace.
+ (setMagFactor):
+ No longer a oneway method.
+ (markDirty, markUnmanaged):
+ Moved to ZoomRegion.
+ (SourceDisplay, TargetDisplay):
+ Changed to BonoboProperty properties.
+ (getProperties): new method.
+ (setROI): moved to ZoomRegion,
+ changed to take RectBounds struct instead of
+ individual longs as in params.
+ (getROI): move to ZoomRegion, now return a RectBounds.
+ (exit): changed to dispose().
+ (resize): moved to ZoomRegion.
+ (getZoomRegionParams): Changed to getProperties() call on
+ the ZoomRegion object.
+ (destroyZoomRegion): Removed, replaced with dispose() and
+ de-referencing of the ZoomRegion object via unref().
+ (addZoomRegion): new method.
+ (general):
+ Created new GNOME_Magnifier_ZoomRegion interface,
+ and return a sequence of ZoomRegions from the Magnifier.
+ Defined a new RectBounds structure, for manipulating
+ bounding boxes.
+ Most methods now operate on these ZoomRegion objects
+ rather than the containing Magnifier.
+ Most properties and settings on both Magnifier and
+ ZoomRegion are now via Bonobo_PropertyBag,
+ which is implemented on Magnifier and ZoomRegion, and
+ available via getProperties() methods on the two
+ interface types.
+
+ * magnifier/Makefile.am:
+ Added zoom-region.h and zoom-region.c to
+ magnifier_SOURCES.
+ Added libgnome-mag.la to LDADD.
+
+ * magnifier/magnifier.c:
+ (#includes):
+ Added "xoom-region.h" and "GNOME_Magnifier.h".
+ (PropIdx):
+ New enum.
+ (impl_magnifier_fullscreen): Removed.
+ (impl_magnifier_set_extents): Removed.
+ (impl_magnifier_set_follow_mouse): Removed.
+ (impl_magnifier_set_contrast): Removed.
+ (impl_magnifier_set_roi): Removed.
+ (impl_magnifier_goto): Removed.
+ (impl_magnifier_set_mag_factor): Removed.
+ (impl_magnifier_mark_dirty): Removed.
+ (impl_magnifier_mark_unmanaged): Removed.
+ (impl_magnifier_get_zoom_region_params): Removed.
+ (impl_magnifier_remove_zoom_region): Removed.
+ (impl_magnifier_resize_zoom_region): Removed.
+ (impl_magnifier_create_zoom_region): Modified for new args.
+ (impl_magnifier_add_zoom_region): New method.
+ (impl_magnifier_get_zoom_regions): New method.
+ (impl_magnifier_exit): changed to impl_magnifier_dispose().
+ (impl_magnifier_destroy): tweaked for new implementation.
+ (magnifier_get_property): New method.
+ (magnifier_set_property): New method.
+ (impl_magnifier_set_source_display): Changed to use properties.
+ (impl_magnifier_set_target_display): Changed to use properties.
+ (magnifier_class_init): Changed to use new IDL methods.
+ (magnifier_instance_init): Changed to use new IDL methods.
+ (magnifier_properties_init): New method.
+ (magnifier_get_type): Changes for new namespace.
+
+ * magnifier/magnifier.h:
+ (Magnifier):
+ Changed Magnifier struct to include members for new properties.
+ (MagnifierClass):
+ Changed POA typename to match new namespace.
+
+ * magnifier/zoom-image.h:
+ New file; implementation of GNOME_Magnifier_ZoomRegion.
+
+ * magnifier/zoom-image.c:
+ New file; structure/type definitions of
+ ZoomRegion BonoboObject which implements
+ GNOME_Magnifier_ZoomRegion.
+
2002-09-02 Kenneth Rohde Christiansen <kenneth@gnu.org>
* po/: Added dir
diff --git a/idl/GNOME_Magnifier.idl b/idl/GNOME_Magnifier.idl
index c9c92dc..340a1d9 100644
--- a/idl/GNOME_Magnifier.idl
+++ b/idl/GNOME_Magnifier.idl
@@ -24,116 +24,133 @@
#define _GNOME_MAGNIFIER_IDL
#include <Bonobo_Unknown.idl>
+#include <Bonobo_Property.idl>
module GNOME {
+ module Magnifier {
+
+ struct RectBounds {
+ long x1, y1, x2, y2;
+ };
- interface Magnifier : Bonobo::Unknown {
+ interface ZoomRegion : Bonobo::Unknown {
/**
* void setMagFactor: sets the current x and y magnification ratio.
- * @zoom_region: the index of the affected zoom region.
+ * (Convenience method for setting mag-factor-x and mag-factor-y properties).
* @magX: the magnification factor in the x direction for the specified region.
* @magY: the magnification factor in the x direction for the specified region.
**/
- oneway void setMagFactor (in short zoom_region, in float magX, in float magY);
+ void setMagFactor (in float magX, in float magY);
/**
- * #attribute SourceDisplay: a @string containing the X display name
- * containing the region to be magnified.
+ * void getMagFactor: gets the current x and y magnification ratios.
+ * (Convenience method for getting mag-factor-x and mag-factor-y properties).
+ * @magX: the magnification factor in the x direction for the specified region.
+ * @magY: the magnification factor in the x direction for the specified region.
**/
- attribute string SourceDisplay;
+ void getMagFactor (out float magX, out float magY);
/**
- * #attribute TargetDisplay: a @string containing the X display name
- * where the magnifier pixels are to be displayed.
+ * PropertyBag getProperties: gets the current property settings for this ZoomRegion.
+ * Properties managed by the ZoomRegion include "smoothing-type", "contrast",
+ * "inverse-video", "border-size", "border-color", "x-alignment", "y-alignment",
+ * "is-managed", "viewport", "mag-factor-x", "mag-factor-y".
+ * returns: a Bonobo::PropertyBag containing the ZoomRegion's properties.
**/
- attribute string TargetDisplay;
+ Bonobo::PropertyBag getProperties ();
/**
* oneway void setROI:
* Sets the region of interest for the magnifier.
- * @zoom_region: the index of the affected zoom region.
- * @x1: the minimum X coordinate of the ROI bounding box
- * @x2: the maximum X coordinate of the ROI bounding box
- * @y1: the minimum Y coordinate of the ROI bounding box
- * @y2: the maximum Y coordinate of the ROI bounding box
+ * @bounds: the ROI bounding box
**/
- oneway void setROI (in short zoom_region,
- in long x1, in long y1, in long x2, in long y2);
+ oneway void setROI (in RectBounds bounds);
/**
- * oneway void setROI:
- * Sets the region of interest for the zoom region.
- * If the zoom region was previously 'unmanaged', this associates
- * it with the ROI.
- * @zoom_region: the index of the affected zoom region.
- * @x1: the minimum X coordinate of the ROI bounding box
- * @x2: the maximum X coordinate of the ROI bounding box
- * @y1: the minimum Y coordinate of the ROI bounding box
- * @y2: the maximum Y coordinate of the ROI bounding box
- **/
- oneway void markDirty (in short zoom_region,
- in long x1, in long y1, in long x2, in long y2);
+ * void markDirty:
+ * Marks the zoom region or a sub-region 'dirty' and in need of updating.
+ * @dirtyRegion: the bounding box of the dirty region.
+ **/
+ void markDirty (in RectBounds dirtyRegion);
/**
- * oneway void markUnmanaged:
- * Mark a zoom region as 'unmanaged', meaning that it should not
- * attempt to get pixels from the source display but will have its
- * pixels drawn by a client.
- * @zoom_region: the index of the affected zoom region.
+ * RectBounds getROI:
+ * Queries a specific zoom region for its ROI.
+ * returns: the RectBounds bounding box of the zoom ROI.
**/
- oneway void markUnmanaged (in short zoom_region);
+ RectBounds getROI ();
/**
- * short createZoomRegion:
- * Creates a new zoom region for the magnifier.
- * The new region is initially unmanaged'.
- * @zx: the scale factor in the x direction for the new zoom region
- * @zy: the scale factor in the y direction for the new zoom region
- * @x1: the minimum X coordinate of the zoomed area bounding box
- * @x2: the maximum X coordinate of the zoomed area bounding box
- * @y1: the minimum Y coordinate of the zoomed area bounding box
- * @y2: the maximum Y coordinate of the zoomed area bounding box
+ * void resize:
+ * Resizes the specified zoom region on the target display.
+ * (Convenience method for setting "viewport" property).
+ * @bounds: the bounding box, in target display coordinates, of the ZoomRegion's
+ * display viewport.
+ **/
+ void resize (in RectBounds bounds);
+
+ /**
+ * void dispose:
+ * Remove the specified zoom region from the magnifier and destroy it.
+ **/
+ void dispose ();
+
+ };
+
+ interface Magnifier : Bonobo::Unknown {
+
+ /**
+ * #attribute SourceDisplay: a @string containing the X display name
+ * containing the region to be magnified.
**/
- short createZoomRegion (in float zx, in float zy,
- in long x1, in long y1,
- in long x2, in long y2);
+ attribute string SourceDisplay;
/**
- * boolean getZoomRegionParams:
- * Queries a specific zoom region for its parameters.
- * returns: FALSE if the specified zoom region does not exist.
- * @zoom_region: the index specifying which zoom region to query.
+ * #attribute TargetDisplay: a @string containing the X display name
+ * where the magnifier pixels are to be displayed.
+ **/
+ attribute string TargetDisplay;
+
+ /**
+ * PropertyBag getProperties: gets the current property settings for this Magnifier.
+ * Properties managed by the magnifier include "cursor-set", "cursor-size",
+ * "cursor-mag-factor", "target-display-size", "source-display-size".
+ * returns: a Bonobo::PropertyBag containing the Magnifier's properties.
+ **/
+ Bonobo::PropertyBag getProperties ();
+
+ typedef sequence<ZoomRegion> ZoomRegionList;
+
+ /**
+ * ZoomRegion createZoomRegion:
+ * Creates a new zoom region for the magnifier.
+ * The new region is initially unmanaged'.
* @zx: the scale factor in the x direction for the new zoom region
* @zy: the scale factor in the y direction for the new zoom region
- * @x1: the minimum X coordinate of the zoomed area bounding box
- * @x2: the maximum X coordinate of the zoomed area bounding box
- * @y1: the minimum Y coordinate of the zoomed area bounding box
- * @y2: the maximum Y coordinate of the zoomed area bounding box
+ * @ROI: the initial ROI of the zoom region. RectBounds of negative width/height
+ * indicates that the zoom region has no initial ROI.
+ * @viewport: the initial bounds of the ZoomRegion's viewport, in
+ * the target display coordinate system.
**/
- boolean getZoomRegionParams (in short zoom_region,
- out float zx, out float zy,
- out long x1, out long y1,
- out long x2, out long y2);
+ ZoomRegion createZoomRegion (in float zx, in float zy,
+ in RectBounds ROI,
+ in RectBounds viewport);
/**
- * void resizeZoomRegion:
- * Resizes the specified zoom region on the target display.
- * @zoom_region: the index of the affected zoom region.
- * @x1: the minimum X coordinate of the zoomed area bounding box
- * @x2: the maximum X coordinate of the zoomed area bounding box
- * @y1: the minimum Y coordinate of the zoomed area bounding box
- * @y2: the maximum Y coordinate of the zoomed area bounding box
+ * ZoomRegionList getZoomRegions:
+ * returns a ZoomRegionList including all currently defined ZoomRegions
+ * for this Magnifier instance.
**/
- oneway void resizeZoomRegion (in short zoom_region,
- in long x1, in long y1,
- in long x2, in long y2);
+ ZoomRegionList getZoomRegions ();
- /**
- * void destroyZoomRegion:
- * Remove the specified zoom region from the magnifier.
+ /**
+ * boolean addZoomRegion:
+ * add a new ZoomRegion to the list of currently defined ZoomRegions
+ * for this Magnifier instance.
+ * returns: #true if successful, #false if the ZoomRegion cannot be added.
**/
- oneway void destroyZoomRegion (in short zoom_region);
+ boolean addZoomRegion (in ZoomRegion region);
/**
* void clearAllZoomRegions:
@@ -142,11 +159,12 @@ module GNOME {
void clearAllZoomRegions ();
/**
- * void exit:
- * Unmap the current magnifier from the display.
+ * void dispose:
+ * Unmap the current magnifier from the display, destroy its resources, and exit.
**/
- void exit ();
+ void dispose ();
+ };
};
};
diff --git a/magnifier/Makefile.am b/magnifier/Makefile.am
index f069c3d..ad503cd 100644
--- a/magnifier/Makefile.am
+++ b/magnifier/Makefile.am
@@ -15,6 +15,8 @@ libgnomemagincludedir=$(includedir)/gnome-mag-1.0/magnifier
libgnomemaginclude_HEADERS=GNOME_Magnifier.h
magnifier_SOURCES = magnifier.c \
+ zoom-region.c \
+ zoom-region.h \
mag_image.c \
mag_image.h \
magnifier.h \
@@ -45,7 +47,7 @@ IDLFLAGS = -I$(BONOBO_ACTIVATION_IDL_DIR) \
orbittypelibdir = $(libdir)/orbit
-LDADD = $(DEPS_LIBS) $(X_LIBS) $(POPT_LIBS)
+LDADD = $(DEPS_LIBS) $(top_builddir)/magnifier/libgnome-mag.la $(X_LIBS) -lXft -lfontconfig $(POPT_LIBS)
server_in_files = GNOME_Magnifier.server.in.in
diff --git a/magnifier/mag_image.c b/magnifier/mag_image.c
index 61bb512..9b79864 100644
--- a/magnifier/mag_image.c
+++ b/magnifier/mag_image.c
@@ -268,6 +268,7 @@ int refresh_image (gpointer data)
DisplayHeight (mag_data->source_display,
mag_data->source_screen_num),
mag_data);
+
return TRUE;
}
@@ -399,6 +400,8 @@ void update_image(MagnifierData *mag_data)
mag_data);
}
+#define PULL_ON_EXPOSE
+
void
expose_event(GtkWidget * w, GdkEventExpose *event, gpointer data)
{
@@ -426,12 +429,13 @@ expose_event(GtkWidget * w, GdkEventExpose *event, gpointer data)
mag_data->source_screen_num) - subimage_y,
(event->area.height + (ey - ry))/mag_data->factor_y + 2);
+#ifdef PULL_ON_EXPOSE
pull_into_scaled_image (mag_data,
subimage_x,
subimage_y,
subimage_width,
subimage_height);
-
+#endif
gdk_pixbuf_render_to_drawable (scaled_image,
drawing_area->window,
drawing_area->style->fg_gc[GTK_STATE_NORMAL],
@@ -442,13 +446,11 @@ expose_event(GtkWidget * w, GdkEventExpose *event, gpointer data)
event->area.width - (ex - rx),
event->area.height - (ey - ry),
GDK_RGB_DITHER_NORMAL,0,0);
-
-/*
+
fprintf (stderr, "expose %d %d %d %d\n",
event->area.x, event->area.y,
event->area.width, event->area.height);
-*/
-
+
}
static void
diff --git a/magnifier/magnifier.c b/magnifier/magnifier.c
index c5b35bd..6c1a77d 100644
--- a/magnifier/magnifier.c
+++ b/magnifier/magnifier.c
@@ -24,7 +24,9 @@
#include <gdk/gdkwindow.h>
#include <libbonobo.h>
#include "magnifier.h"
+#include "zoom-region.h"
#include "mag_image.h"
+#include "GNOME_Magnifier.h"
#define ENV_STRING_MAX_SIZE 128
@@ -33,6 +35,16 @@
*/
#define PARENT_TYPE BONOBO_OBJECT_TYPE
+enum {
+ MAGNIFIER_SOURCE_DISPLAY_PROP,
+ MAGNIFIER_TARGET_DISPLAY_PROP,
+ MAGNIFIER_SOURCE_SIZE_PROP,
+ MAGNIFIER_TARGET_SIZE_PROP,
+ MAGNIFIER_CURSOR_SET_PROP,
+ MAGNIFIER_CURSOR_SIZE_PROP,
+ MAGNIFIER_CURSOR_ZOOM_PROP
+} PropIdx;
+
typedef struct {
gchar *target_display;
gchar *source_display;
@@ -240,7 +252,7 @@ main (int argc, char** argv)
gtk_container_add (GTK_CONTAINER (window),drawing_area);
gtk_widget_add_events(GTK_WIDGET(drawing_area),GDK_BUTTON_PRESS_MASK);
gtk_signal_connect (GTK_OBJECT (drawing_area),"expose_event",
- GTK_SIGNAL_FUNC(expose_event),magnifier->mag_data);
+ GTK_SIGNAL_FUNC(expose_event),magnifier->mag_data);
/* init image information */
if (!global_options.source_display) global_options.source_display = gdk_get_display();
@@ -328,8 +340,9 @@ main (int argc, char** argv)
if (global_options.timing_test == 0)
{
/* gtk_timeout_add(global_options.min_refresh_time, refresh_image, magnifier->mag_data); */
- refresh_image (magnifier->mag_data);
- g_idle_add(display_image, magnifier->mag_data);
+ refresh_image (magnifier->mag_data);
+ g_idle_add(display_image, magnifier->mag_data);
+
gtk_timeout_add(25, pan_image, magnifier->mag_data);
obj_id = "OAFIID:Accessibility_Util_Magnifier:proto0.1";
@@ -359,44 +372,90 @@ main (int argc, char** argv)
}
static void
-impl_magnifier_fullscreen (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->mag_width = DisplayWidth (magnifier->mag_data->target_display, screen_num);
- magnifier->mag_data->mag_height = DisplayHeight (magnifier->mag_data->target_display, screen_num);
-}
-
-static void
-impl_magnifier_set_extents (PortableServer_Servant servant,
- CORBA_long x1,
- CORBA_long y1,
- CORBA_long x2,
- CORBA_long y2,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->mag_width = x2 - x1;
- magnifier->mag_data->mag_height = y2 - y1;
- gdk_window_move(window->window, x1, y1);
-}
-
-static void
-impl_magnifier_set_follow_mouse (PortableServer_Servant servant,
- const CORBA_boolean follow_mouse,
- CORBA_Environment *ev)
+magnifier_get_property (BonoboPropertyBag *bag,
+ BonoboArg *arg,
+ guint arg_id,
+ CORBA_Environment *ev,
+ gpointer user_data)
{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->follow_mouse = (int) follow_mouse;
+ Magnifier *magnifier = user_data;
+ GNOME_Magnifier_RectBounds rect_bounds;
+
+ switch (arg_id) {
+ case MAGNIFIER_SOURCE_SIZE_PROP:
+ rect_bounds.x1 = 0;
+ rect_bounds.x2 = DisplayWidth (magnifier->source_display,
+ magnifier->source_screen_num);
+ rect_bounds.y1 = 0;
+ rect_bounds.y2 = DisplayHeight (magnifier->source_display,
+ magnifier->source_screen_num);
+ BONOBO_ARG_SET_GENERAL (arg, rect_bounds,
+ TC_GNOME_Magnifier_RectBounds,
+ GNOME_Magnifier_RectBounds, NULL);
+ break;
+ case MAGNIFIER_TARGET_SIZE_PROP:
+ rect_bounds.x1 = 0;
+ rect_bounds.x2 = DisplayWidth (magnifier->target_display,
+ magnifier->target_screen_num);
+ rect_bounds.y1 = 0;
+ rect_bounds.y2 = DisplayHeight (magnifier->target_display,
+ magnifier->target_screen_num);
+ BONOBO_ARG_SET_GENERAL (arg, rect_bounds,
+ TC_GNOME_Magnifier_RectBounds,
+ GNOME_Magnifier_RectBounds, NULL);
+ break;
+ case MAGNIFIER_CURSOR_SET_PROP:
+ BONOBO_ARG_SET_STRING (arg, magnifier->cursor_set);
+ break;
+ case MAGNIFIER_CURSOR_SIZE_PROP:
+ BONOBO_ARG_SET_INT (arg, magnifier->cursor_size);
+ break;
+ case MAGNIFIER_CURSOR_ZOOM_PROP:
+ BONOBO_ARG_SET_FLOAT (arg, magnifier->cursor_scale_factor);
+ break;
+ default:
+ bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
+ };
}
static void
-impl_magnifier_set_contrast (PortableServer_Servant servant,
- const CORBA_short contrast,
- CORBA_Environment *ev)
+magnifier_set_property (BonoboPropertyBag *bag,
+ BonoboArg *arg,
+ guint arg_id,
+ CORBA_Environment *ev,
+ gpointer user_data)
{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->contrast = (int) contrast;
+ Magnifier *magnifier = user_data;
+
+ switch (arg_id) {
+ case MAGNIFIER_SOURCE_DISPLAY_PROP:
+ magnifier->source_display =
+ XOpenDisplay (BONOBO_ARG_GET_STRING (arg));
+ magnifier->source_screen_num =
+ 0; /* TODO: FIXME! */
+ break;
+ case MAGNIFIER_TARGET_DISPLAY_PROP:
+ magnifier->target_display =
+ XOpenDisplay (BONOBO_ARG_GET_STRING (arg));
+ magnifier->target_screen_num =
+ 1; /* TODO: FIXME */
+ break;
+ case MAGNIFIER_SOURCE_SIZE_PROP:
+ case MAGNIFIER_TARGET_SIZE_PROP:
+ bonobo_exception_set (ev, ex_Bonobo_PropertyBag_ReadOnly);
+ break;
+ case MAGNIFIER_CURSOR_SET_PROP:
+ magnifier->cursor_set = BONOBO_ARG_GET_STRING (arg);
+ break;
+ case MAGNIFIER_CURSOR_SIZE_PROP:
+ magnifier->cursor_size = BONOBO_ARG_GET_INT (arg);
+ break;
+ case MAGNIFIER_CURSOR_ZOOM_PROP:
+ magnifier->cursor_scale_factor = BONOBO_ARG_GET_FLOAT (arg);
+ break;
+ default:
+ bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
+ };
}
static void
@@ -405,8 +464,19 @@ impl_magnifier_set_source_display (PortableServer_Servant servant,
CORBA_Environment *ev)
{
Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->source_display =
- XOpenDisplay (global_options.source_display);
+ 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);
+
+ magnifier->source_display =
+ XOpenDisplay (display);
}
static void
@@ -415,161 +485,93 @@ impl_magnifier_set_target_display (PortableServer_Servant servant,
CORBA_Environment *ev)
{
Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->target_display = GDK_DISPLAY();
-}
+ BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
+ BONOBO_ARG_SET_STRING (arg, display);
-static void
-impl_magnifier_goto (PortableServer_Servant servant,
- const CORBA_long x,
- const CORBA_long y,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->center.x = (int) x;
- magnifier->mag_data->center.y = (int) y;
- display_image (magnifier->mag_data);
-}
-
-static void
-impl_magnifier_set_roi (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- const CORBA_long x1,
- const CORBA_long y1,
- const CORBA_long x2,
- const CORBA_long y2,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->center.x = (int) ((x1 + x2)/2);
- magnifier->mag_data->center.y = (int) ((y1 + y2)/2);
- display_image (magnifier->mag_data);
-}
+ magnifier_set_property (magnifier->property_bag,
+ arg,
+ MAGNIFIER_TARGET_DISPLAY_PROP,
+ ev,
+ magnifier);
-static void
-impl_magnifier_set_mag_factor (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- const CORBA_float mag_factor_x,
- const CORBA_float mag_factor_y,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (zoom_region == (CORBA_short) 0) /* TODO: fix for multi-zoom-regions */
- {
- magnifier->mag_data->factor_x = (float) mag_factor_x;
- magnifier->mag_data->factor_y = (float) mag_factor_y;
- }
- scaled_image = gdk_pixbuf_new (GDK_COLORSPACE_RGB,FALSE, 8,
- DisplayWidth (magnifier->mag_data->source_display,screen_num)*magnifier->mag_data->factor_x,
- DisplayHeight(magnifier->mag_data->source_display,screen_num)*magnifier->mag_data->factor_y);
-
- display_image (magnifier->mag_data);
-}
-
-static void
-impl_magnifier_mark_dirty (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- const CORBA_long x1,
- const CORBA_long y1,
- const CORBA_long x2,
- const CORBA_long y2,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- /* TODO: implement */
- display_image (magnifier->mag_data);
-}
-
-static void
-impl_magnifier_mark_unmanaged (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- CORBA_Environment *ev)
-{
-/* Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant)); */
- /* TODO: implement */
+ bonobo_arg_release (arg);
+
+ magnifier->target_display =
+ XOpenDisplay (display);
}
-static CORBA_short
+static GNOME_Magnifier_ZoomRegion
impl_magnifier_create_zoom_region (PortableServer_Servant servant,
const CORBA_float zx,
const CORBA_float zy,
- const CORBA_long x1,
- const CORBA_long y1,
- const CORBA_long x2,
- const CORBA_long y2,
+ const GNOME_Magnifier_RectBounds *roi,
+ const GNOME_Magnifier_RectBounds *viewport,
CORBA_Environment *ev)
{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (magnifier->mag_data->zoom_regions == NULL)
- {
- magnifier->mag_data->zoom_regions =
- g_list_prepend (magnifier->mag_data->zoom_regions,
- g_new0 (ZoomRegionData, 1));
- magnifier->mag_data->factor_x = (int) zx;
- magnifier->mag_data->factor_y = (int) zy;
- magnifier->mag_data->mag_x = x1;
- magnifier->mag_data->mag_y = y1;
- magnifier->mag_data->mag_width = (x2 - x1);
- magnifier->mag_data->mag_height = (y2 - y1);
- magnifier_pack_regions (magnifier);
- return 0;
- }
- else
- {
- return -1;
- }
+ GNOME_Magnifier_ZoomRegion retval;
+ Bonobo_PropertyBag properties;
+
+ retval = BONOBO_OBJREF (zoom_region_new ());
+ /* XXX: should check ev after each call, below */
+ GNOME_Magnifier_ZoomRegion_setMagFactor (retval, zx, zy, ev);
+ GNOME_Magnifier_ZoomRegion_setROI (retval, roi, ev);
+ properties = GNOME_Magnifier_ZoomRegion_getProperties (retval, ev);
+ Bonobo_PropertyBag_setValue (properties,
+ CORBA_string_dup ("viewport"),
+ (CORBA_any *) viewport,
+ ev);
+ return retval;
}
-static CORBA_boolean
-impl_magnifier_get_zoom_region_params (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- CORBA_float * zx,
- CORBA_float * zy, CORBA_long * x1,
- CORBA_long * y1, CORBA_long * x2,
- CORBA_long * y2,
- CORBA_Environment * ev)
+static
+CORBA_boolean
+impl_magnifier_add_zoom_region (PortableServer_Servant servant,
+ const GNOME_Magnifier_ZoomRegion region,
+ CORBA_Environment * ev)
{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (zoom_region == (CORBA_short) 0)
- {
- *zx = magnifier->mag_data->factor_x;
- *zy = magnifier->mag_data->factor_y;
- *x1 = 0;
- *y1 = 0;
- *x2 = *x1 + magnifier->mag_data->mag_width;
- *y2 = *y1 + magnifier->mag_data->mag_height;
- return CORBA_TRUE;
- }
- else return CORBA_FALSE;
+ Magnifier *magnifier =
+ MAGNIFIER (bonobo_object_from_servant (servant));
+ g_list_append (magnifier->zoom_regions, region);
+ return CORBA_TRUE;
}
-static void
-impl_magnifier_resize_zoom_region (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- const CORBA_long x1, const CORBA_long y1,
- const CORBA_long x2, const CORBA_long y2,
- CORBA_Environment * ev)
+static Bonobo_PropertyBag
+impl_magnifier_get_properties (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (zoom_region == 0)
- {
- magnifier->mag_data->mag_x = x1;
- magnifier->mag_data->mag_y = y1;
- magnifier->mag_data->mag_width = (x2 - x1);
- magnifier->mag_data->mag_height = (y2 - y1);
- magnifier_pack_regions (magnifier);
- }
+ Magnifier *magnifier =
+ MAGNIFIER (bonobo_object_from_servant (servant));
+
+ return BONOBO_OBJREF (magnifier->property_bag);
}
-static void
-impl_magnifier_destroy_zoom_region (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- CORBA_Environment * ev)
+GNOME_Magnifier_Magnifier_ZoomRegionList *
+impl_magnifier_get_zoom_regions (PortableServer_Servant servant,
+ CORBA_Environment * ev)
{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (zoom_region == 0)
- {
- g_list_free (magnifier->mag_data->zoom_regions);
- }
+ Magnifier *magnifier =
+ MAGNIFIER (bonobo_object_from_servant (servant));
+
+ GNOME_Magnifier_Magnifier_ZoomRegionList *list;
+ CORBA_Object objref;
+ int i, len;
+
+ len = g_list_length (magnifier->zoom_regions);
+ list = GNOME_Magnifier_Magnifier_ZoomRegionList__alloc ();
+ list->_length = 1;
+ list->_buffer =
+ GNOME_Magnifier_Magnifier_ZoomRegionList_allocbuf (len);
+ for (i = 0; i < len; ++i) {
+ objref = BONOBO_OBJREF (
+ BONOBO_OBJECT (
+ g_list_nth_data (magnifier->zoom_regions, i)));
+
+ list->_buffer [i] =
+ CORBA_Object_duplicate (objref, ev);
+ }
+ CORBA_sequence_set_release (list, CORBA_TRUE);
+
+ return list;
}
static void
@@ -577,40 +579,131 @@ impl_magnifier_clear_all_zoom_regions (PortableServer_Servant servant,
CORBA_Environment * ev)
{
Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- g_list_free (magnifier->mag_data->zoom_regions);
- magnifier->mag_data->zoom_regions = NULL;
+ g_list_free (magnifier->zoom_regions);
+ magnifier->zoom_regions = NULL;
}
static void
-impl_magnifier_exit (PortableServer_Servant servant, CORBA_Environment *ev)
+impl_magnifier_dispose (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (magnifier->mag_data->zoom_regions)
- g_list_free (magnifier->mag_data->zoom_regions);
- g_free (magnifier->mag_data);
- magnifier_exit();
+ Magnifier *magnifier =
+ MAGNIFIER (bonobo_object_from_servant (servant));
+ g_list_free (magnifier->zoom_regions);
+ magnifier->zoom_regions = NULL;
+
+/* won't reuse impl until I figure out if servant needs to be
+ copied/duped before passing to another server-side
+ method...
+ impl_magnifier_clear_all_zoom_regions (servant, ev); */
+
+ bonobo_object_unref (BONOBO_OBJECT (magnifier->property_bag));
}
static void
magnifier_class_init (MagnifierClass *klass)
{
/* GObjectClass * object_class = (GObjectClass *) klass; */
- POA_GNOME_Magnifier__epv *epv = &klass->epv;
+ POA_GNOME_Magnifier_Magnifier__epv *epv = &klass->epv;
/*
object_class->finalize = magnifier_finalize;
*/
epv->_set_SourceDisplay = impl_magnifier_set_source_display;
epv->_set_TargetDisplay = impl_magnifier_set_target_display;
- epv->setROI = impl_magnifier_set_roi;
- epv->setMagFactor = impl_magnifier_set_mag_factor;
- epv->markDirty = impl_magnifier_mark_dirty;
- epv->markUnmanaged = impl_magnifier_mark_unmanaged;
+ epv->getProperties = impl_magnifier_get_properties;
+ epv->getZoomRegions = impl_magnifier_get_zoom_regions;
epv->createZoomRegion = impl_magnifier_create_zoom_region;
- epv->getZoomRegionParams = impl_magnifier_get_zoom_region_params;
- epv->resizeZoomRegion = impl_magnifier_resize_zoom_region;
- epv->destroyZoomRegion = impl_magnifier_destroy_zoom_region;
+ epv->addZoomRegion = impl_magnifier_add_zoom_region;
epv->clearAllZoomRegions = impl_magnifier_clear_all_zoom_regions;
- epv->exit = impl_magnifier_exit;
+ epv->dispose = impl_magnifier_dispose;
+}
+
+static void
+magnifier_properties_init (Magnifier *magnifier)
+{
+ BonoboArg *def;
+
+ magnifier->property_bag =
+ bonobo_property_bag_new_closure (
+ g_cclosure_new_object (
+ G_CALLBACK (magnifier_get_property),
+ G_OBJECT (magnifier)),
+ g_cclosure_new_object (
+ G_CALLBACK (magnifier_set_property),
+ G_OBJECT (magnifier)));
+
+ /* Aggregate so magnifier implements Bonobo_PropertyBag */
+ 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,
+ "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,
+ "target display screen",
+ Bonobo_PROPERTY_WRITEABLE);
+
+ bonobo_property_bag_add (magnifier->property_bag,
+ "source-display-size",
+ MAGNIFIER_SOURCE_SIZE_PROP,
+ TC_GNOME_Magnifier_RectBounds,
+ NULL,
+ "source display bounds/size",
+ Bonobo_PROPERTY_READABLE);
+
+ bonobo_property_bag_add (magnifier->property_bag,
+ "target-display-size",
+ MAGNIFIER_TARGET_SIZE_PROP,
+ TC_GNOME_Magnifier_RectBounds,
+ NULL,
+ "target display bounds/size",
+ Bonobo_PROPERTY_READABLE);
+
+ bonobo_property_bag_add (magnifier->property_bag,
+ "cursor-set",
+ MAGNIFIER_CURSOR_SET_PROP,
+ BONOBO_ARG_STRING,
+ NULL,
+ "name of cursor set",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ def = bonobo_arg_new (BONOBO_ARG_INT);
+ BONOBO_ARG_SET_INT (def, 64);
+
+ bonobo_property_bag_add (magnifier->property_bag,
+ "cursor-size",
+ MAGNIFIER_CURSOR_SIZE_PROP,
+ BONOBO_ARG_INT,
+ def,
+ "cursor size, in pixels",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ bonobo_property_bag_add (magnifier->property_bag,
+ "cursor-mag-factor",
+ MAGNIFIER_CURSOR_ZOOM_PROP,
+ BONOBO_ARG_FLOAT,
+ NULL,
+ "scale factor for cursors (overrides size)",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
}
static void
@@ -626,6 +719,9 @@ magnifier_init (Magnifier *magnifier)
magnifier->mag_data->center.y = 0;
magnifier->mag_data->interp_type = GDK_INTERP_NEAREST;
magnifier->mag_data->zoom_regions = NULL;
+
+ magnifier_properties_init (magnifier);
+ magnifier->zoom_regions = NULL;
}
GType
@@ -654,7 +750,7 @@ magnifier_get_type (void)
*/
type = bonobo_type_unique (
PARENT_TYPE,
- POA_GNOME_Magnifier__init,
+ POA_GNOME_Magnifier_Magnifier__init,
NULL,
G_STRUCT_OFFSET (MagnifierClass, epv),
&tinfo,
diff --git a/magnifier/magnifier.h b/magnifier/magnifier.h
index b8e28db..67fddab 100644
--- a/magnifier/magnifier.h
+++ b/magnifier/magnifier.h
@@ -40,12 +40,21 @@ extern "C" {
typedef struct {
BonoboObject parent;
- MagnifierData *mag_data;
+ BonoboPropertyBag *property_bag;
+ void *source_display;
+ void *target_display;
+ int source_screen_num;
+ int target_screen_num;
+ GList *zoom_regions;
+ gchar *cursor_set;
+ gint cursor_size;
+ float cursor_scale_factor;
+ MagnifierData *mag_data; /* TODO: remove this */
} Magnifier;
typedef struct {
BonoboObjectClass parent_class;
- POA_GNOME_Magnifier__epv epv;
+ POA_GNOME_Magnifier_Magnifier__epv epv;
} MagnifierClass;
GType magnifier_get_type (void);
diff --git a/magnifier/zoom-region.c b/magnifier/zoom-region.c
new file mode 100644
index 0000000..e44e5eb
--- /dev/null
+++ b/magnifier/zoom-region.c
@@ -0,0 +1,489 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <popt.h>
+#include <gdk/gdkwindow.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <libbonobo.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include "zoom-region.h"
+
+/*
+ * Our parent GObject type
+ */
+#define PARENT_TYPE BONOBO_OBJECT_TYPE
+
+enum {
+ ZOOM_REGION_MANAGED_PROP,
+ ZOOM_REGION_INVERT_PROP,
+ ZOOM_REGION_SMOOTHING_PROP,
+ ZOOM_REGION_CONTRAST_PROP,
+ ZOOM_REGION_XSCALE_PROP,
+ ZOOM_REGION_YSCALE_PROP,
+ ZOOM_REGION_BORDERSIZE_PROP,
+ ZOOM_REGION_BORDERCOLOR_PROP,
+ ZOOM_REGION_XALIGN_PROP,
+ ZOOM_REGION_YALIGN_PROP,
+ ZOOM_REGION_VIEWPORT_PROP
+} PropIdx;
+
+typedef union {
+ gint i;
+ glong l;
+ gboolean b;
+ gfloat f;
+ gdouble d;
+ char *s;
+ GNOME_Magnifier_RectBounds r;
+} PropData;
+
+static void zoom_region_display (ZoomRegion *region);
+static void zoom_region_finalize (GObject *object);
+
+static void
+zoom_region_realize (GtkWidget *widget)
+{
+ XWMHints wm_hints;
+ Atom wm_window_protocols[2];
+ static gboolean initialized = FALSE;
+
+ 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");
+ }
+
+ wm_hints.flags = InputHint;
+ wm_hints.input = False;
+
+ XSetWMHints (GDK_WINDOW_XDISPLAY (widget->window),
+ GDK_WINDOW_XWINDOW (widget->window), &wm_hints);
+
+ XSetWMProtocols (GDK_WINDOW_XDISPLAY (widget->window),
+ GDK_WINDOW_XWINDOW (widget->window), wm_window_protocols, 2);
+}
+
+static void
+zoom_region_display (ZoomRegion *zoom_region)
+{
+}
+
+static void
+zoom_region_get_property (BonoboPropertyBag *bag,
+ BonoboArg *arg,
+ guint arg_id,
+ CORBA_Environment *ev,
+ gpointer user_data)
+{
+ ZoomRegion *zoom_region = user_data;
+
+ switch (arg_id) {
+ case ZOOM_REGION_INVERT_PROP:
+ BONOBO_ARG_SET_BOOLEAN (arg, zoom_region->invert);
+ break;
+ case ZOOM_REGION_SMOOTHING_PROP:
+ BONOBO_ARG_SET_STRING (arg, zoom_region->smoothing);
+ break;
+ case ZOOM_REGION_CONTRAST_PROP:
+ BONOBO_ARG_SET_FLOAT (arg, zoom_region->contrast);
+ break;
+ case ZOOM_REGION_XSCALE_PROP:
+ BONOBO_ARG_SET_FLOAT (arg, zoom_region->xscale);
+ break;
+ case ZOOM_REGION_YSCALE_PROP:
+ BONOBO_ARG_SET_FLOAT (arg, zoom_region->yscale);
+ break;
+ case ZOOM_REGION_BORDERSIZE_PROP:
+ BONOBO_ARG_SET_INT (arg, zoom_region->border_size);
+ break;
+ case ZOOM_REGION_XALIGN_PROP:
+ /* TODO: enums here */
+ BONOBO_ARG_SET_INT (arg, zoom_region->x_align_policy);
+ break;
+ case ZOOM_REGION_YALIGN_PROP:
+ BONOBO_ARG_SET_INT (arg, zoom_region->y_align_policy);
+ break;
+ case ZOOM_REGION_BORDERCOLOR_PROP:
+ BONOBO_ARG_SET_LONG (arg,
+ zoom_region->border_color);
+ case ZOOM_REGION_VIEWPORT_PROP:
+ BONOBO_ARG_SET_GENERAL (arg, zoom_region->viewport,
+ TC_GNOME_Magnifier_RectBounds,
+ GNOME_Magnifier_RectBounds,
+ NULL);
+ break;
+ default:
+ bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
+ };
+}
+
+static void
+zoom_region_set_property (BonoboPropertyBag *bag,
+ BonoboArg *arg,
+ guint arg_id,
+ CORBA_Environment *ev,
+ gpointer user_data)
+{
+ ZoomRegion *zoom_region = user_data;
+
+ switch (arg_id) {
+ case ZOOM_REGION_INVERT_PROP:
+ zoom_region->invert = BONOBO_ARG_GET_BOOLEAN (arg);
+ break;
+ case ZOOM_REGION_SMOOTHING_PROP:
+ zoom_region->smoothing = BONOBO_ARG_GET_STRING (arg);
+ break;
+ case ZOOM_REGION_CONTRAST_PROP:
+ zoom_region->contrast = BONOBO_ARG_GET_FLOAT (arg);
+ break;
+ case ZOOM_REGION_XSCALE_PROP:
+ zoom_region->xscale = BONOBO_ARG_GET_FLOAT (arg);
+ break;
+ case ZOOM_REGION_YSCALE_PROP:
+ zoom_region->yscale = BONOBO_ARG_GET_FLOAT (arg);
+ break;
+ case ZOOM_REGION_BORDERSIZE_PROP:
+ zoom_region->border_size = BONOBO_ARG_GET_INT (arg);
+ break;
+ case ZOOM_REGION_BORDERCOLOR_PROP:
+ zoom_region->border_color =
+ BONOBO_ARG_GET_LONG (arg);
+ break;
+ case ZOOM_REGION_XALIGN_PROP:
+ zoom_region->x_align_policy = BONOBO_ARG_GET_INT (arg);
+ break;
+ case ZOOM_REGION_YALIGN_PROP:
+ /* TODO: enums here */
+ zoom_region->y_align_policy = BONOBO_ARG_GET_INT (arg);
+ break;
+ case ZOOM_REGION_VIEWPORT_PROP:
+ zoom_region->viewport =
+ BONOBO_ARG_GET_GENERAL (arg,
+ TC_GNOME_Magnifier_RectBounds,
+ GNOME_Magnifier_RectBounds,
+ NULL);
+ break;
+ default:
+ bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
+ };
+}
+
+static void
+impl_zoom_region_set_roi (PortableServer_Servant servant,
+ const GNOME_Magnifier_RectBounds *bounds,
+ CORBA_Environment *ev)
+{
+ ZoomRegion *zoom_region = ZOOM_REGION (bonobo_object_from_servant (servant));
+ zoom_region->roi = *bounds; /* FIXME */
+ zoom_region_display (zoom_region);
+}
+
+static void
+impl_zoom_region_set_mag_factor (PortableServer_Servant servant,
+ const CORBA_float mag_factor_x,
+ const CORBA_float mag_factor_y,
+ CORBA_Environment *ev)
+{
+ ZoomRegion *zoom_region = ZOOM_REGION (bonobo_object_from_servant (servant));
+/* zoom_region->scaled_image = gdk_pixbuf_new (GDK_COLORSPACE_RGB,FALSE, 8,
+ DisplayWidth (magnifier->source_display, screen_num)*magnifier->mag_data->factor_x,
+ DisplayHeight(magnifier->source_display, screen_num)*magnifier->mag_data->factor_y); */
+ zoom_region_display (zoom_region);
+}
+
+static void
+impl_zoom_region_get_mag_factor (PortableServer_Servant servant,
+ CORBA_float *mag_factor_x,
+ CORBA_float *mag_factor_y,
+ CORBA_Environment *ev)
+{
+ ZoomRegion *zoom_region = ZOOM_REGION (bonobo_object_from_servant (servant));
+ *mag_factor_x = zoom_region->xscale;
+ *mag_factor_y = zoom_region->yscale;
+}
+
+static Bonobo_PropertyBag
+impl_zoom_region_get_properties (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ ZoomRegion *zoom_region = ZOOM_REGION (bonobo_object_from_servant (servant));
+ return BONOBO_OBJREF (zoom_region->properties);
+}
+
+static void
+impl_zoom_region_mark_dirty (PortableServer_Servant servant,
+ const GNOME_Magnifier_RectBounds *dirty_bounds,
+ CORBA_Environment *ev)
+{
+ ZoomRegion *zoom_region = ZOOM_REGION (bonobo_object_from_servant (servant));
+ /* TODO: implement something smarter than just redrawing everything */
+ zoom_region_display (zoom_region);
+}
+
+static GNOME_Magnifier_RectBounds
+impl_zoom_region_get_roi (PortableServer_Servant servant,
+ CORBA_Environment * ev)
+{
+ ZoomRegion *zoom_region = ZOOM_REGION (bonobo_object_from_servant (servant));
+ return zoom_region->roi;
+}
+
+static void
+impl_zoom_region_resize (PortableServer_Servant servant,
+ const GNOME_Magnifier_RectBounds *viewport_bounds,
+ CORBA_Environment * ev)
+{
+ ZoomRegion *zoom_region = ZOOM_REGION (bonobo_object_from_servant (servant));
+ zoom_region->viewport.x1 = viewport_bounds->x1;
+ zoom_region->viewport.y1 = viewport_bounds->y1;
+ zoom_region->viewport.x2 = viewport_bounds->x2;
+ zoom_region->viewport.y2 = viewport_bounds->y2;
+}
+
+static void
+impl_zoom_region_dispose (PortableServer_Servant servant,
+ CORBA_Environment * ev)
+{
+ ZoomRegion *zoom_region =
+ ZOOM_REGION (bonobo_object_from_servant (servant));
+}
+
+static void
+zoom_region_class_init (ZoomRegionClass *klass)
+{
+ GObjectClass * object_class = (GObjectClass *) klass;
+ POA_GNOME_Magnifier_ZoomRegion__epv *epv = &klass->epv;
+
+ object_class->finalize = zoom_region_finalize; /* TODO */
+
+ epv->setMagFactor = impl_zoom_region_set_mag_factor;
+ epv->getMagFactor = impl_zoom_region_get_mag_factor;
+ epv->getProperties = impl_zoom_region_get_properties;
+ epv->setROI = impl_zoom_region_set_roi;
+ epv->markDirty = impl_zoom_region_mark_dirty;
+ epv->getROI = impl_zoom_region_get_roi;
+ epv->resize = impl_zoom_region_resize;
+ epv->dispose = impl_zoom_region_dispose;
+}
+
+static void
+zoom_region_properties_init (ZoomRegion *zoom_region)
+{
+ BonoboArg *def;
+
+ zoom_region->properties =
+ bonobo_property_bag_new_closure (
+ g_cclosure_new_object (
+ G_CALLBACK (zoom_region_get_property),
+ G_OBJECT (zoom_region)),
+ g_cclosure_new_object (
+ G_CALLBACK (zoom_region_set_property),
+ G_OBJECT (zoom_region)));
+
+ def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
+ BONOBO_ARG_SET_BOOLEAN (def, TRUE);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "is-managed",
+ ZOOM_REGION_MANAGED_PROP,
+ BONOBO_ARG_BOOLEAN,
+ def,
+ "If false, zoom region does not auto-update, but is drawn into directly by the client",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
+ BONOBO_ARG_SET_BOOLEAN (def, TRUE);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "inverse-video",
+ ZOOM_REGION_INVERT_PROP,
+ BONOBO_ARG_BOOLEAN,
+ def,
+ "inverse video display",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ def = bonobo_arg_new (BONOBO_ARG_STRING);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "smoothing-type",
+ ZOOM_REGION_SMOOTHING_PROP,
+ BONOBO_ARG_STRING,
+ NULL,
+ "image smoothing algorithm used",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ def = bonobo_arg_new (BONOBO_ARG_FLOAT);
+ BONOBO_ARG_SET_FLOAT (def, 1.0);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "contrast",
+ ZOOM_REGION_CONTRAST_PROP,
+ BONOBO_ARG_FLOAT,
+ def,
+ "image contrast ratio",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ def = bonobo_arg_new (BONOBO_ARG_FLOAT);
+ BONOBO_ARG_SET_FLOAT (def, 2.0);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "mag-factor-x",
+ ZOOM_REGION_XSCALE_PROP,
+ BONOBO_ARG_FLOAT,
+ def,
+ "x scale factor",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ def = bonobo_arg_new (BONOBO_ARG_FLOAT);
+ BONOBO_ARG_SET_FLOAT (def, 2.0);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "mag-factor-y",
+ ZOOM_REGION_YSCALE_PROP,
+ BONOBO_ARG_FLOAT,
+ def,
+ "y scale factor",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ def = bonobo_arg_new (BONOBO_ARG_INT);
+ BONOBO_ARG_SET_INT (def, 0);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "border-size",
+ ZOOM_REGION_BORDERSIZE_PROP,
+ BONOBO_ARG_INT,
+ def,
+ "size of zoom-region borders, in pixels",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ def = bonobo_arg_new (BONOBO_ARG_LONG);
+ BONOBO_ARG_SET_LONG (def, 0x00000000);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "border-color",
+ ZOOM_REGION_BORDERCOLOR_PROP,
+ BONOBO_ARG_LONG,
+ def,
+ "border color, as RGBA32",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ def = bonobo_arg_new (BONOBO_ARG_INT);
+ BONOBO_ARG_SET_INT (def, 0);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "x-alignment",
+ ZOOM_REGION_XALIGN_PROP,
+ BONOBO_ARG_INT,
+ def,
+ "x-alignment policy for this region",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ def = bonobo_arg_new (BONOBO_ARG_INT);
+ BONOBO_ARG_SET_INT (def, 0);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "y-alignment",
+ ZOOM_REGION_YALIGN_PROP,
+ BONOBO_ARG_INT,
+ def,
+ "y-alignment policy for this region",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+ bonobo_property_bag_add (zoom_region->properties,
+ "viewport",
+ ZOOM_REGION_VIEWPORT_PROP,
+ TC_GNOME_Magnifier_RectBounds,
+ NULL,
+ "viewport bounding box",
+ Bonobo_PROPERTY_READABLE |
+ Bonobo_PROPERTY_WRITEABLE);
+
+}
+
+static void
+zoom_region_init (ZoomRegion *zoom_region)
+{
+ zoom_region_properties_init (zoom_region);
+ bonobo_object_add_interface (BONOBO_OBJECT (zoom_region),
+ BONOBO_OBJECT (zoom_region->properties));
+}
+
+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 ()
+{
+ ZoomRegion *zoom_region =
+ ZOOM_REGION (g_object_new (zoom_region_get_type(), NULL));
+ return zoom_region;
+}
+
+static void
+zoom_region_finalize (GObject *region)
+{
+}
diff --git a/magnifier/zoom-region.h b/magnifier/zoom-region.h
new file mode 100644
index 0000000..816d4bc
--- /dev/null
+++ b/magnifier/zoom-region.h
@@ -0,0 +1,69 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef ZOOM_REGION_H_
+#define ZOOM_REGION_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <bonobo/bonobo-object.h>
+#include "GNOME_Magnifier.h"
+
+#define ZOOM_REGION_TYPE (zoom_region_get_type ())
+#define ZOOM_REGION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZOOM_REGION_TYPE, ZoomRegion))
+#define ZOOM_REGION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZOOM_REGION_TYPE, ZoomRegionClass))
+#define IS_ZOOM_REGION(o) (G_TYPE_CHECK__INSTANCE_TYPE ((o), ZOOM_REGION_TYPE))
+#define IS_ZOOM_REGION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZOOM_REGION_TYPE))
+
+typedef struct {
+ BonoboObject parent;
+ BonoboPropertyBag *properties;
+ GdkPixbuf *scaled_image;
+ GNOME_Magnifier_RectBounds roi;
+ gboolean invert;
+ gchar *smoothing;
+ gfloat contrast;
+ gfloat xscale;
+ gfloat yscale;
+ gint border_size;
+ guint32 border_color; /* A-RGB, 8 bits each, MSB==alpha */
+ gint x_align_policy; /* TODO: enums here */
+ gint y_align_policy;
+ GNOME_Magnifier_RectBounds viewport;
+} ZoomRegion;
+
+typedef struct {
+ BonoboObjectClass parent_class;
+ POA_GNOME_Magnifier_ZoomRegion__epv epv;
+} ZoomRegionClass;
+
+GType zoom_region_get_type (void);
+ZoomRegion *zoom_region_new (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* ZOOM_REGION_H_ */