diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-12-21 21:11:01 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-12-22 00:28:18 +0900 |
commit | 49273f227770052f99dcb4be6fbe8224712d0944 (patch) | |
tree | f73c997370d252a7fbd57fc5615abeb4aae44dc1 /tests/testtreeedit.c | |
parent | c8ae68c33dc65dc4407863553d059caa1d41e464 (diff) | |
download | gtk+-49273f227770052f99dcb4be6fbe8224712d0944.tar.gz |
Added "fixed-size" cell property to GtkCellAreaBox
Now a cell can either have a "fixed" size or it can have
an "aligned" starting point or both. "fixed" size cells take
no space when they are invisible.
Diffstat (limited to 'tests/testtreeedit.c')
-rw-r--r-- | tests/testtreeedit.c | 75 |
1 files changed, 54 insertions, 21 deletions
diff --git a/tests/testtreeedit.c b/tests/testtreeedit.c index 01e1f2bbe7..712dad4128 100644 --- a/tests/testtreeedit.c +++ b/tests/testtreeedit.c @@ -156,27 +156,50 @@ expand_cell_toggled (GtkToggleButton *toggle, } static void -create_control (GtkWidget *box, gint number, gboolean align, CallbackData *data) +fixed_cell_toggled (GtkToggleButton *toggle, + CallbackData *data) +{ + gboolean active = gtk_toggle_button_get_active (toggle); + + gtk_cell_area_cell_set (data->area, data->renderer, "fixed-size", active, NULL); +} + +enum { + CNTL_EXPAND, + CNTL_ALIGN, + CNTL_FIXED +}; + +static void +create_control (GtkWidget *box, gint number, gint cntl, CallbackData *data) { GtkWidget *checkbutton; - gchar *name; + GCallback callback = NULL; + gchar *name = NULL; - if (align) - name = g_strdup_printf ("Align Cell #%d", number); - else - name = g_strdup_printf ("Expand Cell #%d", number); + switch (cntl) + { + case CNTL_EXPAND: + name = g_strdup_printf ("Expand Cell #%d", number); + callback = G_CALLBACK (expand_cell_toggled); + break; + case CNTL_ALIGN: + name = g_strdup_printf ("Align Cell #%d", number); + callback = G_CALLBACK (align_cell_toggled); + break; + case CNTL_FIXED: + name = g_strdup_printf ("Fix size Cell #%d", number); + callback = G_CALLBACK (fixed_cell_toggled); + break; + } checkbutton = gtk_check_button_new_with_label (name); gtk_widget_show (checkbutton); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), align); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), cntl == CNTL_FIXED); gtk_box_pack_start (GTK_BOX (box), checkbutton, FALSE, FALSE, 0); - if (align) - g_signal_connect (G_OBJECT (checkbutton), "toggled", - G_CALLBACK (align_cell_toggled), data); - else - g_signal_connect (G_OBJECT (checkbutton), "toggled", - G_CALLBACK (expand_cell_toggled), data); + g_signal_connect (G_OBJECT (checkbutton), "toggled", callback, data); + g_free (name); } gint @@ -296,20 +319,30 @@ main (gint argc, gchar **argv) gtk_widget_show (cntl_vbox); gtk_box_pack_start (GTK_BOX (hbox), cntl_vbox, FALSE, FALSE, 0); - create_control (cntl_vbox, 1, TRUE, &callback[0]); - create_control (cntl_vbox, 2, TRUE, &callback[1]); - create_control (cntl_vbox, 3, TRUE, &callback[2]); - create_control (cntl_vbox, 4, TRUE, &callback[3]); + create_control (cntl_vbox, 1, CNTL_ALIGN, &callback[0]); + create_control (cntl_vbox, 2, CNTL_ALIGN, &callback[1]); + create_control (cntl_vbox, 3, CNTL_ALIGN, &callback[2]); + create_control (cntl_vbox, 4, CNTL_ALIGN, &callback[3]); /* Expand controls */ cntl_vbox = gtk_vbox_new (FALSE, 2); gtk_widget_show (cntl_vbox); gtk_box_pack_start (GTK_BOX (hbox), cntl_vbox, FALSE, FALSE, 0); - create_control (cntl_vbox, 1, FALSE, &callback[0]); - create_control (cntl_vbox, 2, FALSE, &callback[1]); - create_control (cntl_vbox, 3, FALSE, &callback[2]); - create_control (cntl_vbox, 4, FALSE, &callback[3]); + create_control (cntl_vbox, 1, CNTL_EXPAND, &callback[0]); + create_control (cntl_vbox, 2, CNTL_EXPAND, &callback[1]); + create_control (cntl_vbox, 3, CNTL_EXPAND, &callback[2]); + create_control (cntl_vbox, 4, CNTL_EXPAND, &callback[3]); + + /* Fixed controls */ + cntl_vbox = gtk_vbox_new (FALSE, 2); + gtk_widget_show (cntl_vbox); + gtk_box_pack_start (GTK_BOX (hbox), cntl_vbox, FALSE, FALSE, 0); + + create_control (cntl_vbox, 1, CNTL_FIXED, &callback[0]); + create_control (cntl_vbox, 2, CNTL_FIXED, &callback[1]); + create_control (cntl_vbox, 3, CNTL_FIXED, &callback[2]); + create_control (cntl_vbox, 4, CNTL_FIXED, &callback[3]); gtk_widget_show_all (window); gtk_main (); |