aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog38
-rw-r--r--data/ui/epiphany-bookmark-editor-ui.xml.in2
-rw-r--r--src/bookmarks/Makefile.am36
-rw-r--r--src/bookmarks/ephy-bookmark-properties.c301
-rw-r--r--src/bookmarks/ephy-bookmark-properties.h58
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c271
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.h2
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c9
-rw-r--r--src/bookmarks/ephy-bookmarks.c94
-rw-r--r--src/bookmarks/ephy-bookmarks.h8
-rw-r--r--src/bookmarks/ephy-new-bookmark.c49
-rw-r--r--src/bookmarks/ephy-topics-selector.c350
-rw-r--r--src/bookmarks/ephy-topics-selector.h63
13 files changed, 896 insertions, 385 deletions
diff --git a/ChangeLog b/ChangeLog
index 3b4415f38..eab7f379f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,43 @@
2003-03-22 Marco Pesenti Gritti <marco@it.gnome.org>
+ * data/ui/epiphany-bookmark-editor-ui.xml.in:
+ * src/bookmarks/Makefile.am:
+ * src/bookmarks/ephy-bookmark-properties.c:
+ (ephy_bookmark_properties_get_type),
+ (ephy_bookmark_properties_class_init),
+ (ephy_bookmark_properties_finalize),
+ (ephy_bookmark_properties_set_bookmark),
+ (ephy_bookmark_properties_set_property),
+ (ephy_bookmark_properties_get_property),
+ (bookmark_properties_response_cb), (build_ui),
+ (ephy_bookmark_properties_init), (ephy_bookmark_properties_new):
+ * src/bookmarks/ephy-bookmark-properties.h:
+ * src/bookmarks/ephy-bookmarks-editor.c:
+ (popup_cmd_bookmark_properties), (ephy_bookmarks_editor_get_type),
+ (keyword_node_selected_cb), (ephy_bookmarks_editor_construct):
+ * src/bookmarks/ephy-bookmarks-editor.h:
+ * src/bookmarks/ephy-bookmarks-import.c: (mozilla_parse_bookmarks),
+ (xbel_parse_single_bookmark), (xbel_parse_folder):
+ * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_add),
+ (ephy_bookmarks_set_keyword), (ephy_bookmarks_unset_keyword):
+ * src/bookmarks/ephy-bookmarks.h:
+ * src/bookmarks/ephy-new-bookmark.c: (ephy_new_bookmark_add),
+ (build_editing_table), (ephy_new_bookmark_construct):
+ * src/bookmarks/ephy-topics-selector.c:
+ (ephy_topics_selector_get_type), (ephy_topics_selector_class_init),
+ (ephy_topics_selector_finalize),
+ (ephy_topics_selector_set_bookmark),
+ (ephy_topics_selector_set_property),
+ (ephy_topics_selector_get_property), (fill_model), (topic_toggled),
+ (ephy_topics_selector_apply), (ephy_topics_build_ui),
+ (ephy_topics_selector_init), (ephy_topics_selector_new):
+ * src/bookmarks/ephy-topics-selector.h:
+
+ Begin bookmarks editor redesign. Please still dont use it or you really
+ want backup your bookmarks ;)
+
+2003-03-22 Marco Pesenti Gritti <marco@it.gnome.org>
+
* src/ephy-window.c: (update_favicon_control):
Cleanup: get active tab using the function
diff --git a/data/ui/epiphany-bookmark-editor-ui.xml.in b/data/ui/epiphany-bookmark-editor-ui.xml.in
index f474213e9..4bd0bb024 100644
--- a/data/ui/epiphany-bookmark-editor-ui.xml.in
+++ b/data/ui/epiphany-bookmark-editor-ui.xml.in
@@ -7,6 +7,8 @@
<menuitem name="OpenInTabBMK" verb="OpenInTab"/>
<separator name="BookmarksPopupSep1"/>
<menuitem name="RemoveBMK" verb="Remove"/>
+ <separator name="BookmarksPopupSep2"/>
+ <menuitem name="BMKProperties" verb="Properties"/>
</popup>
</popups>
diff --git a/src/bookmarks/Makefile.am b/src/bookmarks/Makefile.am
index 24fa968da..b0410e184 100644
--- a/src/bookmarks/Makefile.am
+++ b/src/bookmarks/Makefile.am
@@ -17,20 +17,24 @@ INCLUDES = \
noinst_LTLIBRARIES = libephybookmarks.la
-libephybookmarks_la_SOURCES = \
- ephy-bookmark-action.c \
- ephy-bookmark-action.h \
- ephy-bookmarks.c \
- ephy-bookmarks.h \
- ephy-bookmarks-editor.c \
- ephy-bookmarks-editor.h \
- ephy-bookmarks-import.c \
- ephy-bookmarks-import.h \
- ephy-keywords-entry.c \
- ephy-keywords-entry.h \
- ephy-new-bookmark.c \
- ephy-new-bookmark.h \
- ephy-node-view.c \
- ephy-node-view.h \
- ephy-tree-model-node.c \
+libephybookmarks_la_SOURCES = \
+ ephy-bookmark-action.c \
+ ephy-bookmark-action.h \
+ ephy-bookmark-properties.c \
+ ephy-bookmark-properties.h \
+ ephy-bookmarks.c \
+ ephy-bookmarks.h \
+ ephy-bookmarks-editor.c \
+ ephy-bookmarks-editor.h \
+ ephy-bookmarks-import.c \
+ ephy-bookmarks-import.h \
+ ephy-keywords-entry.c \
+ ephy-keywords-entry.h \
+ ephy-new-bookmark.c \
+ ephy-new-bookmark.h \
+ ephy-node-view.c \
+ ephy-node-view.h \
+ ephy-topics-selector.c \
+ ephy-topics-selector.h \
+ ephy-tree-model-node.c \
ephy-tree-model-node.h
diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c
new file mode 100644
index 000000000..9da4dffa8
--- /dev/null
+++ b/src/bookmarks/ephy-bookmark-properties.c
@@ -0,0 +1,301 @@
+/*
+ * Copyright (C) 2002 Marco Pesenti Gritti <mpeseng@tin.it>
+ *
+ * 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 of the License, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "ephy-bookmark-properties.h"
+#include "ephy-topics-selector.h"
+#include "ephy-debug.h"
+
+#include <gtk/gtkstock.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkmisc.h>
+#include <libgnome/gnome-i18n.h>
+
+static void ephy_bookmark_properties_class_init (EphyBookmarkPropertiesClass *klass);
+static void ephy_bookmark_properties_init (EphyBookmarkProperties *editor);
+static void ephy_bookmark_properties_finalize (GObject *object);
+static void ephy_bookmark_properties_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void ephy_bookmark_properties_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+struct EphyBookmarkPropertiesPrivate
+{
+ EphyBookmarks *bookmarks;
+ EphyNode *bookmark;
+
+ GtkWidget *title_entry;
+ GtkWidget *location_entry;
+ GtkWidget *topics_selector;
+};
+
+enum
+{
+ PROP_0,
+ PROP_BOOKMARKS,
+ PROP_BOOKMARK
+};
+
+static GObjectClass *parent_class = NULL;
+
+GType
+ephy_bookmark_properties_get_type (void)
+{
+ static GType ephy_bookmark_properties_type = 0;
+
+ if (ephy_bookmark_properties_type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyBookmarkPropertiesClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) ephy_bookmark_properties_class_init,
+ NULL,
+ NULL,
+ sizeof (EphyBookmarkProperties),
+ 0,
+ (GInstanceInitFunc) ephy_bookmark_properties_init
+ };
+
+ ephy_bookmark_properties_type = g_type_register_static (GTK_TYPE_DIALOG,
+ "EphyBookmarkProperties",
+ &our_info, 0);
+ }
+
+ return ephy_bookmark_properties_type;
+}
+
+static void
+ephy_bookmark_properties_class_init (EphyBookmarkPropertiesClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = ephy_bookmark_properties_finalize;
+
+ object_class->set_property = ephy_bookmark_properties_set_property;
+ object_class->get_property = ephy_bookmark_properties_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_BOOKMARKS,
+ g_param_spec_object ("bookmarks",
+ "Bookmarks set",
+ "Bookmarks set",
+ EPHY_BOOKMARKS_TYPE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_BOOKMARK,
+ g_param_spec_object ("bookmark",
+ "Bookmark",
+ "Bookmark",
+ EPHY_TYPE_NODE,
+ G_PARAM_READWRITE));
+}
+
+static void
+ephy_bookmark_properties_finalize (GObject *object)
+{
+ EphyBookmarkProperties *editor;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (EPHY_IS_BOOKMARK_PROPERTIES (object));
+
+ editor = EPHY_BOOKMARK_PROPERTIES (object);
+
+ g_return_if_fail (editor->priv != NULL);
+
+ g_free (editor->priv);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+ephy_bookmark_properties_set_bookmark (EphyBookmarkProperties *selector,
+ EphyNode *bookmark)
+{
+ LOG ("Set bookmark")
+
+ selector->priv->bookmark = bookmark;
+
+ g_object_notify (G_OBJECT (selector), "bookmark");
+}
+
+static void
+ephy_bookmark_properties_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyBookmarkProperties *selector = EPHY_BOOKMARK_PROPERTIES (object);
+
+ switch (prop_id)
+ {
+ case PROP_BOOKMARKS:
+ selector->priv->bookmarks = g_value_get_object (value);
+ break;
+ case PROP_BOOKMARK:
+ ephy_bookmark_properties_set_bookmark
+ (selector, g_value_get_object (value));
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ephy_bookmark_properties_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyBookmarkProperties *selector = EPHY_BOOKMARK_PROPERTIES (object);
+
+ switch (prop_id)
+ {
+ case PROP_BOOKMARK:
+ g_value_set_object (value, selector);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+bookmark_properties_response_cb (GtkDialog *dialog,
+ int response_id,
+ gpointer data)
+{
+ switch (response_id)
+ {
+ case GTK_RESPONSE_CLOSE:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ break;
+ }
+}
+
+static void
+build_ui (EphyBookmarkProperties *editor)
+{
+ GtkWidget *table, *label, *entry, *topics_selector;
+ char *str;
+
+ g_signal_connect (G_OBJECT (editor),
+ "response",
+ G_CALLBACK (bookmark_properties_response_cb),
+ editor);
+
+ gtk_window_set_title (GTK_WINDOW (editor),
+ _("Bookmark properties"));
+
+ gtk_dialog_set_has_separator (GTK_DIALOG (editor), FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (editor)->vbox), 12);
+
+ table = gtk_table_new (2, 2, FALSE);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 6);
+ gtk_widget_show (table);
+
+ label = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ str = g_strconcat ("<b>", _("Title:"), "</b>", NULL);
+ gtk_label_set_markup (GTK_LABEL (label), str);
+ g_free (str);
+ gtk_widget_show (label);
+ entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
+ editor->priv->title_entry = entry;
+ gtk_widget_set_size_request (entry, 200, -1);
+ gtk_widget_show (entry);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ str = g_strconcat ("<b>", _("Location:"), "</b>", NULL);
+ gtk_label_set_markup (GTK_LABEL (label), str);
+ g_free (str);
+ gtk_widget_show (label);
+ entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
+ editor->priv->location_entry = entry;
+ gtk_widget_show (entry);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
+ str = g_strconcat ("<b>", _("Topics:"), "</b>", NULL);
+ gtk_label_set_markup (GTK_LABEL (label), str);
+ g_free (str);
+ gtk_widget_show (label);
+ topics_selector = ephy_topics_selector_new (editor->priv->bookmarks);
+ gtk_widget_show (topics_selector);
+ editor->priv->topics_selector = topics_selector;
+
+ gtk_widget_show (entry);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), topics_selector, 1, 2, 2, 3,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (editor)->vbox),
+ table, TRUE, TRUE, 0);
+
+ gtk_dialog_add_button (GTK_DIALOG (editor),
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE);
+ gtk_dialog_set_default_response (GTK_DIALOG (editor), GTK_RESPONSE_CLOSE);
+}
+
+static void
+ephy_bookmark_properties_init (EphyBookmarkProperties *editor)
+{
+ editor->priv = g_new0 (EphyBookmarkPropertiesPrivate, 1);
+
+ editor->priv->bookmark = NULL;
+}
+
+GtkWidget *
+ephy_bookmark_properties_new (EphyBookmarks *bookmarks,
+ EphyNode *bookmark)
+{
+ EphyBookmarkProperties *editor;
+
+ g_assert (bookmarks != NULL);
+
+ editor = EPHY_BOOKMARK_PROPERTIES (g_object_new
+ (EPHY_TYPE_BOOKMARK_PROPERTIES,
+ "bookmarks", bookmarks,
+ "bookmark", bookmark,
+ NULL));
+
+ build_ui (editor);
+
+ return GTK_WIDGET (editor);
+}
diff --git a/src/bookmarks/ephy-bookmark-properties.h b/src/bookmarks/ephy-bookmark-properties.h
new file mode 100644
index 000000000..1790259ca
--- /dev/null
+++ b/src/bookmarks/ephy-bookmark-properties.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2002 Marco Pesenti Gritti <mpeseng@tin.it>
+ *
+ * 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 of the License, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_BOOKMARK_PROPERTIES_H
+#define EPHY_BOOKMARK_PROPERTIES_H
+
+#include "ephy-bookmarks.h"
+
+#include <gtk/gtkdialog.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_BOOKMARK_PROPERTIES (ephy_bookmark_properties_get_type ())
+#define EPHY_BOOKMARK_PROPERTIES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_BOOKMARK_PROPERTIES, EphyBookmarkProperties))
+#define EPHY_BOOKMARK_PROPERTIES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_BOOKMARK_PROPERTIES, EphyBookmarkPropertiesClass))
+#define EPHY_IS_BOOKMARK_PROPERTIES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_BOOKMARK_PROPERTIES))
+#define EPHY_IS_BOOKMARK_PROPERTIES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_BOOKMARK_PROPERTIES))
+#define EPHY_BOOKMARK_PROPERTIES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_BOOKMARK_PROPERTIES, EphyBookmarkPropertiesClass))
+
+typedef struct EphyBookmarkPropertiesPrivate EphyBookmarkPropertiesPrivate;
+
+typedef struct
+{
+ GtkDialog parent;
+
+ EphyBookmarkPropertiesPrivate *priv;
+} EphyBookmarkProperties;
+
+typedef struct
+{
+ GtkDialogClass parent;
+} EphyBookmarkPropertiesClass;
+
+GType ephy_bookmark_properties_get_type (void);
+
+GtkWidget *ephy_bookmark_properties_new (EphyBookmarks *bookmarks,
+ EphyNode *bookmark);
+
+G_END_DECLS
+
+#endif /* EPHY_BOOKMARK_PROPERTIES_H */
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 2a0ba3352..1037ada63 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -19,7 +19,6 @@
#include <gtk/gtktable.h>
#include <gtk/gtklabel.h>
-#include <gtk/gtkentry.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkvbox.h>
@@ -28,6 +27,7 @@
#include <string.h>
#include "ephy-bookmarks-editor.h"
+#include "ephy-bookmark-properties.h"
#include "ephy-node-view.h"
#include "ephy-window.h"
#include "ephy-keywords-entry.h"
@@ -59,6 +59,8 @@ static void popup_cmd_open_bookmarks_in_browser (EggAction *action,
EphyBookmarksEditor *editor);
static void popup_cmd_remove_bookmarks (EggAction *action,
EphyBookmarksEditor *editor);
+static void popup_cmd_bookmark_properties (EggAction *action,
+ EphyBookmarksEditor *editor);
struct EphyBookmarksEditorPrivate
{
@@ -66,11 +68,7 @@ struct EphyBookmarksEditorPrivate
EphyNodeView *bm_view;
EphyNodeView *key_view;
EphyNodeFilter *bookmarks_filter;
- GtkWidget *title_entry;
- GtkWidget *location_entry;
- GtkWidget *keywords_entry;
GtkWidget *search_entry;
- GtkWidget *go_button;
EggMenuMerge *ui_merge;
EggActionGroup *action_group;
};
@@ -101,10 +99,12 @@ static EggActionGroupEntry ephy_bookmark_popup_entries [] = {
{ "Remove", N_("_Remove"), GTK_STOCK_REMOVE, NULL,
NULL, G_CALLBACK (popup_cmd_remove_bookmarks), NULL },
+
+ { "Properties", N_("_Properties"), GTK_STOCK_PROPERTIES, NULL,
+ NULL, G_CALLBACK (popup_cmd_bookmark_properties), NULL },
};
static guint ephy_bookmark_popup_n_entries = G_N_ELEMENTS (ephy_bookmark_popup_entries);
-
static void
popup_cmd_open_bookmarks_in_tabs (EggAction *action,
EphyBookmarksEditor *editor)
@@ -170,6 +170,29 @@ popup_cmd_remove_bookmarks (EggAction *action,
ephy_node_view_remove (editor->priv->bm_view);
}
+static void
+popup_cmd_bookmark_properties (EggAction *action,
+ EphyBookmarksEditor *editor)
+{
+ GtkWidget *dialog;
+ GList *selection;
+ GList *l;
+
+ selection = ephy_node_view_get_selection (editor->priv->bm_view);
+
+ for (l = selection; l; l = l->next)
+ {
+ EphyNode *node = EPHY_NODE (l->data);
+ dialog = ephy_bookmark_properties_new (editor->priv->bookmarks, node);
+ gtk_widget_show (GTK_WIDGET (dialog));
+ }
+
+ if (selection)
+ {
+ g_list_free (selection);
+ }
+}
+
GType
ephy_bookmarks_editor_get_type (void)
{
@@ -190,7 +213,7 @@ ephy_bookmarks_editor_get_type (void)
(GInstanceInitFunc) ephy_bookmarks_editor_init
};
- ephy_bookmarks_editor_type = g_type_register_static (GTK_TYPE_DIALOG,
+ ephy_bookmarks_editor_type = g_type_register_static (GTK_TYPE_WINDOW,
"EphyBookmarksEditor",
&our_info, 0);
}
@@ -287,53 +310,6 @@ ephy_bookmarks_editor_finalize (GObject *object)
}
static void
-ephy_bookmarks_editor_node_selected_cb (GtkWidget *view,
- EphyNode *node,
- EphyBookmarksEditor *editor)
-{
- const char *title;
- const char *keywords;
- const char *location;
- GList *selection;
-
- selection = ephy_node_view_get_selection (editor->priv->bm_view);
-
- if (node != NULL && g_list_length (selection) == 1)
- {
- g_assert (EPHY_IS_NODE (node));
-
- title = ephy_node_get_property_string
- (node, EPHY_NODE_BMK_PROP_TITLE);
- keywords = ephy_node_get_property_string
- (node, EPHY_NODE_BMK_PROP_KEYWORDS);
- location = ephy_node_get_property_string
- (node, EPHY_NODE_BMK_PROP_LOCATION);
- gtk_entry_set_text (GTK_ENTRY (editor->priv->title_entry),
- title ? g_strdup (title) : "");
- gtk_entry_set_text (GTK_ENTRY (editor->priv->keywords_entry),
- keywords ? g_strdup (keywords) : "");
- gtk_entry_set_text (GTK_ENTRY (editor->priv->location_entry),
- location ? g_strdup (location) : "");
- gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->title_entry), TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->keywords_entry), TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->location_entry), TRUE);
- /* Activate the Go button */
- gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->go_button), TRUE);
-
- g_list_free (selection);
- }
- else
- {
- gtk_entry_set_text (GTK_ENTRY (editor->priv->title_entry), "");
- gtk_entry_set_text (GTK_ENTRY (editor->priv->keywords_entry), "");
- gtk_entry_set_text (GTK_ENTRY (editor->priv->location_entry), "");
- gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->title_entry), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->keywords_entry), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->location_entry), FALSE);
- }
-}
-
-static void
ephy_bookmarks_editor_show_popup_cb (GtkWidget *view,
EphyBookmarksEditor *editor)
{
@@ -401,153 +377,6 @@ ephy_bookmarks_editor_go_to_location (EphyBookmarksEditor *editor)
}
static void
-ephy_bookmarks_editor_response_cb (GtkDialog *dialog,
- int response_id,
- EphyBookmarksEditor *editor)
-{
- switch (response_id)
- {
- case GTK_RESPONSE_CLOSE:
- gtk_widget_destroy (GTK_WIDGET (dialog));
- break;
- case RESPONSE_REMOVE:
- ephy_node_view_remove (editor->priv->bm_view);
- break;
- case RESPONSE_GO:
- ephy_bookmarks_editor_go_to_location (editor);
- break;
- }
-}
-
-static void
-update_prop_from_entry (EphyBookmarksEditor *editor,
- GtkWidget *entry,
- guint id)
-{
- GList *selection;
- GValue value = { 0, };
-
- selection = ephy_node_view_get_selection (editor->priv->bm_view);
- if (selection != NULL && g_list_length (selection) == 1)
- {
- EphyNode *bm = EPHY_NODE (selection->data);
- char *tmp;
-
- tmp = gtk_editable_get_chars
- (GTK_EDITABLE (entry), 0, -1);
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, tmp);
- ephy_node_set_property (bm, id, &value);
- g_value_unset (&value);
- g_free (tmp);
- g_list_free (selection);
- }
-}
-
-static void
-title_entry_changed_cb (GtkWidget *entry, EphyBookmarksEditor *editor)
-{
- update_prop_from_entry (editor, editor->priv->title_entry,
- EPHY_NODE_BMK_PROP_TITLE);
-}
-
-static void
-location_entry_changed_cb (GtkWidget *entry, EphyBookmarksEditor *editor)
-{
- update_prop_from_entry (editor, editor->priv->location_entry,
- EPHY_NODE_BMK_PROP_LOCATION);
-}
-
-static void
-keywords_changed_cb (GtkWidget *entry,
- EphyBookmarksEditor *editor)
-{
- EphyNode *node;
- GList *selection;
- char *keywords;
-
- selection = ephy_node_view_get_selection (editor->priv->bm_view);
- if (selection == NULL) return;
- node = EPHY_NODE (selection->data);
- g_list_free (selection);
-
- keywords = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
- ephy_bookmarks_update_keywords (editor->priv->bookmarks,
- keywords, node);
- g_free (keywords);
-
- update_prop_from_entry (editor, editor->priv->keywords_entry,
- EPHY_NODE_BMK_PROP_KEYWORDS);
-}
-
-static GtkWidget *
-build_editing_table (EphyBookmarksEditor *editor)
-{
- GtkWidget *table, *label, *entry;
- char *str;
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
- gtk_widget_show (table);
-
- /* Title entry */
- label = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- str = g_strconcat ("<b>", _("Title:"), "</b>", NULL);
- gtk_label_set_markup (GTK_LABEL (label), str);
- g_free (str);
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- editor->priv->title_entry = entry;
- gtk_widget_set_sensitive (GTK_WIDGET (entry), FALSE);
- gtk_widget_show (entry);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
- gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 0, 1);
- g_signal_connect (G_OBJECT (entry), "changed",
- G_CALLBACK (title_entry_changed_cb),
- editor);
-
- /* Location entry */
- label = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- str = g_strconcat ("<b>", _("Location:"), "</b>", NULL);
- gtk_label_set_markup (GTK_LABEL (label), str);
- g_free (str);
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- editor->priv->location_entry = entry;
- gtk_widget_set_sensitive (GTK_WIDGET (entry), FALSE);
- gtk_widget_show (entry);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
- gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 1, 2);
- g_signal_connect (G_OBJECT (entry), "changed",
- G_CALLBACK (location_entry_changed_cb),
- editor);
-
- /* Keywords entry */
- label = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- str = g_strconcat ("<b>", _("Topics:"), "</b>", NULL);
- gtk_label_set_markup (GTK_LABEL (label), str);
- g_free (str);
- gtk_widget_show (label);
- entry = ephy_keywords_entry_new ();
- ephy_keywords_entry_set_bookmarks (EPHY_KEYWORDS_ENTRY (entry),
- editor->priv->bookmarks);
- editor->priv->keywords_entry = entry;
- gtk_widget_set_sensitive (GTK_WIDGET (entry), FALSE);
- gtk_widget_show (entry);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
- gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 2, 3);
- g_signal_connect (G_OBJECT (entry), "keywords_changed",
- G_CALLBACK (keywords_changed_cb),
- editor);
-
- return table;
-}
-
-static void
bookmarks_filter (EphyBookmarksEditor *editor,
EphyNode *keyword)
{
@@ -574,9 +403,6 @@ keyword_node_selected_cb (EphyNodeView *view,
else
{
bookmarks_filter (editor, node);
- /* Desactivate the Go button */
- gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->go_button),
- FALSE);
}
}
@@ -650,7 +476,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
EggMenuMerge *ui_merge;
EggActionGroup *action_group;
int i;
-
+
for (i = 0; i < ephy_bookmark_popup_n_entries; i++)
{
ephy_bookmark_popup_entries[i].user_data = editor;
@@ -667,30 +493,23 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
NULL);
editor->priv->ui_merge = ui_merge;
editor->priv->action_group = action_group;
-
gtk_window_set_title (GTK_WINDOW (editor), _("Bookmarks"));
- gtk_dialog_set_has_separator (GTK_DIALOG (editor), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
gtk_widget_set_size_request (GTK_WIDGET (editor), 500, 450);
- g_signal_connect (G_OBJECT (editor),
- "response",
- G_CALLBACK (ephy_bookmarks_editor_response_cb),
- editor);
hbox = gtk_hbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (editor)->vbox),
- hbox, TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (editor), hbox);
gtk_widget_show (hbox);
g_assert (editor->priv->bookmarks);
node = ephy_bookmarks_get_keywords (editor->priv->bookmarks);
-
+
/* Keywords View */
- key_view = ephy_node_view_new (node, NULL);
+ key_view = ephy_node_view_new (node, NULL);
ephy_node_view_enable_drag_source (key_view);
ephy_node_view_set_browse_mode (key_view);
ephy_node_view_add_column (key_view, _("Topics"),
@@ -735,32 +554,10 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
G_CALLBACK (ephy_bookmarks_editor_node_activated_cb),
editor);
g_signal_connect (G_OBJECT (bm_view),
- "node_selected",
- G_CALLBACK (ephy_bookmarks_editor_node_selected_cb),
- editor);
- g_signal_connect (G_OBJECT (bm_view),
"show_popup",
G_CALLBACK (ephy_bookmarks_editor_show_popup_cb),
editor);
- gtk_box_pack_start (GTK_BOX (vbox),
- build_editing_table (editor),
- FALSE, FALSE, 0);
-
- editor->priv->go_button = gtk_dialog_add_button (GTK_DIALOG (editor),
- GTK_STOCK_JUMP_TO,
- RESPONSE_GO);
- /* The Go button is insensitive by default */
- gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->go_button), FALSE);
-
- gtk_dialog_add_button (GTK_DIALOG (editor),
- GTK_STOCK_REMOVE,
- RESPONSE_REMOVE);
- gtk_dialog_add_button (GTK_DIALOG (editor),
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE);
- gtk_dialog_set_default_response (GTK_DIALOG (editor), GTK_RESPONSE_CLOSE);
-
selected_id_str = eel_gconf_get_string (CONF_BOOKMARKS_SELECTED_NODE);
selected_id = g_ascii_strtoull (selected_id_str, NULL, 10);
if (selected_id <= 0)
diff --git a/src/bookmarks/ephy-bookmarks-editor.h b/src/bookmarks/ephy-bookmarks-editor.h
index f79dfa673..cb2eeea59 100644
--- a/src/bookmarks/ephy-bookmarks-editor.h
+++ b/src/bookmarks/ephy-bookmarks-editor.h
@@ -39,7 +39,7 @@ typedef struct EphyBookmarksEditorPrivate EphyBookmarksEditorPrivate;
typedef struct
{
- GtkDialog parent;
+ GtkWindow parent;
EphyBookmarksEditorPrivate *priv;
} EphyBookmarksEditor;
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c
index 182f8b887..4eda2a025 100644
--- a/src/bookmarks/ephy-bookmarks-import.c
+++ b/src/bookmarks/ephy-bookmarks-import.c
@@ -62,8 +62,7 @@ mozilla_parse_bookmarks (EphyBookmarks *bookmarks,
ephy_bookmarks_add (bookmarks,
title,
url,
- NULL,
- *keyword);
+ NULL);
xmlFree (title);
xmlFree (url);
}
@@ -104,7 +103,7 @@ xbel_parse_single_bookmark (EphyBookmarks *bookmarks,
{
xbel->smarturl = xmlNodeGetContent (child);
}
-
+
child = child->next;
}
}
@@ -144,12 +143,10 @@ xbel_parse_folder (EphyBookmarks *bookmarks,
child->children,
xbel);
-
ephy_bookmarks_add (bookmarks,
xbel->title,
url,
- xbel->smarturl,
- keyword);
+ xbel->smarturl);
if (url)
xmlFree (url);
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 8425ad92a..81a06e738 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -552,8 +552,7 @@ EphyNode *
ephy_bookmarks_add (EphyBookmarks *eb,
const char *title,
const char *url,
- const char *smart_url,
- const char *keywords)
+ const char *smart_url)
{
EphyNode *bm;
GValue value = { 0, };
@@ -578,14 +577,6 @@ ephy_bookmarks_add (EphyBookmarks *eb,
&value);
g_value_unset (&value);
- ephy_bookmarks_update_keywords (eb, keywords, bm);
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, keywords);
- ephy_node_set_property (bm, EPHY_NODE_BMK_PROP_KEYWORDS,
- &value);
- g_value_unset (&value);
-
ephy_node_add_child (eb->priv->bookmarks, bm);
ephy_bookmarks_emit_data_changed (eb);
@@ -868,6 +859,8 @@ ephy_bookmarks_set_keyword (EphyBookmarks *eb,
EphyNode *keyword,
EphyNode *bookmark)
{
+ if (ephy_node_has_child (keyword, bookmark)) return;
+
ephy_node_add_child (keyword, bookmark);
}
@@ -876,89 +869,12 @@ ephy_bookmarks_unset_keyword (EphyBookmarks *eb,
EphyNode *keyword,
EphyNode *bookmark)
{
+ if (!ephy_node_has_child (keyword, bookmark)) return;
+
ephy_node_remove_child (keyword, bookmark);
ephy_bookmarks_clean_empty_keywords (eb);
}
-static GList *
-diff_keywords (char **ks1, char **ks2)
-{
- GList *result = NULL;
- int i, j;
-
- for (i = 0; ks1 != NULL && ks1[i] != NULL; i++)
- {
- gboolean found = FALSE;
-
- LOG ("Diff keywords, keyword:\"%s\"", ks1[i])
-
- for (j = 0; ks2 != NULL && ks2[j] != NULL; j++)
- {
- if (strcmp (ks1[i], ks2[j]) == 0)
- {
- found = TRUE;
- }
- }
-
- if (!found && g_utf8_strlen (ks1[i], -1) > 0)
- {
- result = g_list_append (result, ks1[i]);
- }
- }
-
- return result;
-}
-
-void
-ephy_bookmarks_update_keywords (EphyBookmarks *eb,
- const char *keywords,
- EphyNode *node)
-{
- const char *prop;
- char **ks, **old_ks = NULL;
- GList *diffs, *l;
- EphyNode *keyword;
-
- prop = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_KEYWORDS);
- ks = g_strsplit (keywords, " ", 10);
- if (prop != NULL)
- {
- old_ks = g_strsplit (prop, " ", 10);
- }
-
- diffs = diff_keywords (ks, old_ks);
- for (l = diffs; l != NULL; l = l->next)
- {
- char *word = (char *)l->data;
-
- keyword = ephy_bookmarks_find_keyword
- (eb, word, FALSE);
-
- if (!keyword)
- {
- keyword = ephy_bookmarks_add_keyword
- (eb, word);
- }
-
- ephy_bookmarks_set_keyword (eb, keyword, node);
- }
- g_list_free (diffs);
-
- diffs = diff_keywords (old_ks, ks);
- for (l = diffs; l != NULL; l = l->next)
- {
- keyword = ephy_bookmarks_find_keyword (eb,
- (char *)l->data, FALSE);
- g_return_if_fail (keyword != NULL);
-
- ephy_bookmarks_unset_keyword (eb, keyword, node);
- }
- g_list_free (diffs);
-
- g_strfreev (ks);
- g_strfreev (old_ks);
-}
-
EphyNode *
ephy_bookmarks_get_keywords (EphyBookmarks *eb)
{
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index 0d8f75efa..4811c5577 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -45,7 +45,6 @@ enum
EPHY_NODE_BMK_PROP_SMART_LOCATION = 6,
EPHY_NODE_BMK_PROP_ICON = 7,
EPHY_NODE_KEYWORD_PROP_ALL_PRIORITY = 8
-
};
struct EphyBookmarks
@@ -68,8 +67,7 @@ EphyBookmarks *ephy_bookmarks_new (void);
EphyNode *ephy_bookmarks_add (EphyBookmarks *eb,
const char *title,
const char *url,
- const char *smart_url,
- const char *keywords);
+ const char *smart_url);
guint ephy_bookmarks_get_bookmark_id (EphyBookmarks *eb,
const char *url);
@@ -99,10 +97,6 @@ void ephy_bookmarks_unset_keyword (EphyBookmarks *eb,
EphyNode *keyword,
EphyNode *bookmark);
-void ephy_bookmarks_update_keywords (EphyBookmarks *eb,
- const char *keywords,
- EphyNode *bookmark_node);
-
/* Favorites */
EphyNode *ephy_bookmarks_get_favorites (EphyBookmarks *eb);
diff --git a/src/bookmarks/ephy-new-bookmark.c b/src/bookmarks/ephy-new-bookmark.c
index a4e65b772..bd14eb974 100644
--- a/src/bookmarks/ephy-new-bookmark.c
+++ b/src/bookmarks/ephy-new-bookmark.c
@@ -27,7 +27,7 @@
#include <libgnome/gnome-i18n.h>
#include "ephy-new-bookmark.h"
-#include "ephy-keywords-entry.h"
+#include "ephy-topics-selector.h"
#include "ephy-debug.h"
static void ephy_new_bookmark_class_init (EphyNewBookmarkClass *klass);
@@ -51,7 +51,7 @@ struct EphyNewBookmarkPrivate
gulong id;
GtkWidget *title_entry;
- GtkWidget *keywords_entry;
+ GtkWidget *topics_selector;
};
enum
@@ -144,18 +144,21 @@ static void
ephy_new_bookmark_add (EphyNewBookmark *new_bookmark)
{
char *title;
- char *keywords;
EphyNode *node;
+ EphyTopicsSelector *selector;
+
+ selector = EPHY_TOPICS_SELECTOR (new_bookmark->priv->topics_selector);
title = gtk_editable_get_chars
(GTK_EDITABLE (new_bookmark->priv->title_entry), 0, -1);
- keywords = gtk_editable_get_chars
- (GTK_EDITABLE (new_bookmark->priv->keywords_entry), 0, -1);
node = ephy_bookmarks_add (new_bookmark->priv->bookmarks, title,
new_bookmark->priv->location,
- new_bookmark->priv->smarturl, keywords);
+ new_bookmark->priv->smarturl);
new_bookmark->priv->id = ephy_node_get_id (node);
+ ephy_topics_selector_set_bookmark (selector, node);
+ ephy_topics_selector_apply (selector);
+
if (new_bookmark->priv->icon)
{
ephy_bookmarks_set_icon (new_bookmark->priv->bookmarks,
@@ -182,7 +185,7 @@ ephy_new_bookmark_response_cb (GtkDialog *dialog,
static GtkWidget *
build_editing_table (EphyNewBookmark *editor)
{
- GtkWidget *table, *label, *entry;
+ GtkWidget *table, *label, *entry, *topics_selector;
char *str;
table = gtk_table_new (2, 2, FALSE);
@@ -202,22 +205,22 @@ build_editing_table (EphyNewBookmark *editor)
gtk_widget_set_size_request (entry, 200, -1);
gtk_widget_show (entry);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
- gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 0, 1);
+ gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
label = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
str = g_strconcat ("<b>", _("Topics:"), "</b>", NULL);
gtk_label_set_markup (GTK_LABEL (label), str);
g_free (str);
gtk_widget_show (label);
- entry = ephy_keywords_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
- ephy_keywords_entry_set_bookmarks (EPHY_KEYWORDS_ENTRY (entry),
- editor->priv->bookmarks);
- editor->priv->keywords_entry = entry;
+ topics_selector = ephy_topics_selector_new (editor->priv->bookmarks);
+ gtk_widget_show (topics_selector);
+ editor->priv->topics_selector = topics_selector;
+
gtk_widget_show (entry);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
- gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 1, 2);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), topics_selector, 1, 2, 1, 2,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
return table;
}
@@ -225,8 +228,6 @@ build_editing_table (EphyNewBookmark *editor)
static void
ephy_new_bookmark_construct (EphyNewBookmark *editor)
{
- GtkWidget *hbox, *vbox;
-
gtk_window_set_title (GTK_WINDOW (editor),
_("Add bookmark"));
@@ -237,20 +238,10 @@ ephy_new_bookmark_construct (EphyNewBookmark *editor)
G_CALLBACK (ephy_new_bookmark_response_cb),
editor);
- hbox = gtk_hbox_new (FALSE, 6);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (editor)->vbox), 12);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (editor)->vbox),
- hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (hbox),
- vbox, TRUE, TRUE, 0);
- gtk_widget_show (vbox);
-
- gtk_box_pack_start (GTK_BOX (vbox),
build_editing_table (editor),
- FALSE, FALSE, 0);
+ TRUE, TRUE, 0);
gtk_dialog_add_button (GTK_DIALOG (editor),
GTK_STOCK_CANCEL,
diff --git a/src/bookmarks/ephy-topics-selector.c b/src/bookmarks/ephy-topics-selector.c
new file mode 100644
index 000000000..f0c64b59d
--- /dev/null
+++ b/src/bookmarks/ephy-topics-selector.c
@@ -0,0 +1,350 @@
+/*
+ * Copyright (C) 2002 Marco Pesenti Gritti <mpeseng@tin.it>
+ *
+ * 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 of the License, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "ephy-topics-selector.h"
+#include "ephy-debug.h"
+
+#include <gtk/gtkliststore.h>
+#include <gtk/gtkcellrenderertoggle.h>
+#include <gtk/gtkcellrenderertext.h>
+#include <gtk/gtktreeview.h>
+
+static void ephy_topics_selector_class_init (EphyTopicsSelectorClass *klass);
+static void ephy_topics_selector_init (EphyTopicsSelector *editor);
+static void ephy_topics_selector_finalize (GObject *object);
+static void ephy_topics_selector_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void ephy_topics_selector_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+struct EphyTopicsSelectorPrivate
+{
+ EphyBookmarks *bookmarks;
+ GtkTreeModel *model;
+ EphyNode *bookmark;
+};
+
+enum
+{
+ PROP_0,
+ PROP_BOOKMARKS,
+ PROP_BOOKMARK
+};
+
+enum
+{
+ COL_HAS_TOPIC,
+ COL_TOPIC,
+ COL_NODE
+};;
+
+static GObjectClass *parent_class = NULL;
+
+GType
+ephy_topics_selector_get_type (void)
+{
+ static GType ephy_topics_selector_type = 0;
+
+ if (ephy_topics_selector_type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyTopicsSelectorClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) ephy_topics_selector_class_init,
+ NULL,
+ NULL,
+ sizeof (EphyTopicsSelector),
+ 0,
+ (GInstanceInitFunc) ephy_topics_selector_init
+ };
+
+ ephy_topics_selector_type = g_type_register_static (GTK_TYPE_SCROLLED_WINDOW,
+ "EphyTopicsSelector",
+ &our_info, 0);
+ }
+
+ return ephy_topics_selector_type;
+}
+
+static void
+ephy_topics_selector_class_init (EphyTopicsSelectorClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = ephy_topics_selector_finalize;
+
+ object_class->set_property = ephy_topics_selector_set_property;
+ object_class->get_property = ephy_topics_selector_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_BOOKMARKS,
+ g_param_spec_object ("bookmarks",
+ "Bookmarks set",
+ "Bookmarks set",
+ EPHY_BOOKMARKS_TYPE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_BOOKMARK,
+ g_param_spec_object ("bookmark",
+ "Bookmark",
+ "Bookmark",
+ EPHY_TYPE_NODE,
+ G_PARAM_READWRITE));
+}
+
+static void
+ephy_topics_selector_finalize (GObject *object)
+{
+ EphyTopicsSelector *editor;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (EPHY_IS_TOPIC_SELECTOR (object));
+
+ editor = EPHY_TOPICS_SELECTOR (object);
+
+ g_return_if_fail (editor->priv != NULL);
+
+ g_free (editor->priv);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+void
+ephy_topics_selector_set_bookmark (EphyTopicsSelector *selector,
+ EphyNode *bookmark)
+{
+ LOG ("Set bookmark")
+
+ selector->priv->bookmark = bookmark;
+
+ g_object_notify (G_OBJECT (selector), "bookmark");
+}
+
+static void
+ephy_topics_selector_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTopicsSelector *selector = EPHY_TOPICS_SELECTOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_BOOKMARKS:
+ selector->priv->bookmarks = g_value_get_object (value);
+ break;
+ case PROP_BOOKMARK:
+ ephy_topics_selector_set_bookmark
+ (selector, g_value_get_object (value));
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ephy_topics_selector_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTopicsSelector *selector = EPHY_TOPICS_SELECTOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_BOOKMARK:
+ g_value_set_object (value, selector);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+fill_model (EphyTopicsSelector *editor)
+{
+ GPtrArray *children;
+ int i;
+ EphyNode *keywords;
+ GtkListStore *model = GTK_LIST_STORE (editor->priv->model);
+
+ keywords = ephy_bookmarks_get_keywords (editor->priv->bookmarks);
+
+ children = ephy_node_get_children (keywords);
+ for (i = 0; i < children->len; i++)
+ {
+ EphyNode *kid;
+ const char *name;
+ gboolean has_keyword;
+ gboolean real_topic;
+ GtkTreeIter iter;
+
+ kid = g_ptr_array_index (children, i);
+
+ name = ephy_node_get_property_string
+ (kid, EPHY_NODE_KEYWORD_PROP_NAME);
+ has_keyword = FALSE;
+ real_topic = !ephy_node_get_property_boolean
+ (kid, EPHY_NODE_KEYWORD_PROP_ALL_PRIORITY);
+
+ if (real_topic)
+ {
+ gtk_list_store_append (model, &iter);
+ gtk_list_store_set (model, &iter,
+ COL_HAS_TOPIC, has_keyword,
+ COL_TOPIC, name,
+ COL_NODE, kid,
+ -1);
+ }
+ }
+ ephy_node_thaw (keywords);
+}
+
+static void
+topic_toggled (GtkCellRendererToggle *cell,
+ char *path_str,
+ EphyTopicsSelector *selector)
+{
+ GtkTreeModel *model = selector->priv->model;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeIter iter;
+ gboolean has_topic;
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, COL_HAS_TOPIC, &has_topic, -1);
+ has_topic = !has_topic;
+
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_HAS_TOPIC, has_topic, -1);
+}
+
+void
+ephy_topics_selector_apply (EphyTopicsSelector *editor)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model = editor->priv->model;
+
+ LOG ("Update topics")
+
+ if (editor->priv->bookmark == NULL) return;
+
+ gtk_tree_model_get_iter_first (model, &iter);
+ do
+ {
+ GValue value = { 0, };
+ gboolean has_topic;
+ EphyNode *node;
+
+ gtk_tree_model_get_value (model, &iter, COL_HAS_TOPIC, &value);
+ has_topic = g_value_get_boolean (&value);
+ g_value_unset (&value);
+
+ gtk_tree_model_get_value (model, &iter, COL_NODE, &value);
+ node = g_value_get_pointer (&value);
+ g_value_unset (&value);
+
+ if (has_topic)
+ {
+ ephy_bookmarks_set_keyword (editor->priv->bookmarks,
+ node,
+ editor->priv->bookmark);
+ }
+ else
+ {
+ ephy_bookmarks_unset_keyword (editor->priv->bookmarks,
+ node,
+ editor->priv->bookmark);
+ }
+ }
+ while (gtk_tree_model_iter_next (model, &iter));
+}
+
+static void
+ephy_topics_build_ui (EphyTopicsSelector *editor)
+{
+ GtkListStore *model;
+ GtkWidget *treeview;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+ editor->priv->model = GTK_TREE_MODEL (model);
+
+ treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+ gtk_widget_show (treeview);
+ g_object_unref (model);
+
+ /* Has topic column */
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_signal_connect (renderer, "toggled",
+ G_CALLBACK (topic_toggled), editor);
+ column = gtk_tree_view_column_new_with_attributes
+ ("", renderer, "active", COL_HAS_TOPIC, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes
+ ("Description", renderer, "text", COL_TOPIC, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ fill_model (editor);
+
+ gtk_container_add (GTK_CONTAINER (editor), treeview);
+}
+
+static void
+ephy_topics_selector_init (EphyTopicsSelector *editor)
+{
+ editor->priv = g_new0 (EphyTopicsSelectorPrivate, 1);
+
+ editor->priv->bookmark = NULL;
+}
+
+GtkWidget *
+ephy_topics_selector_new (EphyBookmarks *bookmarks)
+{
+ EphyTopicsSelector *editor;
+
+ g_assert (bookmarks != NULL);
+
+ editor = EPHY_TOPICS_SELECTOR (g_object_new
+ (EPHY_TYPE_TOPIC_SELECTOR,
+ "bookmarks", bookmarks,
+ "hadjustment", NULL,
+ "vadjustment", NULL,
+ "hscrollbar_policy", GTK_POLICY_AUTOMATIC,
+ "vscrollbar_policy", GTK_POLICY_AUTOMATIC,
+ "shadow_type", GTK_SHADOW_IN,
+ NULL));
+
+ ephy_topics_build_ui (editor);
+
+ return GTK_WIDGET (editor);
+}
diff --git a/src/bookmarks/ephy-topics-selector.h b/src/bookmarks/ephy-topics-selector.h
new file mode 100644
index 000000000..5af7a65af
--- /dev/null
+++ b/src/bookmarks/ephy-topics-selector.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2002 Marco Pesenti Gritti <mpeseng@tin.it>
+ *
+ * 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 of the License, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_TOPICS_SELECTOR_H
+#define EPHY_TOPICS_SELECTOR_H
+
+#include "ephy-bookmarks.h"
+
+#include <gtk/gtkscrolledwindow.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_TOPIC_SELECTOR (ephy_topics_selector_get_type ())
+#define EPHY_TOPICS_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_TOPIC_SELECTOR, EphyTopicsSelector))
+#define EPHY_TOPICS_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_TOPIC_SELECTOR, EphyTopicsSelectorClass))
+#define EPHY_IS_TOPIC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_TOPIC_SELECTOR))
+#define EPHY_IS_TOPIC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_TOPIC_SELECTOR))
+#define EPHY_TOPICS_SELECTOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_TOPIC_SELECTOR, EphyTopicsSelectorClass))
+
+typedef struct EphyTopicsSelectorPrivate EphyTopicsSelectorPrivate;
+
+typedef struct
+{
+ GtkScrolledWindow parent;
+
+ EphyTopicsSelectorPrivate *priv;
+} EphyTopicsSelector;
+
+typedef struct
+{
+ GtkScrolledWindowClass parent;
+} EphyTopicsSelectorClass;
+
+GType ephy_topics_selector_get_type (void);
+
+GtkWidget *ephy_topics_selector_new (EphyBookmarks *bookmarks);
+
+void ephy_topics_selector_set_bookmark (EphyTopicsSelector *selector,
+ EphyNode *bookmark);
+
+void ephy_topics_selector_apply (EphyTopicsSelector *selector);
+
+
+G_END_DECLS
+
+#endif /* EPHY_TOPICS_SELECTOR_H */