Commit ebf39e70 authored by Sébastien Wilmet's avatar Sébastien Wilmet

latexila -> gnome-latex migration: migrate GSettings

The list of GSettings keys didn't change between the latest LaTeXila
version and now. The list has been generated with:

$ gsettings list-recursively org.gnome.gnome-latex | cut -d" " -f1,2 | sort
parent 4e5d8b8f
<!--
When modifying this GSettings schema, don't forget to update the list of
keys in latexila_utils_migrate_latexila_to_gnome_latex_gsettings().
-->
<schemalist>
<schema id="org.gnome.gnome-latex" path="/org/gnome/gnome-latex/">
<child schema="org.gnome.gnome-latex.preferences" name="preferences" />
<child schema="org.gnome.gnome-latex.state" name="state" />
<key name="latexila-to-gnome-latex-migration-done" type="b">
<default>false</default>
</key>
</schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gnome-latex.preferences" path="/org/gnome/gnome-latex/preferences/">
......
......@@ -280,6 +280,7 @@ latexila_utils_join_widgets
latexila_utils_get_pixbuf_from_icon_name
latexila_utils_str_replace
latexila_utils_register_icons
latexila_utils_migrate_latexila_to_gnome_latex_gsettings
</SECTION>
<SECTION>
......
/*
* This file is part of GNOME LaTeX.
*
* Copyright © 2010-2015, 2017 Sébastien Wilmet
* Copyright © 2010-2015, 2017, 2018 Sébastien Wilmet
*
* GNOME LaTeX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -119,6 +119,8 @@ public class LatexilaApp : Gtk.Application
{
hold ();
Latexila.utils_migrate_latexila_to_gnome_latex_gsettings ();
add_action_entries (_app_actions, this);
Latexila.latex_commands_add_action_infos (this);
......
......@@ -6,7 +6,7 @@
* Copyright (C) 2000, 2002 - Chema Celorio, Paolo Maggi
* Copyright (C) 2003-2005 - Paolo Maggi
*
* Copyright (C) 2014, 2015, 2017 - Sébastien Wilmet <swilmet@gnome.org>
* Copyright (C) 2014, 2015, 2017, 2018 - Sébastien Wilmet <swilmet@gnome.org>
*
* GNOME LaTeX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -32,6 +32,7 @@
#include "latexila-utils.h"
#include <string.h>
#include "dh-dconf-migration.h"
#include "latexila-synctex.h"
static gint
......@@ -488,3 +489,95 @@ latexila_utils_join_widgets (GtkWidget *widget_top,
return GTK_WIDGET (vbox);
}
/**
* latexila_utils_migrate_latexila_to_gnome_latex_gsettings:
*
* Migrates the #GSettings values from LaTeXila to GNOME LaTeX, so that users
* don't lose all their settings.
*/
void
latexila_utils_migrate_latexila_to_gnome_latex_gsettings (void)
{
GSettings *settings;
DhDconfMigration *migration;
gint i;
const gchar *keys[] =
{
"preferences/editor/auto-save",
"preferences/editor/auto-save-interval",
"preferences/editor/bracket-matching",
"preferences/editor/create-backup-copy",
"preferences/editor/display-line-numbers",
"preferences/editor/editor-font",
"preferences/editor/forget-no-tabs",
"preferences/editor/highlight-current-line",
"preferences/editor/highlight-misspelled-words",
"preferences/editor/insert-spaces",
"preferences/editor/reopen-files",
"preferences/editor/scheme",
"preferences/editor/spell-checking-language",
"preferences/editor/tabs-size",
"preferences/editor/use-default-font",
"preferences/file-browser/current-directory",
"preferences/file-browser/show-build-files",
"preferences/file-browser/show-hidden-files",
"preferences/latex/automatic-clean",
"preferences/latex/clean-extensions",
"preferences/latex/disabled-default-build-tools",
"preferences/latex/enabled-default-build-tools",
"preferences/latex/interactive-completion",
"preferences/latex/interactive-completion-num",
"preferences/latex/no-confirm-clean",
"preferences/ui/bottom-panel-visible",
"preferences/ui/edit-toolbar-visible",
"preferences/ui/main-toolbar-visible",
"preferences/ui/show-build-badboxes",
"preferences/ui/show-build-warnings",
"preferences/ui/side-panel-component",
"preferences/ui/side-panel-visible",
"state/dialogs/finance/last-shown-date",
"state/dialogs/finance/remind-later",
"state/window/documents",
"state/window/side-panel-size",
"state/window/size",
"state/window/state",
"state/window/structure-paned-position",
"state/window/vertical-paned-position",
NULL
};
settings = g_settings_new ("org.gnome.gnome-latex");
if (g_settings_get_boolean (settings, "latexila-to-gnome-latex-migration-done"))
{
goto out;
}
migration = _dh_dconf_migration_new ();
for (i = 0; keys[i] != NULL; i++)
{
const gchar *cur_key = keys[i];
gchar *cur_glatex_key;
gchar *cur_latexila_key;
cur_glatex_key = g_strconcat ("/org/gnome/gnome-latex/", cur_key, NULL);
cur_latexila_key = g_strconcat ("/org/gnome/latexila/", cur_key, NULL);
_dh_dconf_migration_migrate_key (migration,
cur_glatex_key,
cur_latexila_key,
NULL);
g_free (cur_glatex_key);
g_free (cur_latexila_key);
}
_dh_dconf_migration_free (migration);
g_settings_set_boolean (settings, "latexila-to-gnome-latex-migration-done", TRUE);
out:
g_object_unref (settings);
}
/*
* This file is part of GNOME LaTeX.
*
* Copyright (C) 2014-2015 - Sébastien Wilmet <swilmet@gnome.org>
* Copyright (C) 2014-2015, 2018 - Sébastien Wilmet <swilmet@gnome.org>
*
* GNOME LaTeX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -26,48 +26,50 @@ G_BEGIN_DECLS
/* File utilities */
gchar * latexila_utils_get_shortname (const gchar *filename);
gchar * latexila_utils_get_shortname (const gchar *filename);
gchar * latexila_utils_get_extension (const gchar *filename);
gchar * latexila_utils_get_extension (const gchar *filename);
gchar * latexila_utils_replace_home_dir_with_tilde (const gchar *filename);
gchar * latexila_utils_replace_home_dir_with_tilde (const gchar *filename);
void latexila_utils_file_query_exists_async (GFile *file,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
void latexila_utils_file_query_exists_async (GFile *file,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean latexila_utils_file_query_exists_finish (GFile *file,
GAsyncResult *result);
gboolean latexila_utils_file_query_exists_finish (GFile *file,
GAsyncResult *result);
gboolean latexila_utils_create_parent_directories (GFile *file,
GError **error);
gboolean latexila_utils_create_parent_directories (GFile *file,
GError **error);
void latexila_utils_show_uri (GtkWidget *widget,
const gchar *uri,
guint32 timestamp,
GError **error);
void latexila_utils_show_uri (GtkWidget *widget,
const gchar *uri,
guint32 timestamp,
GError **error);
/* UI utilities */
GtkWidget * latexila_utils_get_dialog_component (const gchar *title,
GtkWidget *widget);
GtkWidget * latexila_utils_get_dialog_component (const gchar *title,
GtkWidget *widget);
GtkWidget * latexila_utils_join_widgets (GtkWidget *widget_top,
GtkWidget *widget_bottom);
GtkWidget * latexila_utils_join_widgets (GtkWidget *widget_top,
GtkWidget *widget_bottom);
GdkPixbuf * latexila_utils_get_pixbuf_from_icon_name (const gchar *icon_name,
GtkIconSize icon_size);
GdkPixbuf * latexila_utils_get_pixbuf_from_icon_name (const gchar *icon_name,
GtkIconSize icon_size);
/* String utilities */
gchar * latexila_utils_str_replace (const gchar *string,
const gchar *search,
const gchar *replacement);
gchar * latexila_utils_str_replace (const gchar *string,
const gchar *search,
const gchar *replacement);
/* Others */
void latexila_utils_register_icons (void);
void latexila_utils_register_icons (void);
void latexila_utils_migrate_latexila_to_gnome_latex_gsettings (void);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment