]> git.sur5r.net Git - glabels/commitdiff
view_text and view_barcode dialogs now track changes to label's merge properties.
authorJim Evins <evins@snaught.com>
Wed, 25 Sep 2002 03:13:22 +0000 (03:13 +0000)
committerJim Evins <evins@snaught.com>
Wed, 25 Sep 2002 03:13:22 +0000 (03:13 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@133 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/label-object.c
glabels2/src/label.c
glabels2/src/label.h
glabels2/src/view-barcode.c
glabels2/src/view-text.c
glabels2/src/wdgt-bc-data.c
glabels2/src/wdgt-bc-data.h
glabels2/src/wdgt-text-entry.c
glabels2/src/wdgt-text-entry.h

index 76eaa6701ed8b4345f6179b4d877d9f6ca88727e..4499b57bf1de4e50575185fd09f81d1c920e5464 100644 (file)
@@ -63,6 +63,9 @@ static void gl_label_object_class_init    (glLabelObjectClass *klass);
 static void gl_label_object_instance_init (glLabelObject      *object);
 static void gl_label_object_finalize      (GObject            *object);
 
+static void merge_changed_cb              (glLabel            *label,
+                                          glLabelObject      *object);
+
 \f
 /*****************************************************************************/
 /* Boilerplate object stuff.                                                 */
@@ -223,10 +226,16 @@ gl_label_object_set_parent (glLabelObject *object,
 
        old_parent = object->parent;
        if ( old_parent != NULL ) {
+               g_signal_handlers_disconnect_by_func (old_parent,
+                                                     G_CALLBACK(merge_changed_cb),
+                                                     object);
                gl_label_remove_object( old_parent, object );
        }
        gl_label_add_object( label, object );
 
+       g_signal_connect (G_OBJECT(label), "merge_changed",
+                         G_CALLBACK(merge_changed_cb), object);
+
        g_signal_emit (G_OBJECT(object), signals[CHANGED], 0);
 
        gl_debug (DEBUG_LABEL, "END");
@@ -424,3 +433,13 @@ gl_label_object_lower_to_bottom (glLabelObject *object)
        gl_debug (DEBUG_LABEL, "END");
 }
 
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Label's merge data changed callback.                           */
+/*--------------------------------------------------------------------------*/
+static void
+merge_changed_cb (glLabel       *label,
+                 glLabelObject *object)
+{
+       gl_label_object_emit_changed (object);
+}
+
index f857ef3dbc035393bb609c033f913a1061ee62dc..498dc5261c2238ee45b20b459ccfaea6413bdd18 100644 (file)
@@ -62,6 +62,7 @@ enum {
        CHANGED,
        NAME_CHANGED,
        MODIFIED_CHANGED,
+       MERGE_CHANGED,
        LAST_SIGNAL
 };
 
@@ -158,6 +159,15 @@ gl_label_class_init (glLabelClass *klass)
                              gl_marshal_VOID__VOID,
                              G_TYPE_NONE,
                              0);
+       signals[MERGE_CHANGED] =
+               g_signal_new ("merge_changed",
+                             G_OBJECT_CLASS_TYPE (object_class),
+                             G_SIGNAL_RUN_LAST,
+                             G_STRUCT_OFFSET (glLabelClass, merge_changed),
+                             NULL, NULL,
+                             gl_marshal_VOID__VOID,
+                             G_TYPE_NONE,
+                             0);
 
        gl_debug (DEBUG_LABEL, "END");
 }
@@ -501,6 +511,7 @@ gl_label_set_merge (glLabel *label,
 
        label->private->modified_flag = TRUE;
 
+       g_signal_emit (G_OBJECT(label), signals[MERGE_CHANGED], 0);
        g_signal_emit (G_OBJECT(label), signals[MODIFIED_CHANGED], 0);
        g_signal_emit (G_OBJECT(label), signals[CHANGED], 0);
 
index 3924de1445f89a2756b662f09f06d6cc883754c1..fbf4688c74f51b395f6f017cd90739565d2c1718 100644 (file)
@@ -58,6 +58,8 @@ struct _glLabelClass {
 
        void (*modified_changed) (glLabel *label, gpointer user_data);
 
+       void (*merge_changed)    (glLabel *label, gpointer user_data);
+
 };
 
 
index aad1f2af7ee58506d966550fb246c2bce31ca4c3..6d2441e78bce7f2556fd7ad0b40963342968fbf9 100644 (file)
@@ -310,6 +310,18 @@ construct_properties_dialog (glViewBarcode *view_barcode)
        wsection = gl_hig_category_new (_("Properties"));
        gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection);
 
