[recipes] Rename file locations



commit 64de86cb4aae61b2fd2751552df38dfb3d43ae00
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Feb 12 20:05:09 2017 -0500

    Rename file locations
    
    'recipes' is too generic for some, so use 'gnome-recipes' as name
    for the binary and for our filesystem locations. We transition
    data from ~/.local/share/recipes when we find it.
    
    At the same time, avoid the redundant subdirectory in the flatpak
    case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=778531

 configure.ac                      |    2 +-
 data/org.gnome.Recipes.desktop.in |    2 +-
 data/org.gnome.Recipes.service.in |    2 +-
 org.gnome.Recipes.flatpak.json    |    2 +-
 src/Makefile.am                   |   16 ++++++++------
 src/gr-recipe-store.c             |   40 +++++++++++++++++++++++++++++-------
 src/gr-utils.c                    |   16 +++++++++++++-
 src/gr-utils.h                    |    1 +
 8 files changed, 61 insertions(+), 20 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 14719a9..4b46353 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@ AX_IS_RELEASE([micro-version])
 dnl ***********************************************************************
 dnl Initialize autoconf
 dnl ***********************************************************************
-AC_INIT([recipes],[package_version],[bug_report_url])
+AC_INIT([gnome-recipes],[package_version],[bug_report_url])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_SRCDIR([configure.ac])
 AC_CONFIG_AUX_DIR([build-aux])
diff --git a/data/org.gnome.Recipes.desktop.in b/data/org.gnome.Recipes.desktop.in
index 9da2de9..a2c190a 100644
--- a/data/org.gnome.Recipes.desktop.in
+++ b/data/org.gnome.Recipes.desktop.in
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Name=GNOME Recipes
 Comment=GNOME cooks unite!
-Exec=recipes %f
+Exec=gnome-recipes %f
 # Translators: Do NOT translate or transliterate this text (this is an icon file name)!
 Icon=org.gnome.Recipes
 Terminal=false
diff --git a/data/org.gnome.Recipes.service.in b/data/org.gnome.Recipes.service.in
index c19cbb6..3fb63e2 100644
--- a/data/org.gnome.Recipes.service.in
+++ b/data/org.gnome.Recipes.service.in
@@ -1,3 +1,3 @@
 [D-BUS Service]
 Name=org.gnome.Recipes
-Exec=@bindir@/recipes --gapplication-service
+Exec=@bindir@/gnome-recipes --gapplication-service
diff --git a/org.gnome.Recipes.flatpak.json b/org.gnome.Recipes.flatpak.json
index 9e86969..57c1f38 100644
--- a/org.gnome.Recipes.flatpak.json
+++ b/org.gnome.Recipes.flatpak.json
@@ -3,7 +3,7 @@
     "runtime": "org.gnome.Platform",
     "runtime-version": "3.22",
     "sdk": "org.gnome.Sdk",
-    "command": "recipes",
+    "command": "gnome-recipes",
     "finish-args": [
         "--share=ipc",
         "--socket=x11",
diff --git a/src/Makefile.am b/src/Makefile.am
index 34bb38a..a3cbd40 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,14 +1,15 @@
-bin_PROGRAMS = recipes
+bin_PROGRAMS = gnome-recipes
 
 commitid := $(shell $(GIT) describe)
 libgd_info = $(shell cat $(top_srcdir)/libgd.info)
 libglnx_info = $(shell cat $(top_srcdir)/libglnx.info)
 
-recipes_CFLAGS = \
+gnome_recipes_CFLAGS = \
        $(WARN_CFLAGS)                  \
        -Wno-sign-compare               \
        -O0 -ggdb                       \
        $(RECIPES_CFLAGS)               \
+       -DPACKAGE_NAME=\"$(PACKAGE_NAME)\"      \
        -DPKGDATADIR=\"$(pkgdatadir)\"  \
        -DLOCALEDIR=\"$(localedir)\"    \
        -DCOMMIT_ID=\"$(commitid)\"     \
@@ -20,15 +21,16 @@ recipes_CFLAGS = \
        -I "$(top_srcdir)/src"          \
        -I "$(top_builddir)/src"
 
-recipes_LDADD = $(RECIPES_LIBS)                        \
-               -lm                             \
-               $(top_builddir)/libgd/libgd.la
+gnome_recipes_LDADD = \
+       $(RECIPES_LIBS)                 \
+       -lm                             \
+       $(top_builddir)/libgd/libgd.la
 
 if USE_AUTOAR
-recipes_LDADD += $(top_builddir)/libglnx.la
+gnome_recipes_LDADD += $(top_builddir)/libglnx.la
 endif
 
-recipes_SOURCES = \
+gnome_recipes_SOURCES = \
        main.c                  \
        gr-about-dialog.h       \
        gr-about-dialog.c       \
diff --git a/src/gr-recipe-store.c b/src/gr-recipe-store.c
index 8b2d20a..d183986 100644
--- a/src/gr-recipe-store.c
+++ b/src/gr-recipe-store.c
@@ -32,6 +32,7 @@
 #include "gr-images.h"
 #include "gr-app.h"
 
+#include "glnx-shutil.h"
 
 struct _GrRecipeStore
 {
@@ -571,7 +572,7 @@ load_picks (GrRecipeStore *self,
         return TRUE;
 }
 
-static void
+static gboolean
 load_favorites (GrRecipeStore *self,
                 const char    *dir)
 {
@@ -590,7 +591,7 @@ load_favorites (GrRecipeStore *self,
                         g_error ("Failed to load favorites db: %s", error->message);
                 else
                         g_message ("No favorites db at: %s", path);
-                return;
+                return FALSE;
         }
 
         g_message ("Load favorites db: %s", path);
@@ -618,6 +619,8 @@ load_favorites (GrRecipeStore *self,
 
         if (tmp)
                 self->favorite_change = date_time_from_string (tmp);
+
+        return TRUE;
 }
 
 static void
@@ -647,7 +650,7 @@ save_favorites (GrRecipeStore *self)
         }
 }
 
-static void
+static gboolean
 load_shopping (GrRecipeStore *self,
                const char    *dir)
 {
@@ -666,7 +669,7 @@ load_shopping (GrRecipeStore *self,
                         g_error ("Failed to load shopping db: %s", error->message);
                 else
                         g_message ("No shopping db at: %s", path);
-                return;
+                return FALSE;
         }
 
         g_message ("Load shopping db: %s", path);
@@ -700,6 +703,8 @@ load_shopping (GrRecipeStore *self,
 
         if (tmp)
                 self->shopping_change = date_time_from_string (tmp);
+
+        return TRUE;
 }
 
 static void
@@ -731,7 +736,7 @@ save_shopping (GrRecipeStore *self)
         }
 }
 
