[epiphany] file-herlpers: Add ephy_dot_dir_is_web_application()
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] file-herlpers: Add ephy_dot_dir_is_web_application()
- Date: Mon, 6 Feb 2017 10:54:12 +0000 (UTC)
commit 7545b63aaa508bffb51256d95ca178eb60f876e9
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Mon Feb 6 11:49:03 2017 +0100
file-herlpers: Add ephy_dot_dir_is_web_application()
lib/ephy-file-helpers.c | 45 ++++++++++++++++++++-----
lib/ephy-file-helpers.h | 1 +
lib/ephy-web-app-utils.h | 1 -
src/profile-migrator/ephy-profile-migrator.c | 1 +
4 files changed, 38 insertions(+), 10 deletions(-)
---
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 6b54d9a..99e85fb 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -29,6 +29,7 @@
#include "ephy-profile-utils.h"
#include "ephy-settings.h"
#include "ephy-string.h"
+#include "ephy-web-app-utils.h"
#include <errno.h>
#include <gdk/gdk.h>
@@ -57,14 +58,20 @@
#define EPHY_MIME_TYPE_PERMISSIONS_URI "/org/gnome/epiphany/mime-types-permissions.xml"
-static GHashTable *files = NULL;
-static GHashTable *mime_table = NULL;
+typedef enum {
+ EPHY_PROFILE_DIR_UNKNOWN,
+ EPHY_PROFILE_DIR_DEFAULT,
+ EPHY_PROFILE_DIR_WEB_APP
+} EphyProfileDirType;
-static gboolean keep_directory = FALSE;
-static char *dot_dir = NULL;
-static char *tmp_dir = NULL;
-static GList *del_on_exit = NULL;
-static gboolean is_default_dot_dir = FALSE;
+static GHashTable *files;
+static GHashTable *mime_table;
+
+static gboolean keep_directory;
+static char *dot_dir;
+static char *tmp_dir;
+static GList *del_on_exit;
+static EphyProfileDirType dot_dir_type;
GQuark ephy_file_helpers_error_quark;
@@ -231,7 +238,20 @@ ephy_dot_dir (void)
gboolean
ephy_dot_dir_is_default (void)
{
- return is_default_dot_dir;
+ return dot_dir_type == EPHY_PROFILE_DIR_DEFAULT;
+}
+
+/**
+ * ephy_dot_dir_is_web_application:
+ *
+ * Returns whether the dot directory in use is a web appplication one.
+ *
+ * Returns: %TRUE if it is a web application dot dir, %FALSE for others
+ */
+gboolean
+ephy_dot_dir_is_web_application (void)
+{
+ return dot_dir_type == EPHY_PROFILE_DIR_WEB_APP;
}
/**
@@ -279,6 +299,8 @@ ephy_file_helpers_init (const char *profile_dir,
steal_data_from_profile = flags & EPHY_FILE_HELPERS_STEAL_DATA;
if (profile_dir != NULL && !steal_data_from_profile) {
+ char *basename;
+
if (g_path_is_absolute (profile_dir)) {
dot_dir = g_strdup (profile_dir);
} else {
@@ -286,6 +308,11 @@ ephy_file_helpers_init (const char *profile_dir,
dot_dir = g_file_get_path (file);
g_object_unref (file);
}
+
+ basename = g_path_get_basename (dot_dir);
+ if (g_str_has_prefix (basename, EPHY_WEB_APP_PREFIX))
+ dot_dir_type = EPHY_PROFILE_DIR_WEB_APP;
+ g_free (basename);
} else if (private_profile) {
if (ephy_file_tmp_dir () == NULL) {
g_set_error (error,
@@ -303,7 +330,7 @@ ephy_file_helpers_init (const char *profile_dir,
if (dot_dir == NULL) {
dot_dir = ephy_default_dot_dir ();
- is_default_dot_dir = TRUE;
+ dot_dir_type = EPHY_PROFILE_DIR_DEFAULT;
}
if (flags & EPHY_FILE_HELPERS_ENSURE_EXISTS)
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index c530a92..8800dbf 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -52,6 +52,7 @@ gboolean ephy_file_helpers_init (const char
GError **error);
const char * ephy_dot_dir (void);
gboolean ephy_dot_dir_is_default (void);
+gboolean ephy_dot_dir_is_web_application (void);
char * ephy_default_dot_dir (void);
void ephy_file_helpers_shutdown (void);
char * ephy_file_get_downloads_dir (void);
diff --git a/lib/ephy-web-app-utils.h b/lib/ephy-web-app-utils.h
index 79bdc96..e1476ea 100644
--- a/lib/ephy-web-app-utils.h
+++ b/lib/ephy-web-app-utils.h
@@ -23,7 +23,6 @@
#include <gio/gdesktopappinfo.h>
#include <glib.h>
#include <gtk/gtk.h>
-#include <webkit2/webkit2.h>
G_BEGIN_DECLS
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index 0be662e..9eee01b 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -53,6 +53,7 @@
#include <locale.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <webkit2/webkit2.h>
static int do_step_n = -1;
static int migration_version = -1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]