From 29b2a2d7ad849248f70907052594d3b6a95d4c55 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Fri, 22 Nov 2002 02:49:20 +0000 Subject: [PATCH] Made set_size and get_size into child methods for label-object, and construct_dialog for view-object. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@180 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/label-object.h | 27 ++++++++++++++++++++++----- glabels2/src/view-barcode.c | 20 ++++++++++---------- glabels2/src/view-box.c | 14 +++++++------- glabels2/src/view-ellipse.c | 14 +++++++------- glabels2/src/view-image.c | 14 +++++++------- glabels2/src/view-line.c | 14 +++++++------- glabels2/src/view-object.c | 37 +++++++++++-------------------------- glabels2/src/view-text.c | 14 +++++++------- 8 files changed, 78 insertions(+), 76 deletions(-) diff --git a/glabels2/src/label-object.h b/glabels2/src/label-object.h index fc008d9e..7d46b71e 100644 --- a/glabels2/src/label-object.h +++ b/glabels2/src/label-object.h @@ -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); diff --git a/glabels2/src/view-barcode.c b/glabels2/src/view-barcode.c index 43382f9f..40020853 100644 --- a/glabels2/src/view-barcode.c +++ b/glabels2/src/view-barcode.c @@ -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); diff --git a/glabels2/src/view-box.c b/glabels2/src/view-box.c index 075312eb..d4a64693 100644 --- a/glabels2/src/view-box.c +++ b/glabels2/src/view-box.c @@ -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; diff --git a/glabels2/src/view-ellipse.c b/glabels2/src/view-ellipse.c index 9c1ec320..36d4fcc2 100644 --- a/glabels2/src/view-ellipse.c +++ b/glabels2/src/view-ellipse.c @@ -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; diff --git a/glabels2/src/view-image.c b/glabels2/src/view-image.c index 8f63e050..05073e1a 100644 --- a/glabels2/src/view-image.c +++ b/glabels2/src/view-image.c @@ -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; diff --git a/glabels2/src/view-line.c b/glabels2/src/view-line.c index 1ec74f69..7d4d8588 100644 --- a/glabels2/src/view-line.c +++ b/glabels2/src/view-line.c @@ -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; diff --git a/glabels2/src/view-object.c b/glabels2/src/view-object.c index 62b951df..db5a7cfc 100644 --- a/glabels2/src/view-object.c +++ b/glabels2/src/view-object.c @@ -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"); diff --git a/glabels2/src/view-text.c b/glabels2/src/view-text.c index 110fa87e..851cec71 100644 --- a/glabels2/src/view-text.c +++ b/glabels2/src/view-text.c @@ -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; -- 2.39.5