[planner: 3/61] Simplify gconf to GSettings migration handling




commit 0d07a1211c6e98230e7fd2e167e68c8c6fa11ed0
Author: Mart Raudsepp <leio gentoo org>
Date:   Thu Mar 5 21:44:03 2020 +0200

    Simplify gconf to GSettings migration handling
    
    Just run the tool on startup, as desktops don't do it for us anymore,
    and don't give any feedback as it really is supposed to be completely
    invisible action. gsettings-data-convert takes care of not running
    it multiple times for a user by itself.
    Note that this works only if new schemas and the .convert file are
    installed to the system - meaning if doing local testing, it won't
    work without installing those system-wide (and updating compiled
    schemas) and use the defaults instead; and if then doing that later,
    it'll overwrite the settings again from gconf.

 src/planner-main.c | 76 +++---------------------------------------------------
 1 file changed, 4 insertions(+), 72 deletions(-)
---
diff --git a/src/planner-main.c b/src/planner-main.c
index ee07dece..63a272d1 100644
--- a/src/planner-main.c
+++ b/src/planner-main.c
@@ -46,73 +46,11 @@ static GOptionEntry options[] = {
                { NULL }
        };
 
-static gchar *
-migrate_gconf_settings (const gchar *name)
-{
-       gboolean   needed = TRUE;
-       GError    *error = NULL;
-       GKeyFile  *kf;
-       gchar    **list;
-       gchar     *msg = NULL;
-       gsize      i, n;
-
-       kf = g_key_file_new ();
-
-       g_key_file_load_from_data_dirs (kf, "gsettings-data-convert",
-                                       NULL, G_KEY_FILE_NONE, NULL);
-       list = g_key_file_get_string_list (kf, "State", "converted", &n, NULL);
-
-       if (list) {
-               for (i = 0; i < n; i++)
-                       if (!g_strcmp0 (list[i], name)) {
-                               needed = FALSE;
-                               break;
-                       }
-
-               g_strfreev (list);
-       }
-
-       g_key_file_free (kf);
-
-       if (needed) {
-               g_spawn_command_line_sync ("gsettings-data-convert",
-                                          NULL, NULL, NULL, &error);
-               if (error) {
-                       msg = g_strdup_printf (
-                               _("Could not migrate old GConf settings: %s\n"
-                                 "Please make sure that GConf is installed "
-                                 "and the gsettings-data-convert tool is in "
-                                 "your PATH.\nAlternatively, ignore this "
-                                 "message and convert your old settings "
-                                 "manually."), error->message);
-                       g_error_free (error);
-               } else {
-                       msg = g_strdup (_("Old GConf settings were "
-                                         "migrated successfully."));
-
-                       /* Allow some time for the GSettings backend
-                          to record the changes, otherwise the
-                          default values from the new schema might be
-                          set.  This timeout is still insufficient to
-                          migrate all keys.  */
-                       sleep (1);
-               }
-       }
-
-       return msg;
-}
-
 static void
-show_migration_dialog (GtkWindow *window, gchar *msg)
+migrate_gconf_settings ()
 {
-       GtkWidget *dlg;
-
-       dlg = gtk_message_dialog_new (window, GTK_DIALOG_DESTROY_WITH_PARENT,
-                                     GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
-                                     "%s", msg);
-       g_free (msg);
-       gtk_dialog_run (GTK_DIALOG (dlg));
-       gtk_widget_destroy (dlg);
+       g_spawn_command_line_sync ("gsettings-data-convert",
+                                  NULL, NULL, NULL, NULL);
 }
 
 int
@@ -120,7 +58,6 @@ main (int argc, char **argv)
 {
         GtkWidget       *main_window;
        GError          *error = NULL;
-       gchar           *gconf_migration_msg = NULL;
        gchar           *filename;
        gchar           *locale_dir;
        gint             i;
@@ -147,8 +84,7 @@ main (int argc, char **argv)
 
        /* Migrate configuration if necessary */
        migrate_config_to_xdg_dir ();
-
-       gconf_migration_msg = migrate_gconf_settings ("planner.convert");
+       migrate_gconf_settings ();
 
        filename = mrp_paths_get_image_dir ("gnome-planner.png");
        gtk_window_set_default_icon_from_file (filename, NULL);
@@ -167,10 +103,6 @@ main (int argc, char **argv)
        application = planner_application_new ();
        main_window = planner_application_new_window (application);
 
-       if (gconf_migration_msg)
-               show_migration_dialog (GTK_WINDOW (main_window),
-                                      gconf_migration_msg);
-
        if ((geometry) && !gtk_window_parse_geometry (GTK_WINDOW (main_window), geometry))
                g_warning(_("Invalid geometry string \"%s\"\n"), geometry);
 


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