[gnome-initial-setup] summary: Move stamp file creation to a global function



commit 20266d351694633d125fc2f34d7738e8bbbd60bd
Author: Rui Matos <tiagomatos gmail com>
Date:   Tue Jan 24 19:19:30 2017 +0100

    summary: Move stamp file creation to a global function
    
    This will be useful in other places. Note that the "done" stamp file
    is now created in both existing user and new user modes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777707

 gnome-initial-setup/gnome-initial-setup.c          |   21 ++++++++++++++++
 gnome-initial-setup/gnome-initial-setup.h          |    2 +
 .../pages/summary/gis-summary-page.c               |   26 +-------------------
 3 files changed, 24 insertions(+), 25 deletions(-)
---
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 396bbea..2ec91b9 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -242,3 +242,24 @@ main (int argc, char *argv[])
   g_option_context_free (context);
   return status;
 }
+
+void
+gis_ensure_stamp_files (void)
+{
+  gchar *file;
+  GError *error = NULL;
+
+  file = g_build_filename (g_get_user_config_dir (), "run-welcome-tour", NULL);
+  if (!g_file_set_contents (file, "yes", -1, &error)) {
+      g_warning ("Unable to create %s: %s", file, error->message);
+      g_clear_error (&error);
+  }
+  g_free (file);
+
+  file = g_build_filename (g_get_user_config_dir (), "gnome-initial-setup-done", NULL);
+  if (!g_file_set_contents (file, "yes", -1, &error)) {
+      g_warning ("Unable to create %s: %s", file, error->message);
+      g_clear_error (&error);
+  }
+  g_free (file);
+}
diff --git a/gnome-initial-setup/gnome-initial-setup.h b/gnome-initial-setup/gnome-initial-setup.h
index 6dce853..dc5cf60 100644
--- a/gnome-initial-setup/gnome-initial-setup.h
+++ b/gnome-initial-setup/gnome-initial-setup.h
@@ -35,5 +35,7 @@ typedef struct _GisPage      GisPage;
 #include "gis-page.h"
 #include "gis-keyring.h"
 
+void gis_ensure_stamp_files (void);
+
 #endif /* __GNOME_INITIAL_SETUP_H__ */
 
diff --git a/gnome-initial-setup/pages/summary/gis-summary-page.c 
b/gnome-initial-setup/pages/summary/gis-summary-page.c
index 2d5acf4..1c624d7 100644
--- a/gnome-initial-setup/pages/summary/gis-summary-page.c
+++ b/gnome-initial-setup/pages/summary/gis-summary-page.c
@@ -214,32 +214,9 @@ log_user_in (GisSummaryPage *page)
 }
 
 static void
-add_setup_done_file (void)
-{
-  gchar *gis_done_path;
-  GError *error = NULL;
-
-  gis_done_path = g_build_filename (g_get_user_config_dir (),
-                                    "gnome-initial-setup-done",
-                                    NULL);
-
-  if (!g_file_set_contents (gis_done_path, "yes", -1, &error)) {
-      g_warning ("Unable to create %s: %s", gis_done_path, error->message);
-      g_clear_error (&error);
-  }
-
-  g_free (gis_done_path);
-}
-
-static void
 done_cb (GtkButton *button, GisSummaryPage *page)
 {
-  gchar *file;
-
-  /* the tour is triggered by $XDG_CONFIG_HOME/run-welcome-tour */
-  file = g_build_filename (g_get_user_config_dir (), "run-welcome-tour", NULL);
-  g_file_set_contents (file, "yes", -1, NULL);
-  g_free (file);
+  gis_ensure_stamp_files ();
 
   switch (gis_driver_get_mode (GIS_PAGE (page)->driver))
     {
@@ -248,7 +225,6 @@ done_cb (GtkButton *button, GisSummaryPage *page)
       log_user_in (page);
       break;
     case GIS_DRIVER_MODE_EXISTING_USER:
-      add_setup_done_file ();
       g_application_quit (G_APPLICATION (GIS_PAGE (page)->driver));
     default:
       break;


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