[gtk+] testframe: Add CheckButton to toggle border off/on
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] testframe: Add CheckButton to toggle border off/on
- Date: Tue, 7 Mar 2017 01:09:50 +0000 (UTC)
commit 2eee3ef79c78cad03fbb25cc5a63c7a4148a1566
Author: Daniel Boles <dboles src gnome org>
Date: Mon Mar 6 23:12:20 2017 +0000
testframe: Add CheckButton to toggle border off/on
We should test this.
tests/testframe.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/tests/testframe.c b/tests/testframe.c
index dcaf1e9..b1e02c4 100644
--- a/tests/testframe.c
+++ b/tests/testframe.c
@@ -128,6 +128,15 @@ spin_yalign_cb (GtkSpinButton *spin, GtkFrame *frame)
gtk_frame_set_label_align (frame, xalign, yalign);
}
+static void
+draw_border_cb (GtkToggleButton *toggle_button, GtkFrame *frame)
+{
+ GtkShadowType shadow_type = gtk_toggle_button_get_active (toggle_button)
+ ? GTK_SHADOW_IN : GTK_SHADOW_NONE;
+
+ gtk_frame_set_shadow_type (frame, shadow_type);
+}
+
int main (int argc, char **argv)
{
GtkStyleContext *context;
@@ -137,6 +146,7 @@ int main (int argc, char **argv)
GtkFrame *frame;
GtkGrid *grid;
gfloat xalign, yalign;
+ gboolean draw_border;
gtk_init ();
@@ -146,6 +156,7 @@ int main (int argc, char **argv)
g_signal_connect (window, "delete-event", gtk_main_quit, NULL);
vbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 5));
+ g_object_set (vbox, "margin", 12, NULL);
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (vbox));
frame = GTK_FRAME (gtk_frame_new ("Test GtkFrame"));
@@ -203,6 +214,13 @@ int main (int argc, char **argv)
g_signal_connect (widget, "value-changed", G_CALLBACK (spin_hpadding_cb), frame);
gtk_grid_attach (grid, widget, 1, 3, 1, 1);
+ /* CheckButton to control whether to draw border */
+ draw_border = gtk_frame_get_shadow_type (frame) != GTK_SHADOW_NONE;
+ widget = gtk_check_button_new_with_label ("draw border");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), draw_border);
+ g_signal_connect (widget, "toggled", G_CALLBACK (draw_border_cb), frame);
+ gtk_grid_attach (grid, widget, 0, 4, 1, 1);
+
gtk_widget_show (window);
gtk_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]