[balsa/gtk3] Port print dialog from GtkTable to GtkGrid
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Port print dialog from GtkTable to GtkGrid
- Date: Thu, 13 Oct 2011 20:42:41 +0000 (UTC)
commit 1574a89f70f24e1e11da3e29e2cde50d54a5b660
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Thu Oct 13 16:41:59 2011 -0400
Port print dialog from GtkTable to GtkGrid
* src/print-gtk.c (begin_print), (add_font_button),
(add_margin_spinbtn), (message_prefs_widget): migrate from
GtkTable to GtkGrid.
ChangeLog | 6 +++++
src/print-gtk.c | 60 ++++++++++++++++++++++++++----------------------------
2 files changed, 35 insertions(+), 31 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c22dac1..f9ddb44 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2011-10-13 Peter Bloomfield
+ * src/print-gtk.c (begin_print), (add_font_button),
+ (add_margin_spinbtn), (message_prefs_widget): migrate from
+ GtkTable to GtkGrid.
+
+2011-10-13 Peter Bloomfield
+
* src/pref-manager.c (attach_entry), (attach_entry_full),
(attach_information_menu), (attach_label), (checking_group),
(quoted_group), (broken_8bit_codeset_group), (mdn_group),
diff --git a/src/print-gtk.c b/src/print-gtk.c
index 1d861e9..548b58a 100644
--- a/src/print-gtk.c
+++ b/src/print-gtk.c
@@ -305,7 +305,7 @@ begin_print(GtkPrintOperation * operation, GtkPrintContext * context,
pango_layout_set_width(layout, C_TO_P(pdata->setup.c_width));
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
- /* calculate the height and adjust the printable region */
+ /* calculate the height and adjust the pringrid region */
p_height = p_string_height_from_layout(layout, footer_string->str);
pdata->c_footer_y =
pdata->setup.c_y0 + pdata->setup.c_height - P_TO_C(p_height);
@@ -401,7 +401,7 @@ get_default_user_units(void)
}
static GtkWidget *
-add_font_button(const gchar * text, const gchar * font, GtkTable * table,
+add_font_button(const gchar * text, const gchar * font, GtkGrid * grid,
gint row)
{
GtkWidget *label;
@@ -410,14 +410,13 @@ add_font_button(const gchar * text, const gchar * font, GtkTable * table,
label = gtk_label_new_with_mnemonic(text);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- gtk_table_attach(table, label, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
+ gtk_widget_set_halign(label, GTK_ALIGN_START);
+ gtk_grid_attach(grid, label, 0, row, 1, 1);
font_button = gtk_font_button_new_with_font(font);
gtk_label_set_mnemonic_widget(GTK_LABEL(label), font_button);
- gtk_table_attach(table, font_button, 1, 2, row, row + 1,
- GTK_EXPAND | GTK_FILL,
- (GtkAttachOptions) (GTK_FILL), 0, 0);
+ gtk_widget_set_hexpand(font_button, TRUE);
+ gtk_grid_attach(grid, font_button, 1, row, 1, 1);
return font_button;
}
@@ -425,7 +424,7 @@ add_font_button(const gchar * text, const gchar * font, GtkTable * table,
/* note: min and max are passed in points = 1/72" */
static GtkWidget *
add_margin_spinbtn(const gchar * text, gdouble min, gdouble max, gdouble dflt,
- GtkTable * table, gint row)
+ GtkGrid * grid, gint row)
{
GtkWidget *label;
GtkWidget *spinbtn;
@@ -434,8 +433,8 @@ add_margin_spinbtn(const gchar * text, gdouble min, gdouble max, gdouble dflt,
label = gtk_label_new_with_mnemonic(text);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- gtk_table_attach(table, label, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
+ gtk_widget_set_halign(label, GTK_ALIGN_START);
+ gtk_grid_attach(grid, label, 0, row, 1, 1);
if (get_default_user_units() == GTK_UNIT_INCH) {
unit = _("inch");
@@ -454,14 +453,13 @@ add_margin_spinbtn(const gchar * text, gdouble min, gdouble max, gdouble dflt,
}
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbtn), TRUE);
gtk_label_set_mnemonic_widget(GTK_LABEL(label), spinbtn);
- gtk_table_attach(table, spinbtn, 1, 2, row, row + 1, GTK_FILL,
- (GtkAttachOptions) (GTK_FILL), 0, 0);
-
+ gtk_grid_attach(grid, spinbtn, 1, row, 1, 1);
+
label = gtk_label_new(unit);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- gtk_table_attach(table, label, 2, 3, row, row + 1, GTK_FILL, 0, 0, 0);
+ gtk_widget_set_halign(label, GTK_ALIGN_START);
+ gtk_grid_attach(grid, label, 2, row, 1, 1);
return spinbtn;
}
@@ -486,7 +484,7 @@ message_prefs_widget(GtkPrintOperation * operation,
GtkWidget *label;
GtkWidget *hbox;
GtkWidget *vbox;
- GtkWidget *table;
+ GtkWidget *grid;
GtkPageSetup *pg_setup;
gchar *markup;
@@ -513,21 +511,21 @@ message_prefs_widget(GtkPrintOperation * operation,
vbox = gtk_vbox_new(FALSE, 6);
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
- table = gtk_table_new(3, 2, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(table), 6);
- gtk_table_set_col_spacings(GTK_TABLE(table), 6);
+ grid = gtk_grid_new();
+ gtk_grid_set_row_spacing(GTK_GRID(grid), 6);
+ gtk_grid_set_column_spacing(GTK_GRID(grid), 6);
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), grid, FALSE, TRUE, 0);
print_prefs->header_font =
add_font_button(_("_Header Font:"), balsa_app.print_header_font,
- GTK_TABLE(table), 0);
+ GTK_GRID(grid), 0);
print_prefs->body_font =
add_font_button(_("B_ody Font:"), balsa_app.print_body_font,
- GTK_TABLE(table), 1);
+ GTK_GRID(grid), 1);
print_prefs->footer_font =
add_font_button(_("_Footer Font:"), balsa_app.print_footer_font,
- GTK_TABLE(table), 2);
+ GTK_GRID(grid), 2);
group = gtk_vbox_new(FALSE, 12);
gtk_box_pack_start(GTK_BOX(page), group, FALSE, TRUE, 0);
@@ -582,11 +580,11 @@ message_prefs_widget(GtkPrintOperation * operation,
vbox = gtk_vbox_new(FALSE, 6);
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
- table = gtk_table_new(4, 3, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(table), 6);
- gtk_table_set_col_spacings(GTK_TABLE(table), 6);
+ grid = gtk_grid_new();
+ gtk_grid_set_row_spacing(GTK_GRID(grid), 6);
+ gtk_grid_set_column_spacing(GTK_GRID(grid), 6);
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), grid, FALSE, TRUE, 0);
pg_setup = gtk_print_operation_get_default_page_setup(operation);
print_prefs->margin_top =
@@ -594,13 +592,13 @@ message_prefs_widget(GtkPrintOperation * operation,
gtk_page_setup_get_top_margin(pg_setup, GTK_UNIT_POINTS),
gtk_page_setup_get_page_height(pg_setup, GTK_UNIT_POINTS),
balsa_app.margin_top,
- GTK_TABLE(table), 0);
+ GTK_GRID(grid), 0);
print_prefs->margin_bottom =
add_margin_spinbtn(_("_Bottom"),
gtk_page_setup_get_bottom_margin(pg_setup, GTK_UNIT_POINTS),
gtk_page_setup_get_page_height(pg_setup, GTK_UNIT_POINTS),
balsa_app.margin_bottom,
- GTK_TABLE(table), 1);
+ GTK_GRID(grid), 1);
g_signal_connect(G_OBJECT(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(print_prefs->margin_top))),
"value-changed", G_CALLBACK(check_margins),
gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(print_prefs->margin_bottom)));
@@ -612,13 +610,13 @@ message_prefs_widget(GtkPrintOperation * operation,
gtk_page_setup_get_left_margin(pg_setup, GTK_UNIT_POINTS),
gtk_page_setup_get_page_width(pg_setup, GTK_UNIT_POINTS),
balsa_app.margin_left,
- GTK_TABLE(table), 2);
+ GTK_GRID(grid), 2);
print_prefs->margin_right =
add_margin_spinbtn(_("_Right"),
gtk_page_setup_get_right_margin(pg_setup, GTK_UNIT_POINTS),
gtk_page_setup_get_page_width(pg_setup, GTK_UNIT_POINTS),
balsa_app.margin_right,
- GTK_TABLE(table), 3);
+ GTK_GRID(grid), 3);
g_signal_connect(G_OBJECT(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(print_prefs->margin_left))),
"value-changed", G_CALLBACK(check_margins),
gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(print_prefs->margin_right)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]