[anjuta] python-support: GSettings migration
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] python-support: GSettings migration
- Date: Fri, 22 Oct 2010 15:25:44 +0000 (UTC)
commit 459370f90107e203d25b25b666f66d3e228e43ca
Author: Johannes Schmid <jhs gnome org>
Date: Fri Oct 22 17:25:19 2010 +0200
python-support: GSettings migration
plugins/Makefile.am | 2 +-
plugins/language-support-python/Makefile.am | 5 +-
plugins/language-support-python/plugin.c | 40 ++++++++++++-------
plugins/language-support-python/plugin.h | 1 +
plugins/language-support-python/python-assist.c | 41 ++++++++++----------
plugins/language-support-python/python-assist.h | 3 +-
.../python.gschema-part.xml | 3 +
7 files changed, 56 insertions(+), 39 deletions(-)
---
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 9f55961..4060b8d 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -22,6 +22,7 @@ SUBDIRS = . \
document-manager \
search \
language-support-cpp-java \
+ language-support-python \
glade \
devhelp \
language-manager \
@@ -36,7 +37,6 @@ SUBDIRS = . \
js-debugger
# language-support-js \
# language-support-vala \
-# language-support-python \
# python-loader
-include $(top_srcdir)/git.mk
diff --git a/plugins/language-support-python/Makefile.am b/plugins/language-support-python/Makefile.am
index e0b818e..f44eee8 100644
--- a/plugins/language-support-python/Makefile.am
+++ b/plugins/language-support-python/Makefile.am
@@ -42,8 +42,9 @@ libpython_plugin_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
libpython_plugin_la_LIBADD = \
$(LIBANJUTA_LIBS)
-prefs_ui_files = $(python_plugin_glade_DATA)
-prefs_keyfile = python-plugin.gschema-part.xml
+prefs_name = org.gnome.anjuta.python
+prefs_ui_files = python-plugin-properties.ui
+prefs_keyfile = python.gschema-part.xml
include $(top_srcdir)/scripts/build-schemas.mk
EXTRA_DIST = \
diff --git a/plugins/language-support-python/plugin.c b/plugins/language-support-python/plugin.c
index 50b9c74..7a61696 100644
--- a/plugins/language-support-python/plugin.c
+++ b/plugins/language-support-python/plugin.c
@@ -64,6 +64,7 @@
/* Preferences keys */
+#define PREF_SCHEMA "org.gnome.anjuta.python"
#define PREF_INDENT_AUTOMATIC "python-indent-automatic"
#define PREF_INDENT_ADAPTIVE "python-indent-adaptive"
#define PREF_INDENT_TAB_INDENTS "python-indent-tab-indents"
@@ -71,7 +72,7 @@
#define PREF_INDENT_BRACE_SIZE "python-indent-brace-size"
#define PREF_NO_ROPE_WARNING "python-no-rope-warning"
-#define PREF_INTERPRETER_PATH "python-interpreter.path"
+#define PREF_INTERPRETER_PATH "python-interpreter-path"
#define TAB_SIZE (ianjuta_editor_get_tabsize (editor, NULL))
@@ -80,12 +81,12 @@
#define INDENT_SIZE \
(plugin->param_statement_indentation >= 0? \
plugin->param_statement_indentation : \
- anjuta_preferences_get_int (plugin->prefs, PREF_INDENT_STATEMENT_SIZE))
+ g_settings_get_int (plugin->settings, PREF_INDENT_STATEMENT_SIZE))
#define BRACE_INDENT \
(plugin->param_brace_indentation >= 0? \
plugin->param_brace_indentation : \
- anjuta_preferences_get_int (plugin->prefs, PREF_INDENT_BRACE_SIZE))
+ g_settings_get_int (plugin->settings, PREF_INDENT_BRACE_SIZE))
#define CASE_INDENT (INDENT_SIZE)
#define LABEL_INDENT (INDENT_SIZE)
@@ -868,7 +869,7 @@ on_editor_char_inserted_cpp (IAnjutaEditor *editor,
iter = ianjuta_iterable_clone (insert_pos, NULL);
/* If autoindent is enabled*/
- if (anjuta_preferences_get_bool (plugin->prefs, PREF_INDENT_AUTOMATIC))
+ if (g_settings_get_boolean (plugin->settings, PREF_INDENT_AUTOMATIC))
{
if (iter_is_newline (iter, ch))
{
@@ -901,7 +902,8 @@ static void
on_check_finished (AnjutaLauncher* launcher,
int child_pid, int exit_status,
gulong time, gpointer user_data)
-{
+{
+ PythonPlugin* plugin = ANJUTA_PLUGIN_PYTHON (user_data);
if (exit_status != 0)
{
GtkWidget* dialog = gtk_dialog_new_with_buttons (_("Python support warning"),
@@ -927,9 +929,8 @@ on_check_finished (AnjutaLauncher* launcher,
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_button)))
{
- anjuta_preferences_set_bool (anjuta_preferences_default (),
- PREF_NO_ROPE_WARNING,
- TRUE);
+ g_settings_get_boolean (plugin->settings,
+ PREF_NO_ROPE_WARNING);
}
gtk_widget_destroy (dialog);
}
@@ -939,12 +940,12 @@ on_check_finished (AnjutaLauncher* launcher,
static void
check_support (PythonPlugin *python_plugin)
{
- if (!anjuta_preferences_get_bool (anjuta_preferences_default (),
- PREF_NO_ROPE_WARNING))
+ if (!g_settings_get_boolean (python_plugin->settings,
+ PREF_NO_ROPE_WARNING))
{
AnjutaLauncher* launcher = anjuta_launcher_new ();
- gchar* python_path = anjuta_preferences_get (anjuta_preferences_default(),
- PREF_INTERPRETER_PATH);
+ gchar* python_path = g_settings_get_string (python_plugin->settings,
+ PREF_INTERPRETER_PATH);
gchar* command = g_strdup_printf ("%s -c \"import rope\"", python_path);
g_signal_connect (launcher, "child-exited",
@@ -1029,7 +1030,9 @@ install_support (PythonPlugin *lang_plugin)
lang_plugin->assist = python_assist_new (iassist,
sym_manager,
docman,
- lang_plugin->prefs, editor_filename, project_root);
+ lang_plugin->settings,
+ editor_filename,
+ project_root);
}
lang_plugin->support_installed = TRUE;
@@ -1322,6 +1325,12 @@ static void
python_plugin_dispose (GObject *obj)
{
/* Disposition codes */
+ PythonPlugin *plugin = (PythonPlugin*)obj;
+
+ if (plugin->settings)
+ g_object_unref (plugin->settings);
+ plugin->settings = NULL;
+
G_OBJECT_CLASS (parent_class)->dispose (obj);
}
@@ -1335,6 +1344,7 @@ python_plugin_instance_init (GObject *obj)
plugin->editor_watch_id = 0;
plugin->uiid = 0;
plugin->assist = NULL;
+ plugin->settings = g_settings_new (PREF_SCHEMA);
}
static void
@@ -1361,7 +1371,9 @@ ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
plugin->bxml = gtk_builder_new();
gtk_builder_add_objects_from_file(plugin->bxml, PROPERTIES_FILE_UI, objects, NULL);
anjuta_preferences_add_from_builder (prefs,
- plugin->bxml, "preferences", _("Python"),
+ plugin->bxml,
+ plugin->settings,
+ "preferences", _("Python"),
ICON_FILE);
}
diff --git a/plugins/language-support-python/plugin.h b/plugins/language-support-python/plugin.h
index 560d46c..41a0836 100644
--- a/plugins/language-support-python/plugin.h
+++ b/plugins/language-support-python/plugin.h
@@ -79,6 +79,7 @@ struct _PythonPlugin{
/* Preferences */
GtkBuilder* bxml;
+ GSettings* settings;
};
struct _PythonPluginClass{
diff --git a/plugins/language-support-python/python-assist.c b/plugins/language-support-python/python-assist.c
index dcc5ac4..f00376a 100644
--- a/plugins/language-support-python/python-assist.c
+++ b/plugins/language-support-python/python-assist.c
@@ -25,6 +25,7 @@
#include <ctype.h>
#include <string.h>
#include <unistd.h>
+#include <glib/gi18n.h>
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/anjuta-launcher.h>
#include <libanjuta/interfaces/ianjuta-file.h>
@@ -39,11 +40,11 @@
#include "python-assist.h"
#include "python-utils.h"
-#define PREF_AUTOCOMPLETE_ENABLE "language.python.code.completion.enable"
-#define PREF_AUTOCOMPLETE_SPACE_AFTER_FUNC "language.python.code.completion.space.after.func"
-#define PREF_AUTOCOMPLETE_BRACE_AFTER_FUNC "language.python.code.completion.brace.after.func"
-#define PREF_CALLTIP_ENABLE "language.python.code.calltip.enable"
-#define PREF_INTERPRETER_PATH "language.python.interpreter.path"
+#define PREF_AUTOCOMPLETE_ENABLE "python-completion-enable"
+#define PREF_AUTOCOMPLETE_SPACE_AFTER_FUNC "python-completion-func-space"
+#define PREF_AUTOCOMPLETE_BRACE_AFTER_FUNC "python-completion-func-brace"
+#define PREF_CALLTIP_ENABLE "python-calltip-enable"
+#define PREF_INTERPRETER_PATH "python-interpreter-path"
#define MAX_COMPLETIONS 30
#define BRACE_SEARCH_LIMIT 500
#define SCOPE_BRACE_JUMP_LIMIT 50
@@ -68,7 +69,7 @@ typedef struct
} PythonAssistTag;
struct _PythonAssistPriv {
- AnjutaPreferences *preferences;
+ GSettings* settings;
IAnjutaSymbolManager* isymbol_manager;
IAnjutaDocumentManager* idocument_manager;
IAnjutaEditorAssist* iassist;
@@ -473,8 +474,8 @@ python_assist_create_word_completion_cache (PythonAssist *assist, IAnjutaIterabl
project = g_get_tmp_dir ();
/* Create rope command and temporary source file */
- interpreter_path = anjuta_preferences_get (assist->priv->preferences,
- PREF_INTERPRETER_PATH);
+ interpreter_path = g_settings_get_string (assist->priv->settings,
+ PREF_INTERPRETER_PATH);
tmp_file = create_tmp_file (source);
g_free (source);
@@ -577,8 +578,8 @@ python_assist_query_calltip (PythonAssist *assist, const gchar *call_context)
if (!project)
project = g_get_tmp_dir ();
- interpreter_path = anjuta_preferences_get (assist->priv->preferences,
- PREF_INTERPRETER_PATH);
+ interpreter_path = g_settings_get_string (assist->priv->settings,
+ PREF_INTERPRETER_PATH);
tmp_file = create_tmp_file (source);
g_free (source);
@@ -790,15 +791,15 @@ python_assist_populate (IAnjutaProvider* self, IAnjutaIterable* cursor, GError**
/* Check for calltip */
if (assist->priv->itip &&
- anjuta_preferences_get_bool (assist->priv->preferences,
- PREF_CALLTIP_ENABLE))
+ g_settings_get_boolean (assist->priv->settings,
+ PREF_CALLTIP_ENABLE))
{
python_assist_calltip (assist);
}
/* Check if we actually want autocompletion at all */
- if (!anjuta_preferences_get_bool (anjuta_preferences_default (),
- PREF_AUTOCOMPLETE_ENABLE))
+ if (!g_settings_get_string (assist->priv->settings,
+ PREF_AUTOCOMPLETE_ENABLE))
{
python_assist_none (self, assist);
return;
@@ -884,11 +885,11 @@ python_assist_activate (IAnjutaProvider* self, IAnjutaIterable* iter, gpointer d
if (tag->is_func)
{
add_space_after_func =
- anjuta_preferences_get_bool (assist->priv->preferences,
- PREF_AUTOCOMPLETE_SPACE_AFTER_FUNC);
+ g_settings_get_boolean (assist->priv->settings,
+ PREF_AUTOCOMPLETE_SPACE_AFTER_FUNC);
add_brace_after_func =
- anjuta_preferences_get_bool (assist->priv->preferences,
- PREF_AUTOCOMPLETE_BRACE_AFTER_FUNC);
+ g_settings_get_boolean (assist->priv->settings,
+ PREF_AUTOCOMPLETE_BRACE_AFTER_FUNC);
if (add_space_after_func)
g_string_append (assistance, " ");
@@ -1002,7 +1003,7 @@ PythonAssist *
python_assist_new (IAnjutaEditorAssist *iassist,
IAnjutaSymbolManager *isymbol_manager,
IAnjutaDocumentManager *idocument_manager,
- AnjutaPreferences *prefs,
+ GSettings* settings,
const gchar *editor_filename,
const gchar *project_root)
{
@@ -1010,7 +1011,7 @@ python_assist_new (IAnjutaEditorAssist *iassist,
assist->priv->isymbol_manager = isymbol_manager;
assist->priv->idocument_manager = idocument_manager;
assist->priv->editor_filename = editor_filename;
- assist->priv->preferences = prefs;
+ assist->priv->settings = settings;
assist->priv->project_root = project_root;
assist->priv->editor=(IAnjutaEditor*)iassist;
python_assist_install (assist, IANJUTA_EDITOR (iassist));
diff --git a/plugins/language-support-python/python-assist.h b/plugins/language-support-python/python-assist.h
index 397690a..b201d77 100644
--- a/plugins/language-support-python/python-assist.h
+++ b/plugins/language-support-python/python-assist.h
@@ -26,7 +26,6 @@
#define _PYTHON_ASSIST_H_
#include <glib-object.h>
-#include <libanjuta/anjuta-preferences.h>
#include <libanjuta/interfaces/ianjuta-editor-assist.h>
#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
#include <libanjuta/interfaces/ianjuta-project-manager.h>
@@ -67,7 +66,7 @@ GType python_assist_get_type (void) G_GNUC_CONST;
PythonAssist *python_assist_new (IAnjutaEditorAssist *assist,
IAnjutaSymbolManager *isymbol_manager,
IAnjutaDocumentManager *idocument_manager,
- AnjutaPreferences *preferences,
+ GSettings* settings,
const gchar *editor_filename,
const gchar *project_root);
diff --git a/plugins/language-support-python/python.gschema-part.xml b/plugins/language-support-python/python.gschema-part.xml
new file mode 100644
index 0000000..e230be5
--- /dev/null
+++ b/plugins/language-support-python/python.gschema-part.xml
@@ -0,0 +1,3 @@
+<key name="python-no-rope-warning" type="b">
+ <default>false</default>
+</key>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]