[gtk+] Add a titlebar testcase
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a titlebar testcase
- Date: Sat, 29 Jun 2013 12:52:44 +0000 (UTC)
commit cf006cbee3ffef34b106a33dc09bcb4c3cd1f543
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 29 08:52:04 2013 -0400
Add a titlebar testcase
This is an experiment towards how we want client-side titlebars
to look.
tests/Makefile.am | 4 +++
tests/testtitlebar.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a6ce995..628a73f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -135,6 +135,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testlogout \
teststack \
testrevealer \
+ testtitlebar \
testwindowsize
if USE_X11
@@ -263,6 +264,7 @@ testgmenu_DEPENDENCIES = $(TEST_DEPS)
testlogout_DEPENDENCIES = $(TEST_DEPS)
teststack_DEPENDENCIES = $(TEST_DEPS)
testrevealer_DEPENDENCIES = $(TEST_DEPS)
+testtitlebar_DEPENDENCIES = $(TEST_DEPS)
testwindowsize_DEPENDENCIES = $(TEST_DEPS)
animated_resizing_SOURCES = \
@@ -478,6 +480,8 @@ teststack_SOURCES = teststack.c
testrevealer_SOURCES = testrevealer.c
+testtitlebar_SOURCES = testrevealer.c
+
testwindowsize_SOURCES = testwindowsize.c
EXTRA_DIST += \
diff --git a/tests/testtitlebar.c b/tests/testtitlebar.c
new file mode 100644
index 0000000..b828a51
--- /dev/null
+++ b/tests/testtitlebar.c
@@ -0,0 +1,68 @@
+#include <gtk/gtk.h>
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+ GtkWidget *header;
+ GtkWidget *title;
+ GtkWidget *button;
+ GtkWidget *box;
+ GtkWidget *image;
+ GIcon *icon;
+
+ gtk_init (NULL, NULL);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
+
+ header = gtk_header_bar_new ();
+ gtk_style_context_add_class (gtk_widget_get_style_context (header), "titlebar");
+ title = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (title), "<b>Welcome to Facebook - Log in, sign up or learn more</b>");
+ gtk_label_set_ellipsize (GTK_LABEL (title), PANGO_ELLIPSIZE_END);
+ gtk_widget_set_margin_left (title, 6);
+ gtk_widget_set_margin_right (title, 6);
+ gtk_header_bar_set_custom_title (GTK_HEADER_BAR (header), title);
+
+ button = gtk_button_new ();
+ icon = g_themed_icon_new ("mail-send-receive-symbolic");
+ image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_BUTTON);
+ g_object_unref (icon);
+ gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
+
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header), gtk_separator_new (GTK_ORIENTATION_VERTICAL));
+
+ button = gtk_button_new ();
+ icon = g_themed_icon_new ("window-close-symbolic");
+ image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_BUTTON);
+ g_object_unref (icon);
+ gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ g_signal_connect (button, "clicked", G_CALLBACK (gtk_window_close), NULL);
+
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_style_context_add_class (gtk_widget_get_style_context (box), "linked");
+ button = gtk_button_new ();
+ gtk_container_add (GTK_CONTAINER (button), gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE));
+ gtk_container_add (GTK_CONTAINER (box), button);
+ button = gtk_button_new ();
+ gtk_container_add (GTK_CONTAINER (button), gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE));
+ gtk_container_add (GTK_CONTAINER (box), button);
+
+ gtk_header_bar_pack_start (GTK_HEADER_BAR (header), box);
+
+ gtk_window_set_titlebar (GTK_WINDOW (window), header);
+
+ gtk_container_add (GTK_CONTAINER (window), gtk_text_view_new ());
+ gtk_widget_show_all (window);
+
+ gtk_main ();
+
+ gtk_widget_destroy (window);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]