+       /* Barcode style widget */
+       view_barcode->private->bc_style = gl_wdgt_bc_style_new ();
+       gl_wdgt_bc_style_set_label_size_group (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
+                                              label_size_group);
+       gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE (view_barcode->private->bc_style),
+                                    style, text_flag);
+       gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
+                                   view_barcode->private->bc_style);
+       g_signal_connect (G_OBJECT (view_barcode->private->bc_style),
+                         "changed", G_CALLBACK (bc_style_changed_cb),
+                         view_barcode);
+
        /* barcode props entry */
        gl_debug (DEBUG_VIEW, "Creating props entry...");
        view_barcode->private->bc_props = gl_wdgt_bc_props_new ();
@@ -323,18 +335,6 @@ construct_properties_dialog (glViewBarcode *view_barcode)
                           "changed", G_CALLBACK (bc_props_changed_cb),
                           view_barcode);
 
-       /* Barcode style widget */
-       view_barcode->private->bc_style = gl_wdgt_bc_style_new ();
-       gl_wdgt_bc_style_set_label_size_group (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
-                                              label_size_group);
-       gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE (view_barcode->private->bc_style),
-                                    style, text_flag);
-       gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
-                                   view_barcode->private->bc_style);
-       g_signal_connect (G_OBJECT (view_barcode->private->bc_style),
-                         "changed", G_CALLBACK (bc_style_changed_cb),
-                         view_barcode);
-
 
        /*----------------------------*/
        /* Position section           */
@@ -549,6 +549,8 @@ update_dialog_cb (glLabelObject  *object,
        gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
                                  (merge->type != GL_MERGE_NONE),
                                  text_node);
+       gl_wdgt_bc_data_set_field_defs (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
+                                       merge->field_defs);
        gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
                                     scale, color);
        gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
index 638ebad66f6ea94334fcdabb254261560eb0c6bf..2092a23d141bbdd535aa575fe84d170d8dedb38d 100644 (file)
@@ -504,6 +504,8 @@ update_dialog_cb (glLabelObject  *object,
        gl_wdgt_text_entry_set_text (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry),
                                     (merge->type != GL_MERGE_NONE),
                                     lines);
+       gl_wdgt_text_entry_set_field_defs (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry),
+                                          merge->field_defs);
        gl_wdgt_text_props_set_params (GL_WDGT_TEXT_PROPS(view_text->private->text_props),
                                       font_family, font_size, font_weight,
                                       font_italic_flag, color, just);
index 42d3844f812d87b176b37ec0cb002b3277497190..58f6a0ea792d499dfb08927f585baa7e64e980f5 100644 (file)
@@ -97,6 +97,8 @@ gl_wdgt_bc_data_class_init (glWdgtBCDataClass *class)
 {
        GObjectClass *object_class;
 
+       gl_debug (DEBUG_WDGT, "START");
+
        object_class = (GObjectClass *) class;
 
        parent_class = g_type_class_peek_parent (class);
@@ -112,16 +114,22 @@ gl_wdgt_bc_data_class_init (glWdgtBCDataClass *class)
                          gl_marshal_VOID__VOID,
                          G_TYPE_NONE, 0);
 
+       gl_debug (DEBUG_WDGT, "END");
 }
 
 static void
 gl_wdgt_bc_data_instance_init (glWdgtBCData *bc_data)
 {
+       gl_debug (DEBUG_WDGT, "START");
+
        bc_data->literal_radio = NULL;
        bc_data->literal_entry = NULL;
 
        bc_data->key_radio = NULL;
+       bc_data->key_combo = NULL;
        bc_data->key_entry = NULL;
+
+       gl_debug (DEBUG_WDGT, "END");
 }
 
 static void
@@ -130,12 +138,16 @@ gl_wdgt_bc_data_finalize (GObject *object)
        glWdgtBCData *bc_data;
        glWdgtBCDataClass *class;
 
+       gl_debug (DEBUG_WDGT, "START");
+
        g_return_if_fail (object != NULL);
        g_return_if_fail (GL_IS_WDGT_BC_DATA (object));
 
        bc_data = GL_WDGT_BC_DATA (object);
 
        G_OBJECT_CLASS (parent_class)->finalize (object);
+
+       gl_debug (DEBUG_WDGT, "END");
 }
 
 /****************************************************************************/
