]> Pileus Git - ~andy/gtk/commitdiff
Add a switch
authorMatthias Clasen <mclasen@redhat.com>
Wed, 11 Jan 2012 05:10:51 +0000 (00:10 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 11 Jan 2012 05:10:51 +0000 (00:10 -0500)
Add a switch. This demonstrates:
- that switches can be placed in toolbars
- that GtkSwitch is actionable
- that actions can be shared between multiple actionables

examples/bloatpad.c

index 41326ababcc2af9e0a6c5060e006202620b56ac3..67c4efdeaa4a29e6cf4e086c272faac65628c7e7 100644 (file)
@@ -104,6 +104,7 @@ new_window (GApplication *app,
   GtkWidget *window, *grid, *scrolled, *view;
   GtkWidget *toolbar;
   GtkToolItem *button;
+  GtkWidget *sw, *box, *label;
 
   window = gtk_application_window_new (GTK_APPLICATION (app));
   gtk_window_set_default_size ((GtkWindow*)window, 640, 480);
@@ -126,6 +127,21 @@ new_window (GApplication *app,
   gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button), "win.justify::right");
   gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (button));
 
+  button = gtk_separator_tool_item_new ();
+  gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (button), FALSE);
+  gtk_tool_item_set_expand (GTK_TOOL_ITEM (button), TRUE);
+  gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (button));
+
+  button = gtk_tool_item_new ();
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+  gtk_container_add (GTK_CONTAINER (button), box);
+  label = gtk_label_new ("Fullscreen:");
+  gtk_container_add (GTK_CONTAINER (box), label);
+  sw = gtk_switch_new ();
+  gtk_actionable_set_action_name (GTK_ACTIONABLE (sw), "win.fullscreen");
+  gtk_container_add (GTK_CONTAINER (box), sw);
+  gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (button));
+
   gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 1, 1);
 
   scrolled = gtk_scrolled_window_new (NULL, NULL);