From 7d0f397683e2a28806fd2cefce1d846a2064f186 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 3 Jan 2004 03:55:02 +0000 Subject: [PATCH] 2004-01-02 Jim Evins * src/object-editor-size-page.c: (h_spin_cb): Fixed cut-n-paste error in h_spin_cb that loaded h from the wrong spinbutton. * src/object-editor.h: * src/object-editor.c: (gl_object_editor_class_init), (gl_object_editor_changed_cb), (gl_object_editor_size_changed_cb): * src/object-editor-private.h: * src/object-editor-size-page.c: (w_spin_cb), (h_spin_cb), (size_reset_cb): Added "size_changed" signal. * src/view-text.c: (construct_properties_editor), (update_object_from_editor_cb), (update_object_from_editor_size_cb): Track size changes from object editor separately from other properties. This is so the default size (0,0) of a text object is not modified unintentionally. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@399 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 21 +++++++++++++ glabels2/src/object-editor-private.h | 2 ++ glabels2/src/object-editor-size-page.c | 5 +++- glabels2/src/object-editor.c | 23 +++++++++++++++ glabels2/src/object-editor.h | 3 +- glabels2/src/view-text.c | 41 ++++++++++++++++++++++++-- 6 files changed, 90 insertions(+), 5 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index ae921b95..502236a4 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,24 @@ +2004-01-02 Jim Evins + + * src/object-editor-size-page.c: (h_spin_cb): + Fixed cut-n-paste error in h_spin_cb that loaded h from + the wrong spinbutton. + + * src/object-editor.h: + * src/object-editor.c: (gl_object_editor_class_init), + (gl_object_editor_changed_cb), (gl_object_editor_size_changed_cb): + * src/object-editor-private.h: + * src/object-editor-size-page.c: (w_spin_cb), (h_spin_cb), + (size_reset_cb): + Added "size_changed" signal. + + * src/view-text.c: (construct_properties_editor), + (update_object_from_editor_cb), + (update_object_from_editor_size_cb): + Track size changes from object editor separately from other + properties. This is so the default size (0,0) of a text + object is not modified unintentionally. + 2003-12-30 Wayne Schuller Added feature: line spacing - allows you to comfortably space a text box to diff --git a/glabels2/src/object-editor-private.h b/glabels2/src/object-editor-private.h index 61122cd7..2bc8c3e2 100644 --- a/glabels2/src/object-editor-private.h +++ b/glabels2/src/object-editor-private.h @@ -123,6 +123,7 @@ struct _glObjectEditorPrivate { enum { CHANGED, + SIZE_CHANGED, LAST_SIGNAL }; @@ -153,6 +154,7 @@ void gl_object_editor_prepare_data_page (glObjectEditor *editor); void gl_object_editor_changed_cb (glObjectEditor *editor); +void gl_object_editor_size_changed_cb (glObjectEditor *editor); void lsize_prefs_changed_cb (glObjectEditor *editor); void size_prefs_changed_cb (glObjectEditor *editor); diff --git a/glabels2/src/object-editor-size-page.c b/glabels2/src/object-editor-size-page.c index 874b2606..85b26cec 100644 --- a/glabels2/src/object-editor-size-page.c +++ b/glabels2/src/object-editor-size-page.c @@ -187,6 +187,7 @@ w_spin_cb (glObjectEditor *editor) /* Emit our "changed" signal */ g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[SIZE_CHANGED], 0); } @@ -202,7 +203,7 @@ h_spin_cb (glObjectEditor *editor) if (gtk_toggle_button_get_active (toggle)) { - h = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin)); + h = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->size_h_spin)); w = h / editor->priv->size_aspect_ratio; @@ -218,6 +219,7 @@ h_spin_cb (glObjectEditor *editor) /* Emit our "changed" signal */ g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[SIZE_CHANGED], 0); } @@ -252,6 +254,7 @@ size_reset_cb (glObjectEditor *editor) editor); /* Emit our "changed" signal */ g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[SIZE_CHANGED], 0); } /*****************************************************************************/ diff --git a/glabels2/src/object-editor.c b/glabels2/src/object-editor.c index e3cc464a..bd8a373a 100644 --- a/glabels2/src/object-editor.c +++ b/glabels2/src/object-editor.c @@ -120,6 +120,15 @@ gl_object_editor_class_init (glObjectEditorClass *klass) gl_marshal_VOID__VOID, G_TYPE_NONE, 0); + gl_object_editor_signals[SIZE_CHANGED] = + g_signal_new ("size_changed", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (glObjectEditorClass, size_changed), + NULL, NULL, + gl_marshal_VOID__VOID, + G_TYPE_NONE, 0); + gl_debug (DEBUG_EDITOR, "END"); } @@ -334,6 +343,20 @@ gl_object_editor_changed_cb (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "END"); } +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Widget size changed callback. Emit our "size-changed" signal. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_size_changed_cb (glObjectEditor *editor) +{ + gl_debug (DEBUG_EDITOR, "START"); + + /* Emit our "size_changed" signal */ + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[SIZE_CHANGED], 0); + + gl_debug (DEBUG_EDITOR, "END"); +} + /*****************************************************************************/ /* Set possible key names from merge object. */ /*****************************************************************************/ diff --git a/glabels2/src/object-editor.h b/glabels2/src/object-editor.h index 2e13c9fd..bf9273f4 100644 --- a/glabels2/src/object-editor.h +++ b/glabels2/src/object-editor.h @@ -71,7 +71,8 @@ struct _glObjectEditorClass { GtkVBoxClass parent_class; - void (*changed) (glObjectEditor *editor, gpointer user_data); + void (*changed) (glObjectEditor *editor, gpointer user_data); + void (*size_changed) (glObjectEditor *editor, gpointer user_data); }; diff --git a/glabels2/src/view-text.c b/glabels2/src/view-text.c index 0727399b..45c60bbd 100644 --- a/glabels2/src/view-text.c +++ b/glabels2/src/view-text.c @@ -84,6 +84,9 @@ static void update_canvas_item_from_object_cb (glLabelObject *object, static void update_object_from_editor_cb (glObjectEditor *editor, glLabelObject *object); +static void update_object_from_editor_size_cb (glObjectEditor *editor, + glLabelObject *object); + static void update_editor_from_object_cb (glLabelObject *object, glObjectEditor *editor); @@ -261,6 +264,8 @@ construct_properties_editor (glViewObject *view_object) /* Connect signals. */ g_signal_connect (G_OBJECT (editor), "changed", G_CALLBACK(update_object_from_editor_cb), object); + g_signal_connect (G_OBJECT (editor), "size_changed", + G_CALLBACK(update_object_from_editor_size_cb), object); g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (update_editor_from_object_cb), editor); g_signal_connect (G_OBJECT (object), "moved", @@ -298,7 +303,7 @@ static void update_object_from_editor_cb (glObjectEditor *editor, glLabelObject *object) { - gdouble x, y, w, h; + gdouble x, y; gchar *font_family; gdouble font_size; GnomeFontWeight font_weight; @@ -317,7 +322,6 @@ update_object_from_editor_cb (glObjectEditor *editor, editor); gl_object_editor_get_position (editor, &x, &y); - gl_object_editor_get_size (editor, &w, &h); font_family = gl_object_editor_get_font_family (editor); font_size = gl_object_editor_get_font_size (editor); font_weight = gl_object_editor_get_font_weight (editor); @@ -327,7 +331,6 @@ update_object_from_editor_cb (glObjectEditor *editor, text_line_spacing = (gdouble) gl_object_editor_get_text_line_spacing (editor); gl_label_object_set_position (object, x, y); - gl_label_object_set_size (object, w, h); gl_label_object_set_font_family (object, font_family); gl_label_object_set_font_size (object, font_size); gl_label_object_set_font_weight (object, font_weight); @@ -348,6 +351,38 @@ update_object_from_editor_cb (glObjectEditor *editor, gl_debug (DEBUG_VIEW, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. editor "changed" callback. */ +/*---------------------------------------------------------------------------*/ +static void +update_object_from_editor_size_cb (glObjectEditor *editor, + glLabelObject *object) +{ + gdouble w, h; + + gl_debug (DEBUG_VIEW, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(object), + update_editor_from_object_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); + + gl_object_editor_get_size (editor, &w, &h); + + gl_label_object_set_size (object, w, h); + + g_signal_handlers_unblock_by_func (G_OBJECT(object), + update_editor_from_object_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); + + gl_debug (DEBUG_VIEW, "END"); +} + /*---------------------------------------------------------------------------*/ /* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ -- 2.39.5