1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) 2000 - 2003 Naba Kumar <naba@gnome.org>
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_
24 #include <glib/gi18n.h>
25 #include <gdk/gdkkeysyms.h>
27 #include <libanjuta/anjuta-preferences-dialog.h>
28 #include <libanjuta/anjuta-plugin-manager.h>
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
;
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 struct _AnjutaProperty AnjutaProperty
;
56 /* Get functions. Add more get functions for AnjutaProperty, if required */
57 /* Gets the widget associated with the property */
58 GtkWidget
* anjuta_property_get_widget (AnjutaProperty
*prop
);
60 #define ANJUTA_TYPE_PREFERENCES (anjuta_preferences_get_type ())
61 #define ANJUTA_PREFERENCES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_PREFERENCES, AnjutaPreferences))
62 #define ANJUTA_PREFERENCES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ANJUTA_TYPE_PREFERENCES, AnjutaPreferencesClass))
63 #define ANJUTA_IS_PREFERENCES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_PREFERENCES))
64 #define ANJUTA_IS_PREFERENCES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_PREFERENCES))
66 typedef struct _AnjutaPreferences AnjutaPreferences
;
67 typedef struct _AnjutaPreferencesClass AnjutaPreferencesClass
;
68 typedef struct _AnjutaPreferencesPriv AnjutaPreferencesPriv
;
70 struct _AnjutaPreferences
75 AnjutaPreferencesPriv
*priv
;
78 struct _AnjutaPreferencesClass
83 typedef gboolean (*AnjutaPreferencesCallback
) (AnjutaPreferences
*pr
,
87 GType
anjuta_preferences_get_type (void);
89 AnjutaPreferences
*anjuta_preferences_new (AnjutaPluginManager
*plugin_manager
);
90 AnjutaPreferences
*anjuta_preferences_default (void);
92 void anjuta_preferences_add_from_builder (AnjutaPreferences
* pr
,GtkBuilder
*builder
,
93 const gchar
* glade_widget_name
,
95 const gchar
*icon_filename
);
97 void anjuta_preferences_remove_page (AnjutaPreferences
*pr
,
98 const gchar
*page_name
);
101 * Registers all properties defined for widgets below the 'parent' widget
102 * in the given gtkbuilder UI tree
104 void anjuta_preferences_register_all_properties_from_builder_xml (AnjutaPreferences
* pr
,
108 anjuta_preferences_register_property_from_string (AnjutaPreferences
*pr
,
110 const gchar
*property_desc
);
113 anjuta_preferences_register_property_raw (AnjutaPreferences
*pr
, GtkWidget
*object
,
115 const gchar
*default_value
,
117 AnjutaPropertyObjectType object_type
,
118 AnjutaPropertyDataType data_type
);
121 anjuta_preferences_register_property_custom (AnjutaPreferences
*pr
,
124 const gchar
*default_value
,
125 AnjutaPropertyDataType data_type
,
127 void (*set_property
) (AnjutaProperty
*prop
, const gchar
*value
),
128 gchar
* (*get_property
) (AnjutaProperty
*));
130 void anjuta_preferences_reset_defaults (AnjutaPreferences
*pr
);
132 /* Calls the callback function for each of the properties with the flags
133 * matching with the given filter
135 void anjuta_preferences_foreach (AnjutaPreferences
*pr
,
136 AnjutaPreferencesCallback callback
,
139 /* This will transfer all the properties values from the main
140 properties database to the parent session properties database */
141 void anjuta_preferences_sync_to_session (AnjutaPreferences
*pr
);
143 /* Sets the value (string) of a key */
144 void anjuta_preferences_set (AnjutaPreferences
*pr
,
148 /* Sets the value (int) of a key */
149 void anjuta_preferences_set_int (AnjutaPreferences
*pr
,
153 void anjuta_preferences_set_bool (AnjutaPreferences
*pr
,
155 const gboolean value
);
157 /* Gets the value (string) of a key */
158 /* Must free the return string */
159 gchar
* anjuta_preferences_get (AnjutaPreferences
*pr
,
162 /* Gets the value (int) of a key. If not found, 0 is returned */
163 gint
anjuta_preferences_get_int (AnjutaPreferences
*pr
,
166 gboolean
anjuta_preferences_get_bool (AnjutaPreferences
*pr
,
169 /* Gets the value (int) of a key. If not found, the default_value is returned */
170 gint
anjuta_preferences_get_int_with_default (AnjutaPreferences
* pr
,
174 gint
anjuta_preferences_get_bool_with_default (AnjutaPreferences
* pr
,
178 gchar
* anjuta_preferences_default_get (AnjutaPreferences
*pr
,
181 /* Gets the value (int) of a key */
182 gint
anjuta_preferences_default_get_int (AnjutaPreferences
*pr
,
185 gint
anjuta_preferences_default_get_bool (AnjutaPreferences
*pr
,
189 GtkWidget
*anjuta_preferences_get_dialog (AnjutaPreferences
*pr
);
190 gboolean
anjuta_preferences_is_dialog_created (AnjutaPreferences
*pr
);
192 /* Key notifications */
194 typedef void (*AnjutaPreferencesNotify
) (AnjutaPreferences
*pr
,
198 typedef void (*AnjutaPreferencesNotifyInt
) (AnjutaPreferences
*pr
,
202 typedef void (*AnjutaPreferencesNotifyBool
) (AnjutaPreferences
*pr
,
207 guint
anjuta_preferences_notify_add_int (AnjutaPreferences
*pr
,
209 AnjutaPreferencesNotifyInt func
,
211 GFreeFunc destroy_notify
);
213 guint
anjuta_preferences_notify_add_string (AnjutaPreferences
*pr
,
215 AnjutaPreferencesNotify func
,
217 GFreeFunc destroy_notify
);
219 guint
anjuta_preferences_notify_add_bool (AnjutaPreferences
*pr
,
221 AnjutaPreferencesNotifyBool func
,
223 GFreeFunc destroy_notify
);
225 void anjuta_preferences_notify_remove (AnjutaPreferences
*pr
, guint notify_id
);
227 const gchar
* anjuta_preferences_get_prefix (AnjutaPreferences
*pr
);