@@ -146,10 +158,14 @@ gl_wdgt_bc_data_new (GList *field_defs)
 {
        glWdgtBCData *bc_data;
 
+       gl_debug (DEBUG_WDGT, "START");
+
        bc_data = g_object_new (gl_wdgt_bc_data_get_type (), NULL);
 
        gl_wdgt_bc_data_construct (bc_data, field_defs);
 
+       gl_debug (DEBUG_WDGT, "END");
+
        return GTK_WIDGET (bc_data);
 }
 
@@ -160,10 +176,12 @@ static void
 gl_wdgt_bc_data_construct (glWdgtBCData *bc_data,
                           GList        *field_defs)
 {
-       GtkWidget *wvbox, *whbox, *wcombo;
+       GtkWidget *wvbox, *whbox;
        GSList *radio_group = NULL;
        GList *keys;
 
+       gl_debug (DEBUG_WDGT, "START");
+
        wvbox = GTK_WIDGET (bc_data);
 
        /* ---- Literal line ---- */
@@ -202,18 +220,21 @@ gl_wdgt_bc_data_construct (glWdgtBCData *bc_data,
        gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_data->key_radio);
 
        /* Key entry widget */
-       wcombo = gtk_combo_new ();
+       bc_data->key_combo = gtk_combo_new ();
        keys = gl_merge_get_key_list (field_defs);
        if (keys != NULL)
-               gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), keys);
+               gtk_combo_set_popdown_strings (GTK_COMBO (bc_data->key_combo),
+                                              keys);
        gl_merge_free_key_list (&keys);
-       bc_data->key_entry = GTK_COMBO (wcombo)->entry;
+       bc_data->key_entry = GTK_COMBO (bc_data->key_combo)->entry;
        gtk_entry_set_editable (GTK_ENTRY (bc_data->key_entry), FALSE);
-       gtk_widget_set_size_request (wcombo, 200, -1);
+       gtk_widget_set_size_request (bc_data->key_combo, 200, -1);
        g_signal_connect_swapped (G_OBJECT (bc_data->key_entry), "changed",
                                  G_CALLBACK (changed_cb),
                                  G_OBJECT (bc_data));
-       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wcombo);
+       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_data->key_combo);
+
+       gl_debug (DEBUG_WDGT, "END");
 }
 
 /*--------------------------------------------------------------------------*/
