[gtk/wip/matthiasc/popup: 61/63] testpopup: Add more things
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup: 61/63] testpopup: Add more things
- Date: Mon, 4 Mar 2019 04:35:01 +0000 (UTC)
commit b0d215026556d8c8b53059adb1cb5b69414b537e
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 3 22:24:51 2019 -0500
testpopup: Add more things
tests/testpopup.c | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/tests/testpopup.c b/tests/testpopup.c
index ba27eb6070..7b0ff49ca9 100644
--- a/tests/testpopup.c
+++ b/tests/testpopup.c
@@ -6,20 +6,18 @@ clicked (GtkButton *button)
g_print ("Yes!\n");
}
-static gboolean
-create_popup (GtkWidget *parent)
+static GtkWidget *
+add_content (GtkWidget *parent)
{
- GtkWidget *popup, *box, *label, *entry, *button;
+ GtkWidget *box, *label, *entry, *button;
- popup = gtk_popup_new ();
- gtk_popup_set_relative_to (GTK_POPUP (popup), parent);
- gtk_style_context_add_class (gtk_widget_get_style_context (popup), "background");
- gtk_style_context_add_class (gtk_widget_get_style_context (popup), "frame");
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
+ gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (box, GTK_ALIGN_CENTER);
label = gtk_label_new_with_mnemonic ("_Test");
entry = gtk_entry_new ();
- button = gtk_button_new_with_label ("Yes!");
+ button = gtk_button_new_with_mnemonic ("_Yes!");
g_signal_connect (button, "clicked", G_CALLBACK (clicked), NULL);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
@@ -29,10 +27,25 @@ create_popup (GtkWidget *parent)
gtk_container_add (GTK_CONTAINER (box), label);
gtk_container_add (GTK_CONTAINER (box), entry);
gtk_container_add (GTK_CONTAINER (box), button);
- gtk_container_add (GTK_CONTAINER (popup), box);
+ gtk_container_add (GTK_CONTAINER (parent), box);
gtk_widget_grab_default (button);
+ return box;
+}
+
+static gboolean
+create_popup (GtkWidget *parent)
+{
+ GtkWidget *popup;
+
+ popup = gtk_popup_new ();
+ gtk_popup_set_relative_to (GTK_POPUP (popup), parent);
+ gtk_style_context_add_class (gtk_widget_get_style_context (popup), "background");
+ gtk_style_context_add_class (gtk_widget_get_style_context (popup), "frame");
+
+ add_content (popup);
+
gtk_widget_show (popup);
return FALSE;
@@ -49,10 +62,7 @@ main (int argc, char *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
- label = gtk_entry_new ();
- gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
- gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
- gtk_container_add (GTK_CONTAINER (window), label);
+ label = add_content (window);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect_swapped (window, "map", G_CALLBACK (create_popup), label);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]