]> git.sur5r.net Git - glabels/commitdiff
Made set_size and get_size into child methods for label-object, and construct_dialog...
authorJim Evins <evins@snaught.com>
Fri, 22 Nov 2002 02:49:20 +0000 (02:49 +0000)
committerJim Evins <evins@snaught.com>
Fri, 22 Nov 2002 02:49:20 +0000 (02:49 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@180 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/label-object.h
glabels2/src/view-barcode.c
glabels2/src/view-box.c
glabels2/src/view-ellipse.c
glabels2/src/view-image.c
glabels2/src/view-line.c
glabels2/src/view-object.c
glabels2/src/view-text.c

index fc008d9ec4e124db8344ac029169909d886fbf91..7d46b71e86853c5023fe7e2460daa95c4c820f08 100644 (file)
@@ -39,11 +39,13 @@ typedef enum {
 } glLabelObjectType;
 
 
-#define GL_TYPE_LABEL_OBJECT            (gl_label_object_get_type ())
-#define GL_LABEL_OBJECT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GL_TYPE_LABEL_OBJECT, glLabelObject))
-#define GL_LABEL_OBJECT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_LABEL_OBJECT, glLabelObjectClass))
-#define GL_IS_LABEL_OBJECT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_LABEL_OBJECT))
-#define GL_IS_LABEL_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_LABEL_OBJECT))
+#define GL_TYPE_LABEL_OBJECT              (gl_label_object_get_type ())
+#define GL_LABEL_OBJECT(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GL_TYPE_LABEL_OBJECT, glLabelObject))
+#define GL_LABEL_OBJECT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_LABEL_OBJECT, glLabelObjectClass))
+#define GL_IS_LABEL_OBJECT(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_LABEL_OBJECT))
+#define GL_IS_LABEL_OBJECT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_LABEL_OBJECT))
+#define GL_LABEL_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GL_TYPE_LABEL_OBJECT, glLabelObjectClass))
+
 
 typedef struct _glLabelObject          glLabelObject;
 typedef struct _glLabelObjectClass     glLabelObjectClass;
@@ -63,6 +65,21 @@ struct _glLabelObject {
 struct _glLabelObjectClass {
        GObjectClass          parent_class;
 
+       /*
+        * Methods
+        */
+
+       void (*set_size)    (glLabelObject     *object,
+                            gdouble            w,
+                            gdouble            h);
+
+       void (*get_size)    (glLabelObject     *object,
+                            gdouble           *w,
+                            gdouble           *h);
+
+       /*
+        * Signals
+        */
        void (*changed)     (glLabelObject     *object,
                             gpointer            user_data);
 
index 43382f9fbee44cf04fdb513d1ee4727505111470..400208530cfd500a17453c823eca6d00c7513fb9 100644 (file)
@@ -82,7 +82,7 @@ static void      gl_view_barcode_finalize      (GObject        *object);
 static void      update_view_barcode_cb        (glLabelObject  *object,
                                                glViewBarcode  *view_barcode);
 
-static GtkWidget *construct_properties_dialog  (glViewBarcode  *view_barcode);
+static GtkWidget *construct_properties_dialog  (glViewObject   *view_object);
 
 static void      response_cb                   (GtkDialog      *dialog,
                                                gint            response,
@@ -142,7 +142,8 @@ gl_view_barcode_get_type (void)
 static void
 gl_view_barcode_class_init (glViewBarcodeClass *klass)
 {
-       GObjectClass *object_class = (GObjectClass *) klass;
+       GObjectClass      *object_class      = (GObjectClass *) klass;
+       glViewObjectClass *view_object_class = (glViewObjectClass *) klass;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -150,6 +151,8 @@ gl_view_barcode_class_init (glViewBarcodeClass *klass)
 
        object_class->finalize = gl_view_barcode_finalize;
 
+       view_object_class->construct_dialog = construct_properties_dialog;
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -204,10 +207,6 @@ gl_view_barcode_new (glLabelBarcode *object,
        g_signal_connect (G_OBJECT (object), "changed",
                          G_CALLBACK (update_view_barcode_cb), view_barcode);
 
-       /* Create a dialog for controlling/viewing object properties. */
-       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_barcode),
-                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
-
        gl_debug (DEBUG_VIEW, "END");
 
        return GL_VIEW_OBJECT (view_barcode);
@@ -237,8 +236,9 @@ update_view_barcode_cb (glLabelObject *object,
 /* Create a properties dialog for a barcode object.                          */
 /*****************************************************************************/
 static GtkWidget *
-construct_properties_dialog (glViewBarcode *view_barcode)
+construct_properties_dialog (glViewObject *view_object)
 {
+       glViewBarcode      *view_barcode = (glViewBarcode *)view_object;
        GtkWidget          *dialog, *wsection;
        glLabelObject      *object;
        gdouble            x, y, w, h, label_width, label_height;
@@ -254,7 +254,7 @@ construct_properties_dialog (glViewBarcode *view_barcode)
        gl_debug (DEBUG_VIEW, "START");
 
        /* retrieve object and query parameters */
-       object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
+       object = gl_view_object_get_object (view_object);
        gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
        text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
@@ -267,7 +267,7 @@ construct_properties_dialog (glViewBarcode *view_barcode)
        /* Build dialog.                                                   */
        /*-----------------------------------------------------------------*/
        window = gtk_widget_get_toplevel (
-               GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_barcode))));
+               GTK_WIDGET(gl_view_object_get_view(view_object)));
        dialog = gl_hig_dialog_new_with_buttons ( _("Edit barcode object properties"),
                                                  GTK_WINDOW (window),
                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -276,7 +276,7 @@ construct_properties_dialog (glViewBarcode *view_barcode)
                                                  NULL );
         gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
        g_signal_connect (G_OBJECT (dialog), "response",
-                         G_CALLBACK (response_cb), view_barcode);
+                         G_CALLBACK (response_cb), view_object);
 
        label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
index 075312ebf3ac3e37e6907abe11edb7a2b49677c9..d4a6469339770f7d9109d6236d2ad29132acf25b 100644 (file)
@@ -78,7 +78,7 @@ static void      gl_view_box_finalize         (GObject        *object);
 static void      update_view_box_cb           (glLabelObject  *object,
                                               glViewBox      *view_box);
 
-static GtkWidget *construct_properties_dialog (glViewBox      *view_box);
+static GtkWidget *construct_properties_dialog (glViewObject   *view_object);
 
 static void      response_cb                  (GtkDialog      *dialog,
                                               gint            response,
@@ -136,7 +136,8 @@ gl_view_box_get_type (void)
 static void
 gl_view_box_class_init (glViewBoxClass *klass)
 {
-       GObjectClass *object_class = (GObjectClass *) klass;
+       GObjectClass      *object_class      = (GObjectClass *) klass;
+       glViewObjectClass *view_object_class = (glViewObjectClass *) klass;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -144,6 +145,8 @@ gl_view_box_class_init (glViewBoxClass *klass)
 
        object_class->finalize = gl_view_box_finalize;
 
+       view_object_class->construct_dialog = construct_properties_dialog;
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -217,10 +220,6 @@ gl_view_box_new (glLabelBox *object,
        g_signal_connect (G_OBJECT (object), "changed",
                          G_CALLBACK (update_view_box_cb), view_box);
 
-       /* Create a dialog for controlling/viewing object properties. */
-       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_box),
-                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
-
        gl_debug (DEBUG_VIEW, "END");
 
        return GL_VIEW_OBJECT (view_box);
@@ -261,8 +260,9 @@ update_view_box_cb (glLabelObject *object,
 /* Create a properties dialog for a box object.                              */
 /*****************************************************************************/
 static GtkWidget *
-construct_properties_dialog (glViewBox *view_box)
+construct_properties_dialog (glViewObject *view_object)
 {
+       glViewBox          *view_box = (glViewBox *)view_object;
        GtkWidget          *dialog, *wsection;
        glLabelObject      *object;
        gdouble            line_width;
index 9c1ec320718579156b2b88f511788d21c4350674..36d4fcc20786b40e12b50f96e8303165005c2758 100644 (file)
@@ -78,7 +78,7 @@ static void      gl_view_ellipse_finalize      (GObject        *object);
 static void      update_view_ellipse_cb        (glLabelObject  *object,
                                                glViewEllipse  *view_ellipse);
 
-static GtkWidget *construct_properties_dialog  (glViewEllipse  *view_ellipse);
+static GtkWidget *construct_properties_dialog  (glViewObject   *view_object);
 
 static void      response_cb                   (GtkDialog      *dialog,
                                                gint            response,
@@ -136,7 +136,8 @@ gl_view_ellipse_get_type (void)
 static void
 gl_view_ellipse_class_init (glViewEllipseClass *klass)
 {
-       GObjectClass *object_class = (GObjectClass *) klass;
+       GObjectClass      *object_class      = (GObjectClass *) klass;
+       glViewObjectClass *view_object_class = (glViewObjectClass *) klass;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -144,6 +145,8 @@ gl_view_ellipse_class_init (glViewEllipseClass *klass)
 
        object_class->finalize = gl_view_ellipse_finalize;
 
+       view_object_class->construct_dialog = construct_properties_dialog;
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -217,10 +220,6 @@ gl_view_ellipse_new (glLabelEllipse *object,
        g_signal_connect (G_OBJECT (object), "changed",
                          G_CALLBACK (update_view_ellipse_cb), view_ellipse);
 
-       /* Create a dialog for controlling/viewing object properties. */
-       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_ellipse),
-                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
-
        gl_debug (DEBUG_VIEW, "END");
 
        return GL_VIEW_OBJECT (view_ellipse);
@@ -261,8 +260,9 @@ update_view_ellipse_cb (glLabelObject *object,
 /* Create a properties dialog for a ellipse object.                          */
 /*****************************************************************************/
 static GtkWidget *
-construct_properties_dialog (glViewEllipse *view_ellipse)
+construct_properties_dialog (glViewObject *view_object)
 {
+       glViewEllipse      *view_ellipse = (glViewEllipse *)view_object;
        GtkWidget          *dialog, *wsection;
        glLabelObject      *object;
        gdouble            line_width;
index 8f63e050717cd5ccd2ac995a1250b2687ac8dc4c..05073e1ad6511086a1ee6176b023f75884164506 100644 (file)
@@ -78,7 +78,7 @@ static void      gl_view_image_finalize        (GObject        *object);
 static void      update_view_image_cb          (glLabelObject  *object,
                                                glViewImage    *view_image);
 
-static GtkWidget *construct_properties_dialog  (glViewImage    *view_image);
+static GtkWidget *construct_properties_dialog  (glViewObject   *view_object);
 
 static void      response_cb                   (GtkDialog      *dialog,
                                                gint            response,
@@ -136,7 +136,8 @@ gl_view_image_get_type (void)
 static void
 gl_view_image_class_init (glViewImageClass *klass)
 {
-       GObjectClass *object_class = (GObjectClass *) klass;
+       GObjectClass      *object_class      = (GObjectClass *) klass;
+       glViewObjectClass *view_object_class = (glViewObjectClass *) klass;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -144,6 +145,8 @@ gl_view_image_class_init (glViewImageClass *klass)
 
        object_class->finalize = gl_view_image_finalize;
 
+       view_object_class->construct_dialog = construct_properties_dialog;
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -214,10 +217,6 @@ gl_view_image_new (glLabelImage *object,
        g_signal_connect (G_OBJECT (object), "changed",
                          G_CALLBACK (update_view_image_cb), view_image);
 
-       /* Create a dialog for controlling/viewing object properties. */
-       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_image),
-                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
-
        gl_debug (DEBUG_VIEW, "END");
 
        return GL_VIEW_OBJECT (view_image);
@@ -255,8 +254,9 @@ update_view_image_cb (glLabelObject *object,
 /* Create a properties dialog for a image object.                          */
 /*****************************************************************************/
 static GtkWidget *
-construct_properties_dialog (glViewImage *view_image)
+construct_properties_dialog (glViewObject *view_object)
 {
+       glViewImage        *view_image = (glViewImage *)view_object;
        GtkWidget          *dialog, *wsection, *wbutton;
        glLabelObject      *object;
        gdouble            x, y, w, h, label_width, label_height;
index 1ec74f69f2fd6366cdd0a4f32cc3f1a0b9aa7e12..7d4d8588a0f960158f5811f95d60b28a425ff5ad 100644 (file)
@@ -74,7 +74,7 @@ static void      gl_view_line_finalize        (GObject        *object);
 static void      update_view_line_cb          (glLabelObject  *object,
                                               glViewLine     *view_line);
 
-static GtkWidget *construct_properties_dialog (glViewLine     *view_line);
+static GtkWidget *construct_properties_dialog (glViewObject   *view_object);
 
 static void      response_cb                  (GtkDialog      *dialog,
                                               gint            response,
@@ -129,7 +129,8 @@ gl_view_line_get_type (void)
 static void
 gl_view_line_class_init (glViewLineClass *klass)
 {
-       GObjectClass *object_class = (GObjectClass *) klass;
+       GObjectClass      *object_class      = (GObjectClass *) klass;
+       glViewObjectClass *view_object_class = (glViewObjectClass *) klass;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -137,6 +138,8 @@ gl_view_line_class_init (glViewLineClass *klass)
 
        object_class->finalize = gl_view_line_finalize;
 
+       view_object_class->construct_dialog = construct_properties_dialog;
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -212,10 +215,6 @@ gl_view_line_new (glLabelLine *object,
        g_signal_connect (G_OBJECT (object), "changed",
                          G_CALLBACK (update_view_line_cb), view_line);
 
-       /* Create a dialog for controlling/viewing object properties. */
-       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_line),
-                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
-
        gl_debug (DEBUG_VIEW, "END");
 
        return GL_VIEW_OBJECT (view_line);
@@ -260,8 +259,9 @@ update_view_line_cb (glLabelObject *object,
 /* Create a properties dialog for a line object.                          */
 /*****************************************************************************/
 static GtkWidget *
-construct_properties_dialog (glViewLine *view_line)
+construct_properties_dialog (glViewObject *view_object)
 {
+       glViewLine         *view_line = (glViewLine *)view_object;
        GtkWidget          *dialog, *wsection;
        glLabelObject      *object;
        gdouble            line_width;
index 62b951dfdc1e435a100f8e76e80e015bb4740c03..db5a7cfced9985f2c8387abf4343fb0b1234c3c3 100644 (file)
@@ -48,8 +48,6 @@ struct _glViewObjectPrivate {
 
        GtkWidget                  *menu;
        GtkWidget                  *property_dialog;
-
-       glViewObjectDlgConstructor  dialog_constructor;
 };
 
 /*========================================================*/
@@ -260,23 +258,6 @@ gl_view_object_set_object     (glViewObject         *view_object,
        gl_debug (DEBUG_VIEW, "END");
 }
 
-/*****************************************************************************/
-/* Set dialog for controlling/viewing object properties.                     */
-/*****************************************************************************/
-void
-gl_view_object_set_dlg_constructor (glViewObject               *view_object,
-                                   glViewObjectDlgConstructor  dlg_constructor)
-
-{
-       gl_debug (DEBUG_VIEW, "START");
-
-       g_return_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object));
-       
-       view_object->private->dialog_constructor = dlg_constructor;
-
-       gl_debug (DEBUG_VIEW, "END");
-}
-
 /*****************************************************************************/
 /* Return parent view associated with this view.                             */
 /*****************************************************************************/
@@ -491,15 +472,19 @@ gl_view_object_show_dialog (glViewObject *view_object)
                return;
        }
 
-       view_object->private->property_dialog =
-               view_object->private->dialog_constructor (view_object);
+       if ( GL_VIEW_OBJECT_GET_CLASS(view_object)->construct_dialog != NULL ) {
+
+               view_object->private->property_dialog =
+                       GL_VIEW_OBJECT_GET_CLASS(view_object)->construct_dialog (view_object);
 
-       g_signal_connect (G_OBJECT (view_object->private->property_dialog),
-                         "destroy",
-                         G_CALLBACK (gtk_widget_destroyed),
-                         &view_object->private->property_dialog);
+               g_signal_connect (G_OBJECT (view_object->private->property_dialog),
+                                 "destroy",
+                                 G_CALLBACK (gtk_widget_destroyed),
+                                 &view_object->private->property_dialog);
        
-       gtk_widget_show_all (view_object->private->property_dialog);
+               gtk_widget_show_all (view_object->private->property_dialog);
+
+       }
 
 
        gl_debug (DEBUG_VIEW, "END");
index 110fa87e75da170d8ff35487818f0e125504e3b9..851cec71ea4f5226f406df4360a762e2fd1a7eb6 100644 (file)
@@ -79,7 +79,7 @@ static void      gl_view_text_finalize         (GObject         *object);
 static void      update_view_text_cb           (glLabelObject   *object,
                                                glViewText      *view_text);
 
-static GtkWidget *construct_properties_dialog  (glViewText      *view_text);
+static GtkWidget *construct_properties_dialog  (glViewObject    *view_object);
 
 static void      response_cb                   (GtkDialog       *dialog,
                                                gint             response,
@@ -136,7 +136,8 @@ gl_view_text_get_type (void)
 static void
 gl_view_text_class_init (glViewTextClass *klass)
 {
-       GObjectClass *object_class = (GObjectClass *) klass;
+       GObjectClass      *object_class      = (GObjectClass *) klass;
+       glViewObjectClass *view_object_class = (glViewObjectClass *) klass;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -144,6 +145,8 @@ gl_view_text_class_init (glViewTextClass *klass)
 
        object_class->finalize = gl_view_text_finalize;
 
+       view_object_class->construct_dialog = construct_properties_dialog;
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -198,10 +201,6 @@ gl_view_text_new (glLabelText *object,
        g_signal_connect (G_OBJECT (object), "changed",
                          G_CALLBACK (update_view_text_cb), view_text);
 
-       /* Create a dialog for controlling/viewing object properties. */
-       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_text),
-                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
-
        gl_debug (DEBUG_VIEW, "END");
 
        return GL_VIEW_OBJECT (view_text);
@@ -226,8 +225,9 @@ update_view_text_cb (glLabelObject *object,
 /* Create a properties dialog for a text object.                          */
 /*****************************************************************************/
 static GtkWidget *
-construct_properties_dialog (glViewText *view_text)
+construct_properties_dialog (glViewObject *view_object)
 {
+       glViewText         *view_text = (glViewText *)view_object;
        GtkWidget          *dialog, *wsection, *wbutton;
        glLabelObject      *object;
        gdouble            x, y, w, h, label_width, label_height;