summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIulian Radu <iulian.radu67@gmail.com>2016-09-27 19:27:03 +0300
committerIulian Radu <iulian.radu67@gmail.com>2016-09-28 16:15:13 +0300
commit88f3e105fc5f6e6360426098044cf5b7fce8aa69 (patch)
tree3e1ffc4f3fe5e22730b1db9ceb116a07d9b96a30
parent1eaad92c8cbe1c884dd3a7b038839217f5af7346 (diff)
downloadepiphany-88f3e105fc5f6e6360426098044cf5b7fce8aa69.tar.gz
Remove obsolete EphyBookmarks
-rw-r--r--src/Makefile.am7
-rw-r--r--src/bookmarks/Makefile.am101
-rw-r--r--src/bookmarks/ephy-bookmarks.c1578
-rw-r--r--src/bookmarks/ephy-bookmarks.h134
-rw-r--r--src/ephy-location-controller.c194
-rw-r--r--src/ephy-main.c2
-rw-r--r--src/ephy-shell.c17
-rw-r--r--src/ephy-shell.h3
-rw-r--r--src/ephy-window.c1
-rw-r--r--src/epiphany.gresource.xml3
-rw-r--r--src/prefs-dialog.c40
-rw-r--r--src/resources/bookmark-properties.ui158
-rw-r--r--src/resources/epiphany-bookmark-editor-ui.xml58
-rw-r--r--src/resources/epiphany-ui.xml0
-rw-r--r--src/window-commands.c24
-rw-r--r--src/window-commands.h3
-rw-r--r--tests/ephy-bookmarks-test.c128
17 files changed, 5 insertions, 2446 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index dd996909e..f617a2fc6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = bookmarks . search-provider profile-migrator
+SUBDIRS = . search-provider profile-migrator
pkglib_LTLIBRARIES = libephymain.la
@@ -81,7 +81,6 @@ libephymain_la_CPPFLAGS = \
-I$(top_srcdir)/lib/egg \
-I$(top_srcdir)/lib/history \
-I$(top_srcdir)/lib/widgets \
- -I$(top_srcdir)/src/bookmarks \
-I$(top_srcdir)/gvdb \
-DLOADER_DIR=\""$(pkglibdir)/$(EPIPHANY_MAJOR)/loaders"\" \
-DDATADIR=\""$(pkgdatadir)"\" \
@@ -104,7 +103,6 @@ libephymain_la_LDFLAGS = \
$(WARN_LDFLAGS) -avoid-version -no-undefined
libephymain_la_LIBADD = \
- $(top_builddir)/src/bookmarks/libephybookmarks.la \
$(top_builddir)/embed/libephyembed.la \
$(top_builddir)/lib/widgets/libephywidgets.la \
$(top_builddir)/lib/libephymisc.la \
@@ -122,7 +120,6 @@ libephymain_la_LIBADD = \
RESOURCE_FILES = \
resources/about.css \
- resources/bookmark-properties.ui \
resources/channel-insecure-symbolic.png \
resources/computer-fail-symbolic.png \
resources/clear-data-dialog.ui \
@@ -130,7 +127,6 @@ RESOURCE_FILES = \
resources/encoding-dialog.ui \
resources/encoding-row.ui \
resources/epiphany-application-menu.ui \
- resources/epiphany-bookmark-editor-ui.xml \
resources/epiphany.css \
resources/error.html \
resources/gtk/menus.ui \
@@ -180,7 +176,6 @@ epiphany_CPPFLAGS = \
-I$(top_srcdir)/lib/history \
-I$(top_srcdir)/lib/widgets \
-I$(top_builddir)/lib/widgets \
- -I$(top_srcdir)/src/bookmarks \
-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
-DLOCALEDIR=\"$(localedir)\" \
$(GLIB_CFLAGS) \
diff --git a/src/bookmarks/Makefile.am b/src/bookmarks/Makefile.am
deleted file mode 100644
index 1c00b5ce8..000000000
--- a/src/bookmarks/Makefile.am
+++ /dev/null
@@ -1,101 +0,0 @@
-noinst_LTLIBRARIES = libephybookmarks.la
-
-TYPES_H_FILES = \
- ephy-bookmarks.h
-
-libephybookmarks_la_SOURCES = \
- ephy-bookmarks.c \
- ephy-bookmarks.h
-
-nodist_libephybookmarks_la_SOURCES = \
- $(BUILT_SOURCES)
-
-BUILT_SOURCES = $(TYPES_SOURCE)
-
-TYPES_SOURCE = \
- ephy-bookmarks-type-builtins.c \
- ephy-bookmarks-type-builtins.h
-
-stamp_files = \
- stamp-ephy-bookmarks-type-builtins.c \
- stamp-ephy-bookmarks-type-builtins.h
-
-ephy-bookmarks-type-builtins.c: stamp-ephy-bookmarks-type-builtins.c Makefile
- @true
-stamp-ephy-bookmarks-type-builtins.c: Makefile $(TYPES_H_FILES)
- $(AM_V_GEN) $(GLIB_MKENUMS) \
- --fhead "#include <config.h>\n\n" \
- --fhead "#include \"ephy-bookmarks-type-builtins.h\"\n\n" \
- --fprod "\n/* enumerations from \"@filename@\" */" \
- --fprod "\n#include \"@filename@\"" \
- --vhead "GType\n@enum_name@_get_type (void)\n{\n" \
- --vhead " static GType type = 0;\n\n" \
- --vhead " if (G_UNLIKELY (type == 0))\n {\n" \
- --vhead " static const G@Type@Value _@enum_name@_values[] = {" \
- --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
- --vtail " { 0, NULL, NULL }\n };\n\n" \
- --vtail " type = g_@type@_register_static (\"@EnumName@\", _@enum_name@_values);\n }\n\n" \
- --vtail " return type;\n}\n\n" \
- $(filter-out $<,$^) > xgen-$(@F) \
- && ( cmp -s xgen-$(@F) $(@F:stamp-%=%) || cp xgen-$(@F) $(@F:stamp-%=%) ) \
- && rm -f xgen-$(@F) \
- && echo timestamp > $(@F)
-
-ephy-bookmarks-type-builtins.h: stamp-ephy-bookmarks-type-builtins.h Makefile
- @true
-stamp-ephy-bookmarks-type-builtins.h: Makefile $(TYPES_H_FILES)
- $(AM_V_GEN) $(GLIB_MKENUMS) \
- --fhead "#ifndef EPHY_BOOKMARKS_TYPE_BUILTINS_H\n" \
- --fhead "#define EPHY_BOOKMARKS_TYPE_BUILTINS_H 1\n\n" \
- --fhead "#include <glib-object.h>\n\n" \
- --fhead "G_BEGIN_DECLS\n\n" \
- --ftail "G_END_DECLS\n\n" \
- --ftail "#endif /* EPHY_TYPE_BUILTINS_H */\n" \
- --fprod "\n/* --- @filename@ --- */" \
- --eprod "#define EPHY_TYPE_@ENUMSHORT@ @enum_name@_get_type()\n" \
- --eprod "GType @enum_name@_get_type (void);\n" \
- $(filter-out $<,$^) > xgen-$(@F) \
- && ( cmp -s xgen-$(@F) $(@F:stamp-%=%) || cp xgen-$(@F) $(@F:stamp-%=%) ) \
- && rm -f xgen-$(@F) \
- && echo timestamp > $(@F)
-
-libephybookmarks_la_CFLAGS = \
- $(WARN_CFLAGS)
-
-libephybookmarks_la_CPPFLAGS = \
- -I$(top_builddir)/lib \
- -I$(top_builddir)/lib/widgets \
- -I$(top_srcdir)/lib \
- -I$(top_srcdir)/src \
- -I$(top_srcdir)/embed \
- -I$(top_srcdir)/lib/widgets \
- -I$(top_srcdir)/lib/history \
- -I$(top_srcdir)/lib/egg \
- -DPKGDATADIR=\"$(pkgdatadir)\" \
- $(AVAHI_CLIENT_CFLAGS) \
- $(AVAHI_GOBJECT_CFLAGS) \
- $(GDK_CFLAGS) \
- $(GIO_CFLAGS) \
- $(GLIB_CFLAGS) \
- $(GTK_CFLAGS) \
- $(LIBXML_CFLAGS) \
- $(LIBXSLT_CFLAGS) \
- $(WEBKIT2GTK_CFLAGS)
-
-libephybookmarks_la_LDFLAGS = \
- $(WARN_LDFLAGS)
-
-libephybookmarks_la_LIBADD = \
- $(AVAHI_CLIENT_LIBS) \
- $(AVAHI_GOBJECT_LIBS) \
- $(GDK_LIBS) \
- $(GIO_LIBS) \
- $(GLIB_LIBS) \
- $(GTK_LIBS) \
- $(LIBXML_LIBS) \
- $(LIBXSLT_LIBS) \
- $(WEBKIT2GTK_LIBS)
-
-CLEANFILES = $(stamp_files) $(BUILT_SOURCES)
-
--include $(top_srcdir)/git.mk
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
deleted file mode 100644
index 26ea6de92..000000000
--- a/src/bookmarks/ephy-bookmarks.c
+++ /dev/null
@@ -1,1578 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * Copyright © 2002-2004 Marco Pesenti Gritti
- * Copyright © 2003, 2004 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
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-#include "ephy-bookmarks.h"
-
-#include "ephy-bookmarks-type-builtins.h"
-#include "ephy-debug.h"
-#include "ephy-embed-shell.h"
-#include "ephy-file-helpers.h"
-#include "ephy-history-service.h"
-#include "ephy-node-common.h"
-#include "ephy-prefs.h"
-#include "ephy-profile-utils.h"
-#include "ephy-settings.h"
-#include "ephy-shell.h"
-#include "ephy-signal-accumulator.h"
-#include "ephy-tree-model-node.h"
-
-#include <avahi-common/error.h>
-#include <avahi-gobject/ga-client.h>
-#include <avahi-gobject/ga-enums.h>
-#include <avahi-gobject/ga-service-browser.h>
-#include <avahi-gobject/ga-service-resolver.h>
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-#include <string.h>
-
-#define EPHY_BOOKMARKS_XML_ROOT "ephy_bookmarks"
-#define EPHY_BOOKMARKS_XML_VERSION "1.03"
-#define BOOKMARKS_SAVE_DELAY 3 /* seconds */
-#define UPDATE_URI_DATA_KEY "updated-uri"
-
-static const char zeroconf_protos[3][6] =
-{
- "http",
- "https",
- "ftp"
-};
-
-struct _EphyBookmarks {
- GObject parent_instance;
-
- gboolean init_defaults;
- gboolean dirty;
- guint save_timeout_id;
- char *xml_file;
- char *rdf_file;
- EphyNodeDb *db;
- EphyNode *bookmarks;
- EphyNode *keywords;
- EphyNode *notcategorized;
- EphyNode *smartbookmarks;
- EphyNode *lower_fav;
- double lower_score;
-
- /* Local sites */
- EphyNode *local;
- GaClient *ga_client;
- GaServiceBrowser *browse_handles[G_N_ELEMENTS (zeroconf_protos)];
- GHashTable *resolve_handles;
-};
-
-static const char *default_topics [] =
-{
- N_("Entertainment"),
- N_("News"),
- N_("Shopping"),
- N_("Sports"),
- N_("Travel"),
- N_("Work")
-};
-
-/* Signals */
-enum {
- TREE_CHANGED,
- LAST_SIGNAL
-};
-
-static guint ephy_bookmarks_signals[LAST_SIGNAL];
-
-static void ephy_bookmarks_finalize (GObject *object);
-static void ephy_local_bookmarks_start_client (EphyBookmarks *bookmarks);
-
-G_DEFINE_TYPE (EphyBookmarks, ephy_bookmarks, G_TYPE_OBJECT)
-
-static void
-ephy_bookmarks_init_defaults (EphyBookmarks *eb)
-{
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (default_topics); i++) {
- ephy_bookmarks_add_keyword (eb, _(default_topics[i]));
- }
-}
-
-static void
-ephy_bookmarks_class_init (EphyBookmarksClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = ephy_bookmarks_finalize;
-
- ephy_bookmarks_signals[TREE_CHANGED] =
- g_signal_new ("tree-changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
-}
-
-static gboolean
-save_filter (EphyNode *node,
- EphyBookmarks *bookmarks)
-{
- return node != bookmarks->bookmarks &&
- node != bookmarks->notcategorized &&
- node != bookmarks->local;
-}
-
-static gboolean
-save_filter_local (EphyNode *node,
- EphyBookmarks *bookmarks)
-{
- return !ephy_node_has_child (bookmarks->local, node);
-}
-
-static void
-ephy_bookmarks_save (EphyBookmarks *eb)
-{
- LOG ("Saving bookmarks");
-
- ephy_node_db_write_to_xml_safe
- (eb->db,
- (xmlChar *)eb->xml_file,
- (xmlChar *)EPHY_BOOKMARKS_XML_ROOT,
- (xmlChar *)EPHY_BOOKMARKS_XML_VERSION,
- (xmlChar *)"Do not rely on this file, it's only for internal use. Use bookmarks.rdf instead.",
- eb->keywords, (EphyNodeFilterFunc)save_filter, eb,
- eb->bookmarks, (EphyNodeFilterFunc)save_filter_local, eb,
- NULL);
-}
-
-static gboolean
-save_bookmarks_delayed (EphyBookmarks *bookmarks)
-{
- ephy_bookmarks_save (bookmarks);
- bookmarks->dirty = FALSE;
- bookmarks->save_timeout_id = 0;
-
- return FALSE;
-}
-
-static void
-ephy_bookmarks_save_delayed (EphyBookmarks *bookmarks, int delay)
-{
- if (!bookmarks->dirty) {
- bookmarks->dirty = TRUE;
-
- if (delay > 0) {
- bookmarks->save_timeout_id =
- g_timeout_add_seconds (BOOKMARKS_SAVE_DELAY,
- (GSourceFunc)save_bookmarks_delayed,
- bookmarks);
- g_source_set_name_by_id (bookmarks->save_timeout_id, "[epiphany] save_bookmarks_delayed");
- } else {
- bookmarks->save_timeout_id =
- g_idle_add ((GSourceFunc)save_bookmarks_delayed,
- bookmarks);
- }
- }
-}
-
-static void
-icon_updated_cb (WebKitFaviconDatabase *favicon_database,
- const char *address,
- const char *icon,
- EphyBookmarks *eb)
-{
- ephy_bookmarks_set_icon (eb, address, icon);
-}
-
-static void
-ephy_setup_history_notifiers (EphyBookmarks *eb)
-{
- WebKitFaviconDatabase *favicon_database;
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
-
- favicon_database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
- g_signal_connect (favicon_database, "favicon-changed",
- G_CALLBACK (icon_updated_cb), eb);
-}
-
-static void
-update_bookmark_keywords (EphyBookmarks *eb, EphyNode *bookmark)
-{
- GPtrArray *children;
- guint i;
- GString *list;
- const char *title;
- char *normalized_keywords, *case_normalized_keywords;
-
- list = g_string_new (NULL);
-
- children = ephy_node_get_children (eb->keywords);
- for (i = 0; i < children->len; i++) {
- EphyNode *kid;
-
- kid = g_ptr_array_index (children, i);
-
- if (kid != eb->notcategorized &&
- kid != eb->bookmarks &&
- kid != eb->local &&
- ephy_node_has_child (kid, bookmark)) {
- const char *topic;
- topic = ephy_node_get_property_string
- (kid, EPHY_NODE_KEYWORD_PROP_NAME);
- g_string_append (list, topic);
- g_string_append (list, " ");
- }
- }
-
- title = ephy_node_get_property_string
- (bookmark, EPHY_NODE_BMK_PROP_TITLE);
- g_string_append (list, " ");
- g_string_append (list, title);
-
- normalized_keywords = g_utf8_normalize (list->str, -1, G_NORMALIZE_ALL);
- case_normalized_keywords = g_utf8_casefold (normalized_keywords, -1);
-
- ephy_node_set_property_string (bookmark, EPHY_NODE_BMK_PROP_KEYWORDS,
- case_normalized_keywords);
-
- g_string_free (list, TRUE);
- g_free (normalized_keywords);
- g_free (case_normalized_keywords);
-}
-
-static void
-bookmarks_changed_cb (EphyNode *node,
- EphyNode *child,
- guint property_id,
- EphyBookmarks *eb)
-{
- if (property_id == EPHY_NODE_BMK_PROP_TITLE) {
- update_bookmark_keywords (eb, child);
- }
-
- ephy_bookmarks_save_delayed (eb, BOOKMARKS_SAVE_DELAY);
-}
-
-static void
-bookmarks_removed_cb (EphyNode *node,
- EphyNode *child,
- guint old_index,
- EphyBookmarks *eb)
-{
- ephy_bookmarks_save_delayed (eb, BOOKMARKS_SAVE_DELAY);
-}
-
-static gboolean
-bookmark_is_categorized (EphyBookmarks *eb, EphyNode *bookmark)
-{
- GPtrArray *children;
- guint i;
-
- children = ephy_node_get_children (eb->keywords);
- for (i = 0; i < children->len; i++) {
- EphyNode *kid;
-
- kid = g_ptr_array_index (children, i);
-
- if (kid != eb->notcategorized &&
- kid != eb->bookmarks &&
- kid != eb->local &&
- ephy_node_has_child (kid, bookmark)) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static void
-topics_removed_cb (EphyNode *node,
- EphyNode *child,
- guint old_index,
- EphyBookmarks *eb)
-{
- GPtrArray *children;
- guint i;
-
- children = ephy_node_get_children (child);
- for (i = 0; i < children->len; i++) {
- EphyNode *kid;
-
- kid = g_ptr_array_index (children, i);
-
- if (!bookmark_is_categorized (eb, kid) &&
- !ephy_node_has_child (eb->notcategorized, kid)) {
- ephy_node_add_child
- (eb->notcategorized, kid);
- }
-
- update_bookmark_keywords (eb, kid);
- }
-}
-
-static void
-fix_hierarchy_topic (EphyBookmarks *eb,
- EphyNode *topic)
-{
- GPtrArray *children;
- EphyNode *bookmark;
- const char *name;
- char **split;
- guint i, j;
-
- children = ephy_node_get_children (topic);
- name = ephy_node_get_property_string (topic, EPHY_NODE_KEYWORD_PROP_NAME);
- split = g_strsplit (name, "->", -1);
-
- for (i = 0; split[i]; i++) {
- if (split[i][0] == '\0') continue;
-
- topic = ephy_bookmarks_find_keyword (eb, split[i], FALSE);
- if (topic == NULL) {
- topic = ephy_bookmarks_add_keyword (eb, split[i]);
- }
- for (j = 0; j < children->len; j++) {
- bookmark = g_ptr_array_index (children, j);
- ephy_bookmarks_set_keyword (eb, topic, bookmark);
- }
- }
-
- g_strfreev (split);
-}
-
-static void
-fix_hierarchy (EphyBookmarks *eb)
-{
- GPtrArray *topics;
- EphyNode *topic;
- const char *name;
- int i;
-
- topics = ephy_node_get_children (eb->keywords);
- for (i = (int)topics->len - 1; i >= 0; i--) {
- topic = (EphyNode *)g_ptr_array_index (topics, i);
- name = ephy_node_get_property_string
- (topic, EPHY_NODE_KEYWORD_PROP_NAME);
- if (strstr (name, "->") != NULL) {
- fix_hierarchy_topic (eb, topic);
- ephy_node_remove_child (eb->keywords, topic);
- }
- }
-}
-
-static void
-backup_file (const char *original_filename, const char *extension)
-{
- char *template, *backup_filename;
- int result = 0;
-
- if (g_file_test (original_filename, G_FILE_TEST_EXISTS) == FALSE) {
- return;
- }
-
- template = g_strconcat (original_filename, ".backup-XXXXXX", NULL);
- backup_filename = ephy_file_tmp_filename (template, extension);
-
- if (backup_filename != NULL) {
- result = rename (original_filename, backup_filename);
- }
-
- if (result >= 0) {
- g_message ("Your old bookmarks file was backed up as \"%s\".\n",
- backup_filename);
- } else {
- g_warning ("Backup failed! Your old bookmarks file was lost.\n");
- }
-
- g_free (template);
- g_free (backup_filename);
-}
-
-/* C&P adapted from gnome-vfs-dns-sd.c */
-static GHashTable *
-decode_txt_record (AvahiStringList *input_text)
-{
- GHashTable *hash;
- guint i;
- int len;
- char *key, *value, *end;
- char *key_dup, *value_dup;
- char *raw_txt;
- size_t raw_txt_len;
-
- if (!input_text)
- return NULL;
-
- raw_txt_len = avahi_string_list_serialize (input_text, NULL, 0);
- raw_txt = g_malloc (raw_txt_len);
- raw_txt_len = avahi_string_list_serialize (input_text, raw_txt, raw_txt_len);
-
- if (raw_txt == NULL)
- return NULL;
-
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- i = 0;
- while (i < raw_txt_len) {
- len = raw_txt[i++];
-
- if (i + len > raw_txt_len) {
- break;
- }
-
- if (len == 0) {
- continue;
- }
-
- key = &raw_txt[i];
- end = &raw_txt[i + len];
- i += len;
-
- if (*key == '=') {
- /* 6.4 - silently ignore keys starting with = */
- continue;
- }
-
- value = memchr (key, '=', len);
- if (value) {
- key_dup = g_strndup (key, value - key);
- value++; /* Skip '=' */
- value_dup = g_strndup (value, end - value);
- } else {
- key_dup = g_strndup (key, len);
- value_dup = NULL;
- }
- if (!g_hash_table_lookup_extended (hash,
- key_dup,
- NULL, NULL)) {
- g_hash_table_insert (hash,
- key_dup,
- value_dup);
- } else {
- g_free (key_dup);
- g_free (value_dup);
- }
- }
-
- return hash;
-}
-
-/* End of copied code */
-
-static char *
-get_id_for_response (const char *type,
- const char *domain,
- const char *name)
-{
- /* FIXME: limit length! */
- return g_strdup_printf ("%s\1%s\1%s",
- type,
- domain,
- name);
-}
-
-typedef struct {
- EphyBookmarks *bookmarks;
- GaServiceResolver *resolver;
- EphyNode *node;
- char *name;
- char *type;
- char *domain;
-} ResolveData;
-
-static void
-resolver_found_cb (GaServiceResolver *resolver,
- int interface,
- GaProtocol protocol,
- const char *name,
- const char *type,
- const char *domain,
- const char *host_name,
- const AvahiAddress *address,
- guint16 port,
- AvahiStringList *txt,
- glong flags,
- ResolveData *data)
-{
- EphyBookmarks *bookmarks = data->bookmarks;
- GValue value = { 0, };
- const char *path = NULL;
- char host[128];
- GHashTable *text_table;
- char *url;
- gboolean was_immutable;
- gboolean is_new_node = FALSE;
- guint i;
-
- LOG ("resolver_found_cb resolver %p\n", resolver);
-
- was_immutable = ephy_node_db_is_immutable (bookmarks->db);
- ephy_node_db_set_immutable (bookmarks->db, FALSE);
-
- /* Find the protocol */
- for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i) {
- char proto[20];
-
- g_snprintf (proto, sizeof (proto), "_%s._tcp", zeroconf_protos[i]);
- if (strcmp (type, proto) == 0) break;
- }
- if (i == G_N_ELEMENTS (zeroconf_protos)) return;
-
- if (address == NULL) {
- g_warning ("Zeroconf failed to resolve host %s", name);
- return;
- }
-
- text_table = decode_txt_record (txt);
-
- if (text_table != NULL) {
- path = g_hash_table_lookup (text_table, "path");
- }
- if (path == NULL || path[0] == '\0') {
- path = "/";
- }
-
- avahi_address_snprint (host, sizeof (host), address);
-
- LOG ("0conf RESOLVED type=%s domain=%s name=%s => proto=%s host=%s port=%d path=%s\n",
- type, domain, name,
- zeroconf_protos[i], host, port, path);
-
- was_immutable = ephy_node_db_is_immutable (bookmarks->db);
- ephy_node_db_set_immutable (bookmarks->db, FALSE);
-
- if (data->node == NULL) {
- is_new_node = TRUE;
-
- data->node = ephy_node_new (bookmarks->db);
- g_assert (data->node != NULL);
-
- /* don't allow dragging this node */
- ephy_node_set_is_drag_source (data->node, FALSE);
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_take_string (&value,
- get_id_for_response (data->type,
- data->domain,
- data->name));
- ephy_node_set_property (data->node, EPHY_NODE_BMK_PROP_SERVICE_ID, &value);
- g_value_unset (&value);
-
- /* FIXME: limit length! */
- ephy_node_set_property_string (data->node,
- EPHY_NODE_BMK_PROP_TITLE,
- name);
-
- ephy_node_set_property_boolean (data->node,
- EPHY_NODE_BMK_PROP_IMMUTABLE,
- TRUE);
- }
-
- /* FIXME: limit length! */
- url = g_strdup_printf ("%s://%s:%d%s", zeroconf_protos[i], host, port, path);
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_take_string (&value, url);
- ephy_node_set_property (data->node, EPHY_NODE_BMK_PROP_LOCATION, &value);
- g_value_unset (&value);
-
- if (is_new_node) {
- ephy_node_add_child (bookmarks->bookmarks, data->node);
- ephy_node_add_child (bookmarks->local, data->node);
- }
-
- ephy_node_db_set_immutable (bookmarks->db, was_immutable);
-
- if (text_table != NULL) {
- g_hash_table_unref (text_table);
- }
-}
-
-static void
-resolver_failure_cb (GaServiceResolver *resolver,
- GError *error,
- ResolveData *data)
-{
- LOG ("resolver_failure_cb resolver %p: %s\n", resolver, error ? error->message : "(null)");
-
- /* Remove the node, if present */
- if (data->node != NULL) {
- EphyBookmarks *bookmarks = data->bookmarks;
- gboolean was_immutable;
-
- was_immutable = ephy_node_db_is_immutable (bookmarks->db);
- ephy_node_db_set_immutable (bookmarks->db, FALSE);
- ephy_node_unref (data->node);
- data->node = NULL;
- ephy_node_db_set_immutable (bookmarks->db, was_immutable);
- }
-}
-
-static void
-resolve_data_free (ResolveData *data)
-{
- if (data->resolver)
- g_object_unref (data->resolver);
-
- g_free (data->type);
- g_free (data->name);
- g_free (data->domain);
- g_slice_free (ResolveData, data);
-}
-
-static void
-browser_new_service_cb (GaServiceBrowser *browser,
- int interface,
- GaProtocol protocol,
- const char *name,
- const char *type,
- const char *domain,
- glong flags,
- EphyBookmarks *bookmarks)
-{
- ResolveData *data;
- char *node_id;
- GError *error = NULL;
-
- node_id = get_id_for_response (type, domain, name);
-
- LOG ("0conf ADD: type=%s domain=%s name=%s\n",
- type, domain, name);
-
- if (g_hash_table_lookup (bookmarks->resolve_handles, node_id) != NULL) {
- g_free (node_id);
- return;
- }
-
- data = g_slice_new0 (ResolveData);
- data->bookmarks = bookmarks;
- data->node = NULL;
- data->type = g_strdup (type);
- data->name = g_strdup (name);
- data->domain = g_strdup (domain);
-
- data->resolver = ga_service_resolver_new (AVAHI_IF_UNSPEC,
- AVAHI_PROTO_UNSPEC,
- name, type, domain,
- AVAHI_PROTO_UNSPEC,
- GA_LOOKUP_USE_MULTICAST);
- g_signal_connect (data->resolver, "found",
- G_CALLBACK (resolver_found_cb), data);
- g_signal_connect (data->resolver, "failure",
- G_CALLBACK (resolver_failure_cb), data);
- if (!ga_service_resolver_attach (data->resolver,
- bookmarks->ga_client,
- &error)) {
- g_warning ("Unable to resolve Zeroconf service %s: %s", name, error ? error->message : "(null)");
- g_clear_error (&error);
- resolve_data_free (data);
- g_free (node_id);
- return;
- }
-
- g_hash_table_insert (bookmarks->resolve_handles,
- node_id /* transfer ownership */, data);
-}
-
-static void
-browser_removed_service_cb (GaServiceBrowser *browser,
- int interface,
- GaProtocol protocol,
- const char *name,
- const char *type,
- const char *domain,
- glong flags,
- EphyBookmarks *bookmarks)
-{
- char *node_id;
- ResolveData *data;
-
- node_id = get_id_for_response (type, domain, name);
- data = g_hash_table_lookup (bookmarks->resolve_handles, node_id);
- /* shouldn't really happen, but let's play safe */
- if (!data) {
- g_free (node_id);
- return;
- }
-
- if (data->node != NULL) {
- gboolean was_immutable;
-
- was_immutable = ephy_node_db_is_immutable (bookmarks->db);
- ephy_node_db_set_immutable (bookmarks->db, FALSE);
- ephy_node_unref (data->node);
- data->node = NULL;
- ephy_node_db_set_immutable (bookmarks->db, was_immutable);
- }
-
- g_hash_table_remove (bookmarks->resolve_handles, node_id);
- g_free (node_id);
-}
-
-static void
-start_browsing (GaClient *ga_client,
- EphyBookmarks *bookmarks)
-{
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i) {
- GaServiceBrowser *browser = NULL;
- char proto[20];
-
- g_snprintf (proto, sizeof (proto), "_%s._tcp", zeroconf_protos[i]);
-
- browser = ga_service_browser_new (proto);
- g_signal_connect (browser, "new-service",
- G_CALLBACK (browser_new_service_cb), bookmarks);
- g_signal_connect (browser, "removed-service",
- G_CALLBACK (browser_removed_service_cb), bookmarks);
- if (!ga_service_browser_attach (browser,
- ga_client,
- NULL)) {
- g_warning ("Unable to start Zeroconf subsystem");
- g_object_unref (browser);
- return;
- }
-
- bookmarks->browse_handles[i] = browser;
- }
-}
-
-static void
-ga_client_state_changed_cb (GaClient *ga_client,
- GaClientState state,
- EphyBookmarks *bookmarks)
-{
- if (state == GA_CLIENT_STATE_FAILURE) {
- if (avahi_client_errno (ga_client->avahi_client) == AVAHI_ERR_DISCONNECTED) {
- g_object_unref (bookmarks->ga_client);
- bookmarks->ga_client = NULL;
-
- ephy_local_bookmarks_start_client (bookmarks);
- }
- }
- if (state == GA_CLIENT_STATE_S_RUNNING) {
- start_browsing (ga_client, bookmarks);
- }
-}
-
-static void
-ephy_local_bookmarks_start_client (EphyBookmarks *bookmarks)
-{
- GaClient *ga_client;
-
- ga_client = ga_client_new (GA_CLIENT_FLAG_NO_FAIL);
- g_signal_connect (ga_client, "state-changed",
- G_CALLBACK (ga_client_state_changed_cb),
- bookmarks);
- if (!ga_client_start (ga_client, NULL)) {
- g_warning ("Unable to start Zeroconf subsystem");
- g_object_unref (ga_client);
- return;
- }
- bookmarks->ga_client = ga_client;
-}
-
-static void
-ephy_local_bookmarks_init (EphyBookmarks *bookmarks)
-{
- bookmarks->resolve_handles = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free,
- (GDestroyNotify)resolve_data_free);
- ephy_local_bookmarks_start_client (bookmarks);
-}
-
-static void
-ephy_local_bookmarks_stop (EphyBookmarks *bookmarks)
-{
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i) {
- if (bookmarks->browse_handles[i] != NULL) {
- g_object_unref (bookmarks->browse_handles[i]);
- bookmarks->browse_handles[i] = NULL;
- }
- }
-
- if (bookmarks->resolve_handles != NULL) {
- g_hash_table_destroy (bookmarks->resolve_handles);
- bookmarks->resolve_handles = NULL;
- }
-
- if (bookmarks->local != NULL) {
- ephy_node_unref (bookmarks->local);
- bookmarks->local = NULL;
- }
-
- if (bookmarks->ga_client != NULL) {
- g_object_unref (bookmarks->ga_client);
- bookmarks->ga_client = NULL;
- }
-}
-
-static void
-ephy_bookmarks_init (EphyBookmarks *eb)
-{
- EphyNodeDb *db;
-
- /* Translators: this topic contains all bookmarks */
- const char *bk_all = C_("bookmarks", "All");
-
- /* Translators: this topic contains the not categorized
- bookmarks */
- const char *bk_not_categorized = C_("bookmarks", "Not Categorized");
-
- /* Translators: this is an automatic topic containing local
- * websites bookmarks autodiscovered with zeroconf. */
- const char *bk_local_sites = C_("bookmarks", "Nearby Sites");
-
- db = ephy_node_db_new (EPHY_NODE_DB_BOOKMARKS);
- eb->db = db;
-
- eb->xml_file = g_build_filename (ephy_dot_dir (),
- EPHY_BOOKMARKS_FILE,
- NULL);
- eb->rdf_file = g_build_filename (ephy_dot_dir (),
- EPHY_BOOKMARKS_FILE_RDF,
- NULL);
-
- /* Bookmarks */
- eb->bookmarks = ephy_node_new_with_id (db, BOOKMARKS_NODE_ID);
-
- ephy_node_set_property_string (eb->bookmarks,
- EPHY_NODE_KEYWORD_PROP_NAME,
- bk_all);
- ephy_node_signal_connect_object (eb->bookmarks,
- EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback)bookmarks_removed_cb,
- G_OBJECT (eb));
- ephy_node_signal_connect_object (eb->bookmarks,
- EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback)bookmarks_changed_cb,
- G_OBJECT (eb));
-
- /* Keywords */
- eb->keywords = ephy_node_new_with_id (db, KEYWORDS_NODE_ID);
- ephy_node_set_property_int (eb->bookmarks,
- EPHY_NODE_KEYWORD_PROP_PRIORITY,
- EPHY_NODE_ALL_PRIORITY);
-
- ephy_node_signal_connect_object (eb->keywords,
- EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback)topics_removed_cb,
- G_OBJECT (eb));
-
- ephy_node_add_child (eb->keywords,
- eb->bookmarks);
-
- /* Not categorized */
- eb->notcategorized = ephy_node_new_with_id (db, BMKS_NOTCATEGORIZED_NODE_ID);
-
-
- ephy_node_set_property_string (eb->notcategorized,
- EPHY_NODE_KEYWORD_PROP_NAME,
- bk_not_categorized);
-
- ephy_node_set_property_int (eb->notcategorized,
- EPHY_NODE_KEYWORD_PROP_PRIORITY,
- EPHY_NODE_SPECIAL_PRIORITY);
-
- ephy_node_add_child (eb->keywords, eb->notcategorized);
-
- /* Local Websites */
- eb->local = ephy_node_new_with_id (db, BMKS_LOCAL_NODE_ID);
-
- /* don't allow drags to this topic */
- ephy_node_set_is_drag_dest (eb->local, FALSE);
-
-
- ephy_node_set_property_string (eb->local,
- EPHY_NODE_KEYWORD_PROP_NAME,
- bk_local_sites);
- ephy_node_set_property_int (eb->local,
- EPHY_NODE_KEYWORD_PROP_PRIORITY,
- EPHY_NODE_SPECIAL_PRIORITY);
-
- ephy_node_add_child (eb->keywords, eb->local);
- ephy_local_bookmarks_init (eb);
-
- /* Smart bookmarks */
- eb->smartbookmarks = ephy_node_new_with_id (db, SMARTBOOKMARKS_NODE_ID);
-
- if (g_file_test (eb->xml_file, G_FILE_TEST_EXISTS) == FALSE
- && g_file_test (eb->rdf_file, G_FILE_TEST_EXISTS) == FALSE) {
- eb->init_defaults = TRUE;
- } else if (ephy_node_db_load_from_file (eb->db, eb->xml_file,
- (xmlChar *)EPHY_BOOKMARKS_XML_ROOT,
- (xmlChar *)EPHY_BOOKMARKS_XML_VERSION) == FALSE) {
- /* save the corrupted files so the user can late try to
- * manually recover them. See bug #128308.
- */
-
- g_warning ("Could not read bookmarks file \"%s\", trying to "
- "re-import bookmarks from \"%s\"\n",
- eb->xml_file, eb->rdf_file);
-
- backup_file (eb->xml_file, "xml");
- }
-
- if (eb->init_defaults) {
- ephy_bookmarks_init_defaults (eb);
- }
-
- fix_hierarchy (eb);
-
- g_settings_bind (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING,
- eb->db, "immutable",
- G_SETTINGS_BIND_GET);
-
- ephy_setup_history_notifiers (eb);
-}
-
-static void
-ephy_bookmarks_finalize (GObject *object)
-{
- EphyBookmarks *eb = EPHY_BOOKMARKS (object);
-
- if (eb->save_timeout_id != 0) {
- g_source_remove (eb->save_timeout_id);
- }
-
- ephy_bookmarks_save (eb);
-
- ephy_local_bookmarks_stop (eb);
-
- ephy_node_unref (eb->bookmarks);
- ephy_node_unref (eb->keywords);
- ephy_node_unref (eb->notcategorized);
- ephy_node_unref (eb->smartbookmarks);
-
- g_object_unref (eb->db);
-
- g_free (eb->xml_file);
- g_free (eb->rdf_file);
-
- LOG ("Bookmarks finalized");
-
- G_OBJECT_CLASS (ephy_bookmarks_parent_class)->finalize (object);
-}
-
-EphyBookmarks *
-ephy_bookmarks_new (void)
-{
- return EPHY_BOOKMARKS (g_object_new (EPHY_TYPE_BOOKMARKS, NULL));
-}
-
-static void
-update_has_smart_address (EphyBookmarks *bookmarks, EphyNode *bmk, const char *address)
-{
- EphyNode *smart_bmks;
- gboolean smart = FALSE, with_options = FALSE;
-
- smart_bmks = bookmarks->smartbookmarks;
-
- if (address) {
- smart = strstr (address, "%s") != NULL;
- with_options = strstr (address, "%s%{") != NULL;
- }
-
- /* if we have a smart bookmark with width specification,
- * remove from smart bookmarks first to force an update
- * in the toolbar
- */
- if (smart && with_options) {
- if (ephy_node_has_child (smart_bmks, bmk)) {
- ephy_node_remove_child (smart_bmks, bmk);
- }
- ephy_node_add_child (smart_bmks, bmk);
- } else if (smart) {
- if (!ephy_node_has_child (smart_bmks, bmk)) {
- ephy_node_add_child (smart_bmks, bmk);
- }
- } else {
- if (ephy_node_has_child (smart_bmks, bmk)) {
- ephy_node_remove_child (smart_bmks, bmk);
- }
- }
-}
-
-EphyNode *
-ephy_bookmarks_add (EphyBookmarks *eb,
- const char *title,
- const char *url)
-{
- EphyNode *bm;
- WebKitFaviconDatabase *favicon_database;
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
-
- bm = ephy_node_new (eb->db);
-
- if (bm == NULL) return NULL;
-
- if (url == NULL) return NULL;
- ephy_node_set_property_string (bm, EPHY_NODE_BMK_PROP_LOCATION, url);
-
- if (title == NULL || title[0] == '\0') {
- title = _("Untitled");
- }
- ephy_node_set_property_string (bm, EPHY_NODE_BMK_PROP_TITLE, title);
-
- favicon_database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
- if (favicon_database != NULL) {
- char *icon = webkit_favicon_database_get_favicon_uri (favicon_database, url);
- if (icon != NULL) {
- ephy_node_set_property_string
- (bm, EPHY_NODE_BMK_PROP_ICON, icon);
- g_free (icon);
- }
- }
-
- update_has_smart_address (eb, bm, url);
- update_bookmark_keywords (eb, bm);
-
- ephy_node_add_child (eb->bookmarks, bm);
- ephy_node_add_child (eb->notcategorized, bm);
-
- ephy_bookmarks_save_delayed (eb, 0);
-
- return bm;
-}
-
-void
-ephy_bookmarks_set_address (EphyBookmarks *eb,
- EphyNode *bookmark,
- const char *address)
-{
- ephy_node_set_property_string (bookmark, EPHY_NODE_BMK_PROP_LOCATION,
- address);
-
- update_has_smart_address (eb, bookmark, address);
-}
-
-EphyNode *
-ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
- const char *url)
-{
- GPtrArray *children;
- guint i;
-
- g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), NULL);
- g_return_val_if_fail (eb->bookmarks != NULL, NULL);
- g_return_val_if_fail (url != NULL, NULL);
-
- children = ephy_node_get_children (eb->bookmarks);
- for (i = 0; i < children->len; i++) {
- EphyNode *kid;
- const char *location;
-
- kid = g_ptr_array_index (children, i);
- location = ephy_node_get_property_string
- (kid, EPHY_NODE_BMK_PROP_LOCATION);
-
- if (location != NULL && strcmp (url, location) == 0) {
- return kid;
- }
- }
-
- return NULL;
-}
-
-static gboolean
-is_similar (const char *url1, const char *url2)
-{
- int i, j;
-
- for (i = 0; url1[i]; i++)
- if (url1[i] == '#' || url1[i] == '?')
- break;
- while (i > 0 && url1[i] == '/')
- i--;
-
- for (j = 0; url2[j]; j++)
- if (url2[j] == '#' || url2[j] == '?')
- break;
- while (j > 0 && url2[j] == '/')
- j--;
-
- if (i != j) return FALSE;
- if (strncmp (url1, url2, i) != 0) return FALSE;
- return TRUE;
-}
-
-gint
-ephy_bookmarks_get_similar (EphyBookmarks *eb,
- EphyNode *bookmark,
- GPtrArray *identical,
- GPtrArray *similar)
-{
- GPtrArray *children;
- const char *url;
- guint i, result;
-
- g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), -1);
- g_return_val_if_fail (eb->bookmarks != NULL, -1);
- g_return_val_if_fail (bookmark != NULL, -1);
-
- url = ephy_node_get_property_string
- (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
-
- g_return_val_if_fail (url != NULL, -1);
-
- result = 0;
-
- children = ephy_node_get_children (eb->bookmarks);
- for (i = 0; i < children->len; i++) {
- EphyNode *kid;
- const char *location;
-
- kid = g_ptr_array_index (children, i);
- if (kid == bookmark) {
- continue;
- }
-
- location = ephy_node_get_property_string
- (kid, EPHY_NODE_BMK_PROP_LOCATION);
-
- if (location != NULL) {
- if (identical != NULL && strcmp (url, location) == 0) {
- g_ptr_array_add (identical, kid);
- result++;
- } else if (is_similar (url, location)) {
- if (similar != NULL) {
- g_ptr_array_add (similar, kid);
- }
- result++;
- }
- }
- }
-
- return result;
-}
-
-void
-ephy_bookmarks_set_icon (EphyBookmarks *eb,
- const char *url,
- const char *icon)
-{
- EphyNode *node;
-
- g_return_if_fail (icon != NULL);
-
- node = ephy_bookmarks_find_bookmark (eb, url);
- if (node == NULL) return;
-
- ephy_node_set_property_string (node, EPHY_NODE_BMK_PROP_ICON, icon);
-}
-
-
-void
-ephy_bookmarks_set_usericon (EphyBookmarks *eb,
- const char *url,
- const char *icon)
-{
- EphyNode *node;
-
- g_return_if_fail (icon != NULL);
-
- node = ephy_bookmarks_find_bookmark (eb, url);
- if (node == NULL) return;
-
- ephy_node_set_property_string (node, EPHY_NODE_BMK_PROP_USERICON,
- icon);
-}
-
-
-/* name must end with '=' */
-static char *
-get_option (char *start,
- const char *name,
- char **optionsend)
-{
- char *end, *p;
-
- *optionsend = start;
-
- if (start == NULL || start[0] != '%' || start[1] != '{') return NULL;
- start += 2;
-
- end = strstr (start, "}");
- if (end == NULL) return NULL;
- *optionsend = end + 1;
-
- start = strstr (start, name);
- if (start == NULL || start > end) return NULL;
- start += strlen (name);
-
- /* Find end of option, either ',' or '}' */
- end = strstr (start, ",");
- if (end == NULL || end >= *optionsend) end = *optionsend - 1;
-
- /* limit option length and sanity-check it */
- if (end - start > 32) return NULL;
- for (p = start; p < end; ++p) {
- if (!g_ascii_isalnum (*p)) return NULL;
- }
-
- return g_strndup (start, end - start);
-}
-
-char *
-ephy_bookmarks_resolve_address (EphyBookmarks *eb,
- const char *address,
- const char *content)
-{
- GString *result;
- char *pos, *oldpos, *arg, *escaped_arg, *encoding, *optionsend;
-
- g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), NULL);
- g_return_val_if_fail (address != NULL, NULL);
-
- if (content == NULL) content = "";
-
- result = g_string_new_len (NULL, strlen (content) + strlen (address));
-
- /* substitute %s's */
- oldpos = (char *)address;
- while ((pos = strstr (oldpos, "%s")) != NULL) {
- g_string_append_len (result, oldpos, pos - oldpos);
- pos += 2;
-
- encoding = get_option (pos, "encoding=", &optionsend);
- if (encoding != NULL) {
- GError *error = NULL;
-
- arg = g_convert (content, strlen (content), encoding,
- "UTF-8", NULL, NULL, &error);
- if (error != NULL) {
- g_warning ("Error when converting arg to encoding '%s': %s\n",
- encoding, error->message);
- g_error_free (error);
- } else {
- escaped_arg = g_uri_escape_string (arg, NULL, TRUE);
- g_string_append (result, escaped_arg);
- g_free (escaped_arg);
- g_free (arg);
- }
-
- g_free (encoding);
- } else {
- arg = g_uri_escape_string (content, NULL, TRUE);
- g_string_append (result, arg);
- g_free (arg);
- }
-
- oldpos = optionsend;
- }
- g_string_append (result, oldpos);
-
- return g_string_free (result, FALSE);
-}
-
-guint
-ephy_bookmarks_get_smart_bookmark_width (EphyNode *bookmark)
-{
- const char *url;
- char *option, *end, *number;
- guint width;
-
- url = ephy_node_get_property_string (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
- if (url == NULL) return 0;
-
- /* this takes the first %s, but that's okay since we only support one text entry box */
- option = strstr (url, "%s%{");
- if (option == NULL) return 0;
- option += 2;
-
- number = get_option (option, "width=", &end);
- if (number == NULL) return 0;
-
- width = (guint)g_ascii_strtoull (number, NULL, 10);
- g_free (number);
-
- return CLAMP (width, 1, 64);
-}
-
-EphyNode *
-ephy_bookmarks_add_keyword (EphyBookmarks *eb,
- const char *name)
-{
- EphyNode *key;
-
- key = ephy_node_new (eb->db);
-
- if (key == NULL) return NULL;
-
- ephy_node_set_property_string (key, EPHY_NODE_KEYWORD_PROP_NAME,
- name);
- ephy_node_set_property_int (key, EPHY_NODE_KEYWORD_PROP_PRIORITY,
- EPHY_NODE_NORMAL_PRIORITY);
-
- ephy_node_add_child (eb->keywords, key);
-
- return key;
-}
-
-void
-ephy_bookmarks_remove_keyword (EphyBookmarks *eb,
- EphyNode *keyword)
-{
- ephy_node_remove_child (eb->keywords, keyword);
-}
-
-char *
-ephy_bookmarks_get_topic_uri (EphyBookmarks *eb,
- EphyNode *node)
-{
- char *uri;
-
- if (ephy_bookmarks_get_bookmarks (eb) == node) {
- uri = g_strdup ("topic://Special/All");
- } else if (ephy_bookmarks_get_not_categorized (eb) == node) {
- uri = g_strdup ("topic://Special/NotCategorized");
- } else if (ephy_bookmarks_get_local (eb) == node) {
- /* Note: do not change to "Nearby" because of existing custom toolbars */
- uri = g_strdup ("topic://Special/Local");
- } else {
- const char *name;
-
- name = ephy_node_get_property_string
- (node, EPHY_NODE_KEYWORD_PROP_NAME);
-
- uri = g_strdup_printf ("topic://%s", name);
- }
-
- return uri;
-}
-
-EphyNode *
-ephy_bookmarks_find_keyword (EphyBookmarks *eb,
- const char *name,
- gboolean partial_match)
-{
- EphyNode *node;
- GPtrArray *children;
- guint i;
- const char *topic_name;
-
- g_return_val_if_fail (name != NULL, NULL);
-
- topic_name = name;
-
- if (g_utf8_strlen (name, -1) == 0) {
- LOG ("Empty name, no keyword matches.");
- return NULL;
- }
-
- if (strcmp (name, "topic://Special/All") == 0) {
- return ephy_bookmarks_get_bookmarks (eb);
- } else if (strcmp (name, "topic://Special/NotCategorized") == 0) {
- return ephy_bookmarks_get_not_categorized (eb);
- } else if (strcmp (name, "topic://Special/Local") == 0) {
- return ephy_bookmarks_get_local (eb);
- } else if (g_str_has_prefix (name, "topic://")) {
- topic_name += strlen ("topic://");
- }
-
- children = ephy_node_get_children (eb->keywords);
- node = NULL;
- for (i = 0; i < children->len; i++) {
- EphyNode *kid;
- const char *key;
-
- kid = g_ptr_array_index (children, i);
- key = ephy_node_get_property_string (kid, EPHY_NODE_KEYWORD_PROP_NAME);
-
- if ((partial_match && g_str_has_prefix (key, topic_name) > 0) ||
- (!partial_match && strcmp (key, topic_name) == 0)) {
- node = kid;
- }
- }
-
- return node;
-}
-
-gboolean
-ephy_bookmarks_has_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark)
-{
- return ephy_node_has_child (keyword, bookmark);
-}
-
-void
-ephy_bookmarks_set_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark)
-{
- if (ephy_node_has_child (keyword, bookmark)) return;
-
- ephy_node_add_child (keyword, bookmark);
-
- if (ephy_node_has_child (eb->notcategorized, bookmark)) {
- LOG ("Remove from categorized bookmarks");
- ephy_node_remove_child
- (eb->notcategorized, bookmark);
- }
-
- update_bookmark_keywords (eb, bookmark);
-
- g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0);
-}
-
-void
-ephy_bookmarks_unset_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark)
-{
- if (!ephy_node_has_child (keyword, bookmark)) return;
-
- ephy_node_remove_child (keyword, bookmark);
-
- if (!bookmark_is_categorized (eb, bookmark) &&
- !ephy_node_has_child (eb->notcategorized, bookmark)) {
- LOG ("Add to not categorized bookmarks");
- ephy_node_add_child
- (eb->notcategorized, bookmark);
- }
-
- update_bookmark_keywords (eb, bookmark);
-
- g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0);
-}
-
-/**
- * ephy_bookmarks_get_smart_bookmarks:
- *
- * Return value: (transfer none):
- **/
-EphyNode *
-ephy_bookmarks_get_smart_bookmarks (EphyBookmarks *eb)
-{
- return eb->smartbookmarks;
-}
-
-/**
- * ephy_bookmarks_get_keywords:
- *
- * Return value: (transfer none):
- **/
-EphyNode *
-ephy_bookmarks_get_keywords (EphyBookmarks *eb)
-{
- return eb->keywords;
-}
-
-/**
- * ephy_bookmarks_get_bookmarks:
- *
- * Return value: (transfer none):
- **/
-EphyNode *
-ephy_bookmarks_get_bookmarks (EphyBookmarks *eb)
-{
- return eb->bookmarks;
-}
-
-/**
- * ephy_bookmarks_get_local:
- *
- * Return value: (transfer none):
- **/
-EphyNode *
-ephy_bookmarks_get_local (EphyBookmarks *eb)
-{
- return eb->local;
-}
-
-/**
- * ephy_bookmarks_get_not_categorized:
- *
- * Return value: (transfer none):
- **/
-EphyNode *
-ephy_bookmarks_get_not_categorized (EphyBookmarks *eb)
-{
- return eb->notcategorized;
-}
-
-/**
- * ephy_bookmarks_get_from_id:
- *
- * Return value: (transfer none):
- **/
-EphyNode *
-ephy_bookmarks_get_from_id (EphyBookmarks *eb, long id)
-{
- return ephy_node_db_get_node_from_id (eb->db, id);
-}
-
-int
-ephy_bookmarks_compare_topics (gconstpointer a, gconstpointer b)
-{
- EphyNode *node_a = (EphyNode *)a;
- EphyNode *node_b = (EphyNode *)b;
- const char *title1, *title2;
- int priority1, priority2;
-
- priority1 = ephy_node_get_property_int (node_a, EPHY_NODE_KEYWORD_PROP_PRIORITY);
- priority2 = ephy_node_get_property_int (node_b, EPHY_NODE_KEYWORD_PROP_PRIORITY);
-
- if (priority1 > priority2) return 1;
- if (priority1 < priority2) return -1;
-
- title1 = ephy_node_get_property_string (node_a, EPHY_NODE_KEYWORD_PROP_NAME);
- title2 = ephy_node_get_property_string (node_b, EPHY_NODE_KEYWORD_PROP_NAME);
-
- if (title1 == title2) return 0;
- if (title1 == NULL) return -1;
- if (title2 == NULL) return 1;
- return g_utf8_collate (title1, title2);
-}
-
-int
-ephy_bookmarks_compare_topic_pointers (gconstpointer a, gconstpointer b)
-{
- EphyNode *node_a = *(EphyNode **)a;
- EphyNode *node_b = *(EphyNode **)b;
-
- return ephy_bookmarks_compare_topics (node_a, node_b);
-}
-
-int
-ephy_bookmarks_compare_bookmarks (gconstpointer a, gconstpointer b)
-{
- EphyNode *node_a = (EphyNode *)a;
- EphyNode *node_b = (EphyNode *)b;
- const char *title1, *title2;
-
- title1 = ephy_node_get_property_string (node_a, EPHY_NODE_BMK_PROP_TITLE);
- title2 = ephy_node_get_property_string (node_b, EPHY_NODE_BMK_PROP_TITLE);
-
- if (title1 == title2) return 0;
- if (title1 == NULL) return -1;
- if (title2 == NULL) return 1;
- return g_utf8_collate (title1, title2);
-}
-
-int
-ephy_bookmarks_compare_bookmark_pointers (gconstpointer a, gconstpointer b)
-{
- EphyNode *node_a = *(EphyNode **)a;
- EphyNode *node_b = *(EphyNode **)b;
-
- return ephy_bookmarks_compare_bookmarks (node_a, node_b);
-}
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
deleted file mode 100644
index 2a5a110cd..000000000
--- a/src/bookmarks/ephy-bookmarks.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * Copyright © 2000-2004 Marco Pesenti Gritti
- * Copyright © 2003, 2004 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
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include <glib-object.h>
-
-#include "ephy-node.h"
-
-G_BEGIN_DECLS
-
-/* Name of a default smart bookmark, to NOT be displayed in the search engine
- * combo in the preferences dialog. This should exactly match the smart bookmark
- * in default-bookmarks.rdf. */
-#define DEFAULT_SMART_BOOKMARK_TEXT _("Search the web")
-
-#define EPHY_TYPE_BOOKMARKS (ephy_bookmarks_get_type ())
-
-G_DECLARE_FINAL_TYPE (EphyBookmarks, ephy_bookmarks, EPHY, BOOKMARKS, GObject)
-
-typedef enum
-{
- EPHY_NODE_BMK_PROP_TITLE = 2,
- EPHY_NODE_BMK_PROP_LOCATION = 3,
- EPHY_NODE_BMK_PROP_KEYWORDS = 4,
- EPHY_NODE_KEYWORD_PROP_NAME = 5,
- EPHY_NODE_BMK_PROP_USERICON = 6,
- EPHY_NODE_BMK_PROP_ICON = 7,
- EPHY_NODE_KEYWORD_PROP_PRIORITY = 8,
- EPHY_NODE_BMK_PROP_SERVICE_ID = 14,
- EPHY_NODE_BMK_PROP_IMMUTABLE = 15
-} EphyBookmarkProperty;
-
-EphyBookmarks *ephy_bookmarks_new (void);
-
-EphyNode *ephy_bookmarks_get_from_id (EphyBookmarks *eb,
- long id);
-
-/* Bookmarks */
-
-EphyNode *ephy_bookmarks_add (EphyBookmarks *eb,
- const char *title,
- const char *url);
-
-EphyNode* ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
- const char *url);
-
-gint ephy_bookmarks_get_similar (EphyBookmarks *eb,
- EphyNode *bookmark,
- GPtrArray *identical,
- GPtrArray *similar);
-
-void ephy_bookmarks_set_icon (EphyBookmarks *eb,
- const char *url,
- const char *icon);
-
-void ephy_bookmarks_set_usericon (EphyBookmarks *eb,
- const char *url,
- const char *icon);
-
-void ephy_bookmarks_set_address (EphyBookmarks *eb,
- EphyNode *bookmark,
- const char *address);
-
-char *ephy_bookmarks_resolve_address (EphyBookmarks *eb,
- const char *address,
- const char *parameter);
-
-guint ephy_bookmarks_get_smart_bookmark_width
- (EphyNode *bookmark);
-
-
-/* Keywords */
-
-EphyNode *ephy_bookmarks_add_keyword (EphyBookmarks *eb,
- const char *name);
-
-EphyNode *ephy_bookmarks_find_keyword (EphyBookmarks *eb,
- const char *name,
- gboolean partial_match);
-
-void ephy_bookmarks_remove_keyword (EphyBookmarks *eb,
- EphyNode *keyword);
-
-gboolean ephy_bookmarks_has_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark);
-
-void ephy_bookmarks_set_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark);
-
-void ephy_bookmarks_unset_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark);
-
-char *ephy_bookmarks_get_topic_uri (EphyBookmarks *eb,
- EphyNode *node);
-
-/* Root */
-
-EphyNode *ephy_bookmarks_get_keywords (EphyBookmarks *eb);
-
-EphyNode *ephy_bookmarks_get_bookmarks (EphyBookmarks *eb);
-
-EphyNode *ephy_bookmarks_get_not_categorized (EphyBookmarks *eb);
-
-EphyNode *ephy_bookmarks_get_smart_bookmarks (EphyBookmarks *eb);
-
-EphyNode *ephy_bookmarks_get_local (EphyBookmarks *eb);
-
-/* Comparison functions, useful for sorting lists and arrays. */
-int ephy_bookmarks_compare_topics (gconstpointer a, gconstpointer b);
-int ephy_bookmarks_compare_topic_pointers (gconstpointer a, gconstpointer b);
-int ephy_bookmarks_compare_bookmarks (gconstpointer a, gconstpointer b);
-int ephy_bookmarks_compare_bookmark_pointers (gconstpointer a, gconstpointer b);
-
-G_END_DECLS
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 8474033cc..44f591735 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -47,10 +47,7 @@ struct _EphyLocationController {
EphyWindow *window;
EphyTitleWidget *title_widget;
- GList *actions;
char *address;
- EphyNode *smart_bmks;
- EphyBookmarks *bookmarks;
guint editable : 1;
gboolean sync_address_is_blocked;
};
@@ -87,38 +84,6 @@ match_func (GtkEntryCompletion *completion,
}
static void
-action_activated_cb (GtkEntryCompletion *completion,
- gint index,
- EphyLocationController *controller)
-{
- GtkWidget *entry;
- char *content;
-
- entry = gtk_entry_completion_get_entry (completion);
- content = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
- if (content) {
- EphyNode *node;
- const char *smart_url;
- char *url;
-
- node = (EphyNode *)g_list_nth_data (controller->actions, index);
- smart_url = ephy_node_get_property_string
- (node, EPHY_NODE_BMK_PROP_LOCATION);
- g_return_if_fail (smart_url != NULL);
-
- url = ephy_bookmarks_resolve_address
- (controller->bookmarks, smart_url, content);
- g_free (content);
- if (url == NULL) return;
-
- ephy_link_open (EPHY_LINK (controller), url, NULL,
- ephy_link_flags_from_current_event () | EPHY_LINK_TYPED);
-
- g_free (url);
- }
-}
-
-static void
entry_drag_data_received_cb (GtkWidget *widget,
GdkDragContext *context,
gint x, gint y,
@@ -171,7 +136,6 @@ static void
entry_activate_cb (GtkEntry *entry,
EphyLocationController *controller)
{
- EphyBookmarks *bookmarks;
const char *content;
char *address;
char *effective_address;
@@ -184,11 +148,7 @@ entry_activate_cb (GtkEntry *entry,
content = gtk_entry_get_text (entry);
if (content == NULL || content[0] == '\0') return;
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
-
- address = ephy_bookmarks_resolve_address (bookmarks, content, NULL);
- g_return_if_fail (address != NULL);
-
+ address = g_strdup (content);
effective_address = ephy_embed_utils_normalize_or_autosearch_address (g_strstrip (address));
g_free (address);
#if 0
@@ -280,47 +240,6 @@ get_title_cb (EphyLocationEntry *entry,
return g_strdup (ephy_embed_get_title (embed));
}
-static void
-remove_completion_actions (EphyLocationController *controller,
- EphyLocationEntry *lentry)
-{
- GtkEntryCompletion *completion;
- GList *l;
-
- completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
-
- for (l = controller->actions; l != NULL; l = l->next) {
- gtk_entry_completion_delete_action (completion, 0);
- }
-
- g_signal_handlers_disconnect_by_func
- (completion, G_CALLBACK (action_activated_cb), controller);
-}
-
-static void
-add_completion_actions (EphyLocationController *controller,
- EphyLocationEntry *lentry)
-{
- GtkEntryCompletion *completion;
- GList *l;
-
- completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
-
- for (l = controller->actions; l != NULL; l = l->next) {
- EphyNode *bmk = l->data;
- const char *title;
- int index;
-
- index = g_list_position (controller->actions, l);
- title = ephy_node_get_property_string
- (bmk, EPHY_NODE_BMK_PROP_TITLE);
- gtk_entry_completion_insert_action_text (completion, index, (char *)title);
- }
-
- g_signal_connect (completion, "action_activated",
- G_CALLBACK (action_activated_cb), controller);
-}
-
static gboolean
focus_in_event_cb (GtkWidget *entry,
GdkEventFocus *event,
@@ -402,8 +321,6 @@ ephy_location_controller_constructed (GObject *object)
controller->title_widget,
NULL);
- add_completion_actions (controller, EPHY_LOCATION_ENTRY (controller->title_widget));
-
g_object_bind_property (controller, "editable",
controller->title_widget, "editable",
G_BINDING_SYNC_CREATE);
@@ -560,120 +477,12 @@ ephy_location_controller_class_init (EphyLocationControllerClass *class)
g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
-static int
-compare_actions (gconstpointer a,
- gconstpointer b)
-{
- EphyNode *node_a = (EphyNode *)a;
- EphyNode *node_b = (EphyNode *)b;
- const char *title1, *title2;
- int retval;
-
- title1 = ephy_node_get_property_string (node_a, EPHY_NODE_BMK_PROP_TITLE);
- title2 = ephy_node_get_property_string (node_b, EPHY_NODE_BMK_PROP_TITLE);
-
- if (title1 == NULL) {
- retval = -1;
- } else if (title2 == NULL) {
- retval = 1;
- } else {
- char *str_a, *str_b;
-
- str_a = g_utf8_casefold (title1, -1);
- str_b = g_utf8_casefold (title2, -1);
- retval = g_utf8_collate (str_a, str_b);
- g_free (str_a);
- g_free (str_b);
- }
-
- return retval;
-}
-
-static void
-init_actions_list (EphyLocationController *controller)
-{
- GPtrArray *children;
- guint i;
-
- children = ephy_node_get_children (controller->smart_bmks);
- for (i = 0; i < children->len; i++) {
- EphyNode *kid;
-
- kid = g_ptr_array_index (children, i);
-
- controller->actions = g_list_prepend
- (controller->actions, kid);
- }
-
- controller->actions =
- g_list_sort (controller->actions, (GCompareFunc)compare_actions);
-}
-
-static void
-update_actions_list (EphyLocationController *controller)
-{
- if (!EPHY_IS_LOCATION_ENTRY (controller->title_widget))
- return;
-
- remove_completion_actions (controller, EPHY_LOCATION_ENTRY (controller->title_widget));
-
- g_list_free (controller->actions);
- controller->actions = NULL;
- init_actions_list (controller);
-
- add_completion_actions (controller, EPHY_LOCATION_ENTRY (controller->title_widget));
-}
-
-static void
-actions_child_removed_cb (EphyNode *node,
- EphyNode *child,
- guint old_index,
- EphyLocationController *controller)
-{
- update_actions_list (controller);
-}
-
-static void
-actions_child_added_cb (EphyNode *node,
- EphyNode *child,
- EphyLocationController *controller)
-{
- update_actions_list (controller);
-}
-
-static void
-actions_child_changed_cb (EphyNode *node,
- EphyNode *child,
- guint property_id,
- EphyLocationController *controller)
-{
- update_actions_list (controller);
-}
-
static void
ephy_location_controller_init (EphyLocationController *controller)
{
controller->address = g_strdup ("");
controller->editable = TRUE;
- controller->bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- controller->smart_bmks = ephy_bookmarks_get_smart_bookmarks
- (controller->bookmarks);
controller->sync_address_is_blocked = FALSE;
-
- init_actions_list (controller);
-
- ephy_node_signal_connect_object (controller->smart_bmks,
- EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback)actions_child_added_cb,
- G_OBJECT (controller));
- ephy_node_signal_connect_object (controller->smart_bmks,
- EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback)actions_child_removed_cb,
- G_OBJECT (controller));
- ephy_node_signal_connect_object (controller->smart_bmks,
- EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback)actions_child_changed_cb,
- G_OBJECT (controller));
}
static void
@@ -681,7 +490,6 @@ ephy_location_controller_finalize (GObject *object)
{
EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
- g_list_free (controller->actions);
g_free (controller->address);
G_OBJECT_CLASS (ephy_location_controller_parent_class)->finalize (object);
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 1ddaf7845..667064d51 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -35,8 +35,10 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libnotify/notify.h>
+#include <libxml/xmlreader.h>
#include <libxml/xmlversion.h>
#include <string.h>
+#include <stdlib.h>
static gboolean open_in_new_tab = FALSE;
static gboolean open_in_new_window = FALSE;
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 161bbd398..3d7d59039 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -52,7 +52,6 @@ struct _EphyShell {
EphySession *session;
GList *windows;
GObject *lockdown;
- EphyBookmarks *bookmarks;
EphyBookmarksManager *bookmarks_manager;
GNetworkMonitor *network_monitor;
GtkWidget *history_window;
@@ -582,7 +581,6 @@ ephy_shell_dispose (GObject *object)
g_clear_object (&shell->lockdown);
g_clear_pointer (&shell->history_window, gtk_widget_destroy);
g_clear_object (&shell->prefs_dialog);
- g_clear_object (&shell->bookmarks);
g_clear_object (&shell->network_monitor);
g_slist_free_full (shell->open_uris_idle_ids, remove_open_uris_idle_cb);
@@ -730,21 +728,6 @@ ephy_shell_get_session (EphyShell *shell)
}
/**
- * ephy_shell_get_bookmarks:
- *
- * Return value: (transfer none):
- **/
-EphyBookmarks *
-ephy_shell_get_bookmarks (EphyShell *shell)
-{
- if (shell->bookmarks == NULL) {
- shell->bookmarks = ephy_bookmarks_new ();
- }
-
- return shell->bookmarks;
-}
-
-/**
* ephy_shell_get_bookmarks_manager:
* @shell: the #EphyShell
*
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index 25f011777..97c620650 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -20,7 +20,6 @@
#pragma once
-#include "ephy-bookmarks.h"
#include "ephy-bookmarks-manager.h"
#include "ephy-embed-shell.h"
#include "ephy-embed.h"
@@ -98,8 +97,6 @@ EphySession *ephy_shell_get_session (EphyShell *shell);
GNetworkMonitor *ephy_shell_get_net_monitor (EphyShell *shell);
-EphyBookmarks *ephy_shell_get_bookmarks (EphyShell *shell);
-
GtkWidget *ephy_shell_get_bookmarks_editor (EphyShell *shell);
EphyBookmarksManager *ephy_shell_get_bookmarks_manager (EphyShell *shell);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index c27602bfe..c06b9e010 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -58,6 +58,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libsoup/soup.h>
+#include <stdlib.h>
#include <webkit2/webkit2.h>
diff --git a/src/epiphany.gresource.xml b/src/epiphany.gresource.xml
index c31903329..49d3fb8ec 100644
--- a/src/epiphany.gresource.xml
+++ b/src/epiphany.gresource.xml
@@ -2,7 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/epiphany">
<file>incognito.png</file>
- <file preprocess="xml-stripblanks" compressed="true">bookmark-properties.ui</file>
<file preprocess="xml-stripblanks" compressed="true">encoding-dialog.ui</file>
<file preprocess="xml-stripblanks" compressed="true">encoding-row.ui</file>
<file preprocess="xml-stripblanks" compressed="true">prefs-dialog.ui</file>
@@ -17,8 +16,6 @@
<file preprocess="xml-stripblanks" compressed="true">gtk/bookmarks-popover.ui</file>
<file preprocess="xml-stripblanks" compressed="true">gtk/menus.ui</file>
<file preprocess="xml-stripblanks" compressed="true">gtk/page-menu-popover.ui</file>
- <file preprocess="xml-stripblanks">epiphany-application-menu.ui</file>
- <file preprocess="xml-stripblanks">epiphany-bookmark-editor-ui.xml</file>
<file>epiphany.css</file>
<file alias="page-templates/error.html" compressed="true">error.html</file>
<file>missing-thumbnail.png</file>
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 0c73f262d..0d8b23a44 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -21,7 +21,6 @@
#include "config.h"
#include "prefs-dialog.h"
-#include "ephy-bookmarks.h"
#include "ephy-debug.h"
#include "ephy-embed-container.h"
#include "ephy-embed-prefs.h"
@@ -931,44 +930,6 @@ search_engine_combo_add_default_engines (GtkListStore *store)
}
}
-static void
-search_engine_combo_add_smart_bookmarks (GtkListStore *store)
-{
- guint i;
- EphyBookmarks *bookmarks;
- EphyNode *smart_bookmarks_parent_node;
- GPtrArray *smart_bookmarks;
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- smart_bookmarks_parent_node = ephy_bookmarks_get_smart_bookmarks (bookmarks);
- smart_bookmarks = ephy_node_get_children (smart_bookmarks_parent_node);
-
- if (!smart_bookmarks)
- return;
-
- for (i = 0; i < smart_bookmarks->len; ++i) {
- EphyNode *bookmark;
- const char *bookmark_name;
- const char *bookmark_url;
-
- bookmark = g_ptr_array_index (smart_bookmarks, i);
- bookmark_name = ephy_node_get_property_string (bookmark, EPHY_NODE_BMK_PROP_TITLE);
- bookmark_url = ephy_node_get_property_string (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
-
- if (!bookmark_name || !bookmark_url)
- continue;
-
- if (strcmp (bookmark_name, DEFAULT_SMART_BOOKMARK_TEXT) == 0)
- continue;
-
- gtk_list_store_insert_with_values (store, NULL, -1,
- SEARCH_ENGINE_COL_NAME, bookmark_name,
- SEARCH_ENGINE_COL_STOCK_URL, bookmark_url,
- SEARCH_ENGINE_COL_URL, bookmark_url,
- -1);
- }
-}
-
/* Has the user manually set the engine to something not in the combo?
* If so, add that URL as an extra item in the combo. */
static void
@@ -1021,7 +982,6 @@ create_search_engine_combo (GtkComboBox *combo)
store = GTK_LIST_STORE (gtk_combo_box_get_model (combo));
search_engine_combo_add_default_engines (store);
- search_engine_combo_add_smart_bookmarks (store);
search_engine_combo_add_current_engine (store);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), SEARCH_ENGINE_COL_NAME,
diff --git a/src/resources/bookmark-properties.ui b/src/resources/bookmark-properties.ui
deleted file mode 100644
index 49a3ad1fc..000000000
--- a/src/resources/bookmark-properties.ui
+++ /dev/null
@@ -1,158 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <requires lib="gtk+" version="3.10"/>
- <template class="EphyBookmarkProperties" parent="GtkDialog">
- <property name="modal">True</property>
- <property name="resizable">False</property>
- <property name="width-request">450</property>
- <property name="type-hint">dialog</property>
- <property name="border-width">5</property>
- <signal name="response" handler="ephy_bookmark_properties_response_cb"/>
- <signal name="destroy" handler="ephy_bookmark_properties_destroy_cb"/>
- <child internal-child="vbox">
- <object class="GtkBox">
- <property name="spacing">2</property>
- <child>
- <object class="GtkGrid" id="grid"> <!-- TODO has (0,3) empty -->
- <property name="visible">True</property>
- <property name="row-spacing">6</property>
- <property name="column-spacing">12</property>
- <property name="border-width">5</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="halign">start</property>
- <property name="use-underline">True</property>
- <property name="label" translatable="yes">_Title:</property>
- <property name="mnemonic-widget">title_entry</property>
- </object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="title_entry">
- <property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="width-request">200</property>
- <property name="activates-default">True</property>
- <signal name="changed" handler="title_entry_changed_cb"/>
- </object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="halign">start</property>
- <property name="use-underline">True</property>
- <property name="label" translatable="yes">A_ddress:</property>
- <property name="mnemonic-widget">adress_entry</property>
- </object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="adress_entry">
- <property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="width-request">200</property>
- <property name="activates-default">True</property>
- <signal name="changed" handler="location_entry_changed_cb"/>
- </object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="topics_label">
- <property name="visible">True</property>
- <property name="halign">start</property>
- <property name="use-underline">True</property>
- <property name="label" translatable="yes">T_opics:</property>
- </object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkExpander" id="topics_expander">
- <property name="visible">True</property>
- <property name="expand">True</property>
- <property name="use-underline">True</property>
- <property name="label" translatable="yes">Sho_w all topics</property>
- <child>
- <object class="GtkScrolledWindow" id="topics_scrolled_window">
- <property name="visible">True</property>
- <property name="shadow-type">in</property>
- <property name="height-request">250</property>
- <child>
- <object class="GtkTreeView" id="topics_tree_view">
- <property name="visible">True</property>
- <property name="search-column">0</property> <!-- COLUMN_TITLE -->
- <property name="headers-visible">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection">
- <property name="mode">none</property>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="topics_column">
- <property name="sizing">fixed</property>
- <property name="fixed-width">290</property>
- <property name="title" translatable="yes">Topics</property>
- <property name="clickable">True</property>
- <property name="sort-indicator">True</property>
- <property name="sort-order">descending</property>
- <child>
- <object class="GtkCellRendererToggle">
- <signal name="toggled" handler="on_topic_toggled"/>
- </object>
- <attributes>
- <attribute name="active">2</attribute> <!-- COLUMN_SELECTED -->
- </attributes>
- </child>
- <child>
- <object class="GtkCellRendererText">
- <signal name="edited" handler="on_topic_edited"/>
- </object>
- <attributes>
- <attribute name="text">0</attribute> <!-- COLUMN_TITLE -->
- </attributes>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="warning_label">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">4</property>
- <property name="width">2</property>
- <property name="height">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </template>
-</interface>
diff --git a/src/resources/epiphany-bookmark-editor-ui.xml b/src/resources/epiphany-bookmark-editor-ui.xml
deleted file mode 100644
index 2998d4792..000000000
--- a/src/resources/epiphany-bookmark-editor-ui.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<ui>
-<menubar>
-
-<menu name="FileMenu" action="File">
- <menuitem action="NewTopic"/>
- <separator/>
- <menuitem action="OpenInWindow"/>
- <menuitem action="OpenInTab"/>
- <separator/>
- <menuitem action="Rename"/>
- <separator/>
- <menuitem action="Properties"/>
- <separator/>
- <menuitem action="Import"/>
- <menuitem action="Export"/>
- <separator/>
- <menuitem action="Close"/>
-</menu>
-
-<menu name="EditMenu" action="Edit">
- <menuitem action="Cut"/>
- <menuitem action="Copy"/>
- <menuitem action="Paste"/>
- <menuitem action="Delete"/>
- <separator/>
- <menuitem action="SelectAll"/>
-</menu>
-
-<menu name="ViewMenu" action="View">
- <menuitem action="ViewTitle"/>
- <menuitem action="ViewAddress"/>
-</menu>
-
-<menu name="HelpMenu" action="Help">
- <menuitem action="HelpContents"/>
- <menuitem action="HelpAbout"/>
-</menu>
-
-</menubar>
-
-<popup name="EphyBookmarkEditorPopup" action="PopupAction">
- <menuitem action="OpenInWindow"/>
- <menuitem action="OpenInTab"/>
- <separator/>
- <menuitem action="Copy"/>
- <separator/>
- <menuitem action="Rename"/>
- <menuitem action="Delete"/>
- <separator/>
- <menuitem action="Properties"/>
-</popup>
-
-<popup name="EphyBookmarkKeywordPopup" action="PopupAction">
- <menuitem action="Rename"/>
- <menuitem action="Delete"/>
-</popup>
-
-</ui>
diff --git a/src/resources/epiphany-ui.xml b/src/resources/epiphany-ui.xml
deleted file mode 100644
index e69de29bb..000000000
--- a/src/resources/epiphany-ui.xml
+++ /dev/null
diff --git a/src/window-commands.c b/src/window-commands.c
index b199e8ada..f4d98b8cd 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1697,30 +1697,6 @@ window_cmd_go_location (GSimpleAction *action,
}
void
-window_cmd_load_location (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- const char *location;
-
- location = ephy_window_get_location (EPHY_WINDOW (user_data));
-
- if (location) {
- EphyBookmarks *bookmarks;
- char *address;
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
-
- address = ephy_bookmarks_resolve_address (bookmarks, location, NULL);
- g_return_if_fail (address != NULL);
-
- ephy_link_open (EPHY_LINK (user_data), address,
- ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (user_data)),
- ephy_link_flags_from_current_event ());
- }
-}
-
-void
window_cmd_go_home (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
diff --git a/src/window-commands.h b/src/window-commands.h
index 0ad03a729..73b1c06b0 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -144,9 +144,6 @@ void window_cmd_go_location (GSimpleAction *action,
void window_cmd_go_home (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
-void window_cmd_load_location (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data);
void window_cmd_change_browse_with_caret_state (GSimpleAction *action,
GVariant *state,
gpointer user_data);
diff --git a/tests/ephy-bookmarks-test.c b/tests/ephy-bookmarks-test.c
deleted file mode 100644
index 0c3353e31..000000000
--- a/tests/ephy-bookmarks-test.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * Copyright © 2012 Igalia S.L.
- *
- * Epiphany is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Epiphany is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Epiphany. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-#include "ephy-bookmarks.h"
-
-#include "ephy-debug.h"
-#include "ephy-file-helpers.h"
-#include "ephy-private.h"
-#include "ephy-profile-utils.h"
-#include "ephy-shell.h"
-
-const char *bookmarks_paths[] = { EPHY_BOOKMARKS_FILE, EPHY_BOOKMARKS_FILE_RDF };
-
-static void
-clear_bookmark_files (void)
-{
- GFile *file;
- char *path;
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (bookmarks_paths); i++) {
- path = g_build_filename (ephy_dot_dir (),
- bookmarks_paths[i],
- NULL);
- file = g_file_new_for_path (path);
- g_file_delete (file, NULL, NULL);
- g_object_unref (file);
- g_free (path);
- }
-}
-
-static void
-test_ephy_bookmarks_create (void)
-{
- EphyBookmarks *bookmarks;
-
- bookmarks = ephy_bookmarks_new ();
- g_assert (bookmarks);
- g_object_unref (bookmarks);
-
- clear_bookmark_files ();
-}
-
-static void
-test_ephy_bookmarks_add (void)
-{
- EphyBookmarks *bookmarks;
- EphyNode *node, *result;
-
- bookmarks = ephy_bookmarks_new ();
- g_assert (bookmarks);
-
- node = ephy_bookmarks_add (bookmarks, "GNOME", "http://www.gnome.org");
- g_assert (node);
- result = ephy_bookmarks_find_bookmark (bookmarks, "http://www.gnome.org");
- g_assert (node == result);
-
- g_object_unref (bookmarks);
-
- clear_bookmark_files ();
-}
-
-static void
-test_ephy_bookmarks_set_address (void)
-{
- EphyBookmarks *bookmarks;
- EphyNode *node;
-
- bookmarks = ephy_bookmarks_new ();
- g_assert (bookmarks);
- node = ephy_bookmarks_add (bookmarks, "GNOME", "http://www.gnome.org");
- g_assert (node);
- ephy_bookmarks_set_address (bookmarks, node, "http://www.google.com");
- node = ephy_bookmarks_find_bookmark (bookmarks, "http://www.gnome.org");
- g_assert (node == NULL);
- node = ephy_bookmarks_find_bookmark (bookmarks, "http://www.google.com");
- g_assert (node);
-
- g_object_unref (bookmarks);
- clear_bookmark_files ();
-}
-
-int
-main (int argc, char *argv[])
-{
- gboolean ret;
-
- gtk_test_init (&argc, &argv);
- ephy_debug_init ();
-
- if (!ephy_file_helpers_init (NULL,
- EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS,
- NULL)) {
- g_debug ("Something wrong happened with ephy_file_helpers_init()");
- return -1;
- }
-
- _ephy_shell_create_instance (EPHY_EMBED_SHELL_MODE_TEST);
-
- g_test_add_func ("/src/bookmarks/ephy-bookmarks/create",
- test_ephy_bookmarks_create);
-
- g_test_add_func ("/src/bookmarks/ephy-bookmarks/add",
- test_ephy_bookmarks_add);
-
- g_test_add_func ("/src/bookmarks/ephy-bookmarks/set_address",
- test_ephy_bookmarks_set_address);
-
- ret = g_test_run ();
-
- return ret;
-}