-static void
+static gboolean
 load_cooked (GrRecipeStore *store,
              const char    *dir)
 {
@@ -750,7 +755,7 @@ load_cooked (GrRecipeStore *store,
                         g_error ("Failed to load cooked db: %s", error->message);
                 else
                         g_message ("No cooked db at: %s", path);
-                return;
+                return FALSE;
         }
 
         g_message ("Load cooked db: %s", path);
@@ -777,6 +782,8 @@ load_cooked (GrRecipeStore *store,
 
                 g_hash_table_insert (store->cooked, g_strdup (name), GINT_TO_POINTER (count));
         }
+
+        return TRUE;
 }
 
 static void
@@ -982,7 +989,7 @@ save_user (GrRecipeStore *self)
         }
 }
 
-static void
+static gboolean
 load_user (GrRecipeStore *self,
            const char    *dir)
 {
@@ -998,7 +1005,7 @@ load_user (GrRecipeStore *self,
                         self->user = g_strdup (g_get_user_name ());
                         save_user (self);
                 }
-                return;
+                return FALSE;
         }
 
         g_message ("Load user id: %s", path);
@@ -1007,6 +1014,8 @@ load_user (GrRecipeStore *self,
 
         if (self->user[strlen (self->user) - 1] == '\n')
                 self->user[strlen (self->user) - 1] = '\0';
+
+        return TRUE;
 }
 
 static void
@@ -1015,6 +1024,7 @@ gr_recipe_store_init (GrRecipeStore *self)
         const char *dir;
         g_autofree char *current_dir = NULL;
         g_autofree char *uninstalled_dir = NULL;
+        g_autoptr(GError) error = NULL;
 
         self->recipes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
         self->chefs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
@@ -1041,6 +1051,20 @@ gr_recipe_store_init (GrRecipeStore *self)
         load_chefs (self, dir, FALSE);
         load_user (self, dir);
 
+        dir = get_old_user_data_dir ();
+        if (load_recipes (self, dir, FALSE))
+                save_recipes (self);
+        if (load_favorites (self, dir))
+                save_favorites (self);
+        if (load_shopping (self, dir))
+                save_favorites (self);
+        if (load_cooked (self, dir))
+                save_cooked (self);
+        if (load_chefs (self, dir, FALSE))
+                save_chefs (self);
+        if (!glnx_shutil_rm_rf_at (-1, dir, NULL, &error))
+                g_message ("Failed to remove %s: %s", dir, error->message);
+
         g_message ("%d recipes loaded", g_hash_table_size (self->recipes));
         g_message ("%d chefs loaded", g_hash_table_size (self->chefs));
 }
diff --git a/src/gr-utils.c b/src/gr-utils.c
index 5af3461..9f6a4c5 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -151,7 +151,10 @@ get_user_data_dir (void)
         static char *dir = NULL;
 
         if (!dir) {
-                dir = g_build_filename (g_get_user_data_dir (), "recipes", NULL);
+                if (in_flatpak_sandbox ())
+                        dir = g_strdup (g_get_user_data_dir ());
+                else
+                        dir = g_build_filename (g_get_user_data_dir (), PACKAGE_NAME, NULL);
                 g_mkdir_with_parents (dir, 0755);
         }
 
@@ -159,6 +162,17 @@ get_user_data_dir (void)
 }
 
 const char *
+get_old_user_data_dir (void)
+{
+        static char *dir = NULL;
+
+        if (!dir)
+                dir = g_build_filename (g_get_user_data_dir (), "recipes", NULL);
+
+        return (const char *)dir;
+}
+
+const char *
 get_pkg_data_dir (void)
 {
         return PKGDATADIR;
diff --git a/src/gr-utils.h b/src/gr-utils.h
index df54b59..7802ddb 100644
--- a/src/gr-utils.h
+++ b/src/gr-utils.h
@@ -39,6 +39,7 @@ char *ensure_rotated_image (const char *path,
 
 const char *get_pkg_data_dir  (void);
 const char *get_user_data_dir (void);
+const char *get_old_user_data_dir (void);
 
 void    container_remove_all (GtkContainer *container);
 


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