Implement support for listing and merging branches.
[anjuta-git-plugin.git] / libanjuta / anjuta-preferences.h
blob33434de4169f38f5646018ff0aadb1ea6e39d0ba
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * preferences.h
4 * Copyright (C) 2000 - 2003 Naba Kumar <naba@gnome.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef _ANJUTA_PREFERENCES_H_
21 #define _ANJUTA_PREFERENCES_H_
23 #include <gnome.h>
24 #include <glade/glade.h>
25 #include <gconf/gconf-client.h>
27 #include <libanjuta/anjuta-preferences-dialog.h>
28 #include <libanjuta/anjuta-plugin-manager.h>
30 G_BEGIN_DECLS
32 typedef enum
34 ANJUTA_PROPERTY_OBJECT_TYPE_TOGGLE,
35 ANJUTA_PROPERTY_OBJECT_TYPE_SPIN,
36 ANJUTA_PROPERTY_OBJECT_TYPE_ENTRY,
37 ANJUTA_PROPERTY_OBJECT_TYPE_COMBO,
38 ANJUTA_PROPERTY_OBJECT_TYPE_TEXT,
39 ANJUTA_PROPERTY_OBJECT_TYPE_COLOR,
40 ANJUTA_PROPERTY_OBJECT_TYPE_FONT,
41 ANJUTA_PROPERTY_OBJECT_TYPE_FILE,
42 ANJUTA_PROPERTY_OBJECT_TYPE_FOLDER
43 } AnjutaPropertyObjectType;
45 typedef enum
47 ANJUTA_PROPERTY_DATA_TYPE_BOOL,
48 ANJUTA_PROPERTY_DATA_TYPE_INT,
49 ANJUTA_PROPERTY_DATA_TYPE_TEXT,
50 ANJUTA_PROPERTY_DATA_TYPE_COLOR,
51 ANJUTA_PROPERTY_DATA_TYPE_FONT
52 } AnjutaPropertyDataType;
54 typedef enum
56 ANJUTA_PREFERENCES_FILTER_NONE = 0,
57 ANJUTA_PREFERENCES_FILTER_PROJECT = 1
58 } AnjutaPreferencesFilterType;
60 typedef struct _AnjutaProperty AnjutaProperty;
62 /* Get functions. Add more get functions for AnjutaProperty, if required */
63 /* Gets the widget associated with the property */
64 GtkWidget* anjuta_property_get_widget (AnjutaProperty *prop);
66 #define ANJUTA_TYPE_PREFERENCES (anjuta_preferences_get_type ())
67 #define ANJUTA_PREFERENCES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_PREFERENCES, AnjutaPreferences))
68 #define ANJUTA_PREFERENCES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ANJUTA_TYPE_PREFERENCES, AnjutaPreferencesClass))
69 #define ANJUTA_IS_PREFERENCES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_PREFERENCES))
70 #define ANJUTA_IS_PREFERENCES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_PREFERENCES))
72 typedef struct _AnjutaPreferences AnjutaPreferences;
73 typedef struct _AnjutaPreferencesClass AnjutaPreferencesClass;
74 typedef struct _AnjutaPreferencesPriv AnjutaPreferencesPriv;
76 struct _AnjutaPreferences
78 GObject parent;
80 /*< private >*/
81 AnjutaPreferencesPriv *priv;
84 struct _AnjutaPreferencesClass
86 GObjectClass parent;
89 typedef gboolean (*AnjutaPreferencesCallback) (AnjutaPreferences *pr,
90 const gchar *key,
91 gpointer data);
93 GType anjuta_preferences_get_type (void);
95 AnjutaPreferences *anjuta_preferences_new (AnjutaPluginManager *plugin_manager);
97 void anjuta_preferences_add_page (AnjutaPreferences* pr, GladeXML *gxml,
98 const gchar* glade_widget_name,
99 const gchar* title,
100 const gchar *icon_filename);
101 void anjuta_preferences_remove_page (AnjutaPreferences *pr,
102 const gchar *page_name);
105 * Registers all properties defined for widgets below the 'parent' widget
106 * in the given gxml glade UI tree
108 void anjuta_preferences_register_all_properties_from_glade_xml (AnjutaPreferences* pr,
109 GladeXML *gxml,
110 GtkWidget *parent);
111 gboolean
112 anjuta_preferences_register_property_from_string (AnjutaPreferences *pr,
113 GtkWidget *object,
114 const gchar *property_desc);
116 gboolean
117 anjuta_preferences_register_property_raw (AnjutaPreferences *pr, GtkWidget *object,
118 const gchar *key,
119 const gchar *default_value,
120 guint flags,
121 AnjutaPropertyObjectType object_type,
122 AnjutaPropertyDataType data_type);
124 gboolean
125 anjuta_preferences_register_property_custom (AnjutaPreferences *pr,
126 GtkWidget *object,
127 const gchar *key,
128 const gchar *default_value,
129 AnjutaPropertyDataType data_type,
130 guint flags,
131 void (*set_property) (AnjutaProperty *prop, const gchar *value),
132 gchar * (*get_property) (AnjutaProperty *));
134 void anjuta_preferences_reset_defaults (AnjutaPreferences *pr);
136 gboolean
137 anjuta_preferences_load_gconf (AnjutaPreferences *pr);
139 gboolean
140 anjuta_preferences_save (AnjutaPreferences *pr, FILE *stream);
142 /* Save excluding the filtered properties. This will save only those
143 * properties which DOES NOT have the flags set to values given by the filter.
145 gboolean
146 anjuta_preferences_save_filtered (AnjutaPreferences *pr, FILE *stream,
147 AnjutaPreferencesFilterType filter);
148 gboolean
149 anjuta_preferences_save_gconf (AnjutaPreferences *pr,
150 AnjutaPreferencesFilterType filter);
154 /* Calls the callback function for each of the properties with the flags
155 * matching with the given filter
157 void anjuta_preferences_foreach (AnjutaPreferences *pr,
158 AnjutaPreferencesFilterType filter,
159 AnjutaPreferencesCallback callback,
160 gpointer data);
162 /* This will transfer all the properties values from the main
163 properties database to the parent session properties database */
164 void anjuta_preferences_sync_to_session (AnjutaPreferences *pr);
166 /* Sets the value (string) of a key */
167 void anjuta_preferences_set (AnjutaPreferences *pr,
168 const gchar *key,
169 const gchar *value);
171 /* Sets the list of a key */
172 void anjuta_preferences_set_list (AnjutaPreferences *pr, const gchar *key,
173 GConfValueType list_type, GSList *list);
175 /* Sets the pair of a key */
176 gboolean anjuta_preferences_set_pair (AnjutaPreferences *pr, const gchar *key,
177 GConfValueType car_type, GConfValueType cdr_type,
178 gconstpointer address_of_car,
179 gconstpointer address_of_cdr);
181 /* Sets the value (int) of a key */
182 void anjuta_preferences_set_int (AnjutaPreferences *pr,
183 const gchar *key,
184 const gint value);
186 /* Gets the value (string) of a key */
187 /* Must free the return string */
188 gchar * anjuta_preferences_get (AnjutaPreferences *pr,
189 const gchar *key);
191 /* Gets the list of a key */
192 GSList *anjuta_preferences_get_list (AnjutaPreferences *pr, const gchar *key,
193 GConfValueType list_type);
195 /* Gets the pair of a key */
196 gboolean anjuta_preferences_get_pair (AnjutaPreferences *pr, const gchar *key,
197 GConfValueType car_type, GConfValueType cdr_type,
198 gpointer car_retloc, gpointer cdr_retloc);
200 /* Gets the value (int) of a key. If not found, 0 is returned */
201 gint anjuta_preferences_get_int (AnjutaPreferences *pr,
202 const gchar *key);
204 /* Gets the value (int) of a key. If not found, the default_value is returned */
205 gint anjuta_preferences_get_int_with_default (AnjutaPreferences* pr,
206 const gchar *key,
207 gint default_value);
209 gchar * anjuta_preferences_default_get (AnjutaPreferences *pr,
210 const gchar *key);
212 /* Gets the value (int) of a key */
213 gint anjuta_preferences_default_get_int (AnjutaPreferences *pr,
214 const gchar *key);
216 /* Dialog methods */
217 GtkWidget *anjuta_preferences_get_dialog (AnjutaPreferences *pr);
219 /* Key notifications */
220 guint anjuta_preferences_notify_add (AnjutaPreferences *pr,
221 const gchar *key,
222 GConfClientNotifyFunc func,
223 gpointer data,
224 GFreeFunc destroy_notify);
225 void anjuta_preferences_notify_remove (AnjutaPreferences *pr, guint notify_id);
227 const gchar* anjuta_preferences_get_prefix (AnjutaPreferences *pr);
229 gboolean anjuta_preferences_dir_exists (AnjutaPreferences *pr, const gchar *dir);
231 void anjuta_preferences_add_dir (AnjutaPreferences *pr, const gchar *dir,
232 GConfClientPreloadType preload);
234 void anjuta_preferences_remove_dir (AnjutaPreferences *pr, const gchar *dir);
236 G_END_DECLS
238 #endif