From 3d67bfa8cac66e625a4aa1d00c867215ed1cc9b9 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 23 Sep 2002 03:59:14 +0000 Subject: [PATCH] Added callbacks to track "moved" signals of label objects and update property dialogs. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@132 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/view-barcode.c | 77 +++++++++++++++++++++++++--------- glabels2/src/view-box.c | 72 ++++++++++++++++++++++++-------- glabels2/src/view-ellipse.c | 72 ++++++++++++++++++++++++-------- glabels2/src/view-image.c | 82 +++++++++++++++++++++++++++---------- glabels2/src/view-line.c | 72 ++++++++++++++++++++++++-------- glabels2/src/view-text.c | 68 +++++++++++++++++++++++------- 6 files changed, 336 insertions(+), 107 deletions(-) diff --git a/glabels2/src/view-barcode.c b/glabels2/src/view-barcode.c index 6b9a92f1..aad1f2af 100644 --- a/glabels2/src/view-barcode.c +++ b/glabels2/src/view-barcode.c @@ -76,35 +76,40 @@ static glViewObjectClass *parent_class = NULL; /* Private function prototypes. */ /*========================================================*/ -static void gl_view_barcode_class_init (glViewBarcodeClass *klass); -static void gl_view_barcode_instance_init (glViewBarcode *view_barcode); -static void gl_view_barcode_finalize (GObject *object); +static void gl_view_barcode_class_init (glViewBarcodeClass *klass); +static void gl_view_barcode_instance_init (glViewBarcode *view_barcode); +static void gl_view_barcode_finalize (GObject *object); -static void update_view_barcode_cb (glLabelObject *object, - glViewBarcode *view_barcode); +static void update_view_barcode_cb (glLabelObject *object, + glViewBarcode *view_barcode); -static GtkWidget *construct_properties_dialog (glViewBarcode *view_barcode); +static GtkWidget *construct_properties_dialog (glViewBarcode *view_barcode); -static void response_cb (GtkDialog *dialog, - gint response, - glViewBarcode *view_barcode); +static void response_cb (GtkDialog *dialog, + gint response, + glViewBarcode *view_barcode); -static void bc_data_changed_cb (glWdgtBCData *bc_data, - glViewBarcode *view_barcode); +static void bc_data_changed_cb (glWdgtBCData *bc_data, + glViewBarcode *view_barcode); -static void bc_props_changed_cb (glWdgtBCProps *bc_props, - glViewBarcode *view_barcode); +static void bc_props_changed_cb (glWdgtBCProps *bc_props, + glViewBarcode *view_barcode); -static void bc_style_changed_cb (glWdgtBCStyle *bc_style, - glViewBarcode *view_barcode); +static void bc_style_changed_cb (glWdgtBCStyle *bc_style, + glViewBarcode *view_barcode); static void position_changed_cb (glWdgtPosition *position, - glViewBarcode *view_barcode); + glViewBarcode *view_barcode); -static void update_dialog_cb (glLabelObject *object, - glViewBarcode *view_barcode); +static void update_dialog_cb (glLabelObject *object, + glViewBarcode *view_barcode); -static void draw_barcode (glViewBarcode *view_barcode); +static void update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewBarcode *view_barcode); + +static void draw_barcode (glViewBarcode *view_barcode); /*****************************************************************************/ @@ -356,6 +361,9 @@ construct_properties_dialog (glViewBarcode *view_barcode) /*----------------------------*/ g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (update_dialog_cb), view_barcode); + g_signal_connect (G_OBJECT (object), "moved", + G_CALLBACK (update_dialog_from_move_cb), + view_barcode); gl_debug (DEBUG_VIEW, "END"); @@ -563,6 +571,37 @@ update_dialog_cb (glLabelObject *object, gl_debug (DEBUG_VIEW, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. label object "moved" callback. */ +/*---------------------------------------------------------------------------*/ +static void +update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewBarcode *view_barcode) +{ + gdouble x, y; + + gl_debug (DEBUG_VIEW, "START"); + + /* Query properties of object. */ + gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); + + /* Block widget handlers to prevent recursion */ + g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->position), + position_changed_cb, view_barcode); + + /* Update widgets in property dialog */ + gl_wdgt_position_set_position (GL_WDGT_POSITION(view_barcode->private->position), + x, y); + + /* Unblock widget handlers */ + g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->position), + position_changed_cb, view_barcode); + + gl_debug (DEBUG_VIEW, "END"); +} + /*****************************************************************************/ /* Return apropos cursor for create object mode. */ /*****************************************************************************/ diff --git a/glabels2/src/view-box.c b/glabels2/src/view-box.c index dba80c2e..6472350e 100644 --- a/glabels2/src/view-box.c +++ b/glabels2/src/view-box.c @@ -73,32 +73,37 @@ static glViewObjectClass *parent_class = NULL; /*========================================================*/ static void gl_view_box_class_init (glViewBoxClass *klass); -static void gl_view_box_instance_init (glViewBox *view_box); -static void gl_view_box_finalize (GObject *object); +static void gl_view_box_instance_init (glViewBox *view_box); +static void gl_view_box_finalize (GObject *object); -static void update_view_box_cb (glLabelObject *object, - glViewBox *view_box); +static void update_view_box_cb (glLabelObject *object, + glViewBox *view_box); -static GtkWidget *construct_properties_dialog (glViewBox *view_box); +static GtkWidget *construct_properties_dialog (glViewBox *view_box); -static void response_cb (GtkDialog *dialog, - gint response, - glViewBox *view_box); +static void response_cb (GtkDialog *dialog, + gint response, + glViewBox *view_box); -static void line_changed_cb (glWdgtLine *line, - glViewBox *view_box); +static void line_changed_cb (glWdgtLine *line, + glViewBox *view_box); -static void fill_changed_cb (glWdgtFill *fill, - glViewBox *view_box); +static void fill_changed_cb (glWdgtFill *fill, + glViewBox *view_box); static void position_changed_cb (glWdgtPosition *position, - glViewBox *view_box); + glViewBox *view_box); -static void size_changed_cb (glWdgtSize *size, - glViewBox *view_box); +static void size_changed_cb (glWdgtSize *size, + glViewBox *view_box); -static void update_dialog_cb (glLabelObject *object, - glViewBox *view_box); +static void update_dialog_cb (glLabelObject *object, + glViewBox *view_box); + +static void update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewBox *view_box); /*****************************************************************************/ @@ -369,6 +374,8 @@ construct_properties_dialog (glViewBox *view_box) /*----------------------------*/ g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (update_dialog_cb), view_box); + g_signal_connect (G_OBJECT (object), "moved", + G_CALLBACK (update_dialog_from_move_cb), view_box); gl_debug (DEBUG_VIEW, "END"); @@ -560,6 +567,37 @@ update_dialog_cb (glLabelObject *object, gl_debug (DEBUG_VIEW, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. label object "moved" callback. */ +/*---------------------------------------------------------------------------*/ +static void +update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewBox *view_box) +{ + gdouble x, y; + + gl_debug (DEBUG_VIEW, "START"); + + /* Query properties of object. */ + gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); + + /* Block widget handlers to prevent recursion */ + g_signal_handlers_block_by_func (G_OBJECT(view_box->private->position), + position_changed_cb, view_box); + + /* Update widgets in property dialog */ + gl_wdgt_position_set_position (GL_WDGT_POSITION(view_box->private->position), + x, y); + + /* Unblock widget handlers */ + g_signal_handlers_unblock_by_func (G_OBJECT(view_box->private->position), + position_changed_cb, view_box); + + gl_debug (DEBUG_VIEW, "END"); +} + /*****************************************************************************/ /* Return apropos cursor for create object mode. */ /*****************************************************************************/ diff --git a/glabels2/src/view-ellipse.c b/glabels2/src/view-ellipse.c index 09b6cf2d..d18fff7c 100644 --- a/glabels2/src/view-ellipse.c +++ b/glabels2/src/view-ellipse.c @@ -73,32 +73,37 @@ static glViewObjectClass *parent_class = NULL; /*========================================================*/ static void gl_view_ellipse_class_init (glViewEllipseClass *klass); -static void gl_view_ellipse_instance_init (glViewEllipse *view_ellipse); -static void gl_view_ellipse_finalize (GObject *object); +static void gl_view_ellipse_instance_init (glViewEllipse *view_ellipse); +static void gl_view_ellipse_finalize (GObject *object); -static void update_view_ellipse_cb (glLabelObject *object, - glViewEllipse *view_ellipse); +static void update_view_ellipse_cb (glLabelObject *object, + glViewEllipse *view_ellipse); -static GtkWidget *construct_properties_dialog (glViewEllipse *view_ellipse); +static GtkWidget *construct_properties_dialog (glViewEllipse *view_ellipse); -static void response_cb (GtkDialog *dialog, - gint response, - glViewEllipse *view_ellipse); +static void response_cb (GtkDialog *dialog, + gint response, + glViewEllipse *view_ellipse); -static void line_changed_cb (glWdgtLine *line, - glViewEllipse *view_ellipse); +static void line_changed_cb (glWdgtLine *line, + glViewEllipse *view_ellipse); -static void fill_changed_cb (glWdgtFill *fill, - glViewEllipse *view_ellipse); +static void fill_changed_cb (glWdgtFill *fill, + glViewEllipse *view_ellipse); static void position_changed_cb (glWdgtPosition *position, - glViewEllipse *view_ellipse); + glViewEllipse *view_ellipse); -static void size_changed_cb (glWdgtSize *size, - glViewEllipse *view_ellipse); +static void size_changed_cb (glWdgtSize *size, + glViewEllipse *view_ellipse); -static void update_dialog_cb (glLabelObject *object, - glViewEllipse *view_ellipse); +static void update_dialog_cb (glLabelObject *object, + glViewEllipse *view_ellipse); + +static void update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewEllipse *view_ellipse); /*****************************************************************************/ @@ -369,6 +374,9 @@ construct_properties_dialog (glViewEllipse *view_ellipse) /*----------------------------*/ g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (update_dialog_cb), view_ellipse); + g_signal_connect (G_OBJECT (object), "moved", + G_CALLBACK (update_dialog_from_move_cb), + view_ellipse); gl_debug (DEBUG_VIEW, "END"); @@ -556,6 +564,36 @@ update_dialog_cb (glLabelObject *object, g_signal_handlers_unblock_by_func (G_OBJECT(view_ellipse->private->size), size_changed_cb, view_ellipse); + gl_debug (DEBUG_VIEW, "END"); +} + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. label object "moved" callback. */ +/*---------------------------------------------------------------------------*/ +static void +update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewEllipse *view_ellipse) +{ + gdouble x, y; + + gl_debug (DEBUG_VIEW, "START"); + + /* Query properties of object. */ + gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); + + /* Block widget handlers to prevent recursion */ + g_signal_handlers_block_by_func (G_OBJECT(view_ellipse->private->position), + position_changed_cb, view_ellipse); + + /* Update widgets in property dialog */ + gl_wdgt_position_set_position (GL_WDGT_POSITION(view_ellipse->private->position), + x, y); + + /* Unblock widget handlers */ + g_signal_handlers_unblock_by_func (G_OBJECT(view_ellipse->private->position), + position_changed_cb, view_ellipse); gl_debug (DEBUG_VIEW, "END"); } diff --git a/glabels2/src/view-image.c b/glabels2/src/view-image.c index 27bb8614..06f52ee0 100644 --- a/glabels2/src/view-image.c +++ b/glabels2/src/view-image.c @@ -72,33 +72,38 @@ static gchar *image_path = NULL; /* Private function prototypes. */ /*========================================================*/ -static void gl_view_image_class_init (glViewImageClass *klass); -static void gl_view_image_instance_init (glViewImage *view_image); -static void gl_view_image_finalize (GObject *object); +static void gl_view_image_class_init (glViewImageClass *klass); +static void gl_view_image_instance_init (glViewImage *view_image); +static void gl_view_image_finalize (GObject *object); -static void update_view_image_cb (glLabelObject *object, - glViewImage *view_image); +static void update_view_image_cb (glLabelObject *object, + glViewImage *view_image); -static GtkWidget *construct_properties_dialog (glViewImage *view_image); +static GtkWidget *construct_properties_dialog (glViewImage *view_image); -static void response_cb (GtkDialog *dialog, - gint response, - glViewImage *view_image); +static void response_cb (GtkDialog *dialog, + gint response, + glViewImage *view_image); -static void file_changed_cb (GtkEntry *pixmap_entry, - glViewImage *view_image); +static void file_changed_cb (GtkEntry *pixmap_entry, + glViewImage *view_image); static void position_changed_cb (glWdgtPosition *position, - glViewImage *view_image); + glViewImage *view_image); -static void size_changed_cb (glWdgtSize *size, - glViewImage *view_image); +static void size_changed_cb (glWdgtSize *size, + glViewImage *view_image); -static void size_reset_cb (GtkButton *button, - glViewImage *view_image); +static void size_reset_cb (GtkButton *button, + glViewImage *view_image); -static void update_dialog_cb (glLabelObject *object, - glViewImage *view_image); +static void update_dialog_cb (glLabelObject *object, + glViewImage *view_image); + +static void update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewImage *view_image); /*****************************************************************************/ @@ -368,6 +373,8 @@ construct_properties_dialog (glViewImage *view_image) /*----------------------------*/ g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (update_dialog_cb), view_image); + g_signal_connect (G_OBJECT (object), "moved", + G_CALLBACK (update_dialog_from_move_cb), view_image); gl_debug (DEBUG_VIEW, "END"); @@ -379,7 +386,7 @@ construct_properties_dialog (glViewImage *view_image) /*---------------------------------------------------------------------------*/ static void response_cb (GtkDialog *dialog, - gint response, + gint response, glViewImage *view_image) { gl_debug (DEBUG_VIEW, "START"); @@ -430,7 +437,7 @@ file_changed_cb (GtkEntry *pixmap_entry, /* PRIVATE. position "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -position_changed_cb (glWdgtPosition *position, +position_changed_cb (glWdgtPosition *position, glViewImage *view_image) { glLabelObject *object; @@ -455,7 +462,7 @@ position_changed_cb (glWdgtPosition *position, /* PRIVATE. size "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -size_changed_cb (glWdgtSize *size, +size_changed_cb (glWdgtSize *size, glViewImage *view_image) { glLabelObject *object; @@ -506,7 +513,7 @@ size_reset_cb (GtkButton *button, /* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_cb (glLabelObject *object, +update_dialog_cb (glLabelObject *object, glViewImage *view_image) { gchar *filename; @@ -550,6 +557,37 @@ update_dialog_cb (glLabelObject *object, gl_debug (DEBUG_VIEW, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. label object "moved" callback. */ +/*---------------------------------------------------------------------------*/ +static void +update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewImage *view_image) +{ + gdouble x, y; + + gl_debug (DEBUG_VIEW, "START"); + + /* Query properties of object. */ + gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); + + /* Block widget handlers to prevent recursion */ + g_signal_handlers_block_by_func (G_OBJECT(view_image->private->position), + position_changed_cb, view_image); + + /* Update widgets in property dialog */ + gl_wdgt_position_set_position (GL_WDGT_POSITION(view_image->private->position), + x, y); + + /* Unblock widget handlers */ + g_signal_handlers_unblock_by_func (G_OBJECT(view_image->private->position), + position_changed_cb, view_image); + + gl_debug (DEBUG_VIEW, "END"); +} + /*****************************************************************************/ /* Return apropos cursor for create object mode. */ /*****************************************************************************/ diff --git a/glabels2/src/view-line.c b/glabels2/src/view-line.c index 2ec83848..2cd987f8 100644 --- a/glabels2/src/view-line.c +++ b/glabels2/src/view-line.c @@ -68,30 +68,35 @@ static glViewObjectClass *parent_class = NULL; /* Private function prototypes. */ /*========================================================*/ -static void gl_view_line_class_init (glViewLineClass *klass); -static void gl_view_line_instance_init (glViewLine *view_line); -static void gl_view_line_finalize (GObject *object); +static void gl_view_line_class_init (glViewLineClass *klass); +static void gl_view_line_instance_init (glViewLine *view_line); +static void gl_view_line_finalize (GObject *object); -static void update_view_line_cb (glLabelObject *object, - glViewLine *view_line); +static void update_view_line_cb (glLabelObject *object, + glViewLine *view_line); -static GtkWidget *construct_properties_dialog (glViewLine *view_line); +static GtkWidget *construct_properties_dialog (glViewLine *view_line); -static void response_cb (GtkDialog *dialog, - gint response, - glViewLine *view_line); +static void response_cb (GtkDialog *dialog, + gint response, + glViewLine *view_line); -static void line_changed_cb (glWdgtLine *line, - glViewLine *view_line); +static void line_changed_cb (glWdgtLine *line, + glViewLine *view_line); -static void position_changed_cb (glWdgtPosition *position, - glViewLine *view_line); +static void position_changed_cb (glWdgtPosition *position, + glViewLine *view_line); -static void vector_changed_cb (glWdgtVector *vector, - glViewLine *view_line); +static void vector_changed_cb (glWdgtVector *vector, + glViewLine *view_line); -static void update_dialog_cb (glLabelObject *object, - glViewLine *view_line); +static void update_dialog_cb (glLabelObject *object, + glViewLine *view_line); + +static void update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewLine *view_line); /*****************************************************************************/ @@ -355,6 +360,8 @@ construct_properties_dialog (glViewLine *view_line) /*----------------------------*/ g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (update_dialog_cb), view_line); + g_signal_connect (G_OBJECT (object), "moved", + G_CALLBACK (update_dialog_from_move_cb), view_line); gl_debug (DEBUG_VIEW, "END"); @@ -515,6 +522,37 @@ update_dialog_cb (glLabelObject *object, gl_debug (DEBUG_VIEW, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. label object "moved" callback. */ +/*---------------------------------------------------------------------------*/ +static void +update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewLine *view_line) +{ + gdouble x, y; + + gl_debug (DEBUG_VIEW, "START"); + + /* Query properties of object. */ + gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); + + /* Block widget handlers to prevent recursion */ + g_signal_handlers_block_by_func (G_OBJECT(view_line->private->position), + position_changed_cb, view_line); + + /* Update widgets in property dialog */ + gl_wdgt_position_set_position (GL_WDGT_POSITION(view_line->private->position), + x, y); + + /* Unblock widget handlers */ + g_signal_handlers_unblock_by_func (G_OBJECT(view_line->private->position), + position_changed_cb, view_line); + + gl_debug (DEBUG_VIEW, "END"); +} + /*****************************************************************************/ /* Return apropos cursor for create object mode. */ /*****************************************************************************/ diff --git a/glabels2/src/view-text.c b/glabels2/src/view-text.c index 2d5ba759..638ebad6 100644 --- a/glabels2/src/view-text.c +++ b/glabels2/src/view-text.c @@ -74,31 +74,36 @@ static glViewObjectClass *parent_class = NULL; /*========================================================*/ static void gl_view_text_class_init (glViewTextClass *klass); -static void gl_view_text_instance_init (glViewText *view_text); -static void gl_view_text_finalize (GObject *object); +static void gl_view_text_instance_init (glViewText *view_text); +static void gl_view_text_finalize (GObject *object); -static void update_view_text_cb (glLabelObject *object, - glViewText *view_text); +static void update_view_text_cb (glLabelObject *object, + glViewText *view_text); -static GtkWidget *construct_properties_dialog (glViewText *view_text); +static GtkWidget *construct_properties_dialog (glViewText *view_text); -static void response_cb (GtkDialog *dialog, - gint response, - glViewText *view_text); +static void response_cb (GtkDialog *dialog, + gint response, + glViewText *view_text); static void text_entry_changed_cb (glWdgtTextEntry *text_entry, - glViewText *view_text); + glViewText *view_text); static void text_props_changed_cb (glWdgtTextProps *text_props, - glViewText *view_text); + glViewText *view_text); -static void position_changed_cb (glWdgtPosition *position, - glViewText *view_text); +static void position_changed_cb (glWdgtPosition *position, + glViewText *view_text); -static void update_dialog_cb (glLabelObject *object, - glViewText *view_text); +static void update_dialog_cb (glLabelObject *object, + glViewText *view_text); -static void draw_hacktext (glViewText *view_text); +static void update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewText *view_text); + +static void draw_hacktext (glViewText *view_text); /*****************************************************************************/ @@ -335,6 +340,8 @@ construct_properties_dialog (glViewText *view_text) /*----------------------------*/ g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (update_dialog_cb), view_text); + g_signal_connect (G_OBJECT (object), "moved", + G_CALLBACK (update_dialog_from_move_cb), view_text); gl_debug (DEBUG_VIEW, "END"); @@ -516,6 +523,37 @@ update_dialog_cb (glLabelObject *object, gl_debug (DEBUG_VIEW, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. label object "moved" callback. */ +/*---------------------------------------------------------------------------*/ +static void +update_dialog_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glViewText *view_text) +{ + gdouble x, y; + + gl_debug (DEBUG_VIEW, "START"); + + /* Query properties of object. */ + gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); + + /* Block widget handlers to prevent recursion */ + g_signal_handlers_block_by_func (G_OBJECT(view_text->private->position), + position_changed_cb, view_text); + + /* Update widgets in property dialog */ + gl_wdgt_position_set_position (GL_WDGT_POSITION(view_text->private->position), + x, y); + + /* Unblock widget handlers */ + g_signal_handlers_unblock_by_func (G_OBJECT(view_text->private->position), + position_changed_cb, view_text); + + gl_debug (DEBUG_VIEW, "END"); +} + /*****************************************************************************/ /* Return apropos cursor for create object mode. */ /*****************************************************************************/ -- 2.39.5