From 59f252b2d259ea8d2ca40a1620171cb71ab557f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Granjoux?= Date: Mon, 1 Nov 2010 15:41:54 +0100 Subject: [PATCH] Port anjuta-extras from gconf to GSettings --- configure.ac | 3 + plugins/scintilla/Makefile.am | 2 + .../anjuta-editor-scintilla.gschema-part.xml | 15 ++ plugins/scintilla/anjuta-editor-scintilla.ui | 80 ++++---- plugins/scintilla/plugin.c | 25 ++- plugins/scintilla/print.c | 19 +- plugins/scintilla/print.h | 12 +- plugins/scintilla/style-editor.c | 8 +- plugins/scintilla/style-editor.h | 3 +- plugins/scintilla/text_editor.c | 37 ++-- plugins/scintilla/text_editor.h | 84 ++++---- plugins/scintilla/text_editor_prefs.c | 221 +++++++++------------ plugins/scratchbox/Makefile.am | 4 + plugins/scratchbox/anjuta-scratchbox.ui | 4 +- plugins/scratchbox/plugin.c | 46 +++-- scripts/build-schemas.mk | 46 ++--- scripts/builder2schema.pl | 157 ++++++++------- 17 files changed, 386 insertions(+), 380 deletions(-) create mode 100644 plugins/scintilla/anjuta-editor-scintilla.gschema-part.xml rewrite scripts/build-schemas.mk (91%) rewrite scripts/builder2schema.pl (74%) diff --git a/configure.ac b/configure.ac index 9a71e3f..1ab6372 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,9 @@ AC_SUBST(GLIB_REQUIRED) AC_SUBST(GCONF_REQUIRED) AC_SUBST(GNOME_REQUIRED) +dnl GSettings +GLIB_GSETTINGS + dnl *************************************************************************** dnl Check for pkgconfig dnl *************************************************************************** diff --git a/plugins/scintilla/Makefile.am b/plugins/scintilla/Makefile.am index ccf18e2..d3f1054 100644 --- a/plugins/scintilla/Makefile.am +++ b/plugins/scintilla/Makefile.am @@ -68,6 +68,8 @@ libanjuta_editor_la_SOURCES= \ anjuta-pcmark-16.xpm \ anjuta-linemark-16.xpm +prefs_name = org.gnome.anjuta.scintilla +prefs_keyfile = anjuta-editor-scintilla.gschema-part.xml prefs_ui_files = anjuta-editor-scintilla.ui include $(top_srcdir)/scripts/build-schemas.mk diff --git a/plugins/scintilla/anjuta-editor-scintilla.gschema-part.xml b/plugins/scintilla/anjuta-editor-scintilla.gschema-part.xml new file mode 100644 index 0000000..1c2aa94 --- /dev/null +++ b/plugins/scintilla/anjuta-editor-scintilla.gschema-part.xml @@ -0,0 +1,15 @@ + + "" + + + "" + + + "" + + + "" + + + false + diff --git a/plugins/scintilla/anjuta-editor-scintilla.ui b/plugins/scintilla/anjuta-editor-scintilla.ui index e032667..181606d 100644 --- a/plugins/scintilla/anjuta-editor-scintilla.ui +++ b/plugins/scintilla/anjuta-editor-scintilla.ui @@ -118,7 +118,7 @@ 5 5 - + True True Choose autocomplete for single match @@ -131,7 +131,7 @@ - + True True Autocomplete XML/HTML closing tags @@ -149,7 +149,7 @@ True 5 - + True True adjustment1 @@ -217,7 +217,7 @@ - + True Enable comments folding True @@ -230,7 +230,7 @@ - + True Enable python comments folding True @@ -243,7 +243,7 @@ - + True Enable python quoted strings folding True @@ -256,7 +256,7 @@ - + True Enable HTML tags folding True @@ -269,7 +269,7 @@ - + True Compact folding True @@ -282,7 +282,7 @@ - + True True Draw line below folded lines @@ -296,7 +296,7 @@ - + True True Collapse all code folds on file open @@ -323,7 +323,7 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK model1 @@ -381,7 +381,7 @@ 5 5 - + True True Disable syntax highlighting @@ -394,7 +394,7 @@ - + True Enable braces check True @@ -407,7 +407,7 @@ - + True Strip trailling spaces on file save True @@ -420,7 +420,7 @@ - + True Filter extraneous characters in DOS mode True @@ -433,7 +433,7 @@ - + True Wrap bookmarks search around True @@ -453,7 +453,7 @@ 5 5 - + True True adjustment2 @@ -467,7 +467,7 @@ - + True adjustment3 10 @@ -481,7 +481,7 @@ - + True adjustment4 1 @@ -538,7 +538,7 @@ - + True adjustment5 1 @@ -633,7 +633,7 @@ - + True Enable automatic indentation True @@ -647,7 +647,7 @@ - + True True Maintain past Indentation @@ -660,7 +660,7 @@ - + True True Pressing tab inserts indentation @@ -677,7 +677,7 @@ - + True True Pressing backspace un-indents @@ -706,7 +706,7 @@ - + True Indent closing braces True @@ -720,7 +720,7 @@ - + True Indent opening braces True @@ -734,7 +734,7 @@ - + True True Use tabs for indentation @@ -749,7 +749,7 @@ - + True True adjustment6 @@ -867,7 +867,7 @@ - + True True View EOL chars @@ -880,7 +880,7 @@ - + True True View Indentation Guides @@ -908,7 +908,7 @@ - + True True View indentation whitespaces @@ -922,7 +922,7 @@ - + True True View Line Wrap @@ -936,7 +936,7 @@ - + True True Margin Linenum visible @@ -950,7 +950,7 @@ - + True True Margin Marker visible @@ -964,7 +964,7 @@ - + True True Margin Fold visible @@ -1000,7 +1000,7 @@ - + True True adjustment8 @@ -1030,7 +1030,7 @@ - + True True Enable line wrap @@ -1046,7 +1046,7 @@ - + True True Add page header @@ -1068,7 +1068,7 @@ Monochrome True True - preferences_toggle:bool:1:0:print.color + preferences_toggle:bool:1:0:print-color 2 @@ -1078,7 +1078,7 @@ - + True True Colour diff --git a/plugins/scintilla/plugin.c b/plugins/scintilla/plugin.c index a4bac13..2b5f2b1 100644 --- a/plugins/scintilla/plugin.c +++ b/plugins/scintilla/plugin.c @@ -51,6 +51,10 @@ struct _EditorPlugin{ IAnjutaSymbolQuery *query_system; IAnjutaSymbolQuery *query_project; + + /* Settings */ + GSettings *settings; + AnjutaPreferences* prefs; }; struct _EditorPluginClass{ @@ -139,9 +143,9 @@ on_system_symbol_scanned (IAnjutaSymbolManager *manager, guint process, IAnjutaS } static void -on_style_button_clicked(GtkWidget* button, AnjutaPreferences* prefs) +on_style_button_clicked(GtkWidget* button, EditorPlugin *plugin) { - StyleEditor* se = style_editor_new(prefs); + StyleEditor* se = style_editor_new(plugin->prefs, plugin->settings); style_editor_show(se); } @@ -237,7 +241,9 @@ deactivate_plugin (AnjutaPlugin *plugin) static void dispose (GObject *obj) { - /* EditorPlugin *eplugin = ANJUTA_PLUGIN_EDITOR (obj); */ + EditorPlugin *plugin = ANJUTA_PLUGIN_EDITOR (obj); + + g_object_unref (plugin->settings); G_OBJECT_CLASS (parent_class)->dispose (obj); } @@ -252,7 +258,10 @@ finalize (GObject *obj) static void editor_plugin_instance_init (GObject *obj) { - /* EditorPlugin *plugin = ANJUTA_PLUGIN_EDITOR (obj); */ + EditorPlugin *plugin = ANJUTA_PLUGIN_EDITOR (obj); + + plugin->settings = g_settings_new (PREF_SCHEMA); + plugin->prefs = NULL; } static void @@ -275,11 +284,10 @@ itext_editor_factory_new_editor(IAnjutaEditorFactory* factory, GError** error) { AnjutaShell *shell = ANJUTA_PLUGIN (factory)->shell; - AnjutaPreferences *prefs = anjuta_shell_get_preferences (shell, NULL); AnjutaStatus *status = anjuta_shell_get_status (shell, NULL); /* file can be NULL, if we open a buffer, not a file */ gchar* uri = file ? g_file_get_uri (file) : NULL; - IAnjutaEditor* editor = IANJUTA_EDITOR(text_editor_new(status, prefs, shell, + IAnjutaEditor* editor = IANJUTA_EDITOR(text_editor_new(status,shell, uri, filename)); g_free(uri); return editor; @@ -302,11 +310,12 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** g_warning ("Couldn't load builder file: %s", error->message); g_error_free (error); } + plugin->prefs = prefs; plugin->style_button = GTK_WIDGET (gtk_builder_get_object (bxml, "style_button")); g_signal_connect(G_OBJECT(plugin->style_button), "clicked", - G_CALLBACK(on_style_button_clicked), prefs); + G_CALLBACK(on_style_button_clicked), plugin); anjuta_preferences_add_from_builder (prefs, - bxml, "prefs_editor", _("Scintilla Editor"), ICON_FILE); + bxml, plugin->settings, "prefs_editor", _("Scintilla Editor"), ICON_FILE); g_object_unref(bxml); } diff --git a/plugins/scintilla/print.c b/plugins/scintilla/print.c index a6316f2..d9ac169 100644 --- a/plugins/scintilla/print.c +++ b/plugins/scintilla/print.c @@ -908,7 +908,7 @@ anjuta_print_begin (GtkPrintOperation *operation, /* First print function called before displayed print dialog */ static GtkPrintOperation* -anjuta_print_setup (AnjutaPreferences *p, TextEditor *te) +anjuta_print_setup (GSettings *settings, TextEditor *te) { PrintJobInfo *pji; GtkPrintOperation* operation; @@ -920,17 +920,16 @@ anjuta_print_setup (AnjutaPreferences *p, TextEditor *te) /* Set preferences */ pji->print_line_numbers = - anjuta_preferences_get_bool_with_default (p, PRINT_LINENUM_COUNT, 1); + g_settings_get_boolean (settings, PRINT_LINENUM_COUNT); pji->print_header = - anjuta_preferences_get_bool_with_default (p, PRINT_HEADER, 1); + g_settings_get_boolean (settings, PRINT_HEADER); pji->print_color = - anjuta_preferences_get_bool_with_default (p, PRINT_COLOR, 1); + g_settings_get_boolean (settings, PRINT_COLOR); pji->wrapping = - anjuta_preferences_get_bool_with_default (p, PRINT_WRAP, 1); + g_settings_get_boolean (settings, PRINT_WRAP); pji->tab_width = - anjuta_preferences_get_int_with_default (p, TAB_SIZE, 8); - pji->zoom_factor = anjuta_preferences_get_int (te->preferences, - TEXT_ZOOM_FACTOR); + g_settings_get_int (settings, TAB_SIZE); + pji->zoom_factor = g_settings_get_int (settings, TEXT_ZOOM_FACTOR); /* Set progress bar */ @@ -957,7 +956,7 @@ anjuta_print_setup (AnjutaPreferences *p, TextEditor *te) } void -anjuta_print (gboolean preview, AnjutaPreferences *p, TextEditor *te) +anjuta_print (gboolean preview, GSettings *settings, TextEditor *te) { GtkPrintOperation* operation; @@ -968,7 +967,7 @@ anjuta_print (gboolean preview, AnjutaPreferences *p, TextEditor *te) return; } - operation = anjuta_print_setup (p, te); + operation = anjuta_print_setup (settings, te); gtk_print_operation_run (operation, preview ? GTK_PRINT_OPERATION_ACTION_PREVIEW : GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, diff --git a/plugins/scintilla/print.h b/plugins/scintilla/print.h index 6ff61dd..053d045 100644 --- a/plugins/scintilla/print.h +++ b/plugins/scintilla/print.h @@ -27,13 +27,13 @@ G_BEGIN_DECLS -void anjuta_print (gboolean preview, AnjutaPreferences *p, TextEditor *te); +void anjuta_print (gboolean preview, GSettings *settings, TextEditor *te); -#define PRINT_HEADER "print.header" -#define PRINT_WRAP "print.linewrap" -#define PRINT_LINENUM_COUNT "print.linenumber.count" -#define PRINT_LANDSCAPE "print.landscape" -#define PRINT_COLOR "print.color" +#define PRINT_HEADER "print-header" +#define PRINT_WRAP "print-linewrap" +#define PRINT_LINENUM_COUNT "print-linenumber-count" +#define PRINT_LANDSCAPE "print-landscape" +#define PRINT_COLOR "print-color" G_END_DECLS diff --git a/plugins/scintilla/style-editor.c b/plugins/scintilla/style-editor.c index 8b516fe..a64f8fa 100644 --- a/plugins/scintilla/style-editor.c +++ b/plugins/scintilla/style-editor.c @@ -849,8 +849,8 @@ apply_styles (StyleEditor *se) fclose (ofile); g_free (filename); } - anjuta_preferences_set_int (se->prefs, DISABLE_SYNTAX_HILIGHTING, 1); - anjuta_preferences_set_int (se->prefs, DISABLE_SYNTAX_HILIGHTING, 0); + g_settings_set_int (se->settings, DISABLE_SYNTAX_HILIGHTING, 1); + g_settings_set_int (se->settings, DISABLE_SYNTAX_HILIGHTING, 0); } static void @@ -949,7 +949,7 @@ create_style_editor_gui (StyleEditor * se) } StyleEditor * -style_editor_new (AnjutaPreferences *prefs) +style_editor_new (AnjutaPreferences *prefs, GSettings *settings) { StyleEditor *se; se = g_new0 (StyleEditor, 1); @@ -957,6 +957,7 @@ style_editor_new (AnjutaPreferences *prefs) se->props = text_editor_get_props (); se->priv->dialog = NULL; se->prefs = prefs; + se->settings = g_object_ref (settings); return se; } @@ -966,6 +967,7 @@ void style_editor_destroy (StyleEditor *se) if (se->priv->dialog) gtk_widget_destroy (se->priv->dialog); g_free (se->priv); + g_object_unref (se->settings); g_free (se); } diff --git a/plugins/scintilla/style-editor.h b/plugins/scintilla/style-editor.h index 279d5ec..68a8892 100644 --- a/plugins/scintilla/style-editor.h +++ b/plugins/scintilla/style-editor.h @@ -40,10 +40,11 @@ struct _StyleEditor PropsID props; StyleEditorPriv *priv; AnjutaPreferences *prefs; + GSettings *settings; }; StyleEditor * -style_editor_new (AnjutaPreferences *prefs); +style_editor_new (AnjutaPreferences *prefs, GSettings *settings); void style_editor_destroy (StyleEditor *se); diff --git a/plugins/scintilla/text_editor.c b/plugins/scintilla/text_editor.c index 93e1047..c8dfdb5 100644 --- a/plugins/scintilla/text_editor.c +++ b/plugins/scintilla/text_editor.c @@ -125,7 +125,6 @@ text_editor_instance_init (TextEditor *te) te->popup_menu = NULL; te->monitor = NULL; - te->preferences = NULL; te->force_hilite = NULL; te->force_pref = FALSE; te->freeze_count = 0; @@ -144,6 +143,9 @@ text_editor_instance_init (TextEditor *te) te->completion_count = 0; te->completion_string = g_string_sized_new (256); te->completion_finished = FALSE; + + te->settings = g_settings_new (PREF_SCHEMA); + te->docman_settings = g_settings_new (DOCMAN_PREF_SCHEMA); } static GtkWidget * @@ -551,7 +553,7 @@ on_shell_value_changed (TextEditor *te, const char *name) } GtkWidget * -text_editor_new (AnjutaStatus *status, AnjutaPreferences *eo, AnjutaShell *shell, const gchar *uri, const gchar *name) +text_editor_new (AnjutaStatus *status, AnjutaShell *shell, const gchar *uri, const gchar *name) { gint zoom_factor; static guint new_file_count; @@ -560,7 +562,6 @@ text_editor_new (AnjutaStatus *status, AnjutaPreferences *eo, AnjutaShell *shell te->status = status; te->shell = shell; - te->preferences = eo; te->props_base = text_editor_get_props(); if (name && strlen(name) > 0) te->filename = g_strdup(name); @@ -599,7 +600,7 @@ text_editor_new (AnjutaStatus *status, AnjutaPreferences *eo, AnjutaShell *shell text_editor_update_controls (te); /* Apply font zoom separately */ - zoom_factor = anjuta_preferences_get_int (te->preferences, TEXT_ZOOM_FACTOR); + zoom_factor = g_settings_get_int (te->docman_settings, TEXT_ZOOM_FACTOR); /* DEBUG_PRINT ("%s", "Initializing zoom factor to: %d", zoom_factor); */ text_editor_set_zoom_factor (te, zoom_factor); @@ -678,6 +679,8 @@ text_editor_dispose (GObject *obj) te->completion_string = NULL; } te->completion_count = 0; + g_object_unref (te->settings); + g_object_unref (te->docman_settings); G_OBJECT_CLASS (parent_class)->dispose (obj); } @@ -734,7 +737,7 @@ text_editor_hilite_one (TextEditor * te, AnEditorID editor_id) /* syntax highlighting is disabled if te->force_pref && pref is disabled */ if (!te->force_pref || - !anjuta_preferences_get_bool (ANJUTA_PREFERENCES (te->preferences), + !g_settings_get_boolean (te->settings, DISABLE_SYNTAX_HILIGHTING)) { if (te->force_hilite) @@ -1504,7 +1507,7 @@ load_from_file (TextEditor *te, gchar *uri, gchar **err) /* DEBUG_PRINT ("File size and loaded size not matching"); */ } dos_filter = - anjuta_preferences_get_bool (ANJUTA_PREFERENCES (te->preferences), + g_settings_get_boolean (te->settings, DOS_EOL_CHECK); /* Set editor mode */ @@ -1626,7 +1629,7 @@ save_to_file (TextEditor *te, gchar *uri, GError **error) } /* Strip trailing spaces */ - strip = anjuta_preferences_get_bool (te->preferences, + strip = g_settings_get_boolean (te->settings, STRIP_TRAILING_SPACES); if (strip) { @@ -1638,7 +1641,7 @@ save_to_file (TextEditor *te, gchar *uri, GError **error) data[size] = '\n'; ++ size; } - dos_filter = anjuta_preferences_get_bool (te->preferences, + dos_filter = g_settings_get_boolean (te->settings, DOS_EOL_CHECK); editor_mode = scintilla_send_message (SCINTILLA (te->scintilla), SCI_GETEOLMODE, 0, 0); @@ -1705,7 +1708,7 @@ text_editor_load_file (TextEditor * te) scintilla_send_message (SCINTILLA (te->scintilla), SCI_EMPTYUNDOBUFFER, 0, 0); text_editor_set_hilite_type (te, NULL); - if (anjuta_preferences_get_bool (te->preferences, FOLD_ON_OPEN)) + if (g_settings_get_boolean (te->settings, FOLD_ON_OPEN)) { aneditor_command (te->editor_id, ANE_CLOSE_FOLDALL, 0, 0); } @@ -2158,8 +2161,8 @@ void text_editor_set_line_number_width (TextEditor* te) { /* Set line numbers with according to file size */ - if (anjuta_preferences_get_bool_with_default(te->preferences, - "margin.linenumber.visible", FALSE)) + if (g_settings_get_boolean (te->settings, + VIEW_LINENUMBERS_MARGIN)) { int lines, line_number_width; gchar* line_number; @@ -3446,14 +3449,14 @@ static void iprint_print(IAnjutaPrint* print, GError** e) { TextEditor* te = TEXT_EDITOR(print); - anjuta_print(FALSE, te->preferences, te); + anjuta_print(FALSE, te->settings, te); } static void iprint_preview(IAnjutaPrint* print, GError** e) { TextEditor* te = TEXT_EDITOR(print); - anjuta_print(TRUE, te->preferences, te); + anjuta_print(TRUE, te->settings, te); } static void @@ -3499,7 +3502,7 @@ static void izoom_in(IAnjutaEditorZoom* zoom, GError** e) { TextEditor* te = TEXT_EDITOR(zoom); - gint zoom_factor = anjuta_preferences_get_int (te->preferences, + gint zoom_factor = g_settings_get_int (te->docman_settings, TEXT_ZOOM_FACTOR) + 1; if (zoom_factor > MAX_ZOOM_FACTOR) @@ -3507,14 +3510,14 @@ izoom_in(IAnjutaEditorZoom* zoom, GError** e) else if (zoom_factor < MIN_ZOOM_FACTOR) zoom_factor = MIN_ZOOM_FACTOR; - anjuta_preferences_set_int (te->preferences, TEXT_ZOOM_FACTOR, zoom_factor); + g_settings_set_int (te->docman_settings, TEXT_ZOOM_FACTOR, zoom_factor); } static void izoom_out(IAnjutaEditorZoom* zoom, GError** e) { TextEditor* te = TEXT_EDITOR(zoom); - gint zoom_factor = anjuta_preferences_get_int (te->preferences, + gint zoom_factor = g_settings_get_int (te->docman_settings, TEXT_ZOOM_FACTOR) - 1; if (zoom_factor > MAX_ZOOM_FACTOR) @@ -3522,7 +3525,7 @@ izoom_out(IAnjutaEditorZoom* zoom, GError** e) else if (zoom_factor < MIN_ZOOM_FACTOR) zoom_factor = MIN_ZOOM_FACTOR; - anjuta_preferences_set_int (te->preferences, TEXT_ZOOM_FACTOR, zoom_factor); + g_settings_set_int (te->docman_settings, TEXT_ZOOM_FACTOR, zoom_factor); } static void diff --git a/plugins/scintilla/text_editor.h b/plugins/scintilla/text_editor.h index 64281c8..27a06c0 100644 --- a/plugins/scintilla/text_editor.h +++ b/plugins/scintilla/text_editor.h @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -83,7 +82,9 @@ struct _TextEditor glong current_line; - AnjutaPreferences *preferences; + /* Settings */ + GSettings *settings; + GSettings *docman_settings; /* Editor ID and widget for AnEditor */ AnEditorID editor_id; @@ -142,7 +143,7 @@ struct _TextEditorClass GType text_editor_get_type (void); /* New instance of TextEditor */ -GtkWidget* text_editor_new (AnjutaStatus *status, AnjutaPreferences * pr, AnjutaShell* shell, const gchar *uri, +GtkWidget* text_editor_new (AnjutaStatus *status, AnjutaShell* shell, const gchar *uri, const gchar *tab_name); /* Freeze and thaw editor */ @@ -283,53 +284,48 @@ void text_editor_scintilla_command (TextEditor *te, gint command, #define linenum_text_editor_to_scintilla(x) (x-1) #define linenum_scintilla_to_text_editor(x) (x+1) +#define DOCMAN_PREF_SCHEMA "org.gnome.anjuta.document-manager" +#define TEXT_ZOOM_FACTOR "text-zoom-factor" + +#define PREF_SCHEMA "org.gnome.anjuta.scintilla" /* Editor preferences */ -#define DISABLE_SYNTAX_HILIGHTING "disable.syntax.hilighting" -#define SAVE_AUTOMATIC "save.automatic" +#define DISABLE_SYNTAX_HILIGHTING "disable-syntax-hilighting" /* -#define INDENT_AUTOMATIC "indent.automatic" +#define INDENT_AUTOMATIC "indent-automatic" */ -#define USE_TABS "use.tabs" -#define BRACES_CHECK "braces.check" -#define DOS_EOL_CHECK "editor.doseol" -#define WRAP_BOOKMARKS "editor.wrapbookmarks" +#define USE_TABS "use-tabs" +#define BRACES_CHECK "braces-check" +#define DOS_EOL_CHECK "editor-doseol" +#define WRAP_BOOKMARKS "editor-wrapbookmarks" #define TAB_SIZE "tabsize" -#define INDENT_SIZE "indent.size" +#define INDENT_SIZE "indent-size" /* -#define INDENT_OPENING "indent.opening" -#define INDENT_CLOSING "indent.closing" +#define INDENT_OPENING "indent-opening" +#define INDENT_CLOSING "indent-closing" */ -#define INDENT_MAINTAIN "indent.maintain" - -#define TAB_INDENTS "tab.indents" -#define BACKSPACE_UNINDENTS "backspace.unindents" -#define AUTOSAVE_TIMER "autosave.timer" -#define SAVE_SESSION_TIMER "save.session.timer" - -#define AUTOFORMAT_DISABLE "autoformat.disable" -#define AUTOFORMAT_STYLE "autoformat.style" -#define AUTOFORMAT_LIST_STYLE "autoformat.list.style" -#define AUTOFORMAT_OPTS "autoformat.opts" - -#define FOLD_SYMBOLS "fold.symbols" -#define FOLD_UNDERLINE "fold.underline" - -#define STRIP_TRAILING_SPACES "strip.trailing.spaces" -#define FOLD_ON_OPEN "fold.on.open" -#define CARET_FORE_COLOR "caret.fore" -#define CALLTIP_BACK_COLOR "calltip.back" -#define SELECTION_FORE_COLOR "selection.fore" -#define SELECTION_BACK_COLOR "selection.back" - -#define VIEW_LINENUMBERS_MARGIN "margin.linenumber.visible" -#define VIEW_MARKER_MARGIN "margin.marker.visible" -#define VIEW_FOLD_MARGIN "margin.fold.visible" -#define VIEW_INDENTATION_GUIDES "view.indentation.guides" -#define VIEW_WHITE_SPACES "view.whitespace" -#define VIEW_EOL "view.eol" -#define VIEW_LINE_WRAP "view.line.wrap" -#define EDGE_COLUMN "edge.column" -#define TEXT_ZOOM_FACTOR "text.zoom.factor" +#define INDENT_MAINTAIN "indent-maintain" + +#define TAB_INDENTS "tab-indents" +#define BACKSPACE_UNINDENTS "backspace-unindents" + +#define FOLD_SYMBOLS "fold-symbols" +#define FOLD_UNDERLINE "fold-underline" + +#define STRIP_TRAILING_SPACES "strip-trailing-spaces" +#define FOLD_ON_OPEN "fold-on-open" +#define CARET_FORE_COLOR "caret-fore" +#define CALLTIP_BACK_COLOR "calltip-back" +#define SELECTION_FORE_COLOR "selection-fore" +#define SELECTION_BACK_COLOR "selection-back" + +#define VIEW_LINENUMBERS_MARGIN "margin-linenumber-visible" +#define VIEW_MARKER_MARGIN "margin-marker-visible" +#define VIEW_FOLD_MARGIN "margin-fold-visible" +#define VIEW_INDENTATION_GUIDES "view-indentation-guides" +#define VIEW_WHITE_SPACES "view-whitespace" +#define VIEW_EOL "view-eol" +#define VIEW_LINE_WRAP "view-line-wrap" +#define EDGE_COLUMN "edge-column" G_END_DECLS diff --git a/plugins/scintilla/text_editor_prefs.c b/plugins/scintilla/text_editor_prefs.c index df779a3..2f32853 100644 --- a/plugins/scintilla/text_editor_prefs.c +++ b/plugins/scintilla/text_editor_prefs.c @@ -77,396 +77,357 @@ pref_notify (GConfClient *gclient, guint cnxn_id, #endif static gint -set_n_get_prop_int (TextEditor *te, const gchar *key) +set_n_get_prop_int (GSettings *settings, const gchar *key) { gint val; - AnjutaPreferences *pr; - pr = te->preferences; - val = anjuta_preferences_get_int (pr, key); + val = g_settings_get_int (settings, key); sci_prop_set_int_with_key (text_editor_get_props (), key, val); return val; } static gint -set_n_get_prop_bool (TextEditor *te, const gchar *key) +set_n_get_prop_bool (GSettings *settings, const gchar *key) { gboolean val; - AnjutaPreferences *pr; - pr = te->preferences; - val = anjuta_preferences_get_bool (pr, key); + val = g_settings_get_boolean (settings, key); sci_prop_set_int_with_key (text_editor_get_props (), key, val); return val; } static gchar * -set_n_get_prop_string (TextEditor *te, const gchar *key) +set_n_get_prop_string (GSettings *settings, const gchar *key) { gchar *val; - AnjutaPreferences *pr; - pr = te->preferences; - val = anjuta_preferences_get (pr, key); + val = g_settings_get_string (settings, key); sci_prop_set_with_key (text_editor_get_props (), key, val); return val; } static void -on_notify_disable_hilite (AnjutaPreferences* prefs, +on_notify_disable_hilite (GSettings *settings, const gchar* key, - gboolean value, gpointer user_data) { TextEditor *te; te = TEXT_EDITOR (user_data); - set_n_get_prop_bool (te, DISABLE_SYNTAX_HILIGHTING); + set_n_get_prop_bool (settings, key); text_editor_hilite (te, TRUE); } static void -on_notify_zoom_factor(AnjutaPreferences* prefs, +on_notify_zoom_factor(GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gint zoom_factor; te = TEXT_EDITOR (user_data); - zoom_factor = set_n_get_prop_int (te, TEXT_ZOOM_FACTOR); + zoom_factor = set_n_get_prop_int (settings, key); text_editor_set_zoom_factor (te, zoom_factor); g_signal_emit_by_name(G_OBJECT (te), "update_ui"); } static void -on_notify_tab_size (AnjutaPreferences* prefs, +on_notify_tab_size (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gint tab_size; te = TEXT_EDITOR (user_data); - tab_size = set_n_get_prop_int (te, TAB_SIZE); + tab_size = set_n_get_prop_int (settings, key); text_editor_command (te, ANE_SETTABSIZE, tab_size, 0); } static void -on_notify_use_tab_for_indentation(AnjutaPreferences* prefs, +on_notify_use_tab_for_indentation(GSettings* settings, const gchar* key, - gboolean value, gpointer user_data) { TextEditor *te; gboolean use_tabs; te = TEXT_EDITOR (user_data); - use_tabs = set_n_get_prop_bool (te, USE_TABS); + use_tabs = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_SETUSETABFORINDENT, use_tabs, 0); - // text_editor_scintilla_command (te, SCI_SETTABWIDTH, use_tabs, 0); } static void -on_notify_indent_size (AnjutaPreferences* prefs, +on_notify_indent_size (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gint indent_size; te = TEXT_EDITOR (user_data); - indent_size = set_n_get_prop_int (te, INDENT_SIZE); + indent_size = set_n_get_prop_int (settings, key); text_editor_command (te, ANE_SETINDENTSIZE, indent_size, 0); } static void -on_notify_wrap_bookmarks(AnjutaPreferences* prefs, +on_notify_wrap_bookmarks(GSettings* settings, const gchar* key, - gboolean value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, WRAP_BOOKMARKS); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_SETWRAPBOOKMARKS, state, 0); } static void -on_notify_braces_check (AnjutaPreferences* prefs, +on_notify_braces_check (GSettings* settings, const gchar* key, - gboolean value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, BRACES_CHECK); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_SETINDENTBRACESCHECK, state, 0); } static void -on_notify_indent_maintain (AnjutaPreferences* prefs, +on_notify_indent_maintain (GSettings* settings, const gchar* key, - gboolean value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, INDENT_MAINTAIN); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_SETINDENTMAINTAIN, state, 0); } static void -on_notify_tab_indents (AnjutaPreferences* prefs, +on_notify_tab_indents (GSettings* settings, const gchar* key, - gboolean value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, TAB_INDENTS); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_SETTABINDENTS, state, 0); } static void -on_notify_backspace_unindents (AnjutaPreferences* prefs, +on_notify_backspace_unindents (GSettings* settings, const gchar* key, - gboolean value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, BACKSPACE_UNINDENTS); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_SETBACKSPACEUNINDENTS, state, 0); } static void -on_notify_view_eols (AnjutaPreferences* prefs, +on_notify_view_eols (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, VIEW_EOL); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_VIEWEOL, state, 0); } static void -on_notify_view_whitespaces (AnjutaPreferences* prefs, +on_notify_view_whitespaces (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, VIEW_WHITE_SPACES); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_VIEWSPACE, state, 0); } static void -on_notify_view_linewrap (AnjutaPreferences* prefs, +on_notify_view_linewrap (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, VIEW_LINE_WRAP); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_LINEWRAP, state, 0); } static void -on_notify_view_indentation_guides (AnjutaPreferences* prefs, +on_notify_view_indentation_guides (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, VIEW_INDENTATION_GUIDES); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_VIEWGUIDES, state, 0); } static void -on_notify_view_folds (AnjutaPreferences* prefs, +on_notify_view_folds (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, VIEW_FOLD_MARGIN); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_FOLDMARGIN, state, 0); } static void -on_notify_view_markers (AnjutaPreferences* prefs, +on_notify_view_markers (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, VIEW_MARKER_MARGIN); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_SELMARGIN, state, 0); } static void -on_notify_view_linenums (AnjutaPreferences* prefs, +on_notify_view_linenums (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, VIEW_LINENUMBERS_MARGIN); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_LINENUMBERMARGIN, state, 0); /* text_editor_set_line_number_width (te); */ } static void -on_notify_fold_symbols (AnjutaPreferences* prefs, +on_notify_fold_symbols (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gchar *symbols; te = TEXT_EDITOR (user_data); - symbols = set_n_get_prop_string (te, FOLD_SYMBOLS); + symbols = set_n_get_prop_string (settings, key); text_editor_command (te, ANE_SETFOLDSYMBOLS, (long)symbols, 0); g_free (symbols); } static void -on_notify_fold_underline (AnjutaPreferences* prefs, +on_notify_fold_underline (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gboolean state; te = TEXT_EDITOR (user_data); - state = set_n_get_prop_bool (te, FOLD_UNDERLINE); + state = set_n_get_prop_bool (settings, key); text_editor_command (te, ANE_SETFOLDUNDERLINE, state, 0); } static void -on_notify_edge_column (AnjutaPreferences* prefs, +on_notify_edge_column (GSettings* settings, const gchar* key, - gint value, gpointer user_data) { TextEditor *te; gint size; te = TEXT_EDITOR (user_data); - size = set_n_get_prop_int (te, EDGE_COLUMN); + size = set_n_get_prop_int (settings, key); text_editor_command (te, ANE_SETEDGECOLUMN, size, 0); } -#define REGISTER_NOTIFY(key, func, type) \ - notify_id = anjuta_preferences_notify_add_##type (te->preferences, \ - key, func, te, NULL); \ - te->notify_ids = g_list_prepend (te->notify_ids, \ - GUINT_TO_POINTER (notify_id)); +#define REGISTER_NOTIFY(settings, key, func) \ + g_signal_connect (settings, "changed::" key, G_CALLBACK(func), te); void text_editor_prefs_init (TextEditor *te) { gint val; - guint notify_id; + GSettings *settings = te->settings; + GSettings *docman_settings = te->docman_settings; /* Sync prefs from gconf to props */ - set_n_get_prop_int (te, TAB_SIZE); - set_n_get_prop_int (te, TEXT_ZOOM_FACTOR); - set_n_get_prop_int (te, INDENT_SIZE); - set_n_get_prop_bool (te, USE_TABS); - set_n_get_prop_bool (te, DISABLE_SYNTAX_HILIGHTING); - set_n_get_prop_bool (te, WRAP_BOOKMARKS); - set_n_get_prop_bool (te, BRACES_CHECK); + set_n_get_prop_int (settings, TAB_SIZE); + set_n_get_prop_int (docman_settings, TEXT_ZOOM_FACTOR); + set_n_get_prop_int (settings, INDENT_SIZE); + set_n_get_prop_bool (settings, USE_TABS); + set_n_get_prop_bool (settings, DISABLE_SYNTAX_HILIGHTING); + set_n_get_prop_bool (settings, WRAP_BOOKMARKS); + set_n_get_prop_bool (settings, BRACES_CHECK); /* This one is special */ - val = set_n_get_prop_bool (te, INDENT_MAINTAIN); + val = set_n_get_prop_bool (settings, INDENT_MAINTAIN); sci_prop_set_int_with_key (te->props_base, INDENT_MAINTAIN".*", val); - set_n_get_prop_bool (te, TAB_INDENTS); - set_n_get_prop_bool (te, BACKSPACE_UNINDENTS); + set_n_get_prop_bool (settings, TAB_INDENTS); + set_n_get_prop_bool (settings, BACKSPACE_UNINDENTS); - set_n_get_prop_bool (te, VIEW_EOL); - set_n_get_prop_bool (te, VIEW_LINE_WRAP); - set_n_get_prop_bool (te, VIEW_WHITE_SPACES); - set_n_get_prop_bool (te, VIEW_INDENTATION_GUIDES); - set_n_get_prop_bool (te, VIEW_FOLD_MARGIN); - set_n_get_prop_bool (te, VIEW_MARKER_MARGIN); - set_n_get_prop_bool (te, VIEW_LINENUMBERS_MARGIN); - g_free (set_n_get_prop_string (te, FOLD_SYMBOLS)); - set_n_get_prop_bool (te, FOLD_UNDERLINE); - set_n_get_prop_int (te, EDGE_COLUMN); + set_n_get_prop_bool (settings, VIEW_EOL); + set_n_get_prop_bool (settings, VIEW_LINE_WRAP); + set_n_get_prop_bool (settings, VIEW_WHITE_SPACES); + set_n_get_prop_bool (settings, VIEW_INDENTATION_GUIDES); + set_n_get_prop_bool (settings, VIEW_FOLD_MARGIN); + set_n_get_prop_bool (settings, VIEW_MARKER_MARGIN); + set_n_get_prop_bool (settings, VIEW_LINENUMBERS_MARGIN); + g_free (set_n_get_prop_string (settings, FOLD_SYMBOLS)); + set_n_get_prop_bool (settings, FOLD_UNDERLINE); + set_n_get_prop_int (settings, EDGE_COLUMN); /* Register gconf notifications */ - REGISTER_NOTIFY (TAB_SIZE, on_notify_tab_size, int); - REGISTER_NOTIFY (TEXT_ZOOM_FACTOR, on_notify_zoom_factor, int); - REGISTER_NOTIFY (INDENT_SIZE, on_notify_indent_size, int); - REGISTER_NOTIFY (USE_TABS, on_notify_use_tab_for_indentation, bool); - REGISTER_NOTIFY (DISABLE_SYNTAX_HILIGHTING, on_notify_disable_hilite, bool); - /* REGISTER_NOTIFY (INDENT_AUTOMATIC, on_notify_automatic_indentation); */ - REGISTER_NOTIFY (WRAP_BOOKMARKS, on_notify_wrap_bookmarks, bool); - REGISTER_NOTIFY (BRACES_CHECK, on_notify_braces_check, bool); - REGISTER_NOTIFY (INDENT_MAINTAIN, on_notify_indent_maintain, bool); - REGISTER_NOTIFY (TAB_INDENTS, on_notify_tab_indents, bool); - REGISTER_NOTIFY (BACKSPACE_UNINDENTS, on_notify_backspace_unindents, bool); - REGISTER_NOTIFY (VIEW_EOL, on_notify_view_eols, bool); - REGISTER_NOTIFY (VIEW_LINE_WRAP, on_notify_view_linewrap, bool); - REGISTER_NOTIFY (VIEW_WHITE_SPACES, on_notify_view_whitespaces, bool); - REGISTER_NOTIFY (VIEW_INDENTATION_GUIDES, on_notify_view_indentation_guides, bool); - REGISTER_NOTIFY (VIEW_FOLD_MARGIN, on_notify_view_folds, bool); - REGISTER_NOTIFY (VIEW_MARKER_MARGIN, on_notify_view_markers, bool); - REGISTER_NOTIFY (VIEW_LINENUMBERS_MARGIN, on_notify_view_linenums, bool); - REGISTER_NOTIFY (FOLD_SYMBOLS, on_notify_fold_symbols, bool); - REGISTER_NOTIFY (FOLD_UNDERLINE, on_notify_fold_underline, bool); - REGISTER_NOTIFY (EDGE_COLUMN, on_notify_edge_column, int); + REGISTER_NOTIFY (settings, TAB_SIZE, on_notify_tab_size); + REGISTER_NOTIFY (docman_settings, TEXT_ZOOM_FACTOR, on_notify_zoom_factor); + REGISTER_NOTIFY (settings, INDENT_SIZE, on_notify_indent_size); + REGISTER_NOTIFY (settings, USE_TABS, on_notify_use_tab_for_indentation); + REGISTER_NOTIFY (settings, DISABLE_SYNTAX_HILIGHTING, on_notify_disable_hilite); + /* REGISTER_NOTIFY (settings, INDENT_AUTOMATIC, on_notify_automatic_indentation); */ + REGISTER_NOTIFY (settings, WRAP_BOOKMARKS, on_notify_wrap_bookmarks); + REGISTER_NOTIFY (settings, BRACES_CHECK, on_notify_braces_check); + REGISTER_NOTIFY (settings, INDENT_MAINTAIN, on_notify_indent_maintain); + REGISTER_NOTIFY (settings, TAB_INDENTS, on_notify_tab_indents); + REGISTER_NOTIFY (settings, BACKSPACE_UNINDENTS, on_notify_backspace_unindents); + REGISTER_NOTIFY (settings, VIEW_EOL, on_notify_view_eols); + REGISTER_NOTIFY (settings, VIEW_LINE_WRAP, on_notify_view_linewrap); + REGISTER_NOTIFY (settings, VIEW_WHITE_SPACES, on_notify_view_whitespaces); + REGISTER_NOTIFY (settings, VIEW_INDENTATION_GUIDES, on_notify_view_indentation_guides); + REGISTER_NOTIFY (settings, VIEW_FOLD_MARGIN, on_notify_view_folds); + REGISTER_NOTIFY (settings, VIEW_MARKER_MARGIN, on_notify_view_markers); + REGISTER_NOTIFY (settings, VIEW_LINENUMBERS_MARGIN, on_notify_view_linenums); + REGISTER_NOTIFY (settings, FOLD_SYMBOLS, on_notify_fold_symbols); + REGISTER_NOTIFY (settings, FOLD_UNDERLINE, on_notify_fold_underline); + REGISTER_NOTIFY (settings, EDGE_COLUMN, on_notify_edge_column); } void text_editor_prefs_finalize (TextEditor *te) { - GList *node; - node = te->notify_ids; - while (node) - { - anjuta_preferences_notify_remove (te->preferences, - GPOINTER_TO_UINT (node->data)); - node = g_list_next (node); - } - g_list_free (te->notify_ids); - te->notify_ids = NULL; } diff --git a/plugins/scratchbox/Makefile.am b/plugins/scratchbox/Makefile.am index f7fe0b1..eaa12ce 100644 --- a/plugins/scratchbox/Makefile.am +++ b/plugins/scratchbox/Makefile.am @@ -36,6 +36,10 @@ libanjuta_scratchbox_la_SOURCES = \ plugin.c \ plugin.h +prefs_ui_files = anjuta-scratchbox.ui +prefs_name = org.gnome.anjuta.scratchbox +include $(top_srcdir)/scripts/build-schemas.mk + EXTRA_DIST = \ $(plugin_in_files) \ $(anjuta_pixmaps_DATA) \ diff --git a/plugins/scratchbox/anjuta-scratchbox.ui b/plugins/scratchbox/anjuta-scratchbox.ui index 1d5c72b..04ce0f6 100644 --- a/plugins/scratchbox/anjuta-scratchbox.ui +++ b/plugins/scratchbox/anjuta-scratchbox.ui @@ -96,7 +96,7 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK model1 @@ -117,7 +117,7 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK False diff --git a/plugins/scratchbox/plugin.c b/plugins/scratchbox/plugin.c index 4fa2bba..75a1bda 100644 --- a/plugins/scratchbox/plugin.c +++ b/plugins/scratchbox/plugin.c @@ -38,12 +38,13 @@ #define ICON_FILE "anjuta-scratchbox-48.png" #define GLADE_FILE PACKAGE_DATA_DIR"/glade/anjuta-scratchbox.ui" -#define SB_ENTRY "preferences_folder:text:/scratchbox:0:build.scratchbox.path" +#define SB_SCHEMA "org.gnome.anjuta.scratchbox" +#define SB_ENTRY "preferences_folder:text:/scratchbox:0:build-scratchbox-path" #define SB_TARGET_ENTRY "combo_target" -#define SB_SBOX_ENTRY "preferences_combo:text:Sbox1,Sbox2:0:scratchbox.version" +#define SB_SBOX_ENTRY "preferences_combo:text:Sbox1,Sbox2:0:scratchbox-version" -#define PREF_SB_PATH "build.scratchbox.path" -#define PREF_SB_VERSION "scratchbox.version" +#define PREF_SB_PATH "build-scratchbox-path" +#define PREF_SB_VERSION "scratchbox-version" /* Type defintions *---------------------------------------------------------------------------*/ @@ -66,6 +67,9 @@ struct _ScratchboxPlugin gint id; gint combo_element; GString *buffer; + + /* Settings */ + GSettings *settings; }; GtkBuilder *bxml; @@ -177,7 +181,7 @@ on_change_target(GtkComboBox *combo, ScratchboxPlugin *plugin) static void on_update_target(GtkComboBox *combo, ScratchboxPlugin *plugin) { - AnjutaPreferences* prefs; + GSettings* settings; GString* command = g_string_new (NULL); gchar* sbox_commands; gchar* sbox_args; @@ -186,11 +190,10 @@ on_update_target(GtkComboBox *combo, ScratchboxPlugin *plugin) g_return_if_fail (plugin != NULL); - prefs = anjuta_shell_get_preferences (ANJUTA_PLUGIN (plugin)->shell, - NULL); - sb_ver = anjuta_preferences_get(prefs, PREF_SB_VERSION); + settings = plugin->settings; + sb_ver = g_settings_get_string (settings, PREF_SB_VERSION); - sb_dir = anjuta_preferences_get(prefs, PREF_SB_PATH); + sb_dir = g_settings_get_string (settings, PREF_SB_PATH); if (!sb_dir) return; @@ -309,7 +312,7 @@ static void sbox2_environment_override (IAnjutaEnvironment* environment, gchar **dir, gchar ***argvp, gchar ***envp, GError** err) { ScratchboxPlugin *plugin = ANJUTA_PLUGIN_SCRATCHBOX (environment); - AnjutaPreferences* prefs; + GSettings* settings; gchar **new_argv; gchar* sb_dir; int i; @@ -317,8 +320,8 @@ sbox2_environment_override (IAnjutaEnvironment* environment, gchar **dir, gchar if (plugin->target == NULL || !strcmp(plugin->target, "host")) return; - prefs = anjuta_shell_get_preferences (ANJUTA_PLUGIN (plugin)->shell, NULL); - sb_dir = anjuta_preferences_get(prefs, PREF_SB_PATH); + settings = plugin->settings; + sb_dir = g_settings_get_string (settings, PREF_SB_PATH); if (plugin->user_dir) g_free (plugin->user_dir); plugin->user_dir = g_strconcat (sb_dir, G_DIR_SEPARATOR_S, NULL); @@ -345,13 +348,13 @@ static void sbox1_environment_override (IAnjutaEnvironment* environment, gchar **dir, gchar ***argvp, gchar ***envp, GError** err) { ScratchboxPlugin *plugin = ANJUTA_PLUGIN_SCRATCHBOX (environment); - AnjutaPreferences* prefs; + GSettings* settings; gchar* sb_dir; gsize len; - prefs = anjuta_shell_get_preferences (ANJUTA_PLUGIN (plugin)->shell, NULL); + settings = plugin->settings; - sb_dir = anjuta_preferences_get(prefs, PREF_SB_PATH); + sb_dir = g_settings_get_string (settings, PREF_SB_PATH); if (plugin->user_dir) g_free (plugin->user_dir); plugin->user_dir = g_strconcat (sb_dir, G_DIR_SEPARATOR_S, @@ -389,17 +392,17 @@ static gboolean ienvironment_override (IAnjutaEnvironment* environment, gchar **dir, gchar ***argvp, gchar ***envp, GError** err) { ScratchboxPlugin *plugin = ANJUTA_PLUGIN_SCRATCHBOX (environment); - AnjutaPreferences* prefs; + GSettings* settings; gchar* sb_dir; gchar* sb_ver; - prefs = anjuta_shell_get_preferences (ANJUTA_PLUGIN (plugin)->shell, NULL); - sb_dir = anjuta_preferences_get(prefs, PREF_SB_PATH); + settings = plugin->settings; + sb_dir = g_settings_get_string (settings, PREF_SB_PATH); if (!sb_dir) return FALSE; - sb_ver = anjuta_preferences_get(prefs, PREF_SB_VERSION); + sb_ver = g_settings_get_string (settings, PREF_SB_VERSION); if (!strcmp(sb_ver, "Sbox1")) sbox1_environment_override(environment, dir, argvp, envp, err); else @@ -461,7 +464,7 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** plugin->id = anjuta_preferences_get_int(prefs, SB_TARGET_ENTRY); - anjuta_preferences_add_from_builder (prefs, bxml, "Scratchbox", _("Scratchbox"), ICON_FILE); + anjuta_preferences_add_from_builder (prefs, bxml, plugin->settings, "Scratchbox", _("Scratchbox"), ICON_FILE); g_signal_connect(chooser_dir_entry, "current-folder-changed", G_CALLBACK(on_change_directory), plugin); @@ -513,6 +516,7 @@ scratchbox_plugin_instance_init (GObject *obj) plugin->launcher = NULL; plugin->id = 0; plugin->target = NULL; + plugin->settings = g_settings_new (SB_SCHEMA); } /* dispose is used to unref object created with instance_init */ @@ -529,6 +533,8 @@ scratchbox_plugin_dispose (GObject *obj) g_free (plugin->user_dir); plugin->user_dir = NULL; } + + g_object_unref (plugin->settings); G_OBJECT_CLASS (parent_class)->dispose (obj); } diff --git a/scripts/build-schemas.mk b/scripts/build-schemas.mk dissimilarity index 91% index 6a12b14..c9ccaf0 100644 --- a/scripts/build-schemas.mk +++ b/scripts/build-schemas.mk @@ -1,29 +1,17 @@ -# Targets for handing ui-to-GConf schema conversion for prefs keys - -prefs_ui_schemasdir = @GCONF_SCHEMA_FILE_DIR@ -prefs_ui_schemas = $(prefs_ui_files:.ui=.schemas) -prefs_ui_schemas_DATA = $(prefs_ui_schemas) - -%.schemas: %.ui - $(top_srcdir)/scripts/builder2schema.pl $< > $@ - -if GCONF_SCHEMAS_INSTALL -install-data-local: $(prefs_ui_schemas) - for p in $(prefs_ui_schemas) ; do \ - GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p ; \ - done - @killall -1 gconfd-2 || true - -uninstall-local: $(prefs_ui_schemas) - for p in $(prefs_ui_schemas) ; do \ - GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-uninstall-rule $$p ; \ - done - @killall -1 gconfd-2 || true - -else -install-data-local: - -uninstall-local: -endif - -CLEANFILES = $(prefs_ui_schemas) +# Targets for handing ui-to-GConf schema conversion for prefs keys + +prefs_ui_schemas = $(prefs_ui_files:.ui=.gschema.xml) + +# gsettings_SCHEMAS is a list of all the schemas you want to install +gsettings_SCHEMAS = $(prefs_name).gschema.xml + +$(prefs_name).gschema.xml: $(prefs_ui_schemas) + mv -f $< $@ + +%.gschema.xml: %.ui + $(AM_V_GEN)$(top_srcdir)/scripts/builder2schema.pl $< $(prefs_name) $(srcdir)/$(prefs_keyfile) > $@ + +# include the appropriate makefile rules for schema handling +@GSETTINGS_RULES@ + +CLEANFILES = $(prefs_ui_schemas) $(gsettings_SCHEMAS) diff --git a/scripts/builder2schema.pl b/scripts/builder2schema.pl dissimilarity index 74% index f9f9dad..0d9c4df 100755 --- a/scripts/builder2schema.pl +++ b/scripts/builder2schema.pl @@ -1,70 +1,87 @@ -#!/usr/bin/perl - -use XML::Parser; - -%datatypes = ( - "bool" => "bool", - "int" => "int", - "string" => "string", - "text" => "string", - "float" => "float", - "color" => "string", - "font" => "string", - "folder" => "string", - "file" => "string" -); - -%boolean = ( - 0 => "FALSE", - 1 => "TRUE" -); - -$schema_path = "/schemas/apps/anjuta/preferences/"; -$key_path ="/apps/anjuta/preferences/"; - -my $parser = new XML::Parser(Style => "Stream"); -print "\n"; -print "\t\n"; - -$parser->parsefile($ARGV[0]); - -print "\t\n"; -print "\n"; - -sub StartTag { - my $parser = shift; - my $key = shift; - if ($key =~ /object/) { - my $k = $_{"id"}; - if ($k =~ /(preferences_color|entry|font|spin|text|toggle|menu|folder|file):(.*):(.*):(\d):(.*)/) { - - my $type = $2; - my $default = $3; - my $flags = $4; - my $propkey = $5; - - - if ($type =~ /bool/) { - $default = $boolean{$default}; - } - - - - print "\t\t\n"; - print "\t\t\t$schema_path$propkey\n"; - print "\t\t\t$key_path$propkey\n"; - print "\t\t\tanjuta\n"; - print "\t\t\t$datatypes{$type}\n"; - print "\t\t\t$default\n"; - - # Hack to keep gconftool happy - print "\t\t\t\n"; - - print "\t\t\n\n"; - } - } -} - -sub EndTag {} - -sub Text {} +#!/usr/bin/perl + +use XML::Parser; + +%datatypes = ( + "bool" => "b", + "int" => "i", + "string" => "s", + "text" => "s", + "float" => "f", + "color" => "s", + "font" => "s", + "folder" => "s", + "file" => "s" +); + +%boolean = ( + 0 => "false", + 1 => "true" +); + +print "\n"; +print "\t\n"; + +if ($#ARGV == 2) { + open FILE, "<", $ARGV[2] or die $!; + while () { print "\t\t$_"; } +} + +my $parser = new XML::Parser(Style => "Stream"); +$parser->parsefile($ARGV[0]); + +print "\t\n"; +print ""; + +sub StartTag { + my %keys = {}; + my $parser = shift; + my $key = shift; + if ($key =~ /object/) { + my $k = $_{"id"}; + if ($k =~ /(preferences_(color|entry|font|spin|text|toggle|menu|folder|file|combo)):(.*):(.*):(\d):(.*)/) { + my $pref = $2; + my $type = $3; + my $default = $4; + my $flags = $5; + my $propkey = $6; + my $realtype = $datatypes{$type}; + + if (exists $keys{$propkey}) + { + return; + } + else + { + $keys{$propkey} = 1; + } + + if ($type =~ /bool/) { + $default = $boolean{$default}; + } + + + print "\t\t\n"; + if ($pref eq "combo") { + @values = split(',', $default); + print "\t\t\t\n"; + foreach (@values) { + print "\t\t\t\t\n" + } + print "\t\t\t\n"; + print "\t\t\t\"$values[$flags]\"\n"; + } + elsif ($realtype ne "s") { + print "\t\t\t$default\n"; + } + else { + print "\t\t\t\"$default\"\n"; + } + print "\t\t\n"; + } + } +} + +sub EndTag {} + +sub Text {} \ No newline at end of file -- 2.11.4.GIT