]> Pileus Git - ~andy/gtk/blob - gtk/gtknotebook.h
Only handle key bindings for tab reordering if the tabs are shown and
[~andy/gtk] / gtk / gtknotebook.h
1 /* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
2 /* GTK - The GIMP Toolkit
3  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 /*
22  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
23  * file for a list of people on the GTK+ Team.  See the ChangeLog
24  * files for a list of changes.  These files are distributed with
25  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
26  */
27
28 #ifndef __GTK_NOTEBOOK_H__
29 #define __GTK_NOTEBOOK_H__
30
31
32 #include <gdk/gdk.h>
33 #include <gtk/gtkcontainer.h>
34
35 G_BEGIN_DECLS
36
37 #define GTK_TYPE_NOTEBOOK                  (gtk_notebook_get_type ())
38 #define GTK_NOTEBOOK(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_NOTEBOOK, GtkNotebook))
39 #define GTK_NOTEBOOK_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_NOTEBOOK, GtkNotebookClass))
40 #define GTK_IS_NOTEBOOK(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_NOTEBOOK))
41 #define GTK_IS_NOTEBOOK_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_NOTEBOOK))
42 #define GTK_NOTEBOOK_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_NOTEBOOK, GtkNotebookClass))
43
44
45 typedef enum
46 {
47   GTK_NOTEBOOK_TAB_FIRST,
48   GTK_NOTEBOOK_TAB_LAST
49 } GtkNotebookTab;
50
51 typedef struct _GtkNotebook       GtkNotebook;
52 typedef struct _GtkNotebookClass  GtkNotebookClass;
53 typedef struct _GtkNotebookPage   GtkNotebookPage;
54
55 struct _GtkNotebook
56 {
57   GtkContainer container;
58   
59   GtkNotebookPage *cur_page;
60   GList *children;
61   GList *first_tab;             /* The first tab visible (for scrolling notebooks) */
62   GList *focus_tab;
63   
64   GtkWidget *menu;
65   GdkWindow *event_window;
66   
67   guint32 timer;
68   
69   guint16 tab_hborder;
70   guint16 tab_vborder;
71   
72   guint show_tabs          : 1;
73   guint homogeneous        : 1;
74   guint show_border        : 1;
75   guint tab_pos            : 2;
76   guint scrollable         : 1;
77   guint in_child           : 3;
78   guint click_child        : 3;
79   guint button             : 2;
80   guint need_timer         : 1;
81   guint child_has_focus    : 1;
82   guint have_visible_child : 1;
83   guint focus_out          : 1; /* Flag used by ::move-focus-out implementation */
84
85   guint has_before_previous : 1;
86   guint has_before_next     : 1;
87   guint has_after_previous  : 1;
88   guint has_after_next      : 1;
89 };
90
91 struct _GtkNotebookClass
92 {
93   GtkContainerClass parent_class;
94   
95   void (* switch_page)       (GtkNotebook     *notebook,
96                               GtkNotebookPage *page,
97                               guint            page_num);
98
99   /* Action signals for keybindings */
100   gboolean (* select_page)     (GtkNotebook       *notebook,
101                                 gboolean           move_focus);
102   gboolean (* focus_tab)       (GtkNotebook       *notebook,
103                                 GtkNotebookTab     type);
104   gboolean (* change_current_page) (GtkNotebook   *notebook,
105                                 gint               offset);
106   void (* move_focus_out)      (GtkNotebook       *notebook,
107                                 GtkDirectionType   direction);
108   gboolean (* reorder_tab)     (GtkNotebook       *notebook,
109                                 GtkDirectionType   direction,
110                                 gboolean           move_to_last);
111
112   /* More vfuncs */
113   gint (* insert_page)         (GtkNotebook       *notebook,
114                                 GtkWidget         *child,
115                                 GtkWidget         *tab_label,
116                                 GtkWidget         *menu_label,
117                                 gint               position);
118
119   void (*_gtk_reserved1) (void);
120   void (*_gtk_reserved2) (void);
121 };
122
123 typedef GtkNotebook* (*GtkNotebookWindowCreationFunc) (GtkNotebook *source,
124                                                        GtkWidget   *page,
125                                                        gint         x,
126                                                        gint         y,
127                                                        gpointer     data);
128
129 /***********************************************************
130  *           Creation, insertion, deletion                 *
131  ***********************************************************/
132
133 GType   gtk_notebook_get_type       (void) G_GNUC_CONST;
134 GtkWidget * gtk_notebook_new        (void);
135 gint gtk_notebook_append_page       (GtkNotebook *notebook,
136                                      GtkWidget   *child,
137                                      GtkWidget   *tab_label);
138 gint gtk_notebook_append_page_menu  (GtkNotebook *notebook,
139                                      GtkWidget   *child,
140                                      GtkWidget   *tab_label,
141                                      GtkWidget   *menu_label);
142 gint gtk_notebook_prepend_page      (GtkNotebook *notebook,
143                                      GtkWidget   *child,
144                                      GtkWidget   *tab_label);
145 gint gtk_notebook_prepend_page_menu (GtkNotebook *notebook,
146                                      GtkWidget   *child,
147                                      GtkWidget   *tab_label,
148                                      GtkWidget   *menu_label);
149 gint gtk_notebook_insert_page       (GtkNotebook *notebook,
150                                      GtkWidget   *child,
151                                      GtkWidget   *tab_label,
152                                      gint         position);
153 gint gtk_notebook_insert_page_menu  (GtkNotebook *notebook,
154                                      GtkWidget   *child,
155                                      GtkWidget   *tab_label,
156                                      GtkWidget   *menu_label,
157                                      gint         position);
158 void gtk_notebook_remove_page       (GtkNotebook *notebook,
159                                      gint         page_num);
160
161 /***********************************************************
162  *           Tabs drag and drop                            *
163  ***********************************************************/
164
165 void gtk_notebook_set_window_creation_hook (GtkNotebookWindowCreationFunc  func,
166                                             gpointer                       data,
167                                             GDestroyNotify                 destroy);
168 void gtk_notebook_set_group_id             (GtkNotebook *notebook,
169                                             gint         group_id);
170 gint gtk_notebook_get_group_id             (GtkNotebook *notebook);
171
172 /***********************************************************
173  *            query, set current NoteebookPage             *
174  ***********************************************************/
175
176 gint       gtk_notebook_get_current_page (GtkNotebook *notebook);
177 GtkWidget* gtk_notebook_get_nth_page     (GtkNotebook *notebook,
178                                           gint         page_num);
179 gint       gtk_notebook_get_n_pages      (GtkNotebook *notebook);
180 gint       gtk_notebook_page_num         (GtkNotebook *notebook,
181                                           GtkWidget   *child);
182 void       gtk_notebook_set_current_page (GtkNotebook *notebook,
183                                           gint         page_num);
184 void       gtk_notebook_next_page        (GtkNotebook *notebook);
185 void       gtk_notebook_prev_page        (GtkNotebook *notebook);
186
187 /***********************************************************
188  *            set Notebook, NotebookTab style              *
189  ***********************************************************/
190
191 void     gtk_notebook_set_show_border      (GtkNotebook     *notebook,
192                                             gboolean         show_border);
193 gboolean gtk_notebook_get_show_border      (GtkNotebook     *notebook);
194 void     gtk_notebook_set_show_tabs        (GtkNotebook     *notebook,
195                                             gboolean         show_tabs);
196 gboolean gtk_notebook_get_show_tabs        (GtkNotebook     *notebook);
197 void     gtk_notebook_set_tab_pos          (GtkNotebook     *notebook,
198                                             GtkPositionType  pos);
199 GtkPositionType gtk_notebook_get_tab_pos   (GtkNotebook     *notebook);
200
201 #ifndef GTK_DISABLE_DEPRECATED
202 void     gtk_notebook_set_homogeneous_tabs (GtkNotebook     *notebook,
203                                             gboolean         homogeneous);
204 void     gtk_notebook_set_tab_border       (GtkNotebook     *notebook,
205                                             guint            border_width);
206 void     gtk_notebook_set_tab_hborder      (GtkNotebook     *notebook,
207                                             guint            tab_hborder);
208 void     gtk_notebook_set_tab_vborder      (GtkNotebook     *notebook,
209                                             guint            tab_vborder);
210 #endif /* GTK_DISABLE_DEPRECATED */
211
212 void     gtk_notebook_set_scrollable       (GtkNotebook     *notebook,
213                                             gboolean         scrollable);
214 gboolean gtk_notebook_get_scrollable       (GtkNotebook     *notebook);
215
216 /***********************************************************
217  *               enable/disable PopupMenu                  *
218  ***********************************************************/
219
220 void gtk_notebook_popup_enable  (GtkNotebook *notebook);
221 void gtk_notebook_popup_disable (GtkNotebook *notebook);
222
223 /***********************************************************
224  *             query/set NotebookPage Properties           *
225  ***********************************************************/
226
227 GtkWidget * gtk_notebook_get_tab_label    (GtkNotebook *notebook,
228                                            GtkWidget   *child);
229 void gtk_notebook_set_tab_label           (GtkNotebook *notebook,
230                                            GtkWidget   *child,
231                                            GtkWidget   *tab_label);
232 void gtk_notebook_set_tab_label_text      (GtkNotebook *notebook,
233                                            GtkWidget   *child,
234                                            const gchar *tab_text);
235 G_CONST_RETURN gchar *gtk_notebook_get_tab_label_text (GtkNotebook *notebook,
236                                                        GtkWidget   *child);
237 GtkWidget * gtk_notebook_get_menu_label   (GtkNotebook *notebook,
238                                            GtkWidget   *child);
239 void gtk_notebook_set_menu_label          (GtkNotebook *notebook,
240                                            GtkWidget   *child,
241                                            GtkWidget   *menu_label);
242 void gtk_notebook_set_menu_label_text     (GtkNotebook *notebook,
243                                            GtkWidget   *child,
244                                            const gchar *menu_text);
245 G_CONST_RETURN gchar *gtk_notebook_get_menu_label_text (GtkNotebook *notebook,
246                                                         GtkWidget   *child);
247 void gtk_notebook_query_tab_label_packing (GtkNotebook *notebook,
248                                            GtkWidget   *child,
249                                            gboolean    *expand,
250                                            gboolean    *fill,
251                                            GtkPackType *pack_type);
252 void gtk_notebook_set_tab_label_packing   (GtkNotebook *notebook,
253                                            GtkWidget   *child,
254                                            gboolean     expand,
255                                            gboolean     fill,
256                                            GtkPackType  pack_type);
257 void gtk_notebook_reorder_child           (GtkNotebook *notebook,
258                                            GtkWidget   *child,
259                                            gint         position);
260 gboolean gtk_notebook_get_tab_reorderable (GtkNotebook *notebook,
261                                            GtkWidget   *child);
262 void gtk_notebook_set_tab_reorderable     (GtkNotebook *notebook,
263                                            GtkWidget   *child,
264                                            gboolean     reorderable);
265 gboolean gtk_notebook_get_tab_detachable  (GtkNotebook *notebook,
266                                            GtkWidget   *child);
267 void gtk_notebook_set_tab_detachable      (GtkNotebook *notebook,
268                                            GtkWidget   *child,
269                                            gboolean     detachable);
270
271 #ifndef GTK_DISABLE_DEPRECATED
272 #define gtk_notebook_current_page               gtk_notebook_get_current_page
273 #define gtk_notebook_set_page                   gtk_notebook_set_current_page
274 #endif /* GTK_DISABLE_DEPRECATED */
275
276 G_END_DECLS
277
278 #endif /* __GTK_NOTEBOOK_H__ */