annotate gtk/gtkscrollbook.c @ 15056:577ddea3ab82

[gaim-migrate @ 17839] I find this to be slightly cleaner committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 28 Nov 2006 09:18:20 +0000
parents 51f3c0df6ab4
children e8ba9f4a3a7d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15033
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file gtkscrollbook.c GTK+ Status Selection Widget
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * @ingroup gtkui
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 *
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * gaim
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * source distribution.
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * (at your option) any later version.
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * GNU General Public License for more details.
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 */
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "gtkscrollbook.h"
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 static void gtk_gaim_scroll_book_init (GtkGaimScrollBook *scroll_book);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 static void gtk_gaim_scroll_book_class_init (GtkGaimScrollBookClass *klass);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 GType
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 gtk_gaim_scroll_book_get_type (void)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 static GType scroll_book_type = 0;
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 if (!scroll_book_type)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 static const GTypeInfo scroll_book_info =
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 sizeof (GtkGaimScrollBookClass),
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 NULL, /* base_init */
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 NULL, /* base_finalize */
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 (GClassInitFunc) gtk_gaim_scroll_book_class_init,
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 NULL, /* class_finalize */
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 NULL, /* class_data */
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 sizeof (GtkGaimScrollBook),
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 0,
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 (GInstanceInitFunc) gtk_gaim_scroll_book_init,
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 NULL /* value_table */
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 };
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 scroll_book_type = g_type_register_static(GTK_TYPE_VBOX,
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 "GtkGaimScrollBook",
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 &scroll_book_info,
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 0);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 }
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 return scroll_book_type;
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 }
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 static void
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 scroll_left_cb(GtkGaimScrollBook *scroll_book)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 int index;
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(scroll_book->notebook));
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 if (index > 0)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 gtk_notebook_set_current_page(GTK_NOTEBOOK(scroll_book->notebook), index - 1);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 }
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 static void
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 scroll_right_cb(GtkGaimScrollBook *scroll_book)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 int index, count;
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(scroll_book->notebook));
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 #if GTK_CHECK_VERSION(2,2,0)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(scroll_book->notebook));
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 #else
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 count = g_list_length(GTK_NOTEBOOK(scroll_book->notebook)->children);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 #endif
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 if (index + 1 < count)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 gtk_notebook_set_current_page(GTK_NOTEBOOK(scroll_book->notebook), index + 1);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 }
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 static void
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 refresh_scroll_box(GtkGaimScrollBook *scroll_book, int index, int count)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 char *label;
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91
15053
51f3c0df6ab4 [gaim-migrate @ 17836]
Mark Doliner <mark@kingant.net>
parents: 15033
diff changeset
92 gtk_widget_show_all(GTK_WIDGET(scroll_book));
15033
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 if (count <= 1)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 gtk_widget_hide(GTK_WIDGET(scroll_book->hbox));
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 else
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 gtk_widget_show_all(GTK_WIDGET(scroll_book->hbox));
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 label = g_strdup_printf("<span size='smaller' weight='bold'>(%d/%d)</span>", index+1, count);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 gtk_label_set_markup(GTK_LABEL(scroll_book->label), label);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 g_free(label);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 if (index == 0)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 gtk_widget_set_sensitive(scroll_book->left_arrow, FALSE);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 else
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 gtk_widget_set_sensitive(scroll_book->left_arrow, TRUE);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 if (index +1== count)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 gtk_widget_set_sensitive(scroll_book->right_arrow, FALSE);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 else
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 gtk_widget_set_sensitive(scroll_book->right_arrow, TRUE);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 }
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 static void
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 page_count_change_cb(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, GtkGaimScrollBook *scroll_book)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 int index = gtk_notebook_get_current_page(GTK_NOTEBOOK(scroll_book->notebook));
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 #if GTK_CHECK_VERSION(2,2,0)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 int count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(scroll_book->notebook));
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 #else
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 count = g_list_length(GTK_NOTEBOOK(scroll_book->notebook)->children);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 #endif
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 refresh_scroll_box(scroll_book, index, count);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 }
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 static void
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 switch_page_cb(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, GtkGaimScrollBook *scroll_book)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 #if GTK_CHECK_VERSION(2,2,0)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 int count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(scroll_book->notebook));
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 #else
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 count = g_list_length(GTK_NOTEBOOK(scroll_book->notebook)->children);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 #endif
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 refresh_scroll_box(scroll_book, page_num, count);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 }
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 static void
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 gtk_gaim_scroll_book_add(GtkContainer *container, GtkWidget *widget)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 gtk_widget_show(widget);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 gtk_notebook_append_page(GTK_NOTEBOOK(GTK_GAIM_SCROLL_BOOK(container)->notebook), widget, NULL);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 }
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 static void
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 gtk_gaim_scroll_book_class_init (GtkGaimScrollBookClass *klass)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 GtkContainerClass *container_class = (GtkContainerClass*)klass;
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 container_class->add = gtk_gaim_scroll_book_add;
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 }
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 static void
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 gtk_gaim_scroll_book_init (GtkGaimScrollBook *scroll_book)
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 GtkWidget *eb;
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 scroll_book->hbox = gtk_hbox_new(FALSE, 0);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 eb = gtk_event_box_new();
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 gtk_box_pack_end(GTK_BOX(scroll_book->hbox), eb, FALSE, FALSE, 0);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 scroll_book->right_arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 gtk_container_add(GTK_CONTAINER(eb), scroll_book->right_arrow);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 g_signal_connect_swapped(G_OBJECT(eb), "button-press-event", G_CALLBACK(scroll_right_cb), scroll_book);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 scroll_book->label = gtk_label_new(NULL);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 gtk_box_pack_end(GTK_BOX(scroll_book->hbox), scroll_book->label, FALSE, FALSE, 0);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 eb = gtk_event_box_new();
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 gtk_box_pack_end(GTK_BOX(scroll_book->hbox), eb, FALSE, FALSE, 0);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 scroll_book->left_arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 gtk_container_add(GTK_CONTAINER(eb), scroll_book->left_arrow);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 g_signal_connect_swapped(G_OBJECT(eb), "button-press-event", G_CALLBACK(scroll_left_cb), scroll_book);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 gtk_box_pack_start(GTK_BOX(scroll_book), scroll_book->hbox, FALSE, FALSE, 0);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 scroll_book->notebook = gtk_notebook_new();
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(scroll_book->notebook), FALSE);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 gtk_notebook_set_show_border(GTK_NOTEBOOK(scroll_book->notebook), FALSE);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 gtk_box_pack_start(GTK_BOX(scroll_book), scroll_book->notebook, TRUE, TRUE, 0);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 g_signal_connect(G_OBJECT(scroll_book->notebook), "page-added", G_CALLBACK(page_count_change_cb), scroll_book);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 g_signal_connect(G_OBJECT(scroll_book->notebook), "page-removed", G_CALLBACK(page_count_change_cb), scroll_book);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 g_signal_connect(G_OBJECT(scroll_book->notebook), "switch-page", G_CALLBACK(switch_page_cb), scroll_book);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 gtk_widget_hide(scroll_book->hbox);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 }
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 GtkWidget *
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 gtk_gaim_scroll_book_new()
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 {
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 return g_object_new(GTK_GAIM_TYPE_SCROLL_BOOK, NULL);
ca46f41aa433 [gaim-migrate @ 17815]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 }