]> www.fi.muni.cz Git - evince.git/blob - cut-n-paste/toolbar-editor/egg-toolbars-model.h
6961ee4ec0f4bd457147ea767a4cd0d56680e911
[evince.git] / cut-n-paste / toolbar-editor / egg-toolbars-model.h
1 /*
2  *  Copyright (C) 2003-2004 Marco Pesenti Gritti
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2, or (at your option)
7  *  any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  * 
18  *  $Id$
19  */
20
21 #ifndef EGG_TOOLBARS_MODEL_H
22 #define EGG_TOOLBARS_MODEL_H
23
24 #include <glib.h>
25 #include <glib-object.h>
26 #include <gdk/gdktypes.h>
27
28 G_BEGIN_DECLS
29
30 #define EGG_TYPE_TOOLBARS_MODEL             (egg_toolbars_model_get_type ())
31 #define EGG_TOOLBARS_MODEL(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModel))
32 #define EGG_TOOLBARS_MODEL_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModelClass))
33 #define EGG_IS_TOOLBARS_MODEL(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TOOLBARS_MODEL))
34 #define EGG_IS_TOOLBARS_MODEL_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TOOLBARS_MODEL))
35 #define EGG_TOOLBARS_MODEL_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModelClass))
36
37 typedef struct EggToolbarsModel         EggToolbarsModel;
38 typedef struct EggToolbarsModelPrivate  EggToolbarsModelPrivate;
39 typedef struct EggToolbarsModelClass    EggToolbarsModelClass;
40
41 #define EGG_TOOLBAR_ITEM_TYPE "application/x-toolbar-item"
42
43 typedef enum
44 {
45   EGG_TB_MODEL_NOT_REMOVABLE     = 1 << 0,
46   EGG_TB_MODEL_NOT_EDITABLE      = 1 << 1,
47   EGG_TB_MODEL_BOTH              = 1 << 2,
48   EGG_TB_MODEL_BOTH_HORIZ        = 1 << 3,
49   EGG_TB_MODEL_ICONS             = 1 << 4,
50   EGG_TB_MODEL_TEXT              = 1 << 5,
51   EGG_TB_MODEL_STYLES_MASK       = 0x3C,
52   EGG_TB_MODEL_ACCEPT_ITEMS_ONLY = 1 << 6,
53   EGG_TB_MODEL_HIDDEN            = 1 << 7
54 } EggTbModelFlags;
55
56 typedef enum
57 {
58   EGG_TB_MODEL_NAME_USED         = 1 << 0,
59   EGG_TB_MODEL_NAME_INFINITE     = 1 << 1,
60   EGG_TB_MODEL_NAME_KNOWN        = 1 << 2
61 } EggTbModelNameFlags;
62
63 struct EggToolbarsModel
64 {
65   GObject parent_object;
66
67   /*< private >*/
68   EggToolbarsModelPrivate *priv;
69 };
70
71 struct EggToolbarsModelClass
72 {
73   GObjectClass parent_class;
74
75   /* Signals */
76   void (* item_added)      (EggToolbarsModel *model,
77                             int toolbar_position,
78                             int position);
79   void (* item_removed)    (EggToolbarsModel *model,
80                             int toolbar_position,
81                             int position);
82   void (* toolbar_added)   (EggToolbarsModel *model,
83                             int position);
84   void (* toolbar_changed) (EggToolbarsModel *model,
85                             int position);
86   void (* toolbar_removed) (EggToolbarsModel *model,
87                             int position);
88
89   /* Virtual Table */
90   gboolean (* add_item)    (EggToolbarsModel *t,
91                             int               toolbar_position,
92                             int               position,
93                             const char       *name);
94 };
95
96 typedef struct EggToolbarsItemType EggToolbarsItemType;
97
98 struct EggToolbarsItemType
99 {
100   GdkAtom type;
101         
102   gboolean (* has_data) (EggToolbarsItemType *type,
103                          const char          *name);
104   char *   (* get_data) (EggToolbarsItemType *type,
105                          const char          *name);
106   
107   char *   (* new_name) (EggToolbarsItemType *type,
108                          const char          *data);
109   char *   (* get_name) (EggToolbarsItemType *type,
110                          const char          *data);
111 };
112
113 GType             egg_toolbars_model_flags_get_type (void);
114 GType             egg_toolbars_model_get_type       (void);
115 EggToolbarsModel *egg_toolbars_model_new            (void);
116 gboolean          egg_toolbars_model_load_names     (EggToolbarsModel *model,
117                                                      const char *xml_file);
118 gboolean          egg_toolbars_model_load_toolbars  (EggToolbarsModel *model,
119                                                      const char *xml_file);
120 void              egg_toolbars_model_save_toolbars  (EggToolbarsModel *model,
121                                                      const char *xml_file,
122                                                      const char *version);
123
124 /* Functions for manipulating the types of portable data this toolbar understands. */
125 GList *           egg_toolbars_model_get_types      (EggToolbarsModel *model);
126 void              egg_toolbars_model_set_types      (EggToolbarsModel *model,
127                                                      GList            *types);
128
129 /* Functions for converting between name and portable data. */
130 char *            egg_toolbars_model_get_name       (EggToolbarsModel *model,
131                                                      GdkAtom           type,
132                                                      const char       *data,
133                                                      gboolean          create);
134 char *            egg_toolbars_model_get_data       (EggToolbarsModel *model,
135                                                      GdkAtom           type,
136                                                      const char       *name);
137
138 /* Functions for retrieving what items are available for adding to the toolbars. */
139 GPtrArray *       egg_toolbars_model_get_name_avail (EggToolbarsModel *model);
140 gint              egg_toolbars_model_get_name_flags (EggToolbarsModel *model,
141                                                      const char *name);
142 void              egg_toolbars_model_set_name_flags (EggToolbarsModel *model,
143                                                      const char *name,
144                                                      gint flags);
145
146 /* Functions for manipulating flags on individual toolbars. */
147 EggTbModelFlags   egg_toolbars_model_get_flags      (EggToolbarsModel *model,
148                                                      int               toolbar_position);
149 void              egg_toolbars_model_set_flags      (EggToolbarsModel *model,
150                                                      int               toolbar_position,
151                                                      EggTbModelFlags   flags);
152
153 /* Functions for adding and removing toolbars. */
154 int               egg_toolbars_model_add_toolbar    (EggToolbarsModel *model,
155                                                      int               position,
156                                                      const char       *name);
157 void              egg_toolbars_model_remove_toolbar (EggToolbarsModel *model,
158                                                      int               position);
159
160 /* Functions for adding, removing and moving items. */
161 gboolean          egg_toolbars_model_add_item       (EggToolbarsModel *model,
162                                                      int               toolbar_position,
163                                                      int               position,
164                                                      const char       *name);
165 void              egg_toolbars_model_remove_item    (EggToolbarsModel *model,
166                                                      int               toolbar_position,
167                                                      int               position);
168 void              egg_toolbars_model_move_item      (EggToolbarsModel *model,
169                                                      int               toolbar_position,
170                                                      int               position,
171                                                      int               new_toolbar_position,
172                                                      int               new_position);
173 void              egg_toolbars_model_delete_item    (EggToolbarsModel *model,
174                                                      const char       *name);
175
176 /* Functions for accessing the names of items. */
177 int               egg_toolbars_model_n_items        (EggToolbarsModel *model,
178                                                      int               toolbar_position);
179 const char *      egg_toolbars_model_item_nth       (EggToolbarsModel *model,
180                                                      int               toolbar_position,
181                                                      int               position);
182
183 /* Functions for accessing the names of toolbars. */
184 int               egg_toolbars_model_n_toolbars     (EggToolbarsModel *model);
185 const char       *egg_toolbars_model_toolbar_nth    (EggToolbarsModel *model,
186                                                      int               position);
187
188 G_END_DECLS
189
190 #endif