diff options
Diffstat (limited to 'lib/widgets/testspinner.c')
-rw-r--r-- | lib/widgets/testspinner.c | 109 |
1 files changed, 105 insertions, 4 deletions
diff --git a/lib/widgets/testspinner.c b/lib/widgets/testspinner.c index 31488d55c..f986d752f 100644 --- a/lib/widgets/testspinner.c +++ b/lib/widgets/testspinner.c @@ -27,6 +27,7 @@ #define STOP_PROFILER(name) #include "ephy-spinner.c" +#include "ephy-spinner-tool-item.c" #define MOVE_TIMEOUT 211 /* ms */ @@ -113,12 +114,60 @@ start_or_stop_repeated_moves (GtkWindow *window) } } +static void +change_toolbar_style_cb (GtkComboBox *combo, + GtkToolbar *toolbar) +{ + int value = gtk_combo_box_get_active (combo); + + gtk_toolbar_set_style (toolbar, value); +} + +static void +change_toolbar_icon_size_cb (GtkComboBox *combo, + GtkToolbar *toolbar) +{ + int value = gtk_combo_box_get_active (combo); + + if (value == GTK_ICON_SIZE_INVALID) + { + gtk_toolbar_unset_icon_size (toolbar); + } + else + { + gtk_toolbar_set_icon_size (toolbar, value); + } +} + +static void +spin_toolbar_spinner_cb (GtkToggleButton *button, + EphySpinnerToolItem *item) +{ + ephy_spinner_tool_item_set_spinning (item, gtk_toggle_button_get_active (button)); +} + int main(int argc, char **argv) { - GtkWidget *window, *vbox, *widget; + GtkWidget *window, *vbox, *vbox2, *widget, *toolbar, *combo; + GtkToolItem *item; GtkTable *table; - int row = 0; - + int row = 0, i; + const char *toolbar_styles[] = { + "icons", + "text", + "both (vertical)", + "both (horizontal)" + }; + const char *icon_sizes[] = { + "default", + "menu", + "small toolbar", + "large toolbar", + "button", + "dnd", + "dialog" + }; + gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); @@ -141,7 +190,59 @@ int main(int argc, char **argv) add_spinner (table, row++, GTK_ICON_SIZE_BUTTON, "Button", 0, FALSE); add_spinner (table, row++, GTK_ICON_SIZE_DND, "Drag-and-drop", 0, FALSE); add_spinner (table, row++, GTK_ICON_SIZE_DIALOG, "Dialog", 0, FALSE); - + + /* Test toolbar */ + vbox2 = gtk_vbox_new (FALSE, 6); + gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0); + + toolbar = gtk_toolbar_new (); + gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH); + gtk_box_pack_end (GTK_BOX (vbox2), toolbar, FALSE, FALSE, 0); + + item = gtk_tool_button_new_from_stock (GTK_STOCK_NEW); + gtk_tool_item_set_homogeneous (item, FALSE); + gtk_tool_item_set_is_important (item, TRUE); + gtk_widget_show (GTK_WIDGET (item)); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0); + + item = gtk_tool_button_new_from_stock (GTK_STOCK_OPEN); + gtk_tool_item_set_homogeneous (item, FALSE); + gtk_widget_show (GTK_WIDGET (item)); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0); + + item = gtk_tool_item_new (); + gtk_tool_item_set_homogeneous (item, FALSE); + gtk_widget_show (GTK_WIDGET (item)); + gtk_tool_item_set_expand (item, TRUE); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); + + item = ephy_spinner_tool_item_new (); + gtk_widget_show (GTK_WIDGET (item)); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); + + widget = gtk_check_button_new_with_label ("Spin"); + g_signal_connect (widget, "toggled", G_CALLBACK (spin_toolbar_spinner_cb), item); + gtk_box_pack_start (GTK_BOX (vbox2), widget, FALSE, FALSE, 0); + + combo = gtk_combo_box_new_text (); + g_signal_connect (combo, "changed", G_CALLBACK (change_toolbar_style_cb), toolbar); + for (i = 0; i < G_N_ELEMENTS (toolbar_styles); ++i) + { + gtk_combo_box_append_text (GTK_COMBO_BOX (combo), toolbar_styles[i]); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), GTK_TOOLBAR_BOTH); + gtk_box_pack_start (GTK_BOX (vbox2), combo, FALSE, FALSE, 0); + + combo = gtk_combo_box_new_text (); + g_signal_connect (combo, "changed", G_CALLBACK (change_toolbar_icon_size_cb), toolbar); + for (i = 0; i < G_N_ELEMENTS (icon_sizes); ++i) + { + gtk_combo_box_append_text (GTK_COMBO_BOX (combo), icon_sizes[i]); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), GTK_ICON_SIZE_INVALID); + gtk_box_pack_start (GTK_BOX (vbox2), combo, FALSE, FALSE, 0); + + /* Controls */ widget = gtk_button_new_with_label ("Move to next screen"); g_signal_connect_swapped (widget, "clicked", G_CALLBACK (move_window), window); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); |