aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-01-20 05:39:01 +0800
committerChristian Persch <chpe@src.gnome.org>2005-01-20 05:39:01 +0800
commita43ee535a9b483a7e28abae496854c65a5c25703 (patch)
treed601fa8db6f06170ba30c5c2b0110d73f9ef953c /src
parent1f991ceea9103d6e4c364e5584d092b1b866b469 (diff)
downloadgsoc2013-epiphany-a43ee535a9b483a7e28abae496854c65a5c25703.tar
gsoc2013-epiphany-a43ee535a9b483a7e28abae496854c65a5c25703.tar.gz
gsoc2013-epiphany-a43ee535a9b483a7e28abae496854c65a5c25703.tar.bz2
gsoc2013-epiphany-a43ee535a9b483a7e28abae496854c65a5c25703.tar.lz
gsoc2013-epiphany-a43ee535a9b483a7e28abae496854c65a5c25703.tar.xz
gsoc2013-epiphany-a43ee535a9b483a7e28abae496854c65a5c25703.tar.zst
gsoc2013-epiphany-a43ee535a9b483a7e28abae496854c65a5c25703.zip
Show profile name for mozilla bookmarks, so we can distinguish between
2005-01-19 Christian Persch <chpe@cvs.gnome.org> * lib/ephy-file-helpers.c: (ephy_find_file_recursive): * src/bookmarks/ephy-bookmarks-editor.c: (add_bookmarks_files), (add_bookmarks_source), (import_dialog_response_cb), (cmd_bookmarks_import): * src/bookmarks/ephy-bookmarks-import.c: (ephy_bookmarks_import): * src/bookmarks/ephy-bookmarks-import.h: Show profile name for mozilla bookmarks, so we can distinguish between different profiles. Don't show firefox bookmarks as mozilla bookmarks. Fixes bug #143982.
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c126
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c21
-rw-r--r--src/bookmarks/ephy-bookmarks-import.h8
3 files changed, 98 insertions, 57 deletions
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 561ac497a..7af62ced3 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -540,29 +540,74 @@ show_properties_dialog (EphyBookmarksEditor *editor,
(editor->priv->bookmarks, bookmark, GTK_WIDGET (editor));
}
-static void
-add_bookmarks_source (GtkListStore *store,
- const char *desc,
- const char *dir,
- const char *filename,
- int max_depth)
+static GSList *
+add_bookmarks_files (const char *dir,
+ const char *filename,
+ int max_depth)
{
- GtkTreeIter iter;
- GSList *l;
+ GSList *list;
char *path;
path = g_build_filename (g_get_home_dir (), dir, NULL);
- l = ephy_file_find (path, filename, max_depth);
+ list = ephy_file_find (path, filename, max_depth);
g_free (path);
- if (l)
+ return list;
+}
+
+static void
+add_bookmarks_source (const char *file,
+ GtkListStore *store)
+{
+ GtkTreeIter iter;
+ char **path;
+ char *description = NULL;
+ int len, i;
+
+ path = g_strsplit (file, G_DIR_SEPARATOR_S, -1);
+ g_return_if_fail (path != NULL);
+
+ len = g_strv_length (path);
+
+ for (i = len - 2; i >= 0 && description == NULL; --i)
{
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, desc, 1, l->data, -1);
+ const char *p = (const char *) path[i];
+
+ g_return_if_fail (p != NULL);
+
+ if (strcmp (p, "firefox") == 0)
+ {
+ description = g_strdup (_("Firefox"));
+ }
+ else if (strcmp (p, ".firefox") == 0)
+ {
+ description = g_strdup (_("Firebird"));
+ }
+ else if (strcmp (p, ".phoenix") == 0)
+ {
+ description = g_strdup (_("Firebird"));
+ }
+ else if (strcmp (p, ".mozilla") == 0)
+ {
+ description = g_strdup_printf (_("Mozilla \"%s\" profile"), path[i+1]);
+ }
+ else if (strcmp (p, ".galeon") == 0)
+ {
+ description = g_strdup (_("Galeon"));
+ }
+ else if (strcmp (p, "konqueror") == 0)
+ {
+ description = g_strdup (_("Konqueror"));
+ }
}
- g_slist_foreach (l, (GFunc) g_free, NULL);
- g_slist_free (l);
+ if (description != NULL)
+ {
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, description, 1, file, -1);
+
+ g_free (description);
+ }
}
static void
@@ -587,25 +632,23 @@ import_from_file_response_cb (GtkDialog *dialog, gint response,
}
static void
-import_dialog_response_cb (GtkDialog *dialog, gint response,
+import_dialog_response_cb (GtkDialog *dialog,
+ gint response,
EphyBookmarksEditor *editor)
{
if (response == GTK_RESPONSE_OK)
{
GtkTreeIter iter;
- char *filename;
+ const char *filename;
GtkWidget *combo;
GtkTreeModel *model;
- int active;
GValue value = { 0, };
combo = g_object_get_data (G_OBJECT (dialog), "combo_box");
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
- active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
- gtk_tree_model_iter_nth_child (model, &iter, NULL, active);
+ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
gtk_tree_model_get_value (model, &iter, 1, &value);
- filename = g_strdup (g_value_get_string (&value));
- g_value_unset (&value);
+ filename = g_value_get_string (&value);
if (filename == NULL)
{
@@ -619,7 +662,7 @@ import_dialog_response_cb (GtkDialog *dialog, gint response,
ephy_file_chooser_add_mime_filter
(dialog,
- _("Firefox/Firebird/Mozilla bookmarks"),
+ _("Firefox/Mozilla bookmarks"),
"application/x-mozilla-bookmarks", NULL);
ephy_file_chooser_add_mime_filter
@@ -647,7 +690,7 @@ import_dialog_response_cb (GtkDialog *dialog, gint response,
ephy_bookmarks_import (editor->priv->bookmarks, filename);
}
- g_free (filename);
+ g_value_unset (&value);
}
gtk_widget_destroy (GTK_WIDGET (dialog));
@@ -747,16 +790,17 @@ cmd_bookmarks_import (GtkAction *action,
GtkListStore *store;
GtkTreeIter iter;
GtkTreeModel *sortmodel;
+ GSList *files;
dialog = gtk_dialog_new_with_buttons (_("Import Bookmarks"),
- GTK_WINDOW (editor),
- GTK_DIALOG_DESTROY_WITH_PARENT |
- GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- _("I_mport"),
- GTK_RESPONSE_OK,
- NULL);
+ GTK_WINDOW (editor),
+ GTK_DIALOG_DESTROY_WITH_PARENT |
+ GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ _("I_mport"),
+ GTK_RESPONSE_OK,
+ NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
@@ -776,16 +820,16 @@ cmd_bookmarks_import (GtkAction *action,
store = GTK_LIST_STORE (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING));
- add_bookmarks_source (store, _("Firebird"),
- FIREBIRD_BOOKMARKS_DIR, "bookmarks.html", 4);
- add_bookmarks_source (store, _("Firefox"),
- FIREFOX_BOOKMARKS_DIR, "bookmarks.html", 4);
- add_bookmarks_source (store, _("Galeon"),
- GALEON_BOOKMARKS_DIR, "bookmarks.xbel", 0);
- add_bookmarks_source (store, _("Konqueror"),
- KDE_BOOKMARKS_DIR, "bookmarks.xml", 0);
- add_bookmarks_source (store, _("Mozilla"),
- MOZILLA_BOOKMARKS_DIR, "bookmarks.html", 4);
+ files = add_bookmarks_files (FIREFOX_BOOKMARKS_DIR_0, "bookmarks.html", 2);
+ files = g_slist_concat (add_bookmarks_files (FIREFOX_BOOKMARKS_DIR_1, "bookmarks.html", 2), files);
+ /* FIREFOX_BOOKMARKS_DIR_2 is subdir of MOZILLA_BOOKMARKS_DIR, so don't search it twice */
+ files = g_slist_concat (add_bookmarks_files (MOZILLA_BOOKMARKS_DIR, "bookmarks.html", 2), files);
+ files = g_slist_concat (add_bookmarks_files (GALEON_BOOKMARKS_DIR, "bookmarks.xbel", 0), files);
+ files = g_slist_concat (add_bookmarks_files (KDE_BOOKMARKS_DIR, "bookmarks.xml", 0), files);
+
+ g_slist_foreach (files, (GFunc) add_bookmarks_source, store);
+ g_slist_foreach (files, (GFunc) g_free, NULL);
+ g_slist_free (files);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, _("File"), 1, NULL, -1);
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c
index 52fb3386d..bc1a5ed59 100644
--- a/src/bookmarks/ephy-bookmarks-import.c
+++ b/src/bookmarks/ephy-bookmarks-import.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2003, 2004 Marco Pesenti Gritti
- * Copyright (C) 2003, 2004 Christian Persch
+ * Copyright (C) 2003, 2004, 2005 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -68,24 +68,20 @@ gboolean
ephy_bookmarks_import (EphyBookmarks *bookmarks,
const char *filename)
{
- GnomeVFSURI *uri;
const char *type;
gboolean success = FALSE;
if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE;
- uri = gnome_vfs_uri_new (filename);
- type = gnome_vfs_get_mime_type_common (uri);
+ type = gnome_vfs_get_file_mime_type (filename, NULL, FALSE);
- LOG ("Importing bookmarks of type %s", type)
+ LOG ("Importing bookmarks of type %s", type ? type : "(null)")
if (type == NULL)
{
- gnome_vfs_uri_unref (uri);
- return FALSE;
+ g_warning ("Couldn't determine the type of the bookmarks file %s!\n", filename);
}
-
- if (strcmp (type, "application/x-mozilla-bookmarks") == 0)
+ else if (strcmp (type, "application/x-mozilla-bookmarks") == 0)
{
success = ephy_bookmarks_import_mozilla (bookmarks, filename);
}
@@ -99,8 +95,9 @@ ephy_bookmarks_import (EphyBookmarks *bookmarks,
success = ephy_bookmarks_import_rdf (bookmarks, filename);
}
else if (strstr (filename, MOZILLA_BOOKMARKS_DIR) != NULL ||
- strstr (filename, FIREBIRD_BOOKMARKS_DIR) != NULL ||
- strstr (filename, FIREFOX_BOOKMARKS_DIR) != NULL)
+ strstr (filename, FIREFOX_BOOKMARKS_DIR_0) != NULL ||
+ strstr (filename, FIREFOX_BOOKMARKS_DIR_1) != NULL ||
+ strstr (filename, FIREFOX_BOOKMARKS_DIR_2) != NULL)
{
success = ephy_bookmarks_import_mozilla (bookmarks, filename);
}
@@ -111,8 +108,6 @@ ephy_bookmarks_import (EphyBookmarks *bookmarks,
}
/* else FIXME: put up some UI to warn user about unrecognised format? */
- gnome_vfs_uri_unref (uri);
-
return success;
}
diff --git a/src/bookmarks/ephy-bookmarks-import.h b/src/bookmarks/ephy-bookmarks-import.h
index 8938baef7..43e5db551 100644
--- a/src/bookmarks/ephy-bookmarks-import.h
+++ b/src/bookmarks/ephy-bookmarks-import.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004, 2005 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,8 +27,9 @@
G_BEGIN_DECLS
#define MOZILLA_BOOKMARKS_DIR ".mozilla"
-#define FIREBIRD_BOOKMARKS_DIR ".phoenix"
-#define FIREFOX_BOOKMARKS_DIR ".firefox"
+#define FIREFOX_BOOKMARKS_DIR_0 ".phoenix"
+#define FIREFOX_BOOKMARKS_DIR_1 ".firefox"
+#define FIREFOX_BOOKMARKS_DIR_2 ".mozilla/firefox"
#define GALEON_BOOKMARKS_DIR ".galeon"
#define KDE_BOOKMARKS_DIR ".kde/share/apps/konqueror"