[anjuta/gsettings-migration: 51/65] language-support-cpp-java: Ported to GSettings



commit f2b38089b0dee56a01c3bc04d74eb0fe69c4e5a1
Author: Johannes Schmid <jhs gnome org>
Date:   Tue Oct 12 18:08:29 2010 +0200

    language-support-cpp-java: Ported to GSettings

 plugins/language-support-cpp-java/Makefile.am      |    1 +
 .../language-support-cpp-java/cpp-java-assist.c    |   26 ++++++++--------
 .../language-support-cpp-java/cpp-java-assist.h    |    2 +-
 plugins/language-support-cpp-java/plugin.c         |   30 ++++++++++++--------
 plugins/language-support-cpp-java/plugin.h         |    2 +-
 5 files changed, 34 insertions(+), 27 deletions(-)
---
diff --git a/plugins/language-support-cpp-java/Makefile.am b/plugins/language-support-cpp-java/Makefile.am
index 16cdc72..24fe48a 100644
--- a/plugins/language-support-cpp-java/Makefile.am
+++ b/plugins/language-support-cpp-java/Makefile.am
@@ -64,6 +64,7 @@ libanjuta_language_cpp_java_la_LIBADD = \
 	cxxparser/libcxxparser.la
 	
 prefs_ui_files = anjuta-language-cpp-java.ui
