Commit 32d9a69e authored by Naba Kumar's avatar Naba Kumar

Increased bounty for on-demand preferences task to $150 as discussed and

	* TODO.tasks: Increased bounty for on-demand preferences task to $150
	as discussed and agreed with James Liggett.

	Patch from James Liggett  <jrliggett@cox.net>:

	* configure.in:
	* libanjuta/anjuta-plugin-manager.c:
	(on_activated_plugin_objects_foreach),
	(anjuta_plugin_manager_get_active_plugin_objects):
	* libanjuta/anjuta-plugin-manager.h:
	* libanjuta/anjuta-plugin.c: (anjuta_plugin_activate),
	(anjuta_plugin_deactivate):
	* libanjuta/anjuta-preferences-dialog.c:
	(anjuta_preferences_dialog_finalize),
	(anjuta_preferences_dialog_class_init), (add_category_columns),
	(anjuta_preferences_dialog_init), (anjuta_preferences_dialog_new),
	(anjuta_preferences_dialog_remove_page):
	* libanjuta/anjuta-preferences.c: (property_destroy),
	(unregister_preferences_key), (register_callbacks),
	(preferences_foreach_callback), (connect_prop_to_object),
	(anjuta_preferences_register_property_raw),
	(anjuta_preferences_register_property_custom),
	(anjuta_preferences_foreach), (anjuta_preferences_add_page),
	(anjuta_preferences_remove_page),
	(on_preferences_dialog_destroyed), (anjuta_preferences_get_dialog),
	(anjuta_preferences_get_type), (anjuta_preferences_dispose),
	(anjuta_preferences_instance_init), (anjuta_preferences_finalize),
	(anjuta_preferences_class_init), (anjuta_preferences_new):
	* libanjuta/anjuta-preferences.h:
	* plugins/build-basic-autotools/Makefile.am:
	* plugins/build-basic-autotools/build-basic-autotools.c:
	(ipreferences_unmerge):
	* plugins/cvs-plugin/Makefile.am:
	* plugins/cvs-plugin/plugin.c: (ipreferences_unmerge):
	* plugins/document-manager/Makefile.am:
	* plugins/document-manager/plugin.c: (ipreferences_unmerge):
	* plugins/editor/plugin.c: (ipreferences_unmerge):
	* plugins/file-manager/Makefile.am:
	* plugins/file-manager/plugin.c: (activate_plugin),
	(deactivate_plugin), (ipreferences_merge), (ipreferences_unmerge):
	* plugins/gtodo/plugin.c: (ipreferences_merge),
	(ipreferences_unmerge):
	* plugins/language-support-cpp-java/Makefile.am:
	* plugins/language-support-cpp-java/plugin.c:
	(ipreferences_unmerge):
	* plugins/message-view/Makefile.am:
	* plugins/message-view/plugin.c: (ipreferences_unmerge):
	* plugins/sourceview/Makefile.am:
	* plugins/sourceview/plugin.c: (ipreferences_unmerge):
	* plugins/symbol-browser/Makefile.am:
	* plugins/symbol-browser/an_symbol_prefs.c:
	(symbol_browser_prefs_finalize):
	* plugins/terminal/Makefile.am:
	* plugins/terminal/terminal.c: (ipreferences_unmerge):
	* plugins/valgrind/plugin.c: (ipreferences_merge),
	(ipreferences_unmerge):
	* scripts/Makefile.am:
	* scripts/glade2schema.pl, (added) scripts/build-schemas.mk:
	* src/Makefile.am:
	* src/action-callbacks.c: (on_set_preferences1_activate):
	* src/anjuta-app.c: (anjuta_app_instance_init),
	(anjuta_app_install_preferences):
	* src/anjuta-app.h:
	* src/shell.c: (anjuta_test_shell_instance_init): Completed bounty
	task: Bug #445314: On demand preferences widgets creation. Thanks
	James for this great work.


