From af9ffce2cdf1661abfb7268bf5e96981ee7c4097 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 23 Sep 2002 02:55:15 +0000 Subject: [PATCH] Additional dialogs and widgets migrated to use HIG module. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@131 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/view-barcode.c | 87 +++---- glabels2/src/view-image.c | 2 +- glabels2/src/wdgt-bc-data.c | 116 ++++----- glabels2/src/wdgt-bc-data.h | 27 ++- glabels2/src/wdgt-bc-props.c | 133 +++++----- glabels2/src/wdgt-bc-props.h | 31 ++- glabels2/src/wdgt-bc-style.c | 455 +++++++++++------------------------ glabels2/src/wdgt-bc-style.h | 44 ++-- 8 files changed, 377 insertions(+), 518 deletions(-) diff --git a/glabels2/src/view-barcode.c b/glabels2/src/view-barcode.c index fe15e158..6b9a92f1 100644 --- a/glabels2/src/view-barcode.c +++ b/glabels2/src/view-barcode.c @@ -239,7 +239,7 @@ update_view_barcode_cb (glLabelObject *object, static GtkWidget * construct_properties_dialog (glViewBarcode *view_barcode) { - GtkWidget *dialog, *notebook, *wvbox, *wbutton; + GtkWidget *dialog, *wsection; BonoboWindow *win = glabels_get_active_window (); glLabelObject *object; gdouble x, y, w, h, label_width, label_height; @@ -249,6 +249,7 @@ construct_properties_dialog (glViewBarcode *view_barcode) guint color; gdouble scale; glMerge *merge; + GtkSizeGroup *label_size_group; gl_debug (DEBUG_VIEW, "START"); @@ -263,98 +264,88 @@ construct_properties_dialog (glViewBarcode *view_barcode) merge = gl_label_get_merge (GL_LABEL(object->parent)); /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ + /* Build dialog. */ /*-----------------------------------------------------------------*/ - gl_debug (DEBUG_VIEW, "Creating dialog..."); - dialog = gtk_dialog_new_with_buttons ( _("Edit barcode object properties"), - GTK_WINDOW (win), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, + dialog = gl_hig_dialog_new_with_buttons ( _("Edit barcode object properties"), + GTK_WINDOW (win), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, - NULL ); + NULL ); + gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (response_cb), view_barcode); - notebook = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), - notebook, TRUE, TRUE, 0); + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); /*---------------------------*/ - /* Data Notebook Tab */ + /* Data section */ /*---------------------------*/ - gl_debug (DEBUG_VIEW, "Creating data tab..."); - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox, - gtk_label_new (_("Data"))); + wsection = gl_hig_category_new (_("Data")); + gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); /* barcode data */ - gl_debug (DEBUG_VIEW, "Creating data entry..."); view_barcode->private->bc_data = - gl_wdgt_bc_data_new (_("Barcode data"), merge->field_defs); - gl_debug (DEBUG_VIEW, "1"); + gl_wdgt_bc_data_new (merge->field_defs); + gl_wdgt_bc_data_set_label_size_group (GL_WDGT_BC_DATA(view_barcode->private->bc_data), + label_size_group); gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data), (merge->type != GL_MERGE_NONE), text_node); - gl_debug (DEBUG_VIEW, "2"); - gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_data, - FALSE, FALSE, 0); - gl_debug (DEBUG_VIEW, "3"); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), + view_barcode->private->bc_data); g_signal_connect ( G_OBJECT(view_barcode->private->bc_data), "changed", G_CALLBACK (bc_data_changed_cb), view_barcode); /*---------------------------*/ - /* Appearance Notebook Tab */ + /* Appearance section */ /*---------------------------*/ - gl_debug (DEBUG_VIEW, "Creating props tab..."); - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox, - gtk_label_new (_("Appearance"))); + wsection = gl_hig_category_new (_("Properties")); + gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); /* barcode props entry */ gl_debug (DEBUG_VIEW, "Creating props entry..."); - view_barcode->private->bc_props = - gl_wdgt_bc_props_new (_("Barcode Properties")); + view_barcode->private->bc_props = gl_wdgt_bc_props_new (); + gl_wdgt_bc_props_set_label_size_group (GL_WDGT_BC_PROPS(view_barcode->private->bc_props), + label_size_group); gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props), scale, color); - gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_props, - FALSE, FALSE, 0); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), + view_barcode->private->bc_props); g_signal_connect ( G_OBJECT(view_barcode->private->bc_props), "changed", G_CALLBACK (bc_props_changed_cb), view_barcode); - /* ------ Barcode Style Frame ------ */ - view_barcode->private->bc_style = gl_wdgt_bc_style_new (_("Style")); + /* 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); - gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_style, - FALSE, FALSE, 0); + 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/Size Notebook Tab */ + /* Position section */ /*----------------------------*/ - gl_debug (DEBUG_VIEW, "Creating position tab..."); - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox, - gtk_label_new (_("Position"))); + wsection = gl_hig_category_new (_("Position")); + gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); /* ------ Position Frame ------ */ - gl_debug (DEBUG_VIEW, "Creating position entry..."); view_barcode->private->position = gl_wdgt_position_new (); + gl_wdgt_position_set_label_size_group (GL_WDGT_POSITION(view_barcode->private->position), + label_size_group); gl_wdgt_position_set_params (GL_WDGT_POSITION (view_barcode->private->position), x, y, label_width, label_height); - gtk_box_pack_start (GTK_BOX (wvbox), - view_barcode->private->position, - FALSE, FALSE, 0); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), + view_barcode->private->position); g_signal_connect (G_OBJECT (view_barcode->private->position), "changed", G_CALLBACK(position_changed_cb), view_barcode); diff --git a/glabels2/src/view-image.c b/glabels2/src/view-image.c index 3f58ec46..27bb8614 100644 --- a/glabels2/src/view-image.c +++ b/glabels2/src/view-image.c @@ -277,7 +277,7 @@ construct_properties_dialog (glViewImage *view_image) &label_width, &label_height); /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ + /* Build dialog. */ /*-----------------------------------------------------------------*/ dialog = gl_hig_dialog_new_with_buttons ( _("Edit image object properties"), GTK_WINDOW (win), diff --git a/glabels2/src/wdgt-bc-data.c b/glabels2/src/wdgt-bc-data.c index 7093cc45..42d3844f 100644 --- a/glabels2/src/wdgt-bc-data.c +++ b/glabels2/src/wdgt-bc-data.c @@ -43,7 +43,7 @@ typedef void (*glWdgtBCDataSignal) (GObject * object, gpointer data); /* Private globals */ /*===========================================*/ -static GtkContainerClass *parent_class; +static glHigVBoxClass *parent_class; static gint wdgt_bc_data_signals[LAST_SIGNAL] = { 0 }; @@ -51,19 +51,20 @@ static gint wdgt_bc_data_signals[LAST_SIGNAL] = { 0 }; /* Local function prototypes */ /*===========================================*/ -static void gl_wdgt_bc_data_class_init (glWdgtBCDataClass * class); -static void gl_wdgt_bc_data_instance_init (glWdgtBCData * bc_data); -static void gl_wdgt_bc_data_finalize (GObject * object); -static void gl_wdgt_bc_data_construct (glWdgtBCData * bc_data, - gchar * label, GList * field_defs); +static void gl_wdgt_bc_data_class_init (glWdgtBCDataClass *class); +static void gl_wdgt_bc_data_instance_init (glWdgtBCData *bc_data); +static void gl_wdgt_bc_data_finalize (GObject *object); +static void gl_wdgt_bc_data_construct (glWdgtBCData *bc_data, + GList *field_defs); + +static void changed_cb (glWdgtBCData *bc_data); +static void radio_toggled_cb (GtkToggleButton *togglebutton, + glWdgtBCData *bc_data); -static void changed_cb (glWdgtBCData * bc_data); -static void radio_toggled_cb (GtkToggleButton * togglebutton, - glWdgtBCData * bc_data); -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ +/****************************************************************************/ +/* Boilerplate Object stuff. */ +/****************************************************************************/ guint gl_wdgt_bc_data_get_type (void) { @@ -83,7 +84,7 @@ gl_wdgt_bc_data_get_type (void) }; wdgt_bc_data_type = - g_type_register_static (gtk_vbox_get_type (), + g_type_register_static (gl_hig_vbox_get_type (), "glWdgtBCData", &wdgt_bc_data_info, 0); } @@ -92,13 +93,13 @@ gl_wdgt_bc_data_get_type (void) } static void -gl_wdgt_bc_data_class_init (glWdgtBCDataClass * class) +gl_wdgt_bc_data_class_init (glWdgtBCDataClass *class) { GObjectClass *object_class; object_class = (GObjectClass *) class; - parent_class = gtk_type_class (gtk_vbox_get_type ()); + parent_class = g_type_class_peek_parent (class); object_class->finalize = gl_wdgt_bc_data_finalize; @@ -114,7 +115,7 @@ gl_wdgt_bc_data_class_init (glWdgtBCDataClass * class) } static void -gl_wdgt_bc_data_instance_init (glWdgtBCData * bc_data) +gl_wdgt_bc_data_instance_init (glWdgtBCData *bc_data) { bc_data->literal_radio = NULL; bc_data->literal_entry = NULL; @@ -124,7 +125,7 @@ gl_wdgt_bc_data_instance_init (glWdgtBCData * bc_data) } static void -gl_wdgt_bc_data_finalize (GObject * object) +gl_wdgt_bc_data_finalize (GObject *object) { glWdgtBCData *bc_data; glWdgtBCDataClass *class; @@ -137,41 +138,37 @@ gl_wdgt_bc_data_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } +/****************************************************************************/ +/* New widget. */ +/****************************************************************************/ GtkWidget * -gl_wdgt_bc_data_new (gchar * label, - GList * field_defs) +gl_wdgt_bc_data_new (GList *field_defs) { glWdgtBCData *bc_data; bc_data = g_object_new (gl_wdgt_bc_data_get_type (), NULL); - gl_wdgt_bc_data_construct (bc_data, label, field_defs); + gl_wdgt_bc_data_construct (bc_data, field_defs); return GTK_WIDGET (bc_data); } -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Construct composite widget. */ +/*--------------------------------------------------------------------------*/ static void -gl_wdgt_bc_data_construct (glWdgtBCData * bc_data, - gchar * label, - GList * field_defs) +gl_wdgt_bc_data_construct (glWdgtBCData *bc_data, + GList *field_defs) { - GtkWidget *wvbox, *wframe, *wtable, *wcombo; + GtkWidget *wvbox, *whbox, *wcombo; GSList *radio_group = NULL; GList *keys; wvbox = GTK_WIDGET (bc_data); - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (2, 2, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); + /* ---- Literal line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); /* Literal radio */ bc_data->literal_radio = gtk_radio_button_new_with_label (radio_group, @@ -182,8 +179,7 @@ gl_wdgt_bc_data_construct (glWdgtBCData * bc_data, g_signal_connect (G_OBJECT (bc_data->literal_radio), "toggled", G_CALLBACK (radio_toggled_cb), G_OBJECT (bc_data)); - gtk_table_attach_defaults (GTK_TABLE (wtable), bc_data->literal_radio, - 0, 1, 0, 1); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_data->literal_radio); /* Literal entry widget */ bc_data->literal_entry = gtk_entry_new (); @@ -191,8 +187,11 @@ gl_wdgt_bc_data_construct (glWdgtBCData * bc_data, g_signal_connect_swapped (G_OBJECT (bc_data->literal_entry), "changed", G_CALLBACK (changed_cb), G_OBJECT (bc_data)); - gtk_table_attach_defaults (GTK_TABLE (wtable), bc_data->literal_entry, - 1, 2, 0, 1); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_data->literal_entry); + + /* ---- Key line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); /* Key radio */ bc_data->key_radio = gtk_radio_button_new_with_label (radio_group, @@ -200,8 +199,7 @@ gl_wdgt_bc_data_construct (glWdgtBCData * bc_data, g_signal_connect (G_OBJECT (bc_data->key_radio), "toggled", G_CALLBACK (radio_toggled_cb), G_OBJECT (bc_data)); - gtk_table_attach_defaults (GTK_TABLE (wtable), bc_data->key_radio, - 0, 1, 1, 2); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_data->key_radio); /* Key entry widget */ wcombo = gtk_combo_new (); @@ -215,15 +213,14 @@ gl_wdgt_bc_data_construct (glWdgtBCData * bc_data, g_signal_connect_swapped (G_OBJECT (bc_data->key_entry), "changed", G_CALLBACK (changed_cb), G_OBJECT (bc_data)); - gtk_table_attach_defaults (GTK_TABLE (wtable), wcombo, 1, 2, 1, 2); - + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wcombo); } /*--------------------------------------------------------------------------*/ /* PRIVATE. Callback for when any control in the widget has changed. */ /*--------------------------------------------------------------------------*/ static void -changed_cb (glWdgtBCData * bc_data) +changed_cb (glWdgtBCData *bc_data) { /* Emit our "changed" signal */ g_signal_emit (G_OBJECT (bc_data), wdgt_bc_data_signals[CHANGED], 0); @@ -233,8 +230,8 @@ changed_cb (glWdgtBCData * bc_data) /* PRIVATE. Callback to handle toggling of radio buttons */ /*--------------------------------------------------------------------------*/ static void -radio_toggled_cb (GtkToggleButton * togglebutton, - glWdgtBCData * bc_data) +radio_toggled_cb (GtkToggleButton *togglebutton, + glWdgtBCData *bc_data) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (bc_data->literal_radio))) { @@ -249,11 +246,11 @@ radio_toggled_cb (GtkToggleButton * togglebutton, g_signal_emit (G_OBJECT (bc_data), wdgt_bc_data_signals[CHANGED], 0); } -/*--------------------------------------------------------------------------*/ +/****************************************************************************/ /* Get widget data. */ -/*--------------------------------------------------------------------------*/ +/****************************************************************************/ glTextNode * -gl_wdgt_bc_data_get_data (glWdgtBCData * bc_data) +gl_wdgt_bc_data_get_data (glWdgtBCData *bc_data) { glTextNode *text_node; @@ -273,13 +270,13 @@ gl_wdgt_bc_data_get_data (glWdgtBCData * bc_data) } } -/*--------------------------------------------------------------------------*/ +/****************************************************************************/ /* Set widget data. */ -/*--------------------------------------------------------------------------*/ +/****************************************************************************/ void -gl_wdgt_bc_data_set_data (glWdgtBCData * bc_data, - gboolean merge_flag, - glTextNode *text_node) +gl_wdgt_bc_data_set_data (glWdgtBCData *bc_data, + gboolean merge_flag, + glTextNode *text_node) { gint pos; @@ -336,3 +333,14 @@ gl_wdgt_bc_data_set_data (glWdgtBCData * bc_data, } } + +/****************************************************************************/ +/* Set size group for internal labels */ +/****************************************************************************/ +void +gl_wdgt_bc_data_set_label_size_group (glWdgtBCData *bc_data, + GtkSizeGroup *label_size_group) +{ + gtk_size_group_add_widget (label_size_group, bc_data->literal_radio); + gtk_size_group_add_widget (label_size_group, bc_data->key_radio); +} diff --git a/glabels2/src/wdgt-bc-data.h b/glabels2/src/wdgt-bc-data.h index e7771b23..909d52f4 100644 --- a/glabels2/src/wdgt-bc-data.h +++ b/glabels2/src/wdgt-bc-data.h @@ -25,6 +25,9 @@ #include #include "text-node.h" +#include "hig.h" + +G_BEGIN_DECLS #define GL_TYPE_WDGT_BC_DATA (gl_wdgt_bc_data_get_type ()) #define GL_WDGT_BC_DATA(obj) \ @@ -40,7 +43,7 @@ typedef struct _glWdgtBCData glWdgtBCData; typedef struct _glWdgtBCDataClass glWdgtBCDataClass; struct _glWdgtBCData { - GtkVBox parent_widget; + glHigVBox parent_widget; GtkWidget *literal_radio; GtkWidget *literal_entry; @@ -50,19 +53,27 @@ struct _glWdgtBCData { }; struct _glWdgtBCDataClass { - GtkVBoxClass parent_class; + glHigVBoxClass parent_class; void (*changed) (glWdgtBCData * bc_data, gpointer user_data); }; -extern guint gl_wdgt_bc_data_get_type (void); +guint gl_wdgt_bc_data_get_type (void); + +GtkWidget *gl_wdgt_bc_data_new (GList *field_defs); + +void gl_wdgt_bc_data_set_field_defs (glWdgtBCData *bc_data, + GList *field_defs); + +glTextNode *gl_wdgt_bc_data_get_data (glWdgtBCData *bc_data); -extern GtkWidget *gl_wdgt_bc_data_new (gchar * label, GList * field_defs); +void gl_wdgt_bc_data_set_data (glWdgtBCData *bc_data, + gboolean merge_flag, + glTextNode *text_node); -extern glTextNode *gl_wdgt_bc_data_get_data (glWdgtBCData * bc_data); +void gl_wdgt_bc_data_set_label_size_group (glWdgtBCData *bc_data, + GtkSizeGroup *label_size_group); -extern void gl_wdgt_bc_data_set_data (glWdgtBCData * bc_data, - gboolean merge_flag, - glTextNode *text_node); +G_END_DECLS #endif diff --git a/glabels2/src/wdgt-bc-props.c b/glabels2/src/wdgt-bc-props.c index b83fd9a3..a81aa8a9 100644 --- a/glabels2/src/wdgt-bc-props.c +++ b/glabels2/src/wdgt-bc-props.c @@ -43,7 +43,7 @@ typedef void (*glWdgtBCPropsSignal) (GObject * object, gpointer data); /* Private globals */ /*===========================================*/ -static GtkContainerClass *parent_class; +static glHigVBoxClass *parent_class; static gint wdgt_bc_props_signals[LAST_SIGNAL] = { 0 }; @@ -51,15 +51,16 @@ static gint wdgt_bc_props_signals[LAST_SIGNAL] = { 0 }; /* Local function prototypes */ /*===========================================*/ -static void gl_wdgt_bc_props_class_init (glWdgtBCPropsClass * class); -static void gl_wdgt_bc_props_instance_init (glWdgtBCProps * prop); -static void gl_wdgt_bc_props_finalize (GObject * object); -static void gl_wdgt_bc_props_construct (glWdgtBCProps * prop, gchar * label); -static void changed_cb (glWdgtBCProps * prop); +static void gl_wdgt_bc_props_class_init (glWdgtBCPropsClass *class); +static void gl_wdgt_bc_props_instance_init (glWdgtBCProps *prop); +static void gl_wdgt_bc_props_finalize (GObject *object); +static void gl_wdgt_bc_props_construct (glWdgtBCProps *prop); + +static void changed_cb (glWdgtBCProps *prop); -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ +/***************************************************************************/ +/* Boilerplate Object stuff. */ +/***************************************************************************/ guint gl_wdgt_bc_props_get_type (void) { @@ -79,21 +80,22 @@ gl_wdgt_bc_props_get_type (void) }; wdgt_bc_props_type = - g_type_register_static (gtk_vbox_get_type (), - "glWdgtBCProps", &wdgt_bc_props_info, 0); + g_type_register_static (gl_hig_vbox_get_type (), + "glWdgtBCProps", + &wdgt_bc_props_info, 0); } return wdgt_bc_props_type; } static void -gl_wdgt_bc_props_class_init (glWdgtBCPropsClass * class) +gl_wdgt_bc_props_class_init (glWdgtBCPropsClass *class) { GObjectClass *object_class; object_class = (GObjectClass *) class; - parent_class = gtk_type_class (gtk_vbox_get_type ()); + parent_class = g_type_class_peek_parent (class); object_class->finalize = gl_wdgt_bc_props_finalize; @@ -109,7 +111,7 @@ gl_wdgt_bc_props_class_init (glWdgtBCPropsClass * class) } static void -gl_wdgt_bc_props_instance_init (glWdgtBCProps * prop) +gl_wdgt_bc_props_instance_init (glWdgtBCProps *prop) { prop->scale_spin = NULL; prop->color_picker = NULL; @@ -129,44 +131,41 @@ gl_wdgt_bc_props_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } +/***************************************************************************/ +/* New widget. */ +/***************************************************************************/ GtkWidget * -gl_wdgt_bc_props_new (gchar * label) +gl_wdgt_bc_props_new (void) { glWdgtBCProps *prop; prop = g_object_new (gl_wdgt_bc_props_get_type (), NULL); - gl_wdgt_bc_props_construct (prop, label); + gl_wdgt_bc_props_construct (prop); return GTK_WIDGET (prop); } - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ + +/*------------------------------------------------------------------------*/ +/* PRIVATE. Construct composite widget. */ +/*------------------------------------------------------------------------*/ static void -gl_wdgt_bc_props_construct (glWdgtBCProps * prop, - gchar * label) +gl_wdgt_bc_props_construct (glWdgtBCProps *prop) { - GtkWidget *wvbox, *wframe, *wtable, *wlabel; + GtkWidget *wvbox, *whbox, *wlabel; GtkObject *adjust; wvbox = GTK_WIDGET (prop); - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (2, 3, TRUE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); + /* ---- Scale line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); /* Scale Label */ - wlabel = gtk_label_new (_("Scale:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); + prop->scale_label = gtk_label_new (_("Scale:")); + gtk_misc_set_alignment (GTK_MISC (prop->scale_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), prop->scale_label); + /* Scale widget */ adjust = gtk_adjustment_new (100.0, 50.0, 200.0, 10.0, 10.0, 10.0); prop->scale_spin = @@ -174,45 +173,47 @@ gl_wdgt_bc_props_construct (glWdgtBCProps * prop, g_signal_connect_swapped (G_OBJECT (prop->scale_spin), "changed", G_CALLBACK (changed_cb), G_OBJECT (prop)); - gtk_table_attach_defaults (GTK_TABLE (wtable), prop->scale_spin, 1, 2, - 0, 1); - /* % Label */ + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), prop->scale_spin); + + /* scale % Label */ wlabel = gtk_label_new (_("%")); gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 2, 3, 0, 1); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wlabel); + + /* ---- Color line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); /* Line Color Label */ - wlabel = gtk_label_new (_("Color:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); + prop->color_label = gtk_label_new (_("Color:")); + gtk_misc_set_alignment (GTK_MISC (prop->color_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), prop->color_label); + /* Line Color picker widget */ prop->color_picker = gnome_color_picker_new (); g_signal_connect_swapped (G_OBJECT (prop->color_picker), "color_set", G_CALLBACK (changed_cb), G_OBJECT (prop)); - gtk_table_attach_defaults (GTK_TABLE (wtable), prop->color_picker, 1, 3, - 1, 2); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), prop->color_picker); } /*--------------------------------------------------------------------------*/ /* PRIVATE. Callback for when any control in the widget has changed. */ /*--------------------------------------------------------------------------*/ static void -changed_cb (glWdgtBCProps * prop) +changed_cb (glWdgtBCProps *prop) { /* Emit our "changed" signal */ g_signal_emit (G_OBJECT (prop), wdgt_bc_props_signals[CHANGED], 0); } - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ + +/***************************************************************************/ +/* query values from controls. */ +/***************************************************************************/ void -gl_wdgt_bc_props_get_params (glWdgtBCProps * prop, - gdouble * scale, - guint * color) +gl_wdgt_bc_props_get_params (glWdgtBCProps *prop, + gdouble *scale, + guint *color) { guint8 r, g, b, a; @@ -228,13 +229,13 @@ gl_wdgt_bc_props_get_params (glWdgtBCProps * prop, } -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ +/***************************************************************************/ +/* fill in values and ranges for controls. */ +/***************************************************************************/ void -gl_wdgt_bc_props_set_params (glWdgtBCProps * prop, - gdouble scale, - guint color) +gl_wdgt_bc_props_set_params (glWdgtBCProps *prop, + gdouble scale, + guint color) { scale *= 100.0; gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop->scale_spin), scale); @@ -245,3 +246,15 @@ gl_wdgt_bc_props_set_params (glWdgtBCProps * prop, GL_COLOR_I_BLUE (color), GL_COLOR_I_ALPHA (color)); } + +/****************************************************************************/ +/* Set size group for internal labels */ +/****************************************************************************/ +void +gl_wdgt_bc_props_set_label_size_group (glWdgtBCProps *prop, + GtkSizeGroup *label_size_group) +{ + gtk_size_group_add_widget (label_size_group, prop->scale_label); + gtk_size_group_add_widget (label_size_group, prop->color_label); +} + diff --git a/glabels2/src/wdgt-bc-props.h b/glabels2/src/wdgt-bc-props.h index 1f67cd87..dfa5b69b 100644 --- a/glabels2/src/wdgt-bc-props.h +++ b/glabels2/src/wdgt-bc-props.h @@ -25,6 +25,9 @@ #include #include "bc.h" +#include "hig.h" + +G_BEGIN_DECLS #define GL_TYPE_WDGT_BC_PROPS (gl_wdgt_bc_props_get_type ()) #define GL_WDGT_BC_PROPS(obj) \ @@ -40,28 +43,36 @@ typedef struct _glWdgtBCProps glWdgtBCProps; typedef struct _glWdgtBCPropsClass glWdgtBCPropsClass; struct _glWdgtBCProps { - GtkVBox parent_widget; + glHigVBox parent_widget; + GtkWidget *scale_label; GtkWidget *scale_spin; + + GtkWidget *color_label; GtkWidget *color_picker; }; struct _glWdgtBCPropsClass { - GtkVBoxClass parent_class; + glHigVBoxClass parent_class; void (*changed) (glWdgtBCProps * prop, gpointer user_data); }; -extern guint gl_wdgt_bc_props_get_type (void); +guint gl_wdgt_bc_props_get_type (void); + +GtkWidget *gl_wdgt_bc_props_new (void); + +void gl_wdgt_bc_props_get_params (glWdgtBCProps *prop, + gdouble *scale, + guint *color); -extern GtkWidget *gl_wdgt_bc_props_new (gchar * label); +void gl_wdgt_bc_props_set_params (glWdgtBCProps *prop, + gdouble scale, + guint color); -extern void gl_wdgt_bc_props_get_params (glWdgtBCProps * prop, - gdouble * scale, - guint * color); +void gl_wdgt_bc_props_set_label_size_group (glWdgtBCProps *prop, + GtkSizeGroup *label_size_group); -extern void gl_wdgt_bc_props_set_params (glWdgtBCProps * prop, - gdouble scale, - guint color); +G_END_DECLS #endif diff --git a/glabels2/src/wdgt-bc-style.c b/glabels2/src/wdgt-bc-style.c index 07049a3e..d19cbe04 100644 --- a/glabels2/src/wdgt-bc-style.c +++ b/glabels2/src/wdgt-bc-style.c @@ -42,7 +42,7 @@ typedef void (*glWdgtBCStyleSignal) (GObject * object, gpointer data); /* Private globals */ /*===========================================*/ -static GtkContainerClass *parent_class; +static glHigVBoxClass *parent_class; static gint wdgt_bc_style_signals[LAST_SIGNAL] = { 0 }; @@ -50,16 +50,16 @@ static gint wdgt_bc_style_signals[LAST_SIGNAL] = { 0 }; /* Local function prototypes */ /*===========================================*/ -static void gl_wdgt_bc_style_class_init (glWdgtBCStyleClass * class); -static void gl_wdgt_bc_style_instance_init (glWdgtBCStyle * prop_style); -static void gl_wdgt_bc_style_finalize (GObject * object); -static void gl_wdgt_bc_style_construct (glWdgtBCStyle * prop_style, - gchar * label); -static void changed_cb (glWdgtBCStyle * prop_style); +static void gl_wdgt_bc_style_class_init (glWdgtBCStyleClass *class); +static void gl_wdgt_bc_style_instance_init (glWdgtBCStyle *bc_style); +static void gl_wdgt_bc_style_finalize (GObject *object); +static void gl_wdgt_bc_style_construct (glWdgtBCStyle *bc_style); + +static void changed_cb (glWdgtBCStyle *bc_style); -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ +/****************************************************************************/ +/* Boilerplate Object stuff. */ +/****************************************************************************/ guint gl_wdgt_bc_style_get_type (void) { @@ -79,7 +79,7 @@ gl_wdgt_bc_style_get_type (void) }; wdgt_bc_style_type = - g_type_register_static (gtk_vbox_get_type (), + g_type_register_static (gl_hig_vbox_get_type (), "glWdgtBCStyle", &wdgt_bc_style_info, 0); } @@ -88,13 +88,13 @@ gl_wdgt_bc_style_get_type (void) } static void -gl_wdgt_bc_style_class_init (glWdgtBCStyleClass * class) +gl_wdgt_bc_style_class_init (glWdgtBCStyleClass *class) { GObjectClass *object_class; object_class = (GObjectClass *) class; - parent_class = gtk_type_class (gtk_vbox_get_type ()); + parent_class = g_type_class_peek_parent (class); object_class->finalize = gl_wdgt_bc_style_finalize; @@ -110,215 +110,107 @@ gl_wdgt_bc_style_class_init (glWdgtBCStyleClass * class) } static void -gl_wdgt_bc_style_instance_init (glWdgtBCStyle * prop_style) +gl_wdgt_bc_style_instance_init (glWdgtBCStyle *bc_style) { - prop_style->postnet_radio = NULL; - prop_style->ean_radio = NULL; - prop_style->upc_radio = NULL; - prop_style->isbn_radio = NULL; - prop_style->code39_radio = NULL; - prop_style->code128_radio = NULL; - prop_style->code128c_radio = NULL; - prop_style->code128b_radio = NULL; - prop_style->i25_radio = NULL; - prop_style->cbr_radio = NULL; - prop_style->msi_radio = NULL; - prop_style->pls_radio = NULL; + bc_style->style_label = NULL; + bc_style->style_entry = NULL; + bc_style->text_check = NULL; } static void -gl_wdgt_bc_style_finalize (GObject * object) +gl_wdgt_bc_style_finalize (GObject *object) { - glWdgtBCStyle *prop_style; + glWdgtBCStyle *bc_style; glWdgtBCStyleClass *class; g_return_if_fail (object != NULL); g_return_if_fail (GL_IS_WDGT_BC_STYLE (object)); - prop_style = GL_WDGT_BC_STYLE (object); + bc_style = GL_WDGT_BC_STYLE (object); G_OBJECT_CLASS (parent_class)->finalize (object); } +/****************************************************************************/ +/* New widget. */ +/****************************************************************************/ GtkWidget * -gl_wdgt_bc_style_new (gchar * label) +gl_wdgt_bc_style_new (void) { - glWdgtBCStyle *prop_style; + glWdgtBCStyle *bc_style; - prop_style = g_object_new (gl_wdgt_bc_style_get_type (), NULL); + bc_style = g_object_new (gl_wdgt_bc_style_get_type (), NULL); - gl_wdgt_bc_style_construct (prop_style, label); + gl_wdgt_bc_style_construct (bc_style); - return GTK_WIDGET (prop_style); + return GTK_WIDGET (bc_style); } - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Construct composite widget. */ +/*--------------------------------------------------------------------------*/ static void -gl_wdgt_bc_style_construct (glWdgtBCStyle * prop, - gchar * label) +gl_wdgt_bc_style_construct (glWdgtBCStyle *bc_style) { - GtkWidget *wvbox, *wframe, *wvbox1, *whbox2, *wvbox2; - GSList *radio_group = NULL; - - wvbox = GTK_WIDGET (prop); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wvbox1 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox1), 10); - gtk_container_add (GTK_CONTAINER (wframe), wvbox1); - - whbox2 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_add (GTK_CONTAINER (wvbox1), whbox2); - - /* ... Start column ... */ - wvbox2 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox2), 10); - gtk_box_pack_start (GTK_BOX (whbox2), wvbox2, FALSE, FALSE, 0); - - /* POSTNET button */ - prop->postnet_radio = - gtk_radio_button_new_with_label (radio_group, "POSTNET"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->postnet_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->postnet_radio, - FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->postnet_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* EAN button */ - prop->ean_radio = gtk_radio_button_new_with_label (radio_group, "EAN"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->ean_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->ean_radio, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->ean_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* UPC button */ - prop->upc_radio = gtk_radio_button_new_with_label (radio_group, "UPC"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->upc_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->upc_radio, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->upc_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* ISBN button */ - prop->isbn_radio = - gtk_radio_button_new_with_label (radio_group, "ISBN"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->isbn_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->isbn_radio, - FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->isbn_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* CODE39 button */ - prop->code39_radio = - gtk_radio_button_new_with_label (radio_group, "Code 39"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->code39_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->code39_radio, - FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->code39_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* CODE128 button */ - prop->code128_radio = - gtk_radio_button_new_with_label (radio_group, "Code 128"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->code128_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->code128_radio, - FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->code128_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* ... Start column ... */ - wvbox2 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox2), 10); - gtk_box_pack_start (GTK_BOX (whbox2), wvbox2, FALSE, FALSE, 0); - - /* CODE128B button */ - prop->code128b_radio = - gtk_radio_button_new_with_label (radio_group, "Code 128-B"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->code128b_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->code128b_radio, - FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->code128b_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* CODE128C button */ - prop->code128c_radio = - gtk_radio_button_new_with_label (radio_group, "Code 128-C"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->code128c_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->code128c_radio, - FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->code128c_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* I25 button */ - prop->i25_radio = - gtk_radio_button_new_with_label (radio_group, "Interleaved 2 of 5"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->i25_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->i25_radio, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->i25_radio), "toggled", + GtkWidget *wvbox, *whbox, *wcombo; + GList *style_list; + + wvbox = GTK_WIDGET (bc_style); + + /* ---- Style line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); + + /* Style Label */ + bc_style->style_label = gtk_label_new (_("Style:")); + gtk_misc_set_alignment (GTK_MISC (bc_style->style_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_style->style_label); + + /* Style entry widget */ + wcombo = gtk_combo_new (); + style_list = NULL; + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_POSTNET)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_EAN)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_UPC)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_ISBN)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_39)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_128)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_128B)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_128C)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_I25)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_CBR)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_MSI)); + style_list = g_list_append (style_list, + (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_PLS)); + gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), style_list); + g_list_free (style_list); + bc_style->style_entry = GTK_COMBO (wcombo)->entry; + gtk_entry_set_editable (GTK_ENTRY (bc_style->style_entry), FALSE); + gtk_widget_set_size_request (wcombo, 200, -1); + g_signal_connect_swapped (G_OBJECT (bc_style->style_entry), "changed", G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* CBR button */ - prop->cbr_radio = - gtk_radio_button_new_with_label (radio_group, "Codabar"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->cbr_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->cbr_radio, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->cbr_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* MSI button */ - prop->msi_radio = gtk_radio_button_new_with_label (radio_group, "MSI"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->msi_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->msi_radio, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->msi_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - - /* PLS button */ - prop->pls_radio = - gtk_radio_button_new_with_label (radio_group, "Plessey"); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (prop->pls_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->pls_radio, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->pls_radio), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); + G_OBJECT (bc_style)); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wcombo); - /* ... Separator ... */ - gtk_box_pack_start (GTK_BOX (wvbox1), gtk_hseparator_new (), FALSE, - FALSE, 0); /* Text checkbox widget */ - prop->text_check = + bc_style->text_check = gtk_check_button_new_with_label (_("Show text with barcode")); - gtk_box_pack_start (GTK_BOX (wvbox1), prop->text_check, - FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (prop->text_check), "toggled", + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), bc_style->text_check); + g_signal_connect_swapped (G_OBJECT (bc_style->text_check), "toggled", G_CALLBACK (changed_cb), - G_OBJECT (prop)); + G_OBJECT (bc_style)); } @@ -326,138 +218,73 @@ gl_wdgt_bc_style_construct (glWdgtBCStyle * prop, /* PRIVATE. Callback for when any control in the widget has changed. */ /*--------------------------------------------------------------------------*/ static void -changed_cb (glWdgtBCStyle * prop_style) +changed_cb (glWdgtBCStyle *bc_style) { /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (prop_style), + g_signal_emit (G_OBJECT (bc_style), wdgt_bc_style_signals[CHANGED], 0); } - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ + +/****************************************************************************/ +/* query values from controls. */ +/****************************************************************************/ void -gl_wdgt_bc_style_get_params (glWdgtBCStyle * prop, - glBarcodeStyle * style, - gboolean * text_flag) +gl_wdgt_bc_style_get_params (glWdgtBCStyle *bc_style, + glBarcodeStyle *style, + gboolean *text_flag) { + gchar *style_string; + + style_string = + gtk_editable_get_chars (GTK_EDITABLE(bc_style->style_entry), + 0, -1); + *style = gl_barcode_text_to_style (style_string); + *text_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prop->text_check)); - - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->postnet_radio))) { - *style = GL_BARCODE_STYLE_POSTNET; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->ean_radio))) { - *style = GL_BARCODE_STYLE_EAN; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->upc_radio))) { - *style = GL_BARCODE_STYLE_UPC; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->isbn_radio))) { - *style = GL_BARCODE_STYLE_ISBN; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->code39_radio))) { - *style = GL_BARCODE_STYLE_39; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->code128_radio))) { - *style = GL_BARCODE_STYLE_128; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->code128c_radio))) { - *style = GL_BARCODE_STYLE_128C; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->code128b_radio))) { - *style = GL_BARCODE_STYLE_128B; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->i25_radio))) { - *style = GL_BARCODE_STYLE_I25; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->cbr_radio))) { - *style = GL_BARCODE_STYLE_CBR; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->msi_radio))) { - *style = GL_BARCODE_STYLE_MSI; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->pls_radio))) { - *style = GL_BARCODE_STYLE_PLS; - } + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (bc_style->text_check)); + g_free (style_string); } -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ +/****************************************************************************/ +/* fill in values and ranges for controls. */ +/****************************************************************************/ void -gl_wdgt_bc_style_set_params (glWdgtBCStyle * prop, - glBarcodeStyle style, - gboolean text_flag) +gl_wdgt_bc_style_set_params (glWdgtBCStyle *bc_style, + glBarcodeStyle style, + gboolean text_flag) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->text_check), + const gchar *style_string; + gint pos; + + style_string = gl_barcode_style_to_text (style); + + g_signal_handlers_block_by_func (G_OBJECT(bc_style->style_entry), + G_CALLBACK (changed_cb), + bc_style); + gtk_editable_delete_text (GTK_EDITABLE (bc_style->style_entry), + 0, -1); + g_signal_handlers_unblock_by_func (G_OBJECT(bc_style->style_entry), + G_CALLBACK(changed_cb), + bc_style); + + pos = 0; + gtk_editable_insert_text (GTK_EDITABLE (bc_style->style_entry), + style_string, + strlen (style_string), + &pos); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bc_style->text_check), text_flag); - switch (style) { - case GL_BARCODE_STYLE_POSTNET: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->postnet_radio), TRUE); - break; - case GL_BARCODE_STYLE_EAN: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->ean_radio), TRUE); - break; - case GL_BARCODE_STYLE_UPC: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->upc_radio), TRUE); - break; - case GL_BARCODE_STYLE_ISBN: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->isbn_radio), TRUE); - break; - case GL_BARCODE_STYLE_39: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->code39_radio), TRUE); - break; - case GL_BARCODE_STYLE_128: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->code128_radio), TRUE); - break; - case GL_BARCODE_STYLE_128C: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->code128c_radio), TRUE); - break; - case GL_BARCODE_STYLE_128B: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->code128b_radio), TRUE); - break; - case GL_BARCODE_STYLE_I25: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->i25_radio), TRUE); - break; - case GL_BARCODE_STYLE_CBR: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->cbr_radio), TRUE); - break; - case GL_BARCODE_STYLE_MSI: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->msi_radio), TRUE); - break; - case GL_BARCODE_STYLE_PLS: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->pls_radio), TRUE); - break; - default: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->postnet_radio), TRUE); - break; - } +} + +/****************************************************************************/ +/* Set size group for internal labels */ +/****************************************************************************/ +void +gl_wdgt_bc_style_set_label_size_group (glWdgtBCStyle *bc_style, + GtkSizeGroup *label_size_group) +{ + gtk_size_group_add_widget (label_size_group, bc_style->style_label); } diff --git a/glabels2/src/wdgt-bc-style.h b/glabels2/src/wdgt-bc-style.h index 78c98634..40d28f40 100644 --- a/glabels2/src/wdgt-bc-style.h +++ b/glabels2/src/wdgt-bc-style.h @@ -25,6 +25,9 @@ #include #include "bc.h" +#include "hig.h" + +G_BEGIN_DECLS #define GL_TYPE_WDGT_BC_STYLE (gl_wdgt_bc_style_get_type ()) #define GL_WDGT_BC_STYLE(obj) \ @@ -40,40 +43,35 @@ typedef struct _glWdgtBCStyle glWdgtBCStyle; typedef struct _glWdgtBCStyleClass glWdgtBCStyleClass; struct _glWdgtBCStyle { - GtkVBox parent_widget; - - GtkWidget *postnet_radio; - GtkWidget *ean_radio; - GtkWidget *upc_radio; - GtkWidget *isbn_radio; - GtkWidget *code39_radio; - GtkWidget *code128_radio; - GtkWidget *code128c_radio; - GtkWidget *code128b_radio; - GtkWidget *i25_radio; - GtkWidget *cbr_radio; - GtkWidget *msi_radio; - GtkWidget *pls_radio; + glHigVBox parent_widget; + + GtkWidget *style_label; + GtkWidget *style_entry; GtkWidget *text_check; }; struct _glWdgtBCStyleClass { - GtkVBoxClass parent_class; + glHigVBoxClass parent_class; void (*changed) (glWdgtBCStyle * prop, gpointer user_data); }; -extern guint gl_wdgt_bc_style_get_type (void); +guint gl_wdgt_bc_style_get_type (void); + +GtkWidget *gl_wdgt_bc_style_new (void); + +void gl_wdgt_bc_style_get_params (glWdgtBCStyle *bc_style, + glBarcodeStyle *style, + gboolean *text_flag); -extern GtkWidget *gl_wdgt_bc_style_new (gchar * label); +void gl_wdgt_bc_style_set_params (glWdgtBCStyle *bc_style, + glBarcodeStyle style, + gboolean text_flag); -extern void gl_wdgt_bc_style_get_params (glWdgtBCStyle * prop_style, - glBarcodeStyle * style, - gboolean * text_flag); +void gl_wdgt_bc_style_set_label_size_group (glWdgtBCStyle *bc_style, + GtkSizeGroup *label_size_group); -extern void gl_wdgt_bc_style_set_params (glWdgtBCStyle * prop_style, - glBarcodeStyle style, - gboolean text_flag); +G_END_DECLS #endif -- 2.39.5