From f35c12acd7a9f4347fbcddf7a45263e281441faa Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 21 Sep 2002 03:16:09 +0000 Subject: [PATCH] Incorporated use of HIG into prefs_dialog, view_text and related widgets. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@129 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/hig.c | 14 ++- glabels2/src/hig.h | 14 ++- glabels2/src/merge-properties.c | 90 ++++++++++--------- glabels2/src/merge-properties.h | 2 +- glabels2/src/merge-ui.c | 4 +- glabels2/src/prefs-dialog.c | 100 +++++++++++----------- glabels2/src/prefs-dialog.h | 5 +- glabels2/src/view-barcode.c | 2 +- glabels2/src/view-box.c | 6 +- glabels2/src/view-ellipse.c | 6 +- glabels2/src/view-image.c | 2 +- glabels2/src/view-line.c | 4 +- glabels2/src/view-text.c | 54 ++++++------ glabels2/src/wdgt-fill.c | 105 ++++++++++++----------- glabels2/src/wdgt-fill.h | 23 +++-- glabels2/src/wdgt-line.c | 127 ++++++++++++++------------- glabels2/src/wdgt-line.h | 31 ++++--- glabels2/src/wdgt-position.c | 147 +++++++++++++++++--------------- glabels2/src/wdgt-position.h | 38 ++++++--- glabels2/src/wdgt-text-entry.c | 101 +++++++++++----------- glabels2/src/wdgt-text-entry.h | 28 +++--- glabels2/src/wdgt-text-props.c | 145 ++++++++++++++++--------------- glabels2/src/wdgt-text-props.h | 53 +++++++----- 23 files changed, 605 insertions(+), 496 deletions(-) diff --git a/glabels2/src/hig.c b/glabels2/src/hig.c index 5315daa6..4f6f2569 100644 --- a/glabels2/src/hig.c +++ b/glabels2/src/hig.c @@ -38,7 +38,7 @@ #define HIG_VBOX_INNER_SPACING 6 -#define HIG_HBOX_SPACING 6 +#define HIG_HBOX_SPACING 12 /*===========================================*/ /* Private globals */ @@ -300,7 +300,7 @@ gl_hig_category_init (glHigCategory *hig_category) /* 2nd row, Column 2: User area (inner vbox) */ hig_category->vbox = gtk_vbox_new (FALSE, HIG_VBOX_INNER_SPACING); gtk_box_pack_start (GTK_BOX(hbox), - hig_category->vbox, FALSE, FALSE, 0); + hig_category->vbox, TRUE, TRUE, 0); } static void @@ -538,4 +538,14 @@ gl_hig_hbox_add_widget (glHigHBox *hig_hbox, gtk_box_pack_start (GTK_BOX (hig_hbox), widget, FALSE, FALSE, 0); } +/****************************************************************************/ +/* Add widget (from left) to hbox with a right justification. */ +/****************************************************************************/ +void +gl_hig_hbox_add_widget_justify (glHigHBox *hig_hbox, + GtkWidget *widget) +{ + gtk_box_pack_start (GTK_BOX (hig_hbox), widget, TRUE, TRUE, 0); +} + diff --git a/glabels2/src/hig.h b/glabels2/src/hig.h index c130fed8..4f1f7011 100644 --- a/glabels2/src/hig.h +++ b/glabels2/src/hig.h @@ -27,6 +27,9 @@ G_BEGIN_DECLS +#define GL_HIG_PAD1 6 +#define GL_HIG_PAD2 12 + /*===========================================================================*/ /* HIG Dialog wrapper. */ /*===========================================================================*/ @@ -167,12 +170,15 @@ struct _glHigHBoxClass { GtkHBoxClass parent_class; }; -guint gl_hig_hbox_get_type (void); +guint gl_hig_hbox_get_type (void); -GtkWidget *gl_hig_hbox_new (void); +GtkWidget *gl_hig_hbox_new (void); -void gl_hig_hbox_add_widget (glHigHBox *hig_hbox, - GtkWidget *widget); +void gl_hig_hbox_add_widget (glHigHBox *hig_hbox, + GtkWidget *widget); + +void gl_hig_hbox_add_widget_justify (glHigHBox *hig_hbox, + GtkWidget *widget); G_END_DECLS diff --git a/glabels2/src/merge-properties.c b/glabels2/src/merge-properties.c index b55770a5..0ade9e48 100644 --- a/glabels2/src/merge-properties.c +++ b/glabels2/src/merge-properties.c @@ -27,6 +27,7 @@ #include "merge.h" #include "merge-ui.h" #include "merge-properties.h" +#include "hig.h" #include "debug.h" @@ -57,20 +58,24 @@ typedef struct { /* Local function prototypes */ /*===========================================*/ -static void create_merge_dialog_widgets (GtkDialog * dialog, - PropertyDialogPassback * data); +static void create_merge_dialog_widgets (glHigDialog *dialog, + PropertyDialogPassback *data); -static void type_changed_cb (GtkWidget * widget, PropertyDialogPassback * data); -static void src_changed_cb (GtkWidget * widget, PropertyDialogPassback * data); +static void type_changed_cb (GtkWidget *widget, + PropertyDialogPassback *data); -static void response_cb (GtkDialog * dialog, gint response, - PropertyDialogPassback * data); +static void src_changed_cb (GtkWidget *widget, + PropertyDialogPassback *data); + +static void response_cb (glHigDialog *dialog, + gint response, + PropertyDialogPassback *data); /****************************************************************************/ /* Launch merge properties dialog. */ /****************************************************************************/ void -gl_merge_properties_dialog (glView * view) +gl_merge_properties_dialog (glView *view) { static PropertyDialogPassback *data = NULL; GtkWidget *dialog; @@ -80,13 +85,13 @@ gl_merge_properties_dialog (glView * view) data = g_new0 (PropertyDialogPassback, 1); } - dialog = gtk_dialog_new_with_buttons ( - _("Edit document-merge properties"), - GTK_WINDOW (win), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_OK, GTK_RESPONSE_OK, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - NULL); + dialog = gl_hig_dialog_new_with_buttons ( + _("Edit document-merge properties"), + GTK_WINDOW (win), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OK, GTK_RESPONSE_OK, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + NULL); data->dialog = dialog; data->view = view; @@ -96,7 +101,7 @@ gl_merge_properties_dialog (glView * view) data->src_entry = NULL; data->field_ws = NULL; - create_merge_dialog_widgets (GTK_DIALOG (dialog), data); + create_merge_dialog_widgets (GL_HIG_DIALOG (dialog), data); g_signal_connect (G_OBJECT(dialog), "response", G_CALLBACK(response_cb), data); @@ -106,74 +111,74 @@ gl_merge_properties_dialog (glView * view) } /*--------------------------------------------------------------------------*/ -/* PRIVATE. Create and add start page to druid. */ +/* PRIVATE. Create merge widgets. */ /*--------------------------------------------------------------------------*/ static void -create_merge_dialog_widgets (GtkDialog * dialog, +create_merge_dialog_widgets (glHigDialog * dialog, PropertyDialogPassback * data) { - GtkWidget *wvbox, *wframe, *whbox, *wtable, *wlabel, *wcombo, *wscroll; + GtkWidget *wframe, *whbox, *wtable, *wlabel, *wcombo, *wscroll; GList *texts; glMerge *merge; glMergeType type; gchar *src; GList *fields; + GtkSizeGroup *label_size_group; merge = gl_label_get_merge (data->label); type = merge->type; src = merge->src; fields = merge->field_defs; - gl_merge_free (&merge); - - wvbox = dialog->vbox; - wframe = gtk_frame_new (_("Source")); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); + /* ---- Source section ---- */ + wframe = gl_hig_category_new (_("Source")); + gl_hig_dialog_add_widget (dialog, wframe); + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - whbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_add (GTK_CONTAINER (wframe), whbox); - - 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_box_pack_start (GTK_BOX (whbox), wtable, FALSE, FALSE, GNOME_PAD); + /* Format line */ + whbox = gl_hig_hbox_new(); + gl_hig_category_add_widget (GL_HIG_CATEGORY (wframe), whbox); wlabel = gtk_label_new (_("Format:")); + gtk_size_group_add_widget (label_size_group, wlabel); gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wlabel); wcombo = gtk_combo_new (); - gtk_widget_set_usize (wcombo, 400, -1); texts = gl_merge_get_long_texts_list (); gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), texts); gl_merge_free_long_texts_list (&texts); data->type_entry = GTK_COMBO (wcombo)->entry; gtk_entry_set_editable (GTK_ENTRY (data->type_entry), FALSE); - gtk_table_attach_defaults (GTK_TABLE (wtable), wcombo, 1, 2, 0, 1); gtk_entry_set_text (GTK_ENTRY (data->type_entry), gl_merge_type_to_long_text (type)); + gl_hig_hbox_add_widget_justify (GL_HIG_HBOX(whbox), wcombo); + + whbox = gl_hig_hbox_new(); + gl_hig_category_add_widget (GL_HIG_CATEGORY (wframe), whbox); + /* Location line */ wlabel = gtk_label_new (_("Location:")); + gtk_size_group_add_widget (label_size_group, wlabel); gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wlabel); data->src_entry = gl_merge_ui_src_new (); - gtk_table_attach_defaults (GTK_TABLE (wtable), data->src_entry, 1, 2, 1, - 2); gl_merge_ui_src_set_type (GL_MERGE_UI_SRC (data->src_entry), type); gl_merge_ui_src_set_value (GL_MERGE_UI_SRC (data->src_entry), src); + gl_hig_hbox_add_widget_justify (GL_HIG_HBOX(whbox), data->src_entry); - wframe = gtk_frame_new (_("Fields")); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); + /* ---- Fields section ---- */ + wframe = gl_hig_category_new (_("Fields")); + gl_hig_dialog_add_widget (dialog, wframe); wscroll = gtk_scrolled_window_new (NULL, NULL); gtk_container_set_border_width (GTK_CONTAINER (wscroll), 5); - gtk_widget_set_usize (wscroll, 500, 300); + gtk_widget_set_usize (wscroll, 400, 250); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (wscroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (wframe), wscroll); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), wscroll); data->field_ws = gl_merge_ui_field_ws_new (); gtk_container_set_border_width (GTK_CONTAINER (data->field_ws), 10); @@ -189,6 +194,7 @@ create_merge_dialog_widgets (GtkDialog * dialog, g_signal_connect (G_OBJECT (data->src_entry), "changed", G_CALLBACK (src_changed_cb), data); + gl_merge_free (&merge); } /*--------------------------------------------------------------------------*/ @@ -233,7 +239,7 @@ src_changed_cb (GtkWidget * widget, /* PRIVATE. response callback. */ /*--------------------------------------------------------------------------*/ static void -response_cb (GtkDialog * dialog, +response_cb (glHigDialog * dialog, gint response, PropertyDialogPassback * data) { diff --git a/glabels2/src/merge-properties.h b/glabels2/src/merge-properties.h index 1d72b587..7af26794 100644 --- a/glabels2/src/merge-properties.h +++ b/glabels2/src/merge-properties.h @@ -24,6 +24,6 @@ #include "view.h" -extern void gl_merge_properties_dialog (glView * view); +extern void gl_merge_properties_dialog (glView *view); #endif diff --git a/glabels2/src/merge-ui.c b/glabels2/src/merge-ui.c index 18a25b51..7e6f6b81 100644 --- a/glabels2/src/merge-ui.c +++ b/glabels2/src/merge-ui.c @@ -222,7 +222,7 @@ gl_merge_ui_src_new (void) src->type = GL_MERGE_NONE; src->backend_widget = gtk_label_new (_("N/A")); gtk_misc_set_alignment (GTK_MISC (src->backend_widget), 0, 0.5); - gtk_box_pack_start (GTK_BOX (src), src->backend_widget, FALSE, FALSE, + gtk_box_pack_start (GTK_BOX (src), src->backend_widget, TRUE, TRUE, 0); gl_debug (DEBUG_MERGE, "END"); @@ -268,7 +268,7 @@ gl_merge_ui_src_set_type (glMergeUISrc * src, } gtk_box_pack_start (GTK_BOX (src), src->backend_widget, - FALSE, FALSE, 0); + TRUE, TRUE, 0); if (GTK_WIDGET_VISIBLE (src)) { gtk_widget_show_all (src->backend_widget); diff --git a/glabels2/src/prefs-dialog.c b/glabels2/src/prefs-dialog.c index 7d09221a..1a5240d9 100644 --- a/glabels2/src/prefs-dialog.c +++ b/glabels2/src/prefs-dialog.c @@ -123,7 +123,7 @@ gl_prefs_dialog_get_type (void) (GInstanceInitFunc) gl_prefs_dialog_init }; - dialog_type = g_type_register_static (GTK_TYPE_DIALOG, + dialog_type = g_type_register_static (GL_TYPE_HIG_DIALOG, "glPrefsDialog", &dialog_info, 0); @@ -212,8 +212,7 @@ gl_prefs_dialog_construct (glPrefsDialog *dlg) G_CALLBACK (response_cb), NULL); notebook = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dlg)->vbox), - notebook, TRUE, TRUE, 0); + gl_hig_dialog_add_widget (GL_HIG_DIALOG(dlg), notebook); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), locale_page (dlg), @@ -263,25 +262,18 @@ response_cb (glPrefsDialog *dlg, static GtkWidget * locale_page (glPrefsDialog *dlg) { - GtkWidget *wlabel, *wvbox, *whbox, *wvbox1, *wframe; + GtkWidget *wlabel, *wvbox, *wframe; GSList *radio_group = NULL; - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); + wvbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER); wlabel = gtk_label_new (_("Select locale specific behavior.")); - gtk_box_pack_start (GTK_BOX (wvbox), wlabel, FALSE, FALSE, 0); - - whbox = gtk_hbox_new (TRUE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (wvbox), whbox, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC(wlabel), 0.0, 0.0); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wlabel); /* ----- Display Units Frame ------------------------------------ */ - wframe = gtk_frame_new (_("Display units")); - gtk_box_pack_start (GTK_BOX (whbox), wframe, FALSE, TRUE, 0); - - wvbox1 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox1), 10); - gtk_container_add (GTK_CONTAINER (wframe), wvbox1); + wframe = gl_hig_category_new (_("Display units")); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wframe); radio_group = NULL; @@ -289,30 +281,26 @@ locale_page (glPrefsDialog *dlg) gtk_radio_button_new_with_label (radio_group, _("Points")); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->units_points_radio)); - gtk_box_pack_start (GTK_BOX (wvbox1), dlg->private->units_points_radio, - FALSE, FALSE, 0); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), + dlg->private->units_points_radio); dlg->private->units_inches_radio = gtk_radio_button_new_with_label (radio_group, _("Inches")); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->units_inches_radio)); - gtk_box_pack_start (GTK_BOX (wvbox1), dlg->private->units_inches_radio, - FALSE, FALSE, 0); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), + dlg->private->units_inches_radio); dlg->private->units_mm_radio = gtk_radio_button_new_with_label (radio_group, _("Millimeters")); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->units_mm_radio)); - gtk_box_pack_start (GTK_BOX (wvbox1), dlg->private->units_mm_radio, - FALSE, FALSE, 0); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), + dlg->private->units_mm_radio); /* ----- Page Size Frame ------------------------------------ */ - wframe = gtk_frame_new (_("Default page size")); - gtk_box_pack_start (GTK_BOX (whbox), wframe, FALSE, TRUE, 0); - - wvbox1 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox1), 10); - gtk_container_add (GTK_CONTAINER (wframe), wvbox1); + wframe = gl_hig_category_new (_("Default page size")); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wframe); radio_group = NULL; @@ -321,15 +309,15 @@ locale_page (glPrefsDialog *dlg) radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->page_size_us_letter_radio)); - gtk_box_pack_start (GTK_BOX (wvbox1), dlg->private->page_size_us_letter_radio, FALSE, - FALSE, 0); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), + dlg->private->page_size_us_letter_radio); dlg->private->page_size_a4_radio = gtk_radio_button_new_with_label (radio_group, A4); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->page_size_a4_radio)); - gtk_box_pack_start (GTK_BOX (wvbox1), dlg->private->page_size_a4_radio, - FALSE, FALSE, 0); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), + dlg->private->page_size_a4_radio); g_signal_connect_swapped ( G_OBJECT(dlg->private->units_points_radio), @@ -356,32 +344,42 @@ locale_page (glPrefsDialog *dlg) static GtkWidget * object_page (glPrefsDialog *dlg) { - GtkWidget *wlabel, *wvbox, *whbox; + GtkWidget *wlabel, *wvbox, *wframe; + GtkSizeGroup *label_size_group; - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); + wvbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER); + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); wlabel = gtk_label_new (_("Select default properties for new objects.")); - gtk_box_pack_start (GTK_BOX (wvbox), wlabel, FALSE, FALSE, 0); - - /* text props entry */ - dlg->private->text = - gl_wdgt_text_props_new ("Text"); - gtk_box_pack_start (GTK_BOX (wvbox), dlg->private->text, - FALSE, FALSE, 0); - - whbox = gtk_hbox_new (TRUE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (wvbox), whbox, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC(wlabel), 0.0, 0.0); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wlabel); + + /* ------ text props entry ------ */ + wframe = gl_hig_category_new (_("Text")); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wframe); + dlg->private->text = gl_wdgt_text_props_new (); + gl_wdgt_text_props_set_label_size_group (GL_WDGT_TEXT_PROPS(dlg->private->text), + label_size_group); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), + dlg->private->text); /* ------ Line box ------ */ - dlg->private->line = gl_wdgt_line_new (_("Line")); - gtk_box_pack_start (GTK_BOX (whbox), dlg->private->line, - FALSE, TRUE, 0); + wframe = gl_hig_category_new (_("Line")); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wframe); + dlg->private->line = gl_wdgt_line_new (); + gl_wdgt_line_set_label_size_group (GL_WDGT_LINE(dlg->private->line), + label_size_group); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), + dlg->private->line); /* ------ Fill box ------ */ - dlg->private->fill = gl_wdgt_fill_new (_("Fill")); - gtk_box_pack_start (GTK_BOX (whbox), dlg->private->fill, - FALSE, TRUE, 0); + wframe = gl_hig_category_new (_("Fill")); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wframe); + dlg->private->fill = gl_wdgt_fill_new (); + gl_wdgt_fill_set_label_size_group (GL_WDGT_FILL(dlg->private->fill), + label_size_group); + gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), + dlg->private->fill); g_signal_connect_swapped (G_OBJECT(dlg->private->text), "changed", diff --git a/glabels2/src/prefs-dialog.h b/glabels2/src/prefs-dialog.h index 6daafdf7..bb21ba18 100644 --- a/glabels2/src/prefs-dialog.h +++ b/glabels2/src/prefs-dialog.h @@ -24,6 +24,7 @@ #define __PREFS_DIALOG_H__ #include +#include "hig.h" #define GL_TYPE_PREFS_DIALOG (gl_prefs_dialog_get_type ()) #define GL_PREFS_DIALOG(obj) (GTK_CHECK_CAST ((obj), GL_TYPE_PREFS_DIALOG, glPrefsDialog)) @@ -40,7 +41,7 @@ typedef struct _glPrefsDialogPrivate glPrefsDialogPrivate; struct _glPrefsDialog { - GtkDialog parent_instance; + glHigDialog parent_instance; glPrefsDialogPrivate *private; @@ -48,7 +49,7 @@ struct _glPrefsDialog struct _glPrefsDialogClass { - GtkDialogClass parent_class; + glHigDialogClass parent_class; }; GtkType gl_prefs_dialog_get_type (void) G_GNUC_CONST; diff --git a/glabels2/src/view-barcode.c b/glabels2/src/view-barcode.c index f88c338e..fe15e158 100644 --- a/glabels2/src/view-barcode.c +++ b/glabels2/src/view-barcode.c @@ -348,7 +348,7 @@ construct_properties_dialog (glViewBarcode *view_barcode) /* ------ Position Frame ------ */ gl_debug (DEBUG_VIEW, "Creating position entry..."); - view_barcode->private->position = gl_wdgt_position_new (_("Position")); + view_barcode->private->position = gl_wdgt_position_new (); gl_wdgt_position_set_params (GL_WDGT_POSITION (view_barcode->private->position), x, y, label_width, label_height); diff --git a/glabels2/src/view-box.c b/glabels2/src/view-box.c index e4e270ff..b956d9bd 100644 --- a/glabels2/src/view-box.c +++ b/glabels2/src/view-box.c @@ -309,7 +309,7 @@ construct_properties_dialog (glViewBox *view_box) gtk_label_new (_("Appearance"))); /* ------ Line box ------ */ - view_box->private->line = gl_wdgt_line_new (_("Outline")); + view_box->private->line = gl_wdgt_line_new (); gl_wdgt_line_set_params (GL_WDGT_LINE (view_box->private->line), line_width, line_color); @@ -319,7 +319,7 @@ construct_properties_dialog (glViewBox *view_box) G_CALLBACK(line_changed_cb), view_box); /* ------ Fill box ------ */ - view_box->private->fill = gl_wdgt_fill_new (_("Fill")); + view_box->private->fill = gl_wdgt_fill_new (); gl_wdgt_fill_set_params (GL_WDGT_FILL (view_box->private->fill), fill_color); gtk_box_pack_start (GTK_BOX (wvbox), view_box->private->fill, @@ -337,7 +337,7 @@ construct_properties_dialog (glViewBox *view_box) gtk_label_new (_("Position/Size"))); /* ------ Position Frame ------ */ - view_box->private->position = gl_wdgt_position_new (_("Position")); + view_box->private->position = gl_wdgt_position_new (); gl_wdgt_position_set_params (GL_WDGT_POSITION (view_box->private->position), x, y, label_width, label_height); diff --git a/glabels2/src/view-ellipse.c b/glabels2/src/view-ellipse.c index 80c3ab24..ae030f26 100644 --- a/glabels2/src/view-ellipse.c +++ b/glabels2/src/view-ellipse.c @@ -309,7 +309,7 @@ construct_properties_dialog (glViewEllipse *view_ellipse) gtk_label_new (_("Appearance"))); /* ------ Line ellipse ------ */ - view_ellipse->private->line = gl_wdgt_line_new (_("Outline")); + view_ellipse->private->line = gl_wdgt_line_new (); gl_wdgt_line_set_params (GL_WDGT_LINE (view_ellipse->private->line), line_width, line_color); @@ -319,7 +319,7 @@ construct_properties_dialog (glViewEllipse *view_ellipse) G_CALLBACK(line_changed_cb), view_ellipse); /* ------ Fill ellipse ------ */ - view_ellipse->private->fill = gl_wdgt_fill_new (_("Fill")); + view_ellipse->private->fill = gl_wdgt_fill_new (); gl_wdgt_fill_set_params (GL_WDGT_FILL (view_ellipse->private->fill), fill_color); gtk_box_pack_start (GTK_BOX (wvbox), view_ellipse->private->fill, @@ -337,7 +337,7 @@ construct_properties_dialog (glViewEllipse *view_ellipse) gtk_label_new (_("Position/Size"))); /* ------ Position Frame ------ */ - view_ellipse->private->position = gl_wdgt_position_new (_("Position")); + view_ellipse->private->position = gl_wdgt_position_new (); gl_wdgt_position_set_params (GL_WDGT_POSITION (view_ellipse->private->position), x, y, label_width, label_height); diff --git a/glabels2/src/view-image.c b/glabels2/src/view-image.c index 13615201..152aa6cf 100644 --- a/glabels2/src/view-image.c +++ b/glabels2/src/view-image.c @@ -337,7 +337,7 @@ construct_properties_dialog (glViewImage *view_image) gtk_label_new (_("Position/Size"))); /* ------ Position Frame ------ */ - view_image->private->position = gl_wdgt_position_new (_("Position")); + view_image->private->position = gl_wdgt_position_new (); gl_wdgt_position_set_params (GL_WDGT_POSITION (view_image->private->position), x, y, label_width, label_height); diff --git a/glabels2/src/view-line.c b/glabels2/src/view-line.c index e80f0bb5..b6242b4c 100644 --- a/glabels2/src/view-line.c +++ b/glabels2/src/view-line.c @@ -308,7 +308,7 @@ construct_properties_dialog (glViewLine *view_line) gtk_label_new (_("Appearance"))); /* ------ Line line ------ */ - view_line->private->line = gl_wdgt_line_new (_("Outline")); + view_line->private->line = gl_wdgt_line_new (); gl_wdgt_line_set_params (GL_WDGT_LINE (view_line->private->line), line_width, line_color); @@ -327,7 +327,7 @@ construct_properties_dialog (glViewLine *view_line) gtk_label_new (_("Position/Size"))); /* ------ Position Frame ------ */ - view_line->private->position = gl_wdgt_position_new (_("Position")); + view_line->private->position = gl_wdgt_position_new (); gl_wdgt_position_set_params (GL_WDGT_POSITION (view_line->private->position), x, y, label_width, label_height); diff --git a/glabels2/src/view-text.c b/glabels2/src/view-text.c index 0e69702a..b72183ad 100644 --- a/glabels2/src/view-text.c +++ b/glabels2/src/view-text.c @@ -26,15 +26,14 @@ #include "view-text.h" #include "canvas-hacktext.h" - #include "view-highlight.h" - #include "glabels.h" #include "wdgt-text-entry.h" #include "wdgt-text-props.h" #include "wdgt-position.h" #include "color.h" #include "prefs.h" +#include "hig.h" #include "pixmaps/cursor_text.xbm" #include "pixmaps/cursor_text_mask.xbm" @@ -245,6 +244,7 @@ construct_properties_dialog (glViewText *view_text) guint color; GtkJustification just; glMerge *merge; + GtkSizeGroup *label_size_group; gl_debug (DEBUG_VIEW, "START"); @@ -264,40 +264,36 @@ construct_properties_dialog (glViewText *view_text) /* Build dialog with notebook. */ /*-----------------------------------------------------------------*/ gl_debug (DEBUG_VIEW, "Creating dialog..."); - dialog = gtk_dialog_new_with_buttons ( _("Edit text object properties"), - GTK_WINDOW (win), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, + dialog = gl_hig_dialog_new_with_buttons ( _("Edit text object properties"), + GTK_WINDOW (win), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, - NULL ); + NULL ); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (response_cb), view_text); notebook = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), - notebook, TRUE, TRUE, 0); + gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), notebook); + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); /*---------------------------*/ /* Text Notebook Tab */ /*---------------------------*/ gl_debug (DEBUG_VIEW, "Creating text tab..."); - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); + wvbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox, gtk_label_new (_("Text"))); /* text entry */ gl_debug (DEBUG_VIEW, "Creating text entry..."); view_text->private->text_entry = - gl_wdgt_text_entry_new ("Text", merge->field_defs); - gl_debug (DEBUG_VIEW, "1"); + gl_wdgt_text_entry_new (merge->field_defs); gl_wdgt_text_entry_set_text (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry), (merge->type != GL_MERGE_NONE), lines); - gl_debug (DEBUG_VIEW, "2"); - gtk_box_pack_start (GTK_BOX (wvbox), view_text->private->text_entry, - FALSE, FALSE, 0); - gl_debug (DEBUG_VIEW, "3"); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), + view_text->private->text_entry); g_signal_connect ( G_OBJECT(view_text->private->text_entry), "changed", G_CALLBACK (text_entry_changed_cb), view_text); @@ -307,20 +303,21 @@ construct_properties_dialog (glViewText *view_text) /* Text Props Notebook Tab */ /*---------------------------*/ gl_debug (DEBUG_VIEW, "Creating props tab..."); - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); + wvbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER); gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox, gtk_label_new (_("Appearance"))); /* text props entry */ gl_debug (DEBUG_VIEW, "Creating props entry..."); - view_text->private->text_props = - gl_wdgt_text_props_new ("Text Properties"); + view_text->private->text_props = gl_wdgt_text_props_new (); + gl_wdgt_text_props_set_label_size_group (GL_WDGT_TEXT_PROPS(view_text->private->text_props), + label_size_group); 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); - gtk_box_pack_start (GTK_BOX (wvbox), view_text->private->text_props, - FALSE, FALSE, 0); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), + view_text->private->text_props); g_signal_connect ( G_OBJECT(view_text->private->text_props), "changed", G_CALLBACK (text_props_changed_cb), view_text); @@ -330,20 +327,19 @@ construct_properties_dialog (glViewText *view_text) /* Position/Size Notebook Tab */ /*----------------------------*/ gl_debug (DEBUG_VIEW, "Creating position tab..."); - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); + wvbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER); gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox, gtk_label_new (_("Position"))); /* ------ Position Frame ------ */ gl_debug (DEBUG_VIEW, "Creating position entry..."); - view_text->private->position = gl_wdgt_position_new (_("Position")); + view_text->private->position = gl_wdgt_position_new (); gl_wdgt_position_set_params (GL_WDGT_POSITION (view_text->private->position), x, y, label_width, label_height); - gtk_box_pack_start (GTK_BOX (wvbox), - view_text->private->position, - FALSE, FALSE, 0); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), + view_text->private->position); g_signal_connect (G_OBJECT (view_text->private->position), "changed", G_CALLBACK(position_changed_cb), view_text); @@ -365,8 +361,8 @@ construct_properties_dialog (glViewText *view_text) /*---------------------------------------------------------------------------*/ static void response_cb (GtkDialog *dialog, - gint response, - glViewText *view_text) + gint response, + glViewText *view_text) { gl_debug (DEBUG_VIEW, "START"); diff --git a/glabels2/src/wdgt-fill.c b/glabels2/src/wdgt-fill.c index 6a3515e5..795fb9a6 100644 --- a/glabels2/src/wdgt-fill.c +++ b/glabels2/src/wdgt-fill.c @@ -51,15 +51,17 @@ static gint wdgt_fill_signals[LAST_SIGNAL] = { 0 }; /* Local function prototypes */ /*===========================================*/ -static void gl_wdgt_fill_class_init (glWdgtFillClass * class); -static void gl_wdgt_fill_instance_init (glWdgtFill * fill); -static void gl_wdgt_fill_finalize (GObject * object); -static void gl_wdgt_fill_construct (glWdgtFill * fill, gchar * label); -static void changed_cb (glWdgtFill * fill); +static void gl_wdgt_fill_class_init (glWdgtFillClass *class); +static void gl_wdgt_fill_instance_init (glWdgtFill *fill); +static void gl_wdgt_fill_finalize (GObject *object); +static void gl_wdgt_fill_construct (glWdgtFill *fill); + +static void changed_cb (glWdgtFill *fill); + -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ +/****************************************************************************/ +/* Boilerplate Object stuff. */ +/****************************************************************************/ guint gl_wdgt_fill_get_type (void) { @@ -79,7 +81,7 @@ gl_wdgt_fill_get_type (void) }; wdgt_fill_type = - g_type_register_static (gtk_vbox_get_type (), + g_type_register_static (gl_hig_vbox_get_type (), "glWdgtFill", &wdgt_fill_info, 0); } @@ -88,13 +90,13 @@ gl_wdgt_fill_get_type (void) } static void -gl_wdgt_fill_class_init (glWdgtFillClass * class) +gl_wdgt_fill_class_init (glWdgtFillClass *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_fill_finalize; @@ -110,13 +112,13 @@ gl_wdgt_fill_class_init (glWdgtFillClass * class) } static void -gl_wdgt_fill_instance_init (glWdgtFill * fill) +gl_wdgt_fill_instance_init (glWdgtFill *fill) { fill->color_picker = NULL; } static void -gl_wdgt_fill_finalize (GObject * object) +gl_wdgt_fill_finalize (GObject *object) { glWdgtFill *fill; glWdgtFillClass *class; @@ -129,70 +131,64 @@ gl_wdgt_fill_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } +/****************************************************************************/ +/* New widget. */ +/****************************************************************************/ GtkWidget * -gl_wdgt_fill_new (gchar * label) +gl_wdgt_fill_new (void) { glWdgtFill *fill; fill = g_object_new (gl_wdgt_fill_get_type (), NULL); - gl_wdgt_fill_construct (fill, label); + gl_wdgt_fill_construct (fill); return GTK_WIDGET (fill); } - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Construct composite widget. */ +/*--------------------------------------------------------------------------*/ static void -gl_wdgt_fill_construct (glWdgtFill * fill, - gchar * label) +gl_wdgt_fill_construct (glWdgtFill *fill) { - GtkWidget *wvbox, *wframe, *wtable, *wlabel; + GtkWidget *wvbox, *whbox; wvbox = GTK_WIDGET (fill); - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (1, 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); + /* ---- Line color line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); /* Fill 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, 0, 1); + fill->color_label = gtk_label_new (_("Color:")); + gtk_misc_set_alignment (GTK_MISC (fill->color_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), fill->color_label); /* Fill Color picker widget */ fill->color_picker = gnome_color_picker_new (); g_signal_connect_swapped (G_OBJECT (fill->color_picker), "color_set", G_CALLBACK (changed_cb), G_OBJECT (fill)); - gtk_table_attach_defaults (GTK_TABLE (wtable), fill->color_picker, 1, 3, - 0, 1); - + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), fill->color_picker); } /*--------------------------------------------------------------------------*/ /* PRIVATE. Callback for when any control in the widget has changed. */ /*--------------------------------------------------------------------------*/ static void -changed_cb (glWdgtFill * fill) +changed_cb (glWdgtFill *fill) { /* Emit our "changed" signal */ g_signal_emit (G_OBJECT (fill), wdgt_fill_signals[CHANGED], 0); } - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ + +/****************************************************************************/ +/* query values from controls. */ +/****************************************************************************/ void -gl_wdgt_fill_get_params (glWdgtFill * fill, - guint * color) +gl_wdgt_fill_get_params (glWdgtFill *fill, + guint *color) { guint8 r, g, b, a; @@ -201,12 +197,12 @@ gl_wdgt_fill_get_params (glWdgtFill * fill, *color = GL_COLOR_A (r, g, b, a); } -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ +/****************************************************************************/ +/* fill in values and ranges for controls. */ +/****************************************************************************/ void -gl_wdgt_fill_set_params (glWdgtFill * fill, - guint color) +gl_wdgt_fill_set_params (glWdgtFill *fill, + guint color) { gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (fill->color_picker), GL_COLOR_I_RED (color), @@ -214,3 +210,14 @@ gl_wdgt_fill_set_params (glWdgtFill * fill, GL_COLOR_I_BLUE (color), GL_COLOR_I_ALPHA (color)); } + +/****************************************************************************/ +/* Set size group for internal labels */ +/****************************************************************************/ +void +gl_wdgt_fill_set_label_size_group (glWdgtFill *fill, + GtkSizeGroup *label_size_group) +{ + gtk_size_group_add_widget (label_size_group, fill->color_label); +} + diff --git a/glabels2/src/wdgt-fill.h b/glabels2/src/wdgt-fill.h index db1d8dac..fae0d0ce 100644 --- a/glabels2/src/wdgt-fill.h +++ b/glabels2/src/wdgt-fill.h @@ -25,6 +25,9 @@ #include #include "label.h" +#include "hig.h" + +G_BEGIN_DECLS #define GL_TYPE_WDGT_FILL (gl_wdgt_fill_get_type ()) #define GL_WDGT_FILL(obj) \ @@ -40,23 +43,31 @@ typedef struct _glWdgtFill glWdgtFill; typedef struct _glWdgtFillClass glWdgtFillClass; struct _glWdgtFill { - GtkVBox parent_widget; + glHigVBox parent_widget; + GtkWidget *color_label; GtkWidget *color_picker; }; struct _glWdgtFillClass { - GtkVBoxClass parent_class; + glHigVBoxClass parent_class; void (*changed) (glWdgtFill * fill, gpointer user_data); }; -extern guint gl_wdgt_fill_get_type (void); +guint gl_wdgt_fill_get_type (void); + +GtkWidget *gl_wdgt_fill_new (void); + +void gl_wdgt_fill_get_params (glWdgtFill *fill, + guint *color); -extern GtkWidget *gl_wdgt_fill_new (gchar * label); +void gl_wdgt_fill_set_params (glWdgtFill *fill, + guint color); -extern void gl_wdgt_fill_get_params (glWdgtFill * fill, guint * color); +void gl_wdgt_fill_set_label_size_group (glWdgtFill *fill, + GtkSizeGroup *label_size_group); -extern void gl_wdgt_fill_set_params (glWdgtFill * fill, guint color); +G_END_DECLS #endif diff --git a/glabels2/src/wdgt-line.c b/glabels2/src/wdgt-line.c index 04d36383..3e7c047f 100644 --- a/glabels2/src/wdgt-line.c +++ b/glabels2/src/wdgt-line.c @@ -51,15 +51,16 @@ static gint wdgt_line_signals[LAST_SIGNAL] = { 0 }; /* Local function prototypes */ /*===========================================*/ -static void gl_wdgt_line_class_init (glWdgtLineClass * class); -static void gl_wdgt_line_instance_init (glWdgtLine * line); -static void gl_wdgt_line_finalize (GObject * object); -static void gl_wdgt_line_construct (glWdgtLine * line, gchar * label); -static void changed_cb (glWdgtLine * line); +static void gl_wdgt_line_class_init (glWdgtLineClass *class); +static void gl_wdgt_line_instance_init (glWdgtLine *line); +static void gl_wdgt_line_finalize (GObject *object); +static void gl_wdgt_line_construct (glWdgtLine *line); + +static void changed_cb (glWdgtLine *line); -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ +/****************************************************************************/ +/* Boilerplate Object stuff. */ +/****************************************************************************/ guint gl_wdgt_line_get_type (void) { @@ -79,7 +80,7 @@ gl_wdgt_line_get_type (void) }; wdgt_line_type = - g_type_register_static (gtk_vbox_get_type (), + g_type_register_static (gl_hig_vbox_get_type (), "glWdgtLine", &wdgt_line_info, 0); } @@ -88,13 +89,13 @@ gl_wdgt_line_get_type (void) } static void -gl_wdgt_line_class_init (glWdgtLineClass * class) +gl_wdgt_line_class_init (glWdgtLineClass *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_line_finalize; @@ -110,7 +111,7 @@ gl_wdgt_line_class_init (glWdgtLineClass * class) } static void -gl_wdgt_line_instance_init (glWdgtLine * line) +gl_wdgt_line_instance_init (glWdgtLine *line) { line->width_spin = NULL; line->color_picker = NULL; @@ -118,7 +119,7 @@ gl_wdgt_line_instance_init (glWdgtLine * line) } static void -gl_wdgt_line_finalize (GObject * object) +gl_wdgt_line_finalize (GObject *object) { glWdgtLine *line; glWdgtLineClass *class; @@ -131,44 +132,41 @@ gl_wdgt_line_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } +/****************************************************************************/ +/* New widget. */ +/****************************************************************************/ GtkWidget * -gl_wdgt_line_new (gchar * label) +gl_wdgt_line_new (void) { glWdgtLine *line; line = g_object_new (gl_wdgt_line_get_type (), NULL); - gl_wdgt_line_construct (line, label); + gl_wdgt_line_construct (line); return GTK_WIDGET (line); } - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Construct composite widget. */ +/*--------------------------------------------------------------------------*/ static void -gl_wdgt_line_construct (glWdgtLine * line, - gchar * label) +gl_wdgt_line_construct (glWdgtLine *line) { - GtkWidget *wvbox, *wframe, *wtable, *wlabel; + GtkWidget *wvbox, *wframe, *whbox; GtkObject *adjust; wvbox = GTK_WIDGET (line); - 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); + /* ---- Line width line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); /* Line Width Label */ - wlabel = gtk_label_new (_("Width:")); - 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); + line->width_label = gtk_label_new (_("Width:")); + gtk_misc_set_alignment (GTK_MISC (line->width_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->width_label); + /* Line Width widget */ adjust = gtk_adjustment_new (1.0, 0.25, 4.0, 0.25, 1.0, 1.0); line->width_spin = @@ -176,25 +174,28 @@ gl_wdgt_line_construct (glWdgtLine * line, g_signal_connect_swapped (G_OBJECT (line->width_spin), "changed", G_CALLBACK (changed_cb), G_OBJECT (line)); - gtk_table_attach_defaults (GTK_TABLE (wtable), line->width_spin, 1, 2, - 0, 1); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->width_spin); + /* Line Width units */ line->units_label = gtk_label_new (_("points")); gtk_misc_set_alignment (GTK_MISC (line->units_label), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), line->units_label, - 2, 3, 0, 1); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->units_label); + + /* ---- Line 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_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); + line->color_label = gtk_label_new (_("Color:")); + gtk_misc_set_alignment (GTK_MISC (line->color_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->color_label); + /* Line Color picker widget */ line->color_picker = gnome_color_picker_new (); g_signal_connect_swapped (G_OBJECT (line->color_picker), "color_set", G_CALLBACK (changed_cb), G_OBJECT (line)); - gtk_table_attach_defaults (GTK_TABLE (wtable), line->color_picker, 1, 3, - 1, 2); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->color_picker); } @@ -202,19 +203,19 @@ gl_wdgt_line_construct (glWdgtLine * line, /* PRIVATE. Callback for when any control in the widget has changed. */ /*--------------------------------------------------------------------------*/ static void -changed_cb (glWdgtLine * line) +changed_cb (glWdgtLine *line) { /* Emit our "changed" signal */ g_signal_emit (G_OBJECT (line), wdgt_line_signals[CHANGED], 0); } - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ + +/****************************************************************************/ +/* query values from controls. */ +/****************************************************************************/ void -gl_wdgt_line_get_params (glWdgtLine * line, - gdouble * width, - guint * color) +gl_wdgt_line_get_params (glWdgtLine *line, + gdouble *width, + guint *color) { guint8 r, g, b, a; @@ -227,13 +228,13 @@ gl_wdgt_line_get_params (glWdgtLine * line, *color = GL_COLOR_A (r, g, b, a); } -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ +/****************************************************************************/ +/* fill in values and ranges for controls. */ +/****************************************************************************/ void -gl_wdgt_line_set_params (glWdgtLine * line, - gdouble width, - guint color) +gl_wdgt_line_set_params (glWdgtLine *line, + gdouble width, + guint color) { gtk_spin_button_set_value (GTK_SPIN_BUTTON (line->width_spin), width); @@ -243,3 +244,15 @@ gl_wdgt_line_set_params (glWdgtLine * line, GL_COLOR_I_BLUE (color), GL_COLOR_I_ALPHA (color)); } + +/****************************************************************************/ +/* Set size group for internal labels */ +/****************************************************************************/ +void +gl_wdgt_line_set_label_size_group (glWdgtLine *line, + GtkSizeGroup *label_size_group) +{ + gtk_size_group_add_widget (label_size_group, line->width_label); + gtk_size_group_add_widget (label_size_group, line->color_label); +} + diff --git a/glabels2/src/wdgt-line.h b/glabels2/src/wdgt-line.h index eec143f3..21abef25 100644 --- a/glabels2/src/wdgt-line.h +++ b/glabels2/src/wdgt-line.h @@ -25,6 +25,9 @@ #include #include "label.h" +#include "hig.h" + +G_BEGIN_DECLS #define GL_TYPE_WDGT_LINE (gl_wdgt_line_get_type ()) #define GL_WDGT_LINE(obj) \ @@ -40,29 +43,37 @@ typedef struct _glWdgtLine glWdgtLine; typedef struct _glWdgtLineClass glWdgtLineClass; struct _glWdgtLine { - GtkVBox parent_widget; + glHigVBox parent_widget; + GtkWidget *width_label; GtkWidget *width_spin; + + GtkWidget *color_label; GtkWidget *color_picker; GtkWidget *units_label; }; struct _glWdgtLineClass { - GtkVBoxClass parent_class; + glHigVBoxClass parent_class; void (*changed) (glWdgtLine * line, gpointer user_data); }; -extern guint gl_wdgt_line_get_type (void); +guint gl_wdgt_line_get_type (void); + +GtkWidget *gl_wdgt_line_new (void); + +void gl_wdgt_line_get_params (glWdgtLine *line, + gdouble *width, + guint *color); -extern GtkWidget *gl_wdgt_line_new (gchar * label); +void gl_wdgt_line_set_params (glWdgtLine *line, + gdouble width, + guint color); -extern void gl_wdgt_line_get_params (glWdgtLine * line, - gdouble * width, - guint * color); +void gl_wdgt_line_set_label_size_group (glWdgtLine *line, + GtkSizeGroup *label_size_group); -extern void gl_wdgt_line_set_params (glWdgtLine * line, - gdouble width, - guint color); +G_END_DECLS #endif diff --git a/glabels2/src/wdgt-position.c b/glabels2/src/wdgt-position.c index e90ba0b0..179ca559 100644 --- a/glabels2/src/wdgt-position.c +++ b/glabels2/src/wdgt-position.c @@ -43,7 +43,7 @@ typedef void (*glWdgtPositionSignal) (GObject * object, gpointer data); /* Private globals */ /*===========================================*/ -static GObjectClass *parent_class; +static glHigVBoxClass *parent_class; static gint wdgt_position_signals[LAST_SIGNAL] = { 0 }; @@ -51,16 +51,17 @@ static gint wdgt_position_signals[LAST_SIGNAL] = { 0 }; /* Local function prototypes */ /*===========================================*/ -static void gl_wdgt_position_class_init (glWdgtPositionClass * class); -static void gl_wdgt_position_instance_init (glWdgtPosition * position); -static void gl_wdgt_position_finalize (GObject * object); -static void gl_wdgt_position_construct (glWdgtPosition * position, - gchar * label); -static void changed_cb (glWdgtPosition * position); +static void gl_wdgt_position_class_init (glWdgtPositionClass *class); +static void gl_wdgt_position_instance_init (glWdgtPosition *position); +static void gl_wdgt_position_finalize (GObject *object); +static void gl_wdgt_position_construct (glWdgtPosition *position); + +static void changed_cb (glWdgtPosition *position); + -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ +/***************************************************************************/ +/* Boilerplate Object stuff. */ +/***************************************************************************/ guint gl_wdgt_position_get_type (void) { @@ -79,10 +80,10 @@ gl_wdgt_position_get_type (void) (GInstanceInitFunc) gl_wdgt_position_instance_init, }; - wdgt_position_type = g_type_register_static (gtk_vbox_get_type (), - "glWdgtPosition", - &wdgt_position_info, - 0); + wdgt_position_type = + g_type_register_static (gl_hig_vbox_get_type (), + "glWdgtPosition", + &wdgt_position_info, 0); } return wdgt_position_type; @@ -95,7 +96,7 @@ gl_wdgt_position_class_init (glWdgtPositionClass * 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_position_finalize; @@ -130,26 +131,28 @@ gl_wdgt_position_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } +/***************************************************************************/ +/* New widget. */ +/***************************************************************************/ GtkWidget * -gl_wdgt_position_new (gchar * label) +gl_wdgt_position_new (void) { glWdgtPosition *position; position = g_object_new (gl_wdgt_position_get_type (), NULL); - gl_wdgt_position_construct (position, label); + gl_wdgt_position_construct (position); return GTK_WIDGET (position); } - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ + +/*-------------------------------------------------------------------------*/ +/* PRIVATE. Construct composite widget. */ +/*-------------------------------------------------------------------------*/ static void -gl_wdgt_position_construct (glWdgtPosition * position, - gchar * label) +gl_wdgt_position_construct (glWdgtPosition *position) { - GtkWidget *wvbox, *wframe, *wtable, *wlabel; + GtkWidget *wvbox, *whbox; GtkObject *x_adjust, *y_adjust; const gchar *units_string; gdouble units_per_point, climb_rate; @@ -169,20 +172,15 @@ gl_wdgt_position_construct (glWdgtPosition * position, wvbox = GTK_WIDGET (position); - 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); + /* ---- X line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); /* X label */ - wlabel = gtk_label_new (_("X:")); - 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); + position->x_label = gtk_label_new (_("X:")); + gtk_misc_set_alignment (GTK_MISC (position->x_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), position->x_label); + /* X spin */ x_adjust = gtk_adjustment_new (0.0, 0.0, 100.0, climb_rate, 10.0, 10.0); position->x_spin = gtk_spin_button_new (GTK_ADJUSTMENT (x_adjust), @@ -193,14 +191,17 @@ gl_wdgt_position_construct (glWdgtPosition * position, g_signal_connect_swapped (G_OBJECT (position->x_spin), "changed", G_CALLBACK (changed_cb), G_OBJECT (position)); - gtk_table_attach_defaults (GTK_TABLE (wtable), position->x_spin, - 1, 2, 0, 1); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), position->x_spin); + + /* ---- Y line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); /* Y label */ - wlabel = gtk_label_new (_("Y:")); - 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); + position->y_label = gtk_label_new (_("Y:")); + gtk_misc_set_alignment (GTK_MISC (position->y_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), position->y_label); + /* Y spin */ y_adjust = gtk_adjustment_new (0.0, 0.0, 100.0, climb_rate, 10.0, 10.0); position->y_spin = gtk_spin_button_new (GTK_ADJUSTMENT (y_adjust), @@ -211,14 +212,12 @@ gl_wdgt_position_construct (glWdgtPosition * position, g_signal_connect_swapped (G_OBJECT (position->y_spin), "changed", G_CALLBACK (changed_cb), G_OBJECT (position)); - gtk_table_attach_defaults (GTK_TABLE (wtable), position->y_spin, - 1, 2, 1, 2); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), position->y_spin); /* Units */ position->units_label = gtk_label_new (units_string); gtk_misc_set_alignment (GTK_MISC (position->units_label), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), - position->units_label, 2, 3, 1, 2); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), position->units_label); gl_debug (DEBUG_WDGT, "END"); } @@ -227,19 +226,19 @@ gl_wdgt_position_construct (glWdgtPosition * position, /* PRIVATE. Callback for when any control in the widget has changed. */ /*--------------------------------------------------------------------------*/ static void -changed_cb (glWdgtPosition * position) +changed_cb (glWdgtPosition *position) { /* Emit our "changed" signal */ g_signal_emit (G_OBJECT (position), wdgt_position_signals[CHANGED], 0); } - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ + +/***************************************************************************/ +/* query values from controls. */ +/***************************************************************************/ void -gl_wdgt_position_get_position (glWdgtPosition * position, - gdouble * x, - gdouble * y) +gl_wdgt_position_get_position (glWdgtPosition *position, + gdouble *x, + gdouble *y) { gdouble units_per_point; @@ -253,15 +252,15 @@ gl_wdgt_position_get_position (glWdgtPosition * position, *y /= units_per_point; } -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ +/***************************************************************************/ +/* fill in values and ranges for controls. */ +/***************************************************************************/ void -gl_wdgt_position_set_params (glWdgtPosition * position, - gdouble x, - gdouble y, - gdouble x_max, - gdouble y_max) +gl_wdgt_position_set_params (glWdgtPosition *position, + gdouble x, + gdouble y, + gdouble x_max, + gdouble y_max) { GtkObject *x_adjust, *y_adjust; const gchar *units_string; @@ -294,13 +293,13 @@ gl_wdgt_position_set_params (glWdgtPosition * position, } -/*====================================================================*/ -/* fill in position info only. */ -/*====================================================================*/ +/***************************************************************************/ +/* fill in position info only. */ +/***************************************************************************/ void -gl_wdgt_position_set_position (glWdgtPosition * position, - gdouble x, - gdouble y) +gl_wdgt_position_set_position (glWdgtPosition *position, + gdouble x, + gdouble y) { gdouble units_per_point; @@ -320,3 +319,15 @@ gl_wdgt_position_set_position (glWdgtPosition * position, gl_debug (DEBUG_WDGT, "END"); } + +/****************************************************************************/ +/* Set size group for internal labels */ +/****************************************************************************/ +void +gl_wdgt_position_set_label_size_group (glWdgtPosition *position, + GtkSizeGroup *label_size_group) +{ + gtk_size_group_add_widget (label_size_group, position->x_label); + gtk_size_group_add_widget (label_size_group, position->y_label); +} + diff --git a/glabels2/src/wdgt-position.h b/glabels2/src/wdgt-position.h index 41b13237..00ecbfbd 100644 --- a/glabels2/src/wdgt-position.h +++ b/glabels2/src/wdgt-position.h @@ -25,6 +25,9 @@ #include #include "label.h" +#include "hig.h" + +G_BEGIN_DECLS #define GL_TYPE_WDGT_POSITION (gl_wdgt_position_get_type ()) #define GL_WDGT_POSITION(obj) \ @@ -40,31 +43,44 @@ typedef struct _glWdgtPosition glWdgtPosition; typedef struct _glWdgtPositionClass glWdgtPositionClass; struct _glWdgtPosition { - GtkVBox parent_widget; + glHigVBox parent_widget; + GtkWidget *x_label; GtkWidget *x_spin; + + GtkWidget *y_label; GtkWidget *y_spin; + GtkWidget *units_label; }; struct _glWdgtPositionClass { - GtkVBoxClass parent_class; + glHigVBoxClass parent_class; void (*changed) (glWdgtPosition * prop, gpointer user_data); }; -extern guint gl_wdgt_position_get_type (void); +guint gl_wdgt_position_get_type (void); + +GtkWidget *gl_wdgt_position_new (void); + +void gl_wdgt_position_get_position (glWdgtPosition *position, + gdouble *x, + gdouble *y); -extern GtkWidget *gl_wdgt_position_new (gchar * label); +void gl_wdgt_position_set_params (glWdgtPosition *position, + gdouble x, + gdouble y, + gdouble x_max, + gdouble y_max); -extern void gl_wdgt_position_get_position (glWdgtPosition * position, - gdouble * x, gdouble * y); +void gl_wdgt_position_set_position (glWdgtPosition *position, + gdouble x, + gdouble y); -extern void gl_wdgt_position_set_params (glWdgtPosition * position, - gdouble x, gdouble y, - gdouble x_max, gdouble y_max); +void gl_wdgt_position_set_label_size_group (glWdgtPosition *position, + GtkSizeGroup *size_group); -extern void gl_wdgt_position_set_position (glWdgtPosition * position, - gdouble x, gdouble y); +G_END_DECLS #endif diff --git a/glabels2/src/wdgt-text-entry.c b/glabels2/src/wdgt-text-entry.c index 912a9053..cd915f10 100644 --- a/glabels2/src/wdgt-text-entry.c +++ b/glabels2/src/wdgt-text-entry.c @@ -44,7 +44,7 @@ typedef void (*glWdgtTextEntrySignal) (GObject * object, gpointer data); /* Private globals */ /*===========================================*/ -static GtkContainerClass *parent_class; +static glHigVBoxClass *parent_class; static gint wdgt_text_entry_signals[LAST_SIGNAL] = { 0 }; @@ -52,18 +52,18 @@ static gint wdgt_text_entry_signals[LAST_SIGNAL] = { 0 }; /* Local function prototypes */ /*===========================================*/ -static void gl_wdgt_text_entry_class_init (glWdgtTextEntryClass * class); -static void gl_wdgt_text_entry_instance_init (glWdgtTextEntry * text_entry); -static void gl_wdgt_text_entry_finalize (GObject * object); -static void gl_wdgt_text_entry_construct (glWdgtTextEntry * text_entry, - gchar * label, GList * field_defs); +static void gl_wdgt_text_entry_class_init (glWdgtTextEntryClass *class); +static void gl_wdgt_text_entry_instance_init (glWdgtTextEntry *text_entry); +static void gl_wdgt_text_entry_finalize (GObject *object); +static void gl_wdgt_text_entry_construct (glWdgtTextEntry *text_entry, + GList *field_defs); -static void changed_cb (glWdgtTextEntry * text_entry); -static void insert_cb (glWdgtTextEntry * text_entry); +static void changed_cb (glWdgtTextEntry *text_entry); +static void insert_cb (glWdgtTextEntry *text_entry); -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ +/****************************************************************************/ +/* Boilerplate Object stuff. */ +/****************************************************************************/ guint gl_wdgt_text_entry_get_type (void) { @@ -82,10 +82,10 @@ gl_wdgt_text_entry_get_type (void) (GInstanceInitFunc) gl_wdgt_text_entry_instance_init, }; - wdgt_text_entry_type = g_type_register_static (gtk_vbox_get_type (), - "glWdgtTextEntry", - &wdgt_text_entry_info, - 0); + wdgt_text_entry_type = + g_type_register_static (gl_hig_vbox_get_type (), + "glWdgtTextEntry", + &wdgt_text_entry_info, 0); } return wdgt_text_entry_type; @@ -100,7 +100,7 @@ gl_wdgt_text_entry_class_init (glWdgtTextEntryClass * 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_text_entry_finalize; @@ -116,7 +116,7 @@ gl_wdgt_text_entry_class_init (glWdgtTextEntryClass * class) } static void -gl_wdgt_text_entry_instance_init (glWdgtTextEntry * text_entry) +gl_wdgt_text_entry_instance_init (glWdgtTextEntry *text_entry) { gl_debug (DEBUG_WDGT, "START"); @@ -128,9 +128,9 @@ gl_wdgt_text_entry_instance_init (glWdgtTextEntry * text_entry) } static void -gl_wdgt_text_entry_finalize (GObject * object) +gl_wdgt_text_entry_finalize (GObject *object) { - glWdgtTextEntry *text_entry; + glWdgtTextEntry *text_entry; glWdgtTextEntryClass *class; gl_debug (DEBUG_WDGT, "START"); @@ -145,9 +145,11 @@ gl_wdgt_text_entry_finalize (GObject * object) gl_debug (DEBUG_WDGT, "END"); } +/****************************************************************************/ +/* New widget. */ +/****************************************************************************/ GtkWidget * -gl_wdgt_text_entry_new (gchar * label, - GList * field_defs) +gl_wdgt_text_entry_new (GList *field_defs) { glWdgtTextEntry *text_entry; @@ -155,51 +157,55 @@ gl_wdgt_text_entry_new (gchar * label, text_entry = g_object_new (gl_wdgt_text_entry_get_type (), NULL); - gl_wdgt_text_entry_construct (text_entry, label, field_defs); + gl_wdgt_text_entry_construct (text_entry, field_defs); gl_debug (DEBUG_WDGT, "END"); return GTK_WIDGET (text_entry); } -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Construct composite widget. */ +/*--------------------------------------------------------------------------*/ static void -gl_wdgt_text_entry_construct (glWdgtTextEntry * text_entry, - gchar * label, - GList * field_defs) +gl_wdgt_text_entry_construct (glWdgtTextEntry *text_entry, + GList *field_defs) { - GtkWidget *wvbox, *wframe, *wtable, *wlabel, *wcombo; + GtkWidget *wvbox, *whbox, *wlabel, *wscroll, *wcombo; GList *keys; gl_debug (DEBUG_WDGT, "START"); wvbox = GTK_WIDGET (text_entry); - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (2, 3, 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); + /* Text Label */ + wlabel = gtk_label_new (_("Edit text:")); + gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wlabel); /* Actual text entry widget */ + wscroll = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_set_size_request (wscroll, -1, 70); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (wscroll), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wscroll); text_entry->text_entry = gtk_text_view_new (); text_entry->text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_entry->text_entry)); + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (wscroll), + text_entry->text_entry); g_signal_connect_swapped (G_OBJECT (text_entry->text_buffer), "changed", G_CALLBACK (changed_cb), G_OBJECT (text_entry)); - gtk_widget_set_size_request (text_entry->text_entry, -1, 70); - gtk_table_attach_defaults (GTK_TABLE (wtable), text_entry->text_entry, - 0, 3, 0, 1); + + /* ---- Merge field line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); /* Insert merge field label */ wlabel = gtk_label_new (_("Key:")); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wlabel); /* Key entry widget */ wcombo = gtk_combo_new (); @@ -210,7 +216,7 @@ gl_wdgt_text_entry_construct (glWdgtTextEntry * text_entry, text_entry->key_entry = GTK_COMBO (wcombo)->entry; gtk_entry_set_editable (GTK_ENTRY (text_entry->key_entry), FALSE); gtk_widget_set_size_request (wcombo, 200, -1); - gtk_table_attach_defaults (GTK_TABLE (wtable), wcombo, 1, 2, 1, 2); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wcombo); /* Insert button */ text_entry->insert_button = @@ -218,8 +224,7 @@ gl_wdgt_text_entry_construct (glWdgtTextEntry * text_entry, g_signal_connect_swapped (G_OBJECT (text_entry->insert_button), "clicked", G_CALLBACK (insert_cb), G_OBJECT (text_entry)); - gtk_table_attach_defaults (GTK_TABLE (wtable), - text_entry->insert_button, 2, 3, 1, 2); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text_entry->insert_button); gl_debug (DEBUG_WDGT, "END"); } @@ -265,9 +270,9 @@ insert_cb (glWdgtTextEntry * text_entry) gl_debug (DEBUG_WDGT, "END"); } -/*--------------------------------------------------------------------------*/ +/****************************************************************************/ /* Get widget data. */ -/*--------------------------------------------------------------------------*/ +/****************************************************************************/ GList * gl_wdgt_text_entry_get_text (glWdgtTextEntry * text_entry) { @@ -293,9 +298,9 @@ gl_wdgt_text_entry_get_text (glWdgtTextEntry * text_entry) return lines; } -/*--------------------------------------------------------------------------*/ +/****************************************************************************/ /* Set widget data. */ -/*--------------------------------------------------------------------------*/ +/****************************************************************************/ void gl_wdgt_text_entry_set_text (glWdgtTextEntry * text_entry, gboolean merge_flag, diff --git a/glabels2/src/wdgt-text-entry.h b/glabels2/src/wdgt-text-entry.h index e5fa697c..a5bbe67d 100644 --- a/glabels2/src/wdgt-text-entry.h +++ b/glabels2/src/wdgt-text-entry.h @@ -24,8 +24,10 @@ #define __WDGT_TEXT_ENTRY_H__ #include - #include "merge.h" +#include "hig.h" + +G_BEGIN_DECLS #define GL_TYPE_WDGT_TEXT_ENTRY (gl_wdgt_text_entry_get_type ()) #define GL_WDGT_TEXT_ENTRY(obj) \ @@ -41,29 +43,31 @@ typedef struct _glWdgtTextEntry glWdgtTextEntry; typedef struct _glWdgtTextEntryClass glWdgtTextEntryClass; struct _glWdgtTextEntry { - GtkVBox parent_widget; + glHigVBox parent_widget; - GtkWidget *text_entry; - GtkWidget *key_entry; - GtkWidget *insert_button; + GtkWidget *text_entry; + GtkWidget *key_entry; + GtkWidget *insert_button; GtkTextBuffer *text_buffer; }; struct _glWdgtTextEntryClass { - GtkVBoxClass parent_class; + glHigVBoxClass parent_class; void (*changed) (glWdgtTextEntry * text_entry, gpointer user_data); }; -extern 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); -extern GtkWidget *gl_wdgt_text_entry_new (gchar * label, GList * field_defs); +GList *gl_wdgt_text_entry_get_text (glWdgtTextEntry *text_entry); -extern 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); -extern void gl_wdgt_text_entry_set_text (glWdgtTextEntry * text_entry, - gboolean merge_flag, - GList * lines); +G_END_DECLS #endif diff --git a/glabels2/src/wdgt-text-props.c b/glabels2/src/wdgt-text-props.c index 1524dcbe..94704585 100644 --- a/glabels2/src/wdgt-text-props.c +++ b/glabels2/src/wdgt-text-props.c @@ -54,19 +54,21 @@ static gint wdgt_text_props_signals[LAST_SIGNAL] = { 0 }; /*===========================================*/ static void gl_wdgt_text_props_class_init (glWdgtTextPropsClass *class); -static void gl_wdgt_text_props_instance_init (glWdgtTextProps *text); -static void gl_wdgt_text_props_finalize (GObject *object); -static void gl_wdgt_text_props_construct (glWdgtTextProps *text, - gchar *label); +static void gl_wdgt_text_props_instance_init (glWdgtTextProps *text); +static void gl_wdgt_text_props_finalize (GObject *object); +static void gl_wdgt_text_props_construct (glWdgtTextProps *text); + +static void family_changed_cb (GtkEntry *entry, + glWdgtTextProps *text); -static void family_changed_cb (GtkEntry *entry, glWdgtTextProps *text); static void changed_cb (glWdgtTextProps *text); + static void just_toggled_cb (GtkToggleButton *togglebutton, - gpointer user_data); + gpointer user_data); -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ +/*****************************************************************************/ +/* Boilerplate Object stuff. */ +/*****************************************************************************/ guint gl_wdgt_text_props_get_type (void) { @@ -86,8 +88,9 @@ gl_wdgt_text_props_get_type (void) }; wdgt_text_props_type = - g_type_register_static (gtk_vbox_get_type (), - "glWdgtTextProps", &wdgt_text_props_info, 0); + g_type_register_static (gl_hig_vbox_get_type (), + "glWdgtTextProps", + &wdgt_text_props_info, 0); } return wdgt_text_props_type; @@ -100,7 +103,7 @@ gl_wdgt_text_props_class_init (glWdgtTextPropsClass *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_text_props_finalize; @@ -143,49 +146,41 @@ gl_wdgt_text_props_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } +/*****************************************************************************/ +/* New widget. */ +/*****************************************************************************/ GtkWidget * -gl_wdgt_text_props_new (gchar *label) +gl_wdgt_text_props_new (void) { glWdgtTextProps *text; text = g_object_new (gl_wdgt_text_props_get_type (), NULL); - gl_wdgt_text_props_construct (text, label); + gl_wdgt_text_props_construct (text); return GTK_WIDGET (text); } - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Construct composite widget. */ +/*--------------------------------------------------------------------------*/ static void -gl_wdgt_text_props_construct (glWdgtTextProps *text, - gchar *label) +gl_wdgt_text_props_construct (glWdgtTextProps *text) { - GtkWidget *wvbox, *wframe, *wtable, *wlabel, *whbox1, *wcombo; + GtkWidget *wvbox, *whbox, *wcombo, *wbhbox; GList *family_names = NULL; GtkObject *adjust; wvbox = GTK_WIDGET (text); - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (3, 3, 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); + /* ---- Font line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); /* Font label */ - wlabel = gtk_label_new (_("Font:")); - 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); - - /* Pack these widgets into an inner hbox */ - whbox1 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_table_attach_defaults (GTK_TABLE (wtable), whbox1, 1, 3, 0, 1); + text->font_label = gtk_label_new (_("Font:")); + gtk_misc_set_alignment (GTK_MISC (text->font_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->font_label); /* Font family entry widget */ wcombo = gtk_combo_new (); @@ -196,7 +191,7 @@ gl_wdgt_text_props_construct (glWdgtTextProps *text, gtk_combo_set_value_in_list (GTK_COMBO(wcombo), TRUE, FALSE); gtk_entry_set_editable (GTK_ENTRY (text->font_family_entry), FALSE); gtk_widget_set_size_request (wcombo, 200, -1); - gtk_box_pack_start (GTK_BOX (whbox1), wcombo, FALSE, FALSE, 0); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wcombo); g_signal_connect (G_OBJECT (text->font_family_entry), "changed", G_CALLBACK (family_changed_cb), text); @@ -204,8 +199,7 @@ gl_wdgt_text_props_construct (glWdgtTextProps *text, adjust = gtk_adjustment_new (1.0, 1.0, 250.0, 1.0, 10.0, 10.0); text->font_size_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 1.0, 0); - gtk_box_pack_start (GTK_BOX (whbox1), text->font_size_spin, FALSE, - FALSE, 0); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->font_size_spin); g_signal_connect_swapped (G_OBJECT (text->font_size_spin), "changed", G_CALLBACK (changed_cb), G_OBJECT (text)); @@ -215,8 +209,7 @@ gl_wdgt_text_props_construct (glWdgtTextProps *text, gtk_container_add (GTK_CONTAINER (text->font_b_button), gtk_image_new_from_stock (GTK_STOCK_BOLD, GTK_ICON_SIZE_BUTTON)); - gtk_box_pack_start (GTK_BOX (whbox1), text->font_b_button, FALSE, FALSE, - 0); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->font_b_button); g_signal_connect_swapped (G_OBJECT (text->font_b_button), "toggled", G_CALLBACK (changed_cb), G_OBJECT (text)); @@ -224,55 +217,52 @@ gl_wdgt_text_props_construct (glWdgtTextProps *text, gtk_container_add (GTK_CONTAINER (text->font_i_button), gtk_image_new_from_stock (GTK_STOCK_ITALIC, GTK_ICON_SIZE_BUTTON)); - gtk_box_pack_start (GTK_BOX (whbox1), text->font_i_button, FALSE, FALSE, - 0); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->font_i_button); g_signal_connect_swapped (G_OBJECT (text->font_i_button), "toggled", G_CALLBACK (changed_cb), G_OBJECT (text)); + /* ---- Color line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); + /* Text 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); + text->color_label = gtk_label_new (_("Color:")); + gtk_misc_set_alignment (GTK_MISC (text->color_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->color_label); /* Text Color picker widget */ text->color_picker = gnome_color_picker_new (); g_signal_connect_swapped (G_OBJECT (text->color_picker), "color_set", G_CALLBACK (changed_cb), G_OBJECT (text)); - gtk_table_attach_defaults (GTK_TABLE (wtable), text->color_picker, 1, 2, - 1, 2); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->color_picker); - /* Alignment label */ - wlabel = gtk_label_new (_("Alignment:")); - 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, 2, 3); + /* ---- Alignment line ---- */ + whbox = gl_hig_hbox_new (); + gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - /* Pack these widgets into an inner hbox */ - whbox1 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_table_attach_defaults (GTK_TABLE (wtable), whbox1, 1, 2, 2, 3); + /* Alignment label */ + text->alignment_label = gtk_label_new (_("Alignment:")); + gtk_misc_set_alignment (GTK_MISC (text->alignment_label), 0, 0.5); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->alignment_label); /* Justification entry widget */ text->left_button = gtk_toggle_button_new (); gtk_container_add (GTK_CONTAINER (text->left_button), gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_LEFT, GTK_ICON_SIZE_BUTTON)); - gtk_box_pack_start (GTK_BOX (whbox1), text->left_button, FALSE, FALSE, - 0); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->left_button); text->center_button = gtk_toggle_button_new (); gtk_container_add (GTK_CONTAINER (text->center_button), gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_CENTER, GTK_ICON_SIZE_BUTTON)); - gtk_box_pack_start (GTK_BOX (whbox1), text->center_button, FALSE, FALSE, - 0); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->center_button); text->right_button = gtk_toggle_button_new (); gtk_container_add (GTK_CONTAINER (text->right_button), gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_RIGHT, GTK_ICON_SIZE_BUTTON)); - gtk_box_pack_start (GTK_BOX (whbox1), text->right_button, FALSE, FALSE, - 0); + gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->right_button); /* Now connect a callback that makes these toggles mutually exclusive */ g_signal_connect (G_OBJECT (text->left_button), "toggled", @@ -317,7 +307,7 @@ changed_cb (glWdgtTextProps *text) /*--------------------------------------------------------------------------*/ static void just_toggled_cb (GtkToggleButton *togglebutton, - gpointer user_data) + gpointer user_data) { glWdgtTextProps *text = GL_WDGT_TEXT_PROPS (user_data); @@ -354,9 +344,9 @@ just_toggled_cb (GtkToggleButton *togglebutton, g_signal_emit (G_OBJECT (text), wdgt_text_props_signals[CHANGED], 0); } -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ +/*****************************************************************************/ +/* query values from controls. */ +/*****************************************************************************/ void gl_wdgt_text_props_get_params (glWdgtTextProps *text, gchar **font_family, @@ -407,9 +397,9 @@ gl_wdgt_text_props_get_params (glWdgtTextProps *text, } -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ +/*****************************************************************************/ +/* fill in values and ranges for controls. */ +/*****************************************************************************/ void gl_wdgt_text_props_set_params (glWdgtTextProps *text, gchar *font_family, @@ -443,3 +433,16 @@ gl_wdgt_text_props_set_params (glWdgtTextProps *text, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text->right_button), (just == GTK_JUSTIFY_RIGHT)); } + +/*****************************************************************************/ +/* Set size group for internal labels */ +/*****************************************************************************/ +void +gl_wdgt_text_props_set_label_size_group (glWdgtTextProps *text, + GtkSizeGroup *label_size_group) +{ + gtk_size_group_add_widget (label_size_group, text->font_label); + gtk_size_group_add_widget (label_size_group, text->color_label); + gtk_size_group_add_widget (label_size_group, text->alignment_label); +} + diff --git a/glabels2/src/wdgt-text-props.h b/glabels2/src/wdgt-text-props.h index 219e8e9b..80b1b224 100644 --- a/glabels2/src/wdgt-text-props.h +++ b/glabels2/src/wdgt-text-props.h @@ -26,6 +26,9 @@ #include #include #include "label.h" +#include "hig.h" + +G_BEGIN_DECLS #define GL_TYPE_WDGT_TEXT_PROPS (gl_wdgt_text_props_get_type ()) #define GL_WDGT_TEXT_PROPS(obj) \ @@ -41,42 +44,50 @@ typedef struct _glWdgtTextProps glWdgtTextProps; typedef struct _glWdgtTextPropsClass glWdgtTextPropsClass; struct _glWdgtTextProps { - GtkVBox parent_widget; + glHigVBox parent_widget; + GtkWidget *font_label; GtkWidget *font_family_entry; GtkWidget *font_size_spin; GtkWidget *font_b_button; GtkWidget *font_i_button; + GtkWidget *color_label; GtkWidget *color_picker; + GtkWidget *alignment_label; GtkWidget *left_button, *right_button, *center_button; }; struct _glWdgtTextPropsClass { - GtkVBoxClass parent_class; + glHigVBoxClass parent_class; void (*changed) (glWdgtTextProps * text, gpointer user_data); }; -extern guint gl_wdgt_text_props_get_type (void); - -extern GtkWidget *gl_wdgt_text_props_new (gchar * label); - -extern void gl_wdgt_text_props_get_params (glWdgtTextProps * text, - gchar ** font_family, - gdouble * font_size, - GnomeFontWeight * font_weight, - gboolean * font_italic_flag, - guint * color, - GtkJustification * just); - -extern void gl_wdgt_text_props_set_params (glWdgtTextProps * text, - gchar * font_family, - gdouble font_size, - GnomeFontWeight font_weight, - gboolean font_italic_flag, - guint color, - GtkJustification just); +guint gl_wdgt_text_props_get_type (void); + +GtkWidget *gl_wdgt_text_props_new (void); + +void gl_wdgt_text_props_get_params (glWdgtTextProps *text, + gchar **font_family, + gdouble *font_size, + GnomeFontWeight *font_weight, + gboolean *font_italic_flag, + guint *color, + GtkJustification *just); + +void gl_wdgt_text_props_set_params (glWdgtTextProps *text, + gchar *font_family, + gdouble font_size, + GnomeFontWeight font_weight, + gboolean font_italic_flag, + guint color, + GtkJustification just); + +void gl_wdgt_text_props_set_label_size_group (glWdgtTextProps *text, + GtkSizeGroup *size_grp); + +G_END_DECLS #endif -- 2.39.5