1 /*************************************************************************/
2 /* Copyright (C) 2012-2013 matias <mati86dl@gmail.com> */
3 /* */
4 /* This program is free software: you can redistribute it and/or modify */
5 /* it under the terms of the GNU General Public License as published by */
6 /* the Free Software Foundation, either version 3 of the License, or */
7 /* (at your option) any later version. */
8 /* */
9 /* This program is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
12 /* GNU General Public License for more details. */
13 /* */
14 /* You should have received a copy of the GNU General Public License */
15 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 /*************************************************************************/
17
18 #include "pragha-hig.h"
19
20 #if !GTK_CHECK_VERSION (3, 12, 0)
21 #define gtk_widget_set_margin_start gtk_widget_set_margin_left
22 #endif
23
24 void
gtk_label_set_attribute_bold(GtkLabel * label)25 gtk_label_set_attribute_bold(GtkLabel *label)
26 {
27 PangoAttrList *Bold = pango_attr_list_new();
28 PangoAttribute *Attribute = NULL;
29 Attribute = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
30 pango_attr_list_insert(Bold, Attribute);
31
32 gtk_label_set_attributes(label, Bold);
33
34 pango_attr_list_unref(Bold);
35 }
36
37 GtkWidget *
pragha_hig_workarea_table_add_section_title(GtkWidget * table,guint * row,const char * section_title)38 pragha_hig_workarea_table_add_section_title(GtkWidget *table, guint *row, const char *section_title)
39 {
40 GtkWidget *section_label;
41
42 section_label = gtk_label_new(section_title);
43
44 gtk_misc_set_alignment(GTK_MISC(section_label), 0.0, 0.5);
45 gtk_label_set_attribute_bold(GTK_LABEL(section_label));
46
47 gtk_grid_attach (GTK_GRID(table), section_label, 0, *row, 2, 1);
48 ++ * row;
49
50 return section_label;
51 }
52
53 void
pragha_hig_workarea_table_add_wide_control(GtkWidget * table,guint * row,GtkWidget * widget)54 pragha_hig_workarea_table_add_wide_control(GtkWidget *table, guint *row, GtkWidget *widget)
55 {
56 gtk_grid_attach (GTK_GRID(table), widget, 0, *row, 2, 1);
57 gtk_widget_set_margin_start (GTK_WIDGET(widget), 12);
58
59 gtk_widget_set_hexpand (GTK_WIDGET(widget), TRUE);
60
61 ++ * row;
62 }
63
64 void
pragha_hig_workarea_table_add_wide_tall_control(GtkWidget * table,guint * row,GtkWidget * widget)65 pragha_hig_workarea_table_add_wide_tall_control(GtkWidget *table, guint *row, GtkWidget *widget)
66 {
67 gtk_grid_attach (GTK_GRID(table), widget, 0, *row, 2, 1);
68 gtk_widget_set_margin_start (GTK_WIDGET(widget), 12);
69
70 gtk_widget_set_hexpand (widget, TRUE);
71 gtk_widget_set_vexpand (widget, TRUE);
72
73 ++ * row;
74 }
75
76 void
pragha_hig_workarea_table_add_row(GtkWidget * table,guint * row,GtkWidget * label,GtkWidget * control)77 pragha_hig_workarea_table_add_row(GtkWidget *table, guint *row, GtkWidget *label, GtkWidget *control)
78 {
79 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
80 gtk_widget_set_margin_start (GTK_WIDGET(label), 12);
81
82 gtk_grid_attach (GTK_GRID(table), label, 0, *row, 1, 1);
83 gtk_grid_attach (GTK_GRID(table), control, 1, *row, 1, 1);
84
85 gtk_widget_set_hexpand (control, TRUE);
86
87 ++ * row;
88 }
89
90 GtkWidget *
pragha_hig_workarea_table_new()91 pragha_hig_workarea_table_new()
92 {
93 GtkWidget *table;
94
95 table = gtk_grid_new ();
96
97 gtk_container_set_border_width(GTK_CONTAINER(table), 12);
98
99 gtk_grid_set_row_spacing (GTK_GRID(table), 12);
100 gtk_grid_set_column_spacing (GTK_GRID(table), 6);
101
102 return table;
103 }
104