forked from AuroraMiddleware/gtk
gtk-demo: Add a scale example
This commit is contained in:
parent
fb0a13b7f0
commit
b048181157
@ -52,6 +52,7 @@ demos_base = \
|
||||
printing.c \
|
||||
revealer.c \
|
||||
rotated_text.c \
|
||||
scale.c \
|
||||
search_entry.c \
|
||||
search_entry2.c \
|
||||
sidebar.c \
|
||||
|
@ -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>
|
||||
|
38
demos/gtk-demo/scale.c
Normal file
38
demos/gtk-demo/scale.c
Normal file
@ -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;
|
||||
}
|
143
demos/gtk-demo/scale.ui
Normal file
143
demos/gtk-demo/scale.ui
Normal file
@ -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>
|
Loading…
Reference in New Issue
Block a user