[gtk/matthiasc/for-master: 4/5] docs: Add box, grid and center box to the gallery
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 4/5] docs: Add box, grid and center box to the gallery
- Date: Tue, 27 Oct 2020 04:43:39 +0000 (UTC)
commit 4f15b988e711f368af6d53c169aaf458de7a5626
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Oct 27 00:24:54 2020 -0400
docs: Add box, grid and center box to the gallery
docs/reference/gtk/images/box.png | Bin 0 -> 5202 bytes
docs/reference/gtk/images/centerbox.png | Bin 0 -> 3142 bytes
docs/reference/gtk/images/grid.png | Bin 0 -> 3110 bytes
docs/reference/gtk/meson.build | 3 +
docs/reference/gtk/visual_index.xml | 5 +
docs/tools/widgets.c | 165 +++++++++++++++++++++++++++++++-
6 files changed, 172 insertions(+), 1 deletion(-)
---
diff --git a/docs/reference/gtk/images/box.png b/docs/reference/gtk/images/box.png
new file mode 100644
index 0000000000..77a04a5948
Binary files /dev/null and b/docs/reference/gtk/images/box.png differ
diff --git a/docs/reference/gtk/images/centerbox.png b/docs/reference/gtk/images/centerbox.png
new file mode 100644
index 0000000000..0ad57fc938
Binary files /dev/null and b/docs/reference/gtk/images/centerbox.png differ
diff --git a/docs/reference/gtk/images/grid.png b/docs/reference/gtk/images/grid.png
new file mode 100644
index 0000000000..8f83c4c118
Binary files /dev/null and b/docs/reference/gtk/images/grid.png differ
diff --git a/docs/reference/gtk/meson.build b/docs/reference/gtk/meson.build
index 30d7737339..6ae52d356a 100644
--- a/docs/reference/gtk/meson.build
+++ b/docs/reference/gtk/meson.build
@@ -240,12 +240,14 @@ images = [
'images/border1.png',
'images/border2.png',
'images/border3.png',
+ 'images/box.png',
'images/box-expand.png',
'images/box-packing.png',
'images/builder-shortcuts.png',
'images/button.png',
'images/calendar.png',
'images/capture-bubble.png',
+ 'images/centerbox.png',
'images/check-button.png',
'images/checks.png',
'images/clocks-shortcuts.png',
@@ -297,6 +299,7 @@ images = [
'images/gradient2.png',
'images/gradient3.png',
'images/gradient4.png',
+ 'images/grid.png',
'images/grid-packing.png',
'images/handles.png',
'images/headerbar.png',
diff --git a/docs/reference/gtk/visual_index.xml b/docs/reference/gtk/visual_index.xml
index 664d3922fe..e1c8883c32 100644
--- a/docs/reference/gtk/visual_index.xml
+++ b/docs/reference/gtk/visual_index.xml
@@ -64,6 +64,11 @@
<section id="visual-containers">
<title>Containers</title>
+ <para role="gallery">
+ <link linkend="GtkBox"><inlinegraphic fileref="box.png" format="PNG"></inlinegraphic></link>
+ <link linkend="GtkGrid"><inlinegraphic fileref="grid.png" format="PNG"></inlinegraphic></link>
+ <link linkend="GtkCenterBox"><inlinegraphic fileref="centerbox.png" format="PNG"></inlinegraphic></link>
+ </para>
<para role="gallery">
<link linkend="GtkScrolledWindow"><inlinegraphic fileref="scrolledwindow.png"
format="PNG"></inlinegraphic></link>
<link linkend="GtkPaned"><inlinegraphic fileref="panes.png" format="PNG"></inlinegraphic></link>
diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
index 3cb08a3410..6dedd9036a 100644
--- a/docs/tools/widgets.c
+++ b/docs/tools/widgets.c
@@ -681,6 +681,7 @@ create_editable_label (void)
return new_widget_info ("editable-label", vbox, SMALL);
}
+
static WidgetInfo *
create_separator (void)
{
@@ -1924,10 +1925,169 @@ create_drawing_area (void)
return info;
}
+static WidgetInfo *
+create_box (void)
+{
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *widget;
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 40);
+ gtk_widget_set_margin_top (hbox, 20);
+ gtk_widget_set_margin_bottom (hbox, 20);
+ gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER);
+ widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
+ for (int i = 0; i < 2; i++)
+ {
+ GtkWidget *button = gtk_button_new ();
+ gtk_widget_add_css_class (button, "small");
+ gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_box_append (GTK_BOX (widget), button);
+ }
+ gtk_box_append (GTK_BOX (widget), gtk_label_new ("⋯"));
+ gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
+ gtk_box_append (GTK_BOX (hbox), widget);
+ widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
+ for (int i = 0; i < 2; i++)
+ {
+ GtkWidget *button = gtk_button_new ();
+ gtk_widget_add_css_class (button, "small");
+ gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_box_append (GTK_BOX (widget), button);
+ }
+ gtk_box_append (GTK_BOX (widget), gtk_label_new ("⋮"));
+ gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
+ gtk_box_append (GTK_BOX (hbox), widget);
+ gtk_box_append (GTK_BOX (vbox), hbox);
+ gtk_box_append (GTK_BOX (vbox), g_object_new (GTK_TYPE_LABEL,
+ "label", "Horizontal and Vertical Boxes",
+ "justify", GTK_JUSTIFY_CENTER,
+ NULL));
+ add_margin (vbox);
+
+ return new_widget_info ("box", vbox, MEDIUM);
+}
+
+static WidgetInfo *
+create_center_box (void)
+{
+ GtkWidget *vbox;
+ GtkWidget *widget;
+ GtkWidget *button;
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
+ widget = gtk_center_box_new ();
+ gtk_widget_set_margin_top (widget, 10);
+ gtk_widget_set_margin_bottom (widget, 10);
+ gtk_widget_set_margin_start (widget, 20);
+ gtk_widget_set_margin_end (widget, 20);
+ gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
+ gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
+
+ button = gtk_button_new ();
+ gtk_widget_add_css_class (button, "small");
+ gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_center_box_set_start_widget (GTK_CENTER_BOX (widget), button);
+
+ button = gtk_button_new ();
+ gtk_widget_add_css_class (button, "small");
+ gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_center_box_set_center_widget (GTK_CENTER_BOX (widget), button);
+
+ button = gtk_button_new ();
+ gtk_widget_add_css_class (button, "small");
+ gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_center_box_set_end_widget (GTK_CENTER_BOX (widget), button);
+
+ gtk_box_append (GTK_BOX (vbox), widget);
+ gtk_box_append (GTK_BOX (vbox), g_object_new (GTK_TYPE_LABEL,
+ "label", "Center Box",
+ "justify", GTK_JUSTIFY_CENTER,
+ NULL));
+ add_margin (vbox);
+
+ return new_widget_info ("centerbox", vbox, SMALL);
+}
+
+static WidgetInfo *
+create_grid (void)
+{
+ GtkWidget *vbox;
+ GtkWidget *widget;
+ GtkWidget *button;
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
+ widget = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (widget), 4);
+ gtk_grid_set_column_spacing (GTK_GRID (widget), 4);
+ gtk_widget_set_margin_top (widget, 20);
+ gtk_widget_set_margin_bottom (widget, 20);
+ gtk_widget_set_margin_start (widget, 20);
+ gtk_widget_set_margin_end (widget, 20);
+ gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
+
+ button = gtk_button_new ();
+ gtk_widget_add_css_class (button, "small");
+ gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_grid_attach (GTK_GRID (widget), button, 0, 0, 1, 1);
+
+ button = gtk_button_new ();
+ gtk_widget_add_css_class (button, "small");
+ gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_grid_attach (GTK_GRID (widget), button, 0, 1, 1, 1);
+
+ button = gtk_button_new ();
+ gtk_widget_add_css_class (button, "small");
+ gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_grid_attach (GTK_GRID (widget), button, 1, 0, 1, 1);
+
+ button = gtk_button_new ();
+ gtk_widget_add_css_class (button, "small");
+ gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_grid_attach (GTK_GRID (widget), button, 1, 1, 1, 1);
+
+ gtk_grid_attach (GTK_GRID (widget), gtk_label_new ("⋯"), 2, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (widget), gtk_label_new ("⋮"), 0, 2, 1, 1);
+
+ gtk_box_append (GTK_BOX (vbox), widget);
+ gtk_box_append (GTK_BOX (vbox), g_object_new (GTK_TYPE_LABEL,
+ "label", "Grid",
+ "justify", GTK_JUSTIFY_CENTER,
+ NULL));
+ add_margin (vbox);
+
+ return new_widget_info ("grid", vbox, MEDIUM);
+}
+
GList *
get_all_widgets (void)
{
GList *retval = NULL;
+ GtkCssProvider *provider;
+
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider,
+ "button.small {\n"
+ " min-width: 16px;\n"
+ " min-height: 16px;\n"
+ " padding: 0;\n"
+ "}", -1);
+ gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+ GTK_STYLE_PROVIDER (provider),
+ 800);
retval = g_list_prepend (retval, create_search_bar ());
retval = g_list_prepend (retval, create_action_bar ());
@@ -1997,7 +2157,10 @@ get_all_widgets (void)
retval = g_list_prepend (retval, create_popover ());
retval = g_list_prepend (retval, create_menu ());
retval = g_list_prepend (retval, create_shortcuts_window ());
- retval = g_list_prepend (retval, create_drawing_area());
+ retval = g_list_prepend (retval, create_drawing_area ());
+ retval = g_list_prepend (retval, create_box ());
+ retval = g_list_prepend (retval, create_center_box ());
+ retval = g_list_prepend (retval, create_grid ());
return retval;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]