@@ -222,8 +243,12 @@ gl_wdgt_bc_data_construct (glWdgtBCData *bc_data,
 static void
 changed_cb (glWdgtBCData *bc_data)
 {
+       gl_debug (DEBUG_WDGT, "START");
+
        /* Emit our "changed" signal */
        g_signal_emit (G_OBJECT (bc_data), wdgt_bc_data_signals[CHANGED], 0);
+
+       gl_debug (DEBUG_WDGT, "END");
 }
 
 /*--------------------------------------------------------------------------*/
@@ -233,19 +258,50 @@ static void
 radio_toggled_cb (GtkToggleButton *togglebutton,
                  glWdgtBCData    *bc_data)
 {
+       gl_debug (DEBUG_WDGT, "START");
+
        if (gtk_toggle_button_get_active
            (GTK_TOGGLE_BUTTON (bc_data->literal_radio))) {
                gtk_widget_set_sensitive (bc_data->literal_entry, TRUE);
-               gtk_widget_set_sensitive (bc_data->key_entry, FALSE);
+               gtk_widget_set_sensitive (bc_data->key_combo, FALSE);
        } else {
                gtk_widget_set_sensitive (bc_data->literal_entry, FALSE);
-               gtk_widget_set_sensitive (bc_data->key_entry, TRUE);
+               gtk_widget_set_sensitive (bc_data->key_combo, TRUE);
        }
 
        /* Emit our "changed" signal */
        g_signal_emit (G_OBJECT (bc_data), wdgt_bc_data_signals[CHANGED], 0);
+
+       gl_debug (DEBUG_WDGT, "END");
 }
 
+/****************************************************************************/
+/* Set new field definitions.                                               */
+/****************************************************************************/
+void
+gl_wdgt_bc_data_set_field_defs  (glWdgtBCData *bc_data,
+                                GList        *field_defs)
+{
+       GList *keys;
+
+       gl_debug (DEBUG_WDGT, "START");
+
+       keys = gl_merge_get_key_list (field_defs);
+       if ( keys != NULL ) {
+               gtk_combo_set_popdown_strings (GTK_COMBO (bc_data->key_combo),
+                                              keys);
+               gl_merge_free_key_list (&keys);
+       } else {
+               keys = g_list_append (keys, "");
+               gtk_combo_set_popdown_strings (GTK_COMBO (bc_data->key_combo),
+                                              keys);
+               g_list_free (keys);
+       }
+
+       gl_debug (DEBUG_WDGT, "END");
+}
+
+
 /****************************************************************************/
 /* Get widget data.                                                         */
 /****************************************************************************/
@@ -254,6 +310,8 @@ gl_wdgt_bc_data_get_data (glWdgtBCData *bc_data)
 {
        glTextNode *text_node;
 
+       gl_debug (DEBUG_WDGT, "START");
+
        text_node = g_new0(glTextNode,1);
 
        if (gtk_toggle_button_get_active
@@ -267,7 +325,13 @@ gl_wdgt_bc_data_get_data (glWdgtBCData *bc_data)
                text_node->data = 
                    gtk_editable_get_chars (GTK_EDITABLE (bc_data->key_entry),
                                            0, -1);
+               gl_debug (DEBUG_WDGT, "text_node: field_flag=%d, data=%s",
+                         text_node->field_flag, text_node->data);
        }
+
+       gl_debug (DEBUG_WDGT, "END");
+
+       return text_node;
 }
 
 /****************************************************************************/
@@ -280,6 +344,8 @@ gl_wdgt_bc_data_set_data (glWdgtBCData *bc_data,
 {
        gint pos;
 
+       gl_debug (DEBUG_WDGT, "START");
+
        gtk_widget_set_sensitive (bc_data->key_radio, merge_flag);
 
        if (!text_node->field_flag) {
@@ -288,7 +354,7 @@ gl_wdgt_bc_data_set_data (glWdgtBCData *bc_data,
                                              (bc_data->literal_radio), TRUE);
 
                gtk_widget_set_sensitive (bc_data->literal_entry, TRUE);
-               gtk_widget_set_sensitive (bc_data->key_entry, FALSE);
+               gtk_widget_set_sensitive (bc_data->key_combo, FALSE);
 
                g_signal_handlers_block_by_func (G_OBJECT
                                                (bc_data->literal_entry),
@@ -312,7 +378,7 @@ gl_wdgt_bc_data_set_data (glWdgtBCData *bc_data,
                                              (bc_data->key_radio), TRUE);
 
                gtk_widget_set_sensitive (bc_data->literal_entry, FALSE);
-               gtk_widget_set_sensitive (bc_data->key_entry, TRUE);
+               gtk_widget_set_sensitive (bc_data->key_combo, TRUE);
 
                g_signal_handlers_block_by_func (G_OBJECT
                                                (bc_data->key_entry),
@@ -332,6 +398,7 @@ gl_wdgt_bc_data_set_data (glWdgtBCData *bc_data,
                                          &pos);
        }
 
+       gl_debug (DEBUG_WDGT, "END");
 }
 
 /****************************************************************************/
@@ -341,6 +408,10 @@ void
 gl_wdgt_bc_data_set_label_size_group (glWdgtBCData   *bc_data,
                                      GtkSizeGroup   *label_size_group)
 {
+       gl_debug (DEBUG_WDGT, "START");
+
        gtk_size_group_add_widget (label_size_group, bc_data->literal_radio);
        gtk_size_group_add_widget (label_size_group, bc_data->key_radio);
+
+       gl_debug (DEBUG_WDGT, "END");
 }
index 909d52f461077147096a41c96107c0a193461ecf..06e15126e475659f0e78cb35a24bfe37a191f161 100644 (file)
@@ -49,6 +49,7 @@ struct _glWdgtBCData {
        GtkWidget *literal_entry;
 
        GtkWidget *key_radio;
+       GtkWidget *key_combo;
        GtkWidget *key_entry;
 };
 
index 679f15036ca2de88a4b25ed09fbefc1b902872bc..1f44555041e83f734925a7049b45aa5d17ee662b 100644 (file)
@@ -120,8 +120,10 @@ gl_wdgt_text_entry_instance_init (glWdgtTextEntry *text_entry)
 {
        gl_debug (DEBUG_WDGT, "START");
 
-       text_entry->text_entry = NULL;
-       text_entry->key_entry = NULL;
+       text_entry->text_entry    = NULL;
+
+       text_entry->key_combo     = NULL;
+       text_entry->key_entry     = NULL;
        text_entry->insert_button = NULL;
 
        gl_debug (DEBUG_WDGT, "END");
@@ -171,7 +173,7 @@ static void
 gl_wdgt_text_entry_construct (glWdgtTextEntry *text_entry,
                              GList           *field_defs)
 {
-       GtkWidget *wvbox, *whbox, *wscroll, *wcombo;
+       GtkWidget *wvbox, *whbox, *wscroll;
        GList *keys;
 
        gl_debug (DEBUG_WDGT, "START");
@@ -213,15 +215,16 @@ gl_wdgt_text_entry_construct (glWdgtTextEntry *text_entry,
        gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text_entry->key_label);
 
        /* Key entry widget */
-       wcombo = gtk_combo_new ();
+       text_entry->key_combo = gtk_combo_new ();
        keys = gl_merge_get_key_list (field_defs);
        if (keys != NULL)
-               gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), keys);
+               gtk_combo_set_popdown_strings (GTK_COMBO (text_entry->key_combo),
+                                              keys);
        gl_merge_free_key_list (&keys);
-       text_entry->key_entry = GTK_COMBO (wcombo)->entry;
+       text_entry->key_entry = GTK_COMBO (text_entry->key_combo)->entry;
        gtk_entry_set_editable (GTK_ENTRY (text_entry->key_entry), FALSE);
-       gtk_widget_set_size_request (wcombo, 200, -1);
-       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wcombo);
+       gtk_widget_set_size_request (text_entry->key_combo, 200, -1);
+       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text_entry->key_combo);
 
        /* Insert button */
        text_entry->insert_button =
@@ -275,6 +278,28 @@ insert_cb (glWdgtTextEntry *text_entry)
        gl_debug (DEBUG_WDGT, "END");
 }
 
+/****************************************************************************/
+/* Set new field definitions.                                               */
+/****************************************************************************/
+void
+gl_wdgt_text_entry_set_field_defs (glWdgtTextEntry *text_entry,
+                                  GList           *field_defs)
+{
+       GList *keys;
+
+       keys = gl_merge_get_key_list (field_defs);
+       if ( keys != NULL ) {
+               gtk_combo_set_popdown_strings (GTK_COMBO (text_entry->key_combo),
+                                              keys);
+               gl_merge_free_key_list (&keys);
+       } else {
+               keys = g_list_append (keys, "");
+               gtk_combo_set_popdown_strings (GTK_COMBO (text_entry->key_combo),
+                                              keys);
+               g_list_free (keys);
+       }
+}
+
 /****************************************************************************/
 /* Get widget data.                                                         */
 /****************************************************************************/
@@ -316,7 +341,7 @@ gl_wdgt_text_entry_set_text (glWdgtTextEntry *text_entry,
 
        gl_debug (DEBUG_WDGT, "START");
 
-       gtk_widget_set_sensitive (text_entry->key_entry, merge_flag);
+       gtk_widget_set_sensitive (text_entry->key_combo, merge_flag);
        gtk_widget_set_sensitive (text_entry->insert_button, merge_flag);
 
        text = gl_text_node_lines_expand (lines, NULL);
index 5be2242a2487075b84d059ba09b7a0f01aac1567..930b93ca75927d6451d4b2f782247964b86e9a70 100644 (file)
@@ -49,6 +49,7 @@ struct _glWdgtTextEntry {
        GtkWidget     *text_entry;
 
        GtkWidget     *key_label;
+       GtkWidget     *key_combo;
        GtkWidget     *key_entry;
        GtkWidget     *insert_button;
 
@@ -61,15 +62,18 @@ struct _glWdgtTextEntryClass {
        void (*changed) (glWdgtTextEntry * text_entry, gpointer user_data);
 };
 
-guint      gl_wdgt_text_entry_get_type (void);
+guint      gl_wdgt_text_entry_get_type       (void);
 
-GtkWidget *gl_wdgt_text_entry_new      (GList           *field_defs);
+GtkWidget *gl_wdgt_text_entry_new            (GList           *field_defs);
 
-GList     *gl_wdgt_text_entry_get_text (glWdgtTextEntry *text_entry);
+void       gl_wdgt_text_entry_set_field_defs (glWdgtTextEntry *text_entry,
+                                             GList           *field_defs);
 
-void       gl_wdgt_text_entry_set_text (glWdgtTextEntry *text_entry,
-                                        gboolean        merge_flag,
-                                        GList          *lines);
+GList     *gl_wdgt_text_entry_get_text       (glWdgtTextEntry *text_entry);
+
+void       gl_wdgt_text_entry_set_text       (glWdgtTextEntry *text_entry,
+                                             gboolean         merge_flag,
+                                             GList           *lines);
 
 void       gl_wdgt_text_entry_set_label_size_group (glWdgtTextEntry *text_entry,
                                                    GtkSizeGroup    *label_size_group);