mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 05:31:07 +00:00
widget-factory: More vertical linking examples
This commit is contained in:
parent
1f8b0852a4
commit
79afd7c8d7
@ -303,6 +303,68 @@ on_record_button_toggled (GtkToggleButton *button,
|
||||
gtk_style_context_add_class (context, "destructive-action");
|
||||
}
|
||||
|
||||
static void
|
||||
on_page_combo_changed (GtkComboBox *combo,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *from;
|
||||
GtkWidget *to;
|
||||
|
||||
from = GTK_WIDGET (g_object_get_data (G_OBJECT (combo), "range_from_spin"));
|
||||
to = GTK_WIDGET (g_object_get_data (G_OBJECT (combo), "range_to_spin"));
|
||||
|
||||
switch (gtk_combo_box_get_active (combo))
|
||||
{
|
||||
case 0: /* Range */
|
||||
gtk_widget_set_sensitive (from, TRUE);
|
||||
gtk_widget_set_sensitive (to, TRUE);
|
||||
break;
|
||||
case 1: /* All */
|
||||
gtk_widget_set_sensitive (from, FALSE);
|
||||
gtk_widget_set_sensitive (to, FALSE);
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (from), 1);
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (to), 99);
|
||||
break;
|
||||
case 2: /* Current */
|
||||
gtk_widget_set_sensitive (from, FALSE);
|
||||
gtk_widget_set_sensitive (to, FALSE);
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (from), 7);
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (to), 7);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_range_from_changed (GtkSpinButton *from)
|
||||
{
|
||||
GtkSpinButton *to;
|
||||
gint v1, v2;
|
||||
|
||||
to = GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (from), "range_to_spin"));
|
||||
|
||||
v1 = gtk_spin_button_get_value_as_int (from);
|
||||
v2 = gtk_spin_button_get_value_as_int (to);
|
||||
|
||||
if (v1 > v2)
|
||||
gtk_spin_button_set_value (to, v1);
|
||||
}
|
||||
|
||||
static void
|
||||
on_range_to_changed (GtkSpinButton *to)
|
||||
{
|
||||
GtkSpinButton *from;
|
||||
gint v1, v2;
|
||||
|
||||
from = GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (to), "range_from_spin"));
|
||||
|
||||
v1 = gtk_spin_button_get_value_as_int (from);
|
||||
v2 = gtk_spin_button_get_value_as_int (to);
|
||||
|
||||
if (v1 > v2)
|
||||
gtk_spin_button_set_value (from, v2);
|
||||
}
|
||||
|
||||
static void
|
||||
update_header (GtkListBoxRow *row,
|
||||
GtkListBoxRow *before,
|
||||
@ -861,6 +923,7 @@ activate (GApplication *app)
|
||||
GtkWindow *window;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *widget2;
|
||||
GtkWidget *widget3;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *dialog;
|
||||
GtkAdjustment *adj;
|
||||
@ -896,6 +959,9 @@ activate (GApplication *app)
|
||||
gtk_builder_add_callback_symbol (builder, "on_scale_button_value_changed", (GCallback)on_scale_button_value_changed);
|
||||
gtk_builder_add_callback_symbol (builder, "on_scale_button_query_tooltip", (GCallback)on_scale_button_query_tooltip);
|
||||
gtk_builder_add_callback_symbol (builder, "on_record_button_toggled", (GCallback)on_record_button_toggled);
|
||||
gtk_builder_add_callback_symbol (builder, "on_page_combo_changed", (GCallback)on_page_combo_changed);
|
||||
gtk_builder_add_callback_symbol (builder, "on_range_from_changed", (GCallback)on_range_from_changed);
|
||||
gtk_builder_add_callback_symbol (builder, "on_range_to_changed", (GCallback)on_range_to_changed);
|
||||
|
||||
gtk_builder_connect_signals (builder, NULL);
|
||||
|
||||
@ -1002,6 +1068,14 @@ activate (GApplication *app)
|
||||
|
||||
populate_colors ((GtkWidget *)gtk_builder_get_object (builder, "munsell"));
|
||||
|
||||
widget = (GtkWidget *)gtk_builder_get_object (builder, "page_combo");
|
||||
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "range_from_spin");
|
||||
widget3 = (GtkWidget *)gtk_builder_get_object (builder, "range_to_spin");
|
||||
g_object_set_data (G_OBJECT (widget), "range_from_spin", widget2);
|
||||
g_object_set_data (G_OBJECT (widget3), "range_from_spin", widget2);
|
||||
g_object_set_data (G_OBJECT (widget), "range_to_spin", widget3);
|
||||
g_object_set_data (G_OBJECT (widget2), "range_to_spin", widget3);
|
||||
|
||||
set_accel (GTK_APPLICATION (app), GTK_WIDGET (gtk_builder_get_object (builder, "quitmenuitem")));
|
||||
set_accel (GTK_APPLICATION (app), GTK_WIDGET (gtk_builder_get_object (builder, "deletemenuitem")));
|
||||
set_accel (GTK_APPLICATION (app), GTK_WIDGET (gtk_builder_get_object (builder, "searchmenuitem")));
|
||||
|
@ -93,6 +93,20 @@
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="pg_adjustment">
|
||||
<property name="upper">99</property>
|
||||
<property name="lower">1</property>
|
||||
<property name="value">2</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="pg_adjustment2">
|
||||
<property name="upper">99</property>
|
||||
<property name="lower">1</property>
|
||||
<property name="value">4</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkListStore" id="liststore1">
|
||||
<columns>
|
||||
<!-- column-name Cool -->
|
||||
@ -3499,6 +3513,54 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<property name="title">Address</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="margin">20</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="page_combo">
|
||||
<property name="visible">True</property>
|
||||
<property name="active">0</property>
|
||||
<signal name="changed" handler="on_page_combo_changed"/>
|
||||
<items>
|
||||
<item>Range</item>
|
||||
<item>All</item>
|
||||
<item>Current</item>
|
||||
</items>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="range_from_spin">
|
||||
<property name="visible">True</property>
|
||||
<property name="adjustment">pg_adjustment</property>
|
||||
<signal name="value-changed" handler="on_range_from_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="range_to_spin">
|
||||
<property name="visible">True</property>
|
||||
<property name="adjustment">pg_adjustment2</property>
|
||||
<signal name="value-changed" handler="on_range_to_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="label">Print</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">pg</property>
|
||||
<property name="title">Pages</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
Loading…
Reference in New Issue
Block a user