svn path=/trunk/; revision=3035
parent 1895fd07
2007-07-02 Naba Kumar <naba.kumar@gnome.org>
* TODO.tasks: Increased bounty for on-demand preferences task to $150
as discussed and agreed with James Liggett.
Patch from James Liggett <jrliggett@cox.net>:
* configure.in:
* libanjuta/anjuta-plugin-manager.c:
(on_activated_plugin_objects_foreach),
(anjuta_plugin_manager_get_active_plugin_objects):
* libanjuta/anjuta-plugin-manager.h:
* libanjuta/anjuta-plugin.c: (anjuta_plugin_activate),
(anjuta_plugin_deactivate):
* libanjuta/anjuta-preferences-dialog.c:
(anjuta_preferences_dialog_finalize),
(anjuta_preferences_dialog_class_init), (add_category_columns),
(anjuta_preferences_dialog_init), (anjuta_preferences_dialog_new),
(anjuta_preferences_dialog_remove_page):
* libanjuta/anjuta-preferences.c: (property_destroy),
(unregister_preferences_key), (register_callbacks),
(preferences_foreach_callback), (connect_prop_to_object),
(anjuta_preferences_register_property_raw),
(anjuta_preferences_register_property_custom),
(anjuta_preferences_foreach), (anjuta_preferences_add_page),
(anjuta_preferences_remove_page),
(on_preferences_dialog_destroyed), (anjuta_preferences_get_dialog),
(anjuta_preferences_get_type), (anjuta_preferences_dispose),
(anjuta_preferences_instance_init), (anjuta_preferences_finalize),
(anjuta_preferences_class_init), (anjuta_preferences_new):
* libanjuta/anjuta-preferences.h:
* plugins/build-basic-autotools/Makefile.am:
* plugins/build-basic-autotools/build-basic-autotools.c:
(ipreferences_unmerge):
* plugins/cvs-plugin/Makefile.am:
* plugins/cvs-plugin/plugin.c: (ipreferences_unmerge):
* plugins/document-manager/Makefile.am:
* plugins/document-manager/plugin.c: (ipreferences_unmerge):
* plugins/editor/plugin.c: (ipreferences_unmerge):
* plugins/file-manager/Makefile.am:
* plugins/file-manager/plugin.c: (activate_plugin),
(deactivate_plugin), (ipreferences_merge), (ipreferences_unmerge):
* plugins/gtodo/plugin.c: (ipreferences_merge),
(ipreferences_unmerge):
* plugins/language-support-cpp-java/Makefile.am:
* plugins/language-support-cpp-java/plugin.c:
(ipreferences_unmerge):
* plugins/message-view/Makefile.am:
* plugins/message-view/plugin.c: (ipreferences_unmerge):
* plugins/sourceview/Makefile.am:
* plugins/sourceview/plugin.c: (ipreferences_unmerge):
* plugins/symbol-browser/Makefile.am:
* plugins/symbol-browser/an_symbol_prefs.c:
(symbol_browser_prefs_finalize):
* plugins/terminal/Makefile.am:
* plugins/terminal/terminal.c: (ipreferences_unmerge):
* plugins/valgrind/plugin.c: (ipreferences_merge),
(ipreferences_unmerge):
* scripts/Makefile.am:
* scripts/glade2schema.pl, (added) scripts/build-schemas.mk:
* src/Makefile.am:
* src/action-callbacks.c: (on_set_preferences1_activate):
* src/anjuta-app.c: (anjuta_app_instance_init),
(anjuta_app_install_preferences):
* src/anjuta-app.h:
* src/shell.c: (anjuta_test_shell_instance_init): Completed bounty
task: Bug #445314: On demand preferences widgets creation. Thanks
James for this great work.
2007-07-02 Naba Kumar <naba.kumar@gnome.org>
* plugins/debug-manager/data_buffer.c,
......
......@@ -103,9 +103,9 @@ should be shown side-by-side in status bar.</comment>
<comment>Add a new page in Settings-&gt;plugins dialog, along side Available plugins page, that lists the plugins that have been remembered from plugin query and selection dialog. And for 'Forget' and 'Forget all' buttons.</comment>
</item>
<item>
<attribute id="1159555613" priority="1" done="0" start_date="732583" enddate="99999999" notify="0" endtime="-60" last_edited="1182419093"/>
<attribute id="1159555613" priority="1" done="0" start_date="732583" enddate="99999999" notify="0" endtime="-60" last_edited="1183374207"/>
<summary>On demand preferences widgets creation</summary>
<comment>[Skill: High, Work: 30hrs, Bounty: $100, Status: Assigned, Bug: #445314]
<comment>[Skill: High, Work: 30hrs, Bounty: $150, Status: Assigned, Bug: #445314]
Currently, preferences are registered at plugins activation time. This has a real drawback that we spend unnecessary time at startup that could easily be avoided by on-demand creation of the preferences. One reason why it isn't straightforward is because preferences dialogs contain the schemas for preference keys, so unless the glade files (of the plugin preferences dialogs) are loaded, the default values of the keys are not available.
......
......@@ -145,6 +145,12 @@ AM_PROG_LIBTOOL
AC_TYPE_SIGNAL
dnl ***************************************************************************
dnl Check for GConf stuff to handle schema installation
dnl ***************************************************************************
AC_PATH_PROG(GCONFTOOL, gconftool-2)
AM_GCONF_SOURCE_2
dnl ***************************************************************************
dnl Check for pkgconfig
dnl ***************************************************************************
......
......@@ -1489,6 +1489,14 @@ on_activated_plugins_foreach (gpointer key, gpointer data, gpointer user_data)
anjuta_plugin_handle_get_description (plugin));
}
static void
on_activated_plugin_objects_foreach (gpointer key, gpointer data, gpointer user_data)
{
GList **active_plugins = (GList **)user_data;
*active_plugins = g_list_prepend (*active_plugins,
data);
}
GList*
anjuta_plugin_manager_get_active_plugins (AnjutaPluginManager *plugin_manager)
{
......@@ -1501,6 +1509,18 @@ anjuta_plugin_manager_get_active_plugins (AnjutaPluginManager *plugin_manager)
return g_list_reverse (active_plugins);
}
GList*
anjuta_plugin_manager_get_active_plugin_objects (AnjutaPluginManager *plugin_manager)
{
GList *active_plugins = NULL;
g_return_val_if_fail (ANJUTA_IS_PLUGIN_MANAGER (plugin_manager), NULL);
g_hash_table_foreach (plugin_manager->priv->activated_plugins,
on_activated_plugin_objects_foreach,
&active_plugins);
return g_list_reverse (active_plugins);
}
gboolean
anjuta_plugin_manager_unload_plugin_by_id (AnjutaPluginManager *plugin_manager,
const gchar *plugin_id)
......
......@@ -81,6 +81,7 @@ gboolean anjuta_plugin_manager_unload_plugin (AnjutaPluginManager *plugin_manage
gboolean anjuta_plugin_manager_unload_plugin_by_id (AnjutaPluginManager *plugin_manager,
const gchar *plugin_id);
GList* anjuta_plugin_manager_get_active_plugins (AnjutaPluginManager *plugin_manager);
GList* anjuta_plugin_manager_get_active_plugin_objects (AnjutaPluginManager *plugin_manager);
/* Selection dialogs */
GtkWidget* anjuta_plugin_manager_get_dialog (AnjutaPluginManager *plugin_manager);
......
......@@ -538,13 +538,8 @@ anjuta_plugin_activate (AnjutaPlugin *plugin)
plugin->priv->activated = klass->activate(plugin);
if (plugin->priv->activated)
{
if (IANJUTA_IS_PREFERENCES(plugin))
ianjuta_preferences_merge(IANJUTA_PREFERENCES(plugin),
ANJUTA_PREFERENCES(anjuta_shell_get_preferences(plugin->shell,
NULL)), NULL);
g_signal_emit_by_name (G_OBJECT (plugin), "activated");
}
return plugin->priv->activated;
}
......@@ -571,10 +566,6 @@ anjuta_plugin_deactivate (AnjutaPlugin *plugin)
klass = ANJUTA_PLUGIN_GET_CLASS(plugin);
g_return_val_if_fail (klass->deactivate != NULL, FALSE);
if (IANJUTA_IS_PREFERENCES(plugin))
ianjuta_preferences_unmerge(IANJUTA_PREFERENCES(plugin),
ANJUTA_PREFERENCES(anjuta_shell_get_preferences(plugin->shell, NULL)), NULL);
success = klass->deactivate(plugin);
plugin->priv->activated = !success;
if (!plugin->priv->activated)
......
......@@ -45,7 +45,6 @@
#include <cell-renderer-captioned-image.h>
#include <libanjuta/anjuta-preferences-dialog.h>
struct _AnjutaPreferencesDialogPrivate {
GtkWidget *treeview;
GtkListStore *store;
......@@ -62,75 +61,34 @@ enum {
};
static void anjuta_preferences_dialog_class_init (AnjutaPreferencesDialogClass *class);
static void anjuta_preferences_dialog_instance_init (AnjutaPreferencesDialog *dlg);
static void anjuta_preferences_dialog_init (AnjutaPreferencesDialog *dlg);
GNOME_CLASS_BOILERPLATE (AnjutaPreferencesDialog,
anjuta_preferences_dialog,
GtkDialog, GTK_TYPE_DIALOG);
G_DEFINE_TYPE (AnjutaPreferencesDialog, anjuta_preferences_dialog,
GTK_TYPE_DIALOG)
static void
anjuta_preferences_dialog_dispose (GObject *obj)
anjuta_preferences_dialog_finalize (GObject *obj)
{
AnjutaPreferencesDialog *dlg = ANJUTA_PREFERENCES_DIALOG (obj);
AnjutaPreferencesDialog *dlg = ANJUTA_PREFERENCES_DIALOG (obj);
if (dlg->priv->store) {
g_object_unref (dlg->priv->store);
dlg->priv->store = NULL;
}
GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (obj));
}
static void
anjuta_preferences_dialog_finalize (GObject *obj)
{
AnjutaPreferencesDialog *dlg = ANJUTA_PREFERENCES_DIALOG (obj);
g_free (dlg->priv);
GNOME_CALL_PARENT (G_OBJECT_CLASS, finalize, (obj));
}
#if 0
static void
anjuta_preferences_dialog_response (GtkDialog *dialog, int response_id)
{
g_return_if_fail (response_id == 0);
gtk_widget_hide (GTK_WIDGET (dialog));
}
#endif
static void
anjuta_preferences_dialog_close (GtkDialog *dialog)
{
gtk_widget_hide (GTK_WIDGET (dialog));
((GObjectClass *) anjuta_preferences_dialog_parent_class)->finalize (obj);
}
static void
anjuta_preferences_dialog_class_init (AnjutaPreferencesDialogClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (class);
parent_class = g_type_class_peek_parent (class);
object_class->dispose = anjuta_preferences_dialog_dispose;
object_class->finalize = anjuta_preferences_dialog_finalize;
/* dialog_class->response = anjuta_preferences_dialog_response; */
dialog_class->close = anjuta_preferences_dialog_close;
}
/*
static gboolean
delete_event_cb (AnjutaPreferencesDialog *dlg, gpointer data)
{
gtk_widget_hide (GTK_WIDGET (dlg));
return FALSE;
}
*/
static void
add_category_columns (AnjutaPreferencesDialog *dlg)
{
......@@ -138,6 +96,7 @@ add_category_columns (AnjutaPreferencesDialog *dlg)
GtkTreeViewColumn *column;
renderer = anjuta_cell_renderer_captioned_image_new ();
g_object_ref_sink (renderer);
column = gtk_tree_view_column_new_with_attributes (_("Category"),
renderer,
"text",
......@@ -171,7 +130,7 @@ selection_changed_cb (GtkTreeSelection *selection,
}
static void
anjuta_preferences_dialog_instance_init (AnjutaPreferencesDialog *dlg)
anjuta_preferences_dialog_init (AnjutaPreferencesDialog *dlg)
{
GtkWidget *hbox;
GtkWidget *scrolled_window;
......@@ -233,6 +192,8 @@ anjuta_preferences_dialog_instance_init (AnjutaPreferencesDialog *dlg)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox,
TRUE, TRUE, 0);
gtk_dialog_add_button (GTK_DIALOG (dlg), GTK_STOCK_CLOSE, -7);
gtk_widget_show (hbox);
}
......@@ -246,8 +207,8 @@ anjuta_preferences_dialog_instance_init (AnjutaPreferencesDialog *dlg)
GtkWidget *
anjuta_preferences_dialog_new (void)
{
return gtk_widget_new (ANJUTA_TYPE_PREFERENCES_DIALOG,
"title", _("Anjuta Preferences Dialog"),
return g_object_new (ANJUTA_TYPE_PREFERENCES_DIALOG,
"title", _("Anjuta Preferences"),
NULL);
}
......@@ -297,6 +258,7 @@ anjuta_preferences_dialog_remove_page (AnjutaPreferencesDialog *dlg,
{
GtkTreeModel* model = GTK_TREE_MODEL(dlg->priv->store);
GtkTreeIter iter;
GtkWidget *page;
if (gtk_tree_model_get_iter_first(model, &iter))
{
......@@ -317,16 +279,18 @@ anjuta_preferences_dialog_remove_page (AnjutaPreferencesDialog *dlg,
page_num = gtk_notebook_page_num (
GTK_NOTEBOOK(dlg->priv->notebook),
GTK_WIDGET (page_widget));
page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (dlg->priv->notebook),
page_num);
gtk_notebook_remove_page(
GTK_NOTEBOOK(dlg->priv->notebook), page_num);
gtk_widget_destroy (page);
gtk_list_store_remove(dlg->priv->store, &iter);
g_object_unref (page_widget);
return;
}
g_object_unref (page_widget);
}
while (gtk_tree_model_iter_next(model, &iter));
}
......
......@@ -72,6 +72,7 @@
#include <libanjuta/anjuta-utils.h>
#include <libanjuta/resources.h>
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/interfaces/ianjuta-preferences.h>
struct _AnjutaProperty
{
......@@ -80,6 +81,7 @@ struct _AnjutaProperty
gchar *default_value;
guint flags;
gint notify_id;
GConfClient *gclient;
/* Set true if custom set/get to be used */
gboolean custom;
......@@ -96,9 +98,20 @@ struct _AnjutaProperty
struct _AnjutaPreferencesPriv
{
GConfClient *gclient;
GList *properties;
gboolean is_showing;
GConfClient *gclient;
GHashTable *properties;
GtkWidget *prefs_dialog;
AnjutaPluginManager *plugin_manager;
gboolean is_showing;
};
/* Internal structure for anjuta_preferences_foreach */
struct _AnjutaPreferencesForeachData
{
AnjutaPreferences *pr;
AnjutaPreferencesFilterType filter;
AnjutaPreferencesCallback callback;
gpointer callback_data;
};
#define PREFERENCE_PROPERTY_PREFIX "preferences_"
......@@ -465,22 +478,14 @@ anjuta_preferences_set_int (AnjutaPreferences *pr, const gchar *key,
}
}
static void
on_preferences_dialog_response (GtkDialog *dialog,
gint response, gpointer user_data)
{
AnjutaPreferences *pr = ANJUTA_PREFERENCES (user_data);
if (pr)
gtk_widget_hide (GTK_WIDGET (pr));
}
static void
property_destroy (AnjutaProperty *property)
{
g_return_if_fail (property);
if (property->key) g_free (property->key);
if (property->default_value) g_free (property->key);
g_object_unref (G_OBJECT (property->object));
if (property->default_value) g_free (property->default_value);
g_object_unref (property->object);
gconf_client_notify_remove (property->gclient, property->notify_id);
g_free (property);
}
......@@ -861,6 +866,23 @@ update_property_on_change_font (GtkWidget *widget,
g_free (val);
}
static void
unregister_preferences_key (GtkWidget *widget,
gpointer user_data)
{
AnjutaProperty *p;
AnjutaPreferences *pr;
gchar *key;
p = (AnjutaProperty *) user_data;
pr = g_object_get_data (G_OBJECT (widget),
"AnjutaPreferences");
key = g_strdup (p->key);
g_hash_table_remove (pr->priv->properties, key);
g_free (key);
}
static void
get_property (GConfClient *gclient, guint cnxt_id,
GConfEntry *entry, gpointer user_data)
......@@ -949,6 +971,49 @@ register_callbacks (AnjutaPreferences *pr, AnjutaProperty *p)
}
p->notify_id = gconf_client_notify_add (gclient, build_key (p->key),
get_property, p, NULL, NULL);
/* Connect to widget destroy signal so we can automatically unregister
* keys so there aren't any potential conflicts or references to
* nonexistent widgets on subsequent uses of the prefs dialog. */
g_signal_connect (G_OBJECT (p->object), "destroy",
G_CALLBACK (unregister_preferences_key),
p);
}
static gboolean
preferences_foreach_callback (gchar *key, struct _AnjutaProperty *p,
struct _AnjutaPreferencesForeachData *data)
{
if (p->object_type != ANJUTA_PROPERTY_OBJECT_TYPE_MENU)
{
if (data->filter == ANJUTA_PREFERENCES_FILTER_NONE)
return data->callback (data->pr, key, data->callback_data);
else if (p->flags & data->filter)
return data->callback (data->pr, key, data->callback_data);
}
return TRUE;
}
static void
connect_prop_to_object (AnjutaPreferences *pr, AnjutaProperty *p)
{
int gconf_value;
gchar *value;
if (p->data_type == ANJUTA_PROPERTY_DATA_TYPE_BOOL ||
p->data_type == ANJUTA_PROPERTY_DATA_TYPE_INT)
{
gconf_value = anjuta_preferences_get_int (pr, p->key);
value = g_strdup_printf ("%d", gconf_value);
set_property_value_as_string (p, value);
}
else
{
value = anjuta_preferences_get (pr, p->key);
set_property_value_as_string (p, value);
g_free (value);
}
}
......@@ -991,6 +1056,7 @@ anjuta_preferences_register_property_raw (AnjutaPreferences *pr,
p->object_type = object_type;
p->data_type = data_type;
p->key = g_strdup (key);
p->gclient = pr->priv->gclient;
value = gconf_client_get (pr->priv->gclient,
build_key (p->key), NULL);
......@@ -1073,7 +1139,9 @@ anjuta_preferences_register_property_raw (AnjutaPreferences *pr,
p->custom = FALSE;
p->set_property = NULL;
p->get_property = NULL;
pr->priv->properties = g_list_prepend (pr->priv->properties, p);
g_hash_table_insert (pr->priv->properties, g_strdup (key), p);
connect_prop_to_object (pr, p);
register_callbacks (pr, p);
return TRUE;
}
......@@ -1119,6 +1187,7 @@ anjuta_preferences_register_property_custom (AnjutaPreferences *pr,
p->object_type = (AnjutaPropertyObjectType) 0;
p->data_type = data_type;
p->key = g_strdup (key);
p->gclient = pr->priv->gclient;
value = gconf_client_get (pr->priv->gclient,
build_key (p->key), NULL);
......@@ -1179,8 +1248,8 @@ anjuta_preferences_register_property_custom (AnjutaPreferences *pr,
p->flags = flags;
p->set_property = set_property;
p->get_property = get_property;
pr->priv->properties = g_list_prepend (pr->priv->properties, p);
g_hash_table_insert (pr->priv->properties, g_strdup (key), p);
return TRUE;
}
......@@ -1352,64 +1421,17 @@ anjuta_preferences_foreach (AnjutaPreferences *pr,
AnjutaPreferencesCallback callback,
gpointer data)
{
AnjutaProperty *p;
GList *node;
gboolean go_on = TRUE;
struct _AnjutaPreferencesForeachData foreach_data;
g_return_if_fail (ANJUTA_IS_PREFERENCES (pr));
g_return_if_fail (callback != NULL);
foreach_data.pr = pr;
foreach_data.filter = filter;
foreach_data.callback = callback;
foreach_data.callback_data = data;
node = pr->priv->properties;
while (node && go_on)
{
p = node->data;
if (p->object_type != ANJUTA_PROPERTY_OBJECT_TYPE_MENU)
{
if (filter == ANJUTA_PREFERENCES_FILTER_NONE)
go_on = callback (pr, p->key, data);
else if (p->flags & filter)
go_on = callback (pr, p->key, data);
}
node = g_list_next (node);
}
}
static gboolean
on_preferences_dialog_delete_event (GtkDialog *dialog,
GdkEvent *event,
gpointer user_data)
{
gtk_widget_hide (GTK_WIDGET(dialog));
return TRUE;
}
g_hash_table_find (pr->priv->properties,
(GHRFunc) preferences_foreach_callback,
&foreach_data);
static gboolean
preferences_prop_to_objects (AnjutaPreferences *pr)
{
AnjutaProperty *p;
GList *node;
node = pr->priv->properties;
while (node)
{
p = node->data;
if (p->data_type == ANJUTA_PROPERTY_DATA_TYPE_BOOL ||
p->data_type == ANJUTA_PROPERTY_DATA_TYPE_INT)
{
int gconf_value;
gchar *value;
gconf_value = anjuta_preferences_get_int (pr, p->key);
value = g_strdup_printf ("%d", gconf_value);
set_property_value_as_string (p, value);
} else {
gchar *value;
value = anjuta_preferences_get (pr, p->key);
set_property_value_as_string (p, value);
g_free (value);
}
node = g_list_next (node);
}
return TRUE;
}
/**
......@@ -1483,7 +1505,7 @@ anjuta_preferences_add_page (AnjutaPreferences* pr, GladeXML *gxml,
}
image_path = anjuta_res_get_pixmap_file (icon_filename);
pixbuf = gdk_pixbuf_new_from_file (image_path, NULL);
anjuta_preferences_dialog_add_page (ANJUTA_PREFERENCES_DIALOG (pr),
anjuta_preferences_dialog_add_page (ANJUTA_PREFERENCES_DIALOG (pr->priv->prefs_dialog),
glade_widget_name, title, pixbuf, page);
anjuta_preferences_register_all_properties_from_glade_xml (pr, gxml, page);
g_object_unref (page);
......@@ -1491,11 +1513,84 @@ anjuta_preferences_add_page (AnjutaPreferences* pr, GladeXML *gxml,
g_object_unref (pixbuf);
}
void
anjuta_preferences_remove_page (AnjutaPreferences *pr,
const gchar *page_name)
{
if (pr->priv->prefs_dialog)
{
anjuta_preferences_dialog_remove_page (ANJUTA_PREFERENCES_DIALOG (pr->priv->prefs_dialog),
page_name);
}
}
static void
on_preferences_dialog_destroyed (GtkWidget *preferencess_dialog,
AnjutaPreferences *pr)
{
GList *plugins;
GList *current_plugin;
plugins = anjuta_plugin_manager_get_active_plugin_objects (pr->priv->plugin_manager);
current_plugin = plugins;
while (current_plugin)
{
if (IANJUTA_IS_PREFERENCES (current_plugin->data))
{
ianjuta_preferences_unmerge (IANJUTA_PREFERENCES (current_plugin->data),
pr, NULL);
}
current_plugin = g_list_next (current_plugin);
}
g_object_unref (pr->priv->prefs_dialog);
g_list_free (plugins);
pr->priv->prefs_dialog = NULL;
}
GtkWidget *
anjuta_preferences_get_dialog (AnjutaPreferences *pr)
{
GList *plugins;
GList *current_plugin;
if (pr->priv->prefs_dialog)
return pr->priv->prefs_dialog;
else
{
pr->priv->prefs_dialog = anjuta_preferences_dialog_new ();
g_signal_connect (G_OBJECT (pr->priv->prefs_dialog), "destroy",
G_CALLBACK (on_preferences_dialog_destroyed),
pr);
plugins = anjuta_plugin_manager_get_active_plugin_objects (pr->priv->plugin_manager);
current_plugin = plugins;
while (current_plugin)
{
if (IANJUTA_IS_PREFERENCES (current_plugin->data))
{
ianjuta_preferences_merge (IANJUTA_PREFERENCES (current_plugin->data),
pr, NULL);
}
current_plugin = g_list_next (current_plugin);
}
g_list_free (plugins);
return g_object_ref_sink (pr->priv->prefs_dialog);
}
}
static void anjuta_preferences_class_init (AnjutaPreferencesClass *class);
static void anjuta_preferences_instance_init (AnjutaPreferences *pr);
static AnjutaPreferencesDialogClass *parent_class;
GType
anjuta_preferences_get_type ()
{
......@@ -1516,7 +1611,7 @@ anjuta_preferences_get_type ()
(GInstanceInitFunc) anjuta_preferences_instance_init,
NULL /* value_table */
};
obj_type = g_type_register_static (ANJUTA_TYPE_PREFERENCES_DIALOG,
obj_type = g_type_register_static (G_TYPE_OBJECT,
"AnjutaPreferences", &obj_info, 0);
}
return obj_type;
......@@ -1526,88 +1621,49 @@ static void
anjuta_preferences_dispose (GObject *obj)
{
AnjutaPreferences *pr = ANJUTA_PREFERENCES (obj);
if (pr->priv->properties)
{
/* This will release the refs on property objects */
g_list_foreach (pr->priv->properties, (GFunc)property_destroy, NULL);
g_hash_table_destroy (pr->priv->properties);
pr->priv->properties = NULL;
}
GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (obj));
}
static void
anjuta_preferences_instance_init (AnjutaPreferences *pr)
{
pr->priv = g_new0(AnjutaPreferencesPriv, 1);
pr->priv->properties = NULL;
pr->priv = g_new0 (AnjutaPreferencesPriv, 1);
/* DEBUG_PRINT ("Initializing AP Instance"); */
pr->priv->properties = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free,
(GDestroyNotify) property_destroy);
pr->priv->is_showing = FALSE;
pr->priv->gclient = gconf_client_get_default();
gconf_client_add_dir (pr->priv->gclient, GCONF_KEY_PREFIX,
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
/* Add buttons: Close button */
gtk_dialog_add_button (GTK_DIALOG (pr),
GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL);
g_signal_connect (G_OBJECT (pr), "delete_event",
G_CALLBACK (on_preferences_dialog_delete_event), pr);
g_signal_connect (G_OBJECT (pr), "response",
G_CALLBACK (on_preferences_dialog_response), pr);
}
static void
anjuta_preferences_finalize (GObject *obj)
{
AnjutaPreferences *pr = ANJUTA_PREFERENCES (obj);