+prefs_name = org.gnome.anjuta.cpp
 include $(top_srcdir)/scripts/build-schemas.mk
 
 EXTRA_DIST = \
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.c b/plugins/language-support-cpp-java/cpp-java-assist.c
index cab4e2d..83d89da 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.c
+++ b/plugins/language-support-cpp-java/cpp-java-assist.c
@@ -62,7 +62,7 @@ typedef struct
 } CppJavaAssistTag;
 
 struct _CppJavaAssistPriv {
-	AnjutaPreferences *preferences;
+	GSettings* settings;
 	IAnjutaEditorAssist* iassist;
 	IAnjutaEditorTip* itip;
 
@@ -1090,8 +1090,8 @@ cpp_java_assist_populate (IAnjutaProvider* self, IAnjutaIterable* cursor, GError
 	CppJavaAssist* assist = CPP_JAVA_ASSIST (self);
 	
 	/* Check if we actually want autocompletion at all */
-	if (!anjuta_preferences_get_bool (anjuta_preferences_default (),
-	                                  PREF_AUTOCOMPLETE_ENABLE))
+	if (!g_settings_get_boolean (assist->priv->settings,
+	                             PREF_AUTOCOMPLETE_ENABLE))
 	{
 		cpp_java_assist_none (self, assist);
 		return;
@@ -1109,8 +1109,8 @@ cpp_java_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))
 	{	
 		assist->priv->calltip_active = cpp_java_assist_calltip (assist);
 			
@@ -1184,11 +1184,11 @@ cpp_java_assist_activate (IAnjutaProvider* self, IAnjutaIterable* iter, gpointer
 	if (prop_data->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, " ");
 		
@@ -1218,8 +1218,8 @@ cpp_java_assist_activate (IAnjutaProvider* self, IAnjutaIterable* iter, gpointer
 	{
 		/* 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))	
 			assist->priv->calltip_active = cpp_java_assist_calltip (assist);
 
 	}	
@@ -1332,7 +1332,7 @@ cpp_java_assist_class_init (CppJavaAssistClass *klass)
 CppJavaAssist *
 cpp_java_assist_new (IAnjutaEditor *ieditor,
 					 IAnjutaSymbolManager *isymbol_manager,
-					 AnjutaPreferences *prefs)
+					 GSettings* settings)
 {
 	CppJavaAssist *assist;
 	static IAnjutaSymbolField calltip_fields[] = {
@@ -1355,7 +1355,7 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
 		return NULL;
 	}
 	assist = g_object_new (TYPE_CPP_JAVA_ASSIST, NULL);
-	assist->priv->preferences = prefs;
+	assist->priv->settings = settings;
 
 	/* Create call tip queries */
 	/* Calltip in file */
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.h b/plugins/language-support-cpp-java/cpp-java-assist.h
index 33cc92d..9e053c8 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.h
+++ b/plugins/language-support-cpp-java/cpp-java-assist.h
@@ -64,7 +64,7 @@ struct _CppJavaAssist
 GType cpp_java_assist_get_type (void) G_GNUC_CONST;
 CppJavaAssist *cpp_java_assist_new (IAnjutaEditor *editor,
 									IAnjutaSymbolManager *isymbol_manager,
-									AnjutaPreferences *preferences);
+									GSettings* settings);
 
 G_END_DECLS
 
diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c
index caa3982..75ca34f 100644
--- a/plugins/language-support-cpp-java/plugin.c
+++ b/plugins/language-support-cpp-java/plugin.c
@@ -53,6 +53,7 @@
 
 /* Preferences keys */
 
+#define PREF_SCHEMA "org.gnome.anjuta.cpp"
 #define PREF_INDENT_AUTOMATIC "cpp-indent-automatic"
 #define PREF_INDENT_STATEMENT_SIZE "cpp-indent-statement-size"
 #define PREF_INDENT_BRACE_SIZE "cpp-indent-brace-size"
@@ -67,12 +68,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)
@@ -583,7 +584,7 @@ initialize_indentation_params (CppJavaPlugin *plugin)
 	gboolean line_comment = FALSE;
 	gchar mini_buffer[MINI_BUFFER_SIZE] = {0};
 	
-	plugin->smart_indentation = anjuta_preferences_get_bool (plugin->prefs, PREF_INDENT_AUTOMATIC);
+	plugin->smart_indentation = g_settings_get_boolean (plugin->settings, PREF_INDENT_AUTOMATIC);
 	/* Disable editor intern auto-indent if smart indentation is enabled */
 	ianjuta_editor_set_auto_indent (IANJUTA_EDITOR(plugin->current_editor),
 								    !plugin->smart_indentation, NULL);
@@ -1073,8 +1074,8 @@ get_line_indentation_base (CppJavaPlugin *plugin,
 		else if (point_ch == '(' || point_ch == '[')
 		{
 			line_indent = 0;
-			if (anjuta_preferences_get_bool (plugin->prefs,
-			                                 PREF_INDENT_PARANTHESE_LINEUP))
+			if (g_settings_get_boolean (plugin->settings,
+			                            PREF_INDENT_PARANTHESE_LINEUP))
 			{
 				while (ianjuta_iterable_previous (iter, NULL))
 				{
@@ -1100,8 +1101,8 @@ get_line_indentation_base (CppJavaPlugin *plugin,
 				line_indent = get_line_indentation (editor, line_for_indent);
 				line_indent += extra_indent;
 
-				(*line_indent_spaces) += anjuta_preferences_get_int (plugin->prefs,
-				                                                     PREF_INDENT_PARANTHESE_SIZE);
+				(*line_indent_spaces) += g_settings_get_boolean (plugin->settings,
+				                                                 PREF_INDENT_PARANTHESE_SIZE);
 			}
 			
 			/* Although statement is incomplete at this point, we don't
@@ -1484,7 +1485,7 @@ on_editor_char_inserted_cpp (IAnjutaEditor *editor,
 		}
 	}
 	
-	if (anjuta_preferences_get_bool (plugin->prefs, PREF_BRACE_AUTOCOMPLETION))
+	if (g_settings_get_boolean (plugin->settings, PREF_BRACE_AUTOCOMPLETION))
 	{
 		if (ch == '[' || ch == '(')
 		{
@@ -1628,7 +1629,7 @@ install_support (CppJavaPlugin *lang_plugin)
 					anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
 												IAnjutaSymbolManager,
 												NULL),
-					lang_plugin->prefs);
+					lang_plugin->settings);
 		lang_plugin->assist = assist;
 	}	
 		
@@ -1923,7 +1924,6 @@ cpp_java_plugin_activate_plugin (AnjutaPlugin *plugin)
 		register_stock_icons (plugin);
 	}
 
-	lang_plugin->prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
 	ui = anjuta_shell_get_ui (plugin->shell, NULL);
 	lang_plugin->action_group = 
 		anjuta_ui_add_action_group_entries (ui, "ActionGroupCppJavaAssist",
@@ -1977,7 +1977,11 @@ cpp_java_plugin_finalize (GObject *obj)
 static void
 cpp_java_plugin_dispose (GObject *obj)
 {
+	CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (obj);
 	/* Disposition codes */
+
+	g_object_unref (plugin->settings);
+	
 	G_OBJECT_CLASS (parent_class)->dispose (obj);
 }
 
@@ -1991,6 +1995,7 @@ cpp_java_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
@@ -2039,8 +2044,9 @@ ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
 		g_error_free (error);
 	}
 	anjuta_preferences_add_from_builder (prefs,
-								 plugin->bxml, "preferences", _("C/C++/Java/Vala"),
-								 ICON_FILE);
+	                                     plugin->bxml, plugin->settings,
+	                                     "preferences", _("C/C++/Java/Vala"),
+	                                     ICON_FILE);
 	toggle = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_AUTO));
 	g_signal_connect (toggle, "toggled", G_CALLBACK (on_autocompletion_toggled),
 	                  plugin->bxml);
diff --git a/plugins/language-support-cpp-java/plugin.h b/plugins/language-support-cpp-java/plugin.h
index 140f8ad..4474294 100644
--- a/plugins/language-support-cpp-java/plugin.h
+++ b/plugins/language-support-cpp-java/plugin.h
@@ -40,7 +40,7 @@ struct _CppJavaPlugin {
 	GtkActionGroup *action_group;
 	gint uiid;
 	
-	AnjutaPreferences *prefs;
+	GSettings* settings;
 	gint editor_watch_id;
 	GObject *current_editor;
 	gboolean support_installed;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]