diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-07-31 16:36:02 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-07-31 16:36:02 -0400 |
commit | b0481811574fd95b96724e4be8fcc0e8d43727e9 (patch) | |
tree | 34b51ea7755295c10c41d92a167c222f08be9794 | |
parent | fb0a13b7f070a14312dafa1e4df6ba03cf33be01 (diff) | |
download | gtk+-b0481811574fd95b96724e4be8fcc0e8d43727e9.tar.gz |
gtk-demo: Add a scale example
-rw-r--r-- | demos/gtk-demo/Makefile.am | 1 | ||||
-rw-r--r-- | demos/gtk-demo/demo.gresource.xml | 4 | ||||
-rw-r--r-- | demos/gtk-demo/scale.c | 38 | ||||
-rw-r--r-- | demos/gtk-demo/scale.ui | 143 |
4 files changed, 186 insertions, 0 deletions
diff --git a/demos/gtk-demo/Makefile.am b/demos/gtk-demo/Makefile.am index f89dd33c44..d85e7cab17 100644 --- a/demos/gtk-demo/Makefile.am +++ b/demos/gtk-demo/Makefile.am @@ -52,6 +52,7 @@ demos_base = \ printing.c \ revealer.c \ rotated_text.c \ + scale.c \ search_entry.c \ search_entry2.c \ sidebar.c \ diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml index 6bdcdf76a3..70eb3b9bc7 100644 --- a/demos/gtk-demo/demo.gresource.xml +++ b/demos/gtk-demo/demo.gresource.xml @@ -159,6 +159,7 @@ <file>printing.c</file> <file>revealer.c</file> <file>rotated_text.c</file> + <file>scale.c</file> <file>search_entry.c</file> <file>search_entry2.c</file> <file>sizegroup.c</file> @@ -205,4 +206,7 @@ <gresource prefix="/markup"> <file>markup.txt</file> </gresource> + <gresource prefix="/scale"> + <file>scale.ui</file> + </gresource> </gresources> diff --git a/demos/gtk-demo/scale.c b/demos/gtk-demo/scale.c new file mode 100644 index 0000000000..6f4d8d4f2c --- /dev/null +++ b/demos/gtk-demo/scale.c @@ -0,0 +1,38 @@ +/* Scale + * + * GtkScale is a way to select a value from a range. + * Scales can have marks to help pick special values, + * and they can also restrict the values that can be + * chosen. + */ + +#include <gtk/gtk.h> + +GtkWidget * +do_scale (GtkWidget *do_widget) +{ + static GtkWidget *window = NULL; + + if (!window) + { + GtkBuilder *builder; + + builder = gtk_builder_new_from_resource ("/scale/scale.ui"); + gtk_builder_connect_signals (builder, NULL); + window = GTK_WIDGET (gtk_builder_get_object (builder, "window1")); + gtk_window_set_screen (GTK_WINDOW (window), + gtk_widget_get_screen (do_widget)); + g_signal_connect (window, "destroy", + G_CALLBACK (gtk_widget_destroyed), &window); + + g_object_unref (builder); + } + + if (!gtk_widget_get_visible (window)) + gtk_widget_show_all (window); + else + gtk_widget_destroy (window); + + + return window; +} diff --git a/demos/gtk-demo/scale.ui b/demos/gtk-demo/scale.ui new file mode 100644 index 0000000000..b09ce43751 --- /dev/null +++ b/demos/gtk-demo/scale.ui @@ -0,0 +1,143 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.6 --> + <object class="GtkAdjustment" id="adjustment1"> + <property name="lower">0</property> + <property name="upper">4</property> + <property name="value">2</property> + </object> + <object class="GtkAdjustment" id="adjustment2"> + <property name="lower">0</property> + <property name="upper">4</property> + <property name="value">2</property> + </object> + <object class="GtkAdjustment" id="adjustment3"> + <property name="lower">0</property> + <property name="upper">4</property> + <property name="value">2</property> + </object> + <object class="GtkWindow" id="window1"> + <property name="can_focus">False</property> + <property name="title" translatable="yes">Scales</property> + <property name="border-width" translatable="yes">20</property> + <child> + <object class="GtkGrid" id="grid1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row-spacing">10</property> + <property name="column-spacing">10</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="label">Plain</property> + <property name="xalign">0</property> + <property name="halign">fill</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkScale"> + <property name="visible">True</property> + <property name="orientation">horizontal</property> + <property name="can_focus">True</property> + <property name="width-request">200</property> + <property name="draw_value">False</property> + <property name="adjustment">adjustment1</property> + <property name="hexpand">True</property> + <property name="halign">fill</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="label">Marks</property> + <property name="xalign">0</property> + <property name="halign">fill</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkScale"> + <property name="visible">True</property> + <property name="orientation">horizontal</property> + <property name="can_focus">True</property> + <property name="width-request">200</property> + <property name="draw_value">False</property> + <property name="adjustment">adjustment2</property> + <property name="hexpand">True</property> + <property name="halign">fill</property> + <marks> + <mark value="0" position="bottom"></mark> + <mark value="1" position="bottom"></mark> + <mark value="2" position="bottom"></mark> + <mark value="3" position="bottom"></mark> + <mark value="4" position="bottom"></mark> + </marks> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="label">Discrete</property> + <property name="xalign">0</property> + <property name="halign">fill</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkScale"> + <property name="visible">True</property> + <property name="orientation">horizontal</property> + <property name="can_focus">True</property> + <property name="width-request">200</property> + <property name="round-digits">0</property> + <property name="draw_value">False</property> + <property name="adjustment">adjustment3</property> + <property name="hexpand">True</property> + <property name="halign">fill</property> + <marks> + <mark value="0" position="bottom"></mark> + <mark value="1" position="bottom"></mark> + <mark value="2" position="bottom"></mark> + <mark value="3" position="bottom"></mark> + <mark value="4" position="bottom"></mark> + </marks> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> |