[gnome-control-center/wip/animated-notebook] shell: Better test case from ebassi
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/animated-notebook] shell: Better test case from ebassi
- Date: Wed, 2 May 2012 16:58:25 +0000 (UTC)
commit cc21521a101c78a03d99c7da4c400d511d693134
Author: Bastien Nocera <hadess hadess net>
Date: Wed May 2 17:42:43 2012 +0100
shell: Better test case from ebassi
shell/test-notebook.c | 81 ++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 63 insertions(+), 18 deletions(-)
---
diff --git a/shell/test-notebook.c b/shell/test-notebook.c
index 611c8a4..ca0a4d7 100644
--- a/shell/test-notebook.c
+++ b/shell/test-notebook.c
@@ -1,28 +1,73 @@
-#include <gtk/gtk.h>
-#include <clutter-gtk/clutter-gtk.h>
+#include <stdlib.h>
#include "cc-notebook.h"
-int main (int argc, char **argv)
+enum {
+ PAGE_1,
+ PAGE_2,
+ PAGE_3,
+ PAGE_4,
+ PAGE_5,
+
+ N_PAGES
+};
+
+static int pages[N_PAGES] = { 0, };
+
+static GtkWidget *
+create_page_contents (const char *text)
+{
+ GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+
+ GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+ GtkWidget *back_button = gtk_button_new_with_label ("â");
+ gtk_widget_set_halign (back_button, GTK_ALIGN_START);
+ gtk_box_pack_start (GTK_BOX (hbox), back_button, FALSE, FALSE, 0);
+
+ GtkWidget *fwd_button = gtk_button_new_with_label ("â");
+ gtk_widget_set_halign (fwd_button, GTK_ALIGN_END);
+ gtk_box_pack_end (GTK_BOX (hbox), fwd_button, FALSE, FALSE, 0);
+
+ GtkWidget *label = gtk_label_new (text);
+
+ gtk_box_pack_end (GTK_BOX (vbox), label, TRUE, TRUE, 0);
+
+ gtk_widget_show_all (vbox);
+
+ return vbox;
+}
+
+static void
+on_page_change (CcNotebook *notebook)
+{
+ g_print (G_STRLOC ": Currently selected page: %d\n",
+ cc_notebook_get_selected_index (notebook));
+}
+
+int
+main (int argc, char *argv[])
{
- GtkWidget *window, *notebook;
+ if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
+ return EXIT_FAILURE;
- if (gtk_clutter_init (&argc, &argv) == FALSE) {
- g_warning ("ARGGGHH");
- return 1;
- }
+ GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ gtk_widget_show (window);
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- gtk_window_resize (GTK_WINDOW (window), 500, 500);
+ GtkWidget *notebook = cc_notebook_new ();
+ gtk_container_add (GTK_CONTAINER (window), notebook);
+ g_signal_connect (notebook, "notify::current-page", G_CALLBACK (on_page_change), NULL);
- notebook = cc_notebook_new ();
- gtk_container_add (GTK_CONTAINER (window), notebook);
+ pages[PAGE_1] = cc_notebook_add_page ((CcNotebook *) notebook, create_page_contents ("Page number 1"));
+ pages[PAGE_2] = cc_notebook_add_page ((CcNotebook *) notebook, create_page_contents ("Page number 2"));
+ pages[PAGE_3] = cc_notebook_add_page ((CcNotebook *) notebook, create_page_contents ("Page number 3"));
+ pages[PAGE_4] = cc_notebook_add_page ((CcNotebook *) notebook, create_page_contents ("Page number 4"));
+ pages[PAGE_5] = cc_notebook_add_page ((CcNotebook *) notebook, create_page_contents ("Page number 5"));
- cc_notebook_add (CC_NOTEBOOK (notebook), gtk_label_new ("fhdkhfjksdhkfjsdhk"));
- cc_notebook_add (CC_NOTEBOOK (notebook), gtk_label_new ("fhdkhfjksdhkfjsdhk2"));
+ gtk_widget_show_all (window);
- gtk_widget_show_all (window);
- gtk_main ();
+ gtk_main ();
- return 0;
+ return EXIT_SUCCESS;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]