mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 05:31:07 +00:00
Test box and toolbar regions in parallel
This makes it easy to see discrepancies. Plus, it is fun
This commit is contained in:
parent
301c120b74
commit
e2a2da224d
@ -30,7 +30,6 @@
|
|||||||
" background-image: none;\n" \
|
" background-image: none;\n" \
|
||||||
" background-color: red;\n" \
|
" background-color: red;\n" \
|
||||||
" border-color: black;\n" \
|
" border-color: black;\n" \
|
||||||
" color: red;\n" \
|
|
||||||
" border-radius: 0;\n" \
|
" border-radius: 0;\n" \
|
||||||
"}\n" \
|
"}\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
@ -97,10 +96,29 @@ remove_widget (GtkWidget *widget)
|
|||||||
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (widget)), widget);
|
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (widget)), widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
add_widget (GtkToolbar *box)
|
|
||||||
{
|
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_button (GtkBox *box)
|
||||||
|
{
|
||||||
|
GtkWidget* button;
|
||||||
|
char *text;
|
||||||
|
|
||||||
|
text = g_strdup_printf ("Remove %d", ++count);
|
||||||
|
button = (GtkWidget *)gtk_button_new_from_stock (text);
|
||||||
|
g_free (text);
|
||||||
|
gtk_style_context_add_class (gtk_widget_get_style_context (button), "play");
|
||||||
|
g_signal_connect_swapped (button,
|
||||||
|
"clicked",
|
||||||
|
G_CALLBACK (remove_widget),
|
||||||
|
button);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), button);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_toolbutton (GtkToolbar *toolbar)
|
||||||
|
{
|
||||||
GtkWidget* button;
|
GtkWidget* button;
|
||||||
char *text;
|
char *text;
|
||||||
|
|
||||||
@ -113,8 +131,7 @@ add_widget (GtkToolbar *box)
|
|||||||
G_CALLBACK (remove_widget),
|
G_CALLBACK (remove_widget),
|
||||||
button);
|
button);
|
||||||
gtk_widget_show (button);
|
gtk_widget_show (button);
|
||||||
gtk_container_add (GTK_CONTAINER (box), button);
|
gtk_container_add (GTK_CONTAINER (toolbar), button);
|
||||||
g_print ("path: %s\n", gtk_widget_path_to_string (gtk_widget_get_path (button)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -126,7 +143,8 @@ set_orientation (GtkSwitch *switch_)
|
|||||||
gint
|
gint
|
||||||
main (gint argc, gchar **argv)
|
main (gint argc, gchar **argv)
|
||||||
{
|
{
|
||||||
GtkWidget *window, *main_box, *box, *container, *child;
|
GtkWidget *window, *main_box, *container, *child;
|
||||||
|
GtkWidget *box, *toolbar;
|
||||||
GtkStyleProvider *provider;
|
GtkStyleProvider *provider;
|
||||||
GtkTextBuffer *css;
|
GtkTextBuffer *css;
|
||||||
|
|
||||||
@ -155,8 +173,11 @@ main (gint argc, gchar **argv)
|
|||||||
main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||||
gtk_container_add (GTK_CONTAINER (window), main_box);
|
gtk_container_add (GTK_CONTAINER (window), main_box);
|
||||||
|
|
||||||
box = gtk_toolbar_new ();
|
toolbar = gtk_toolbar_new ();
|
||||||
gtk_toolbar_set_style (GTK_TOOLBAR (box), GTK_TOOLBAR_TEXT);
|
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_TEXT);
|
||||||
|
gtk_box_pack_start (GTK_BOX (main_box), toolbar, FALSE, TRUE, 0);
|
||||||
|
|
||||||
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (main_box), box, FALSE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (main_box), box, FALSE, TRUE, 0);
|
||||||
|
|
||||||
container = gtk_scrolled_window_new (NULL, NULL);
|
container = gtk_scrolled_window_new (NULL, NULL);
|
||||||
@ -188,17 +209,28 @@ main (gint argc, gchar **argv)
|
|||||||
gtk_box_pack_start (GTK_BOX (container), child, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (container), child, FALSE, FALSE, 0);
|
||||||
child = gtk_label_new ("left-to-right");
|
child = gtk_label_new ("left-to-right");
|
||||||
gtk_box_pack_start (GTK_BOX (container), child, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (container), child, FALSE, FALSE, 0);
|
||||||
child = gtk_button_new_with_label ("Add widget");
|
child = gtk_button_new_with_label ("Add button");
|
||||||
g_signal_connect_swapped (child,
|
g_signal_connect_swapped (child,
|
||||||
"clicked",
|
"clicked",
|
||||||
G_CALLBACK (add_widget),
|
G_CALLBACK (add_button),
|
||||||
box);
|
box);
|
||||||
gtk_box_pack_end (GTK_BOX (container), child, FALSE, FALSE, 0);
|
gtk_box_pack_end (GTK_BOX (container), child, FALSE, FALSE, 0);
|
||||||
|
child = gtk_button_new_with_label ("Add toolbutton");
|
||||||
|
g_signal_connect_swapped (child,
|
||||||
|
"clicked",
|
||||||
|
G_CALLBACK (add_toolbutton),
|
||||||
|
toolbar);
|
||||||
|
gtk_box_pack_end (GTK_BOX (container), child, FALSE, FALSE, 0);
|
||||||
|
|
||||||
add_widget (GTK_TOOLBAR (box));
|
add_toolbutton (GTK_TOOLBAR (toolbar));
|
||||||
add_widget (GTK_TOOLBAR (box));
|
add_toolbutton (GTK_TOOLBAR (toolbar));
|
||||||
add_widget (GTK_TOOLBAR (box));
|
add_toolbutton (GTK_TOOLBAR (toolbar));
|
||||||
add_widget (GTK_TOOLBAR (box));
|
add_toolbutton (GTK_TOOLBAR (toolbar));
|
||||||
|
|
||||||
|
add_button (GTK_BOX (box));
|
||||||
|
add_button (GTK_BOX (box));
|
||||||
|
add_button (GTK_BOX (box));
|
||||||
|
add_button (GTK_BOX (box));
|
||||||
|
|
||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user