[epiphany] Add ephy_web_application_get_profile_directory()



commit 09bbf1441056fc858db9bca5452bd0ff8e83a1b1
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Thu Sep 1 22:53:55 2011 +0300

    Add ephy_web_application_get_profile_directory()
    
    And factor out some code

 embed/ephy-web-app-utils.c |   28 +++++++++++++++++++++++-----
 embed/ephy-web-app-utils.h |    2 ++
 embed/ephy-web-view.c      |    5 +----
 3 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/embed/ephy-web-app-utils.c b/embed/ephy-web-app-utils.c
index e64eb1a..c1c9856 100644
--- a/embed/ephy-web-app-utils.c
+++ b/embed/ephy-web-app-utils.c
@@ -78,6 +78,27 @@ out:
 }
 
 /**
+ * ephy_web_application_get_directory:
+ * @app_name: the application name
+ *
+ * Gets the directory whre the profile for @app_name is meant
+ * to be stored.
+ *
+ * Returns: (transfer full): A newly allocated string.
+ **/
+char *
+ephy_web_application_get_profile_directory (const char *app_name)
+{
+  char *app_dir, *profile_dir;
+
+  app_dir = g_strconcat (EPHY_WEB_APP_PREFIX, app_name, NULL);
+  profile_dir = g_build_filename (ephy_dot_dir (), app_dir, NULL);
+  g_free (app_dir);
+
+  return profile_dir;
+}
+
+/**
  * ephy_delete_web_application:
  * @name: the name of the web application do delete
  * 
@@ -89,16 +110,14 @@ out:
 gboolean
 ephy_delete_web_application (const char *name)
 {
-  char *app_dir = NULL, *profile_dir = NULL;
+  char *profile_dir = NULL;
   char *desktop_file = NULL, *desktop_path = NULL;
   GFile *profile = NULL, *launcher = NULL;
   gboolean return_value = FALSE;
 
   g_return_val_if_fail (name, FALSE);
 
-  app_dir = g_strconcat (EPHY_WEB_APP_PREFIX, name, NULL);
-  profile_dir = g_build_filename (ephy_dot_dir (), app_dir, NULL);
-
+  profile_dir = ephy_web_application_get_profile_directory (name);
   /* If there's no profile dir for this app, it means it does not
    * exist. */
   if (!g_file_test (profile_dir, G_FILE_TEST_IS_DIR)) {
@@ -125,7 +144,6 @@ out:
   if (profile)
     g_object_unref (profile);
   g_free (profile_dir);
-  g_free (app_dir);
 
   if (launcher)
     g_object_unref (launcher);
diff --git a/embed/ephy-web-app-utils.h b/embed/ephy-web-app-utils.h
index a28ae76..ef8d88f 100644
--- a/embed/ephy-web-app-utils.h
+++ b/embed/ephy-web-app-utils.h
@@ -32,6 +32,8 @@ G_BEGIN_DECLS
 
 gboolean ephy_delete_web_application (const char *name);
 
+char    *ephy_web_application_get_profile_directory (const char *app_name);
+
 G_END_DECLS
 
 #endif
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index ef87f19..30127b8 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -3806,7 +3806,6 @@ create_cookie_jar_for_domain (EphyWebView *view, const char *directory)
 char *
 ephy_web_view_create_web_application (EphyWebView *view, const char *title, GdkPixbuf *icon)
 {
-  char *app_dir;
   char *profile_dir = NULL;
   char *toolbar_path = NULL;
   char *desktop_file_path = NULL;
@@ -3816,9 +3815,7 @@ ephy_web_view_create_web_application (EphyWebView *view, const char *title, GdkP
   /* If there's already a WebApp profile for the contents of this
    * view, do nothing. TODO: create a method to check this and use it
    * to ask the user if she wants to overwrite the existing WebApp. */
-  app_dir = g_strconcat (EPHY_WEB_APP_PREFIX, title, NULL);
-  profile_dir = g_build_filename (ephy_dot_dir (), app_dir, NULL);
-  g_free (app_dir);
+  profile_dir = ephy_web_application_get_profile_directory (title);
   if (g_file_test (profile_dir, G_FILE_TEST_IS_DIR))
     goto out;
 



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