diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2006-01-17 08:37:55 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-01-17 08:37:55 +0800 |
commit | a64fca9e1257503b5d3b5944f2254c227775b9f9 (patch) | |
tree | d51bff14a83e8b4fc094e4b557caf82b8ebb9e50 /src | |
parent | 4e874b34f9b185ce3d2c29a97c4b8dd78861b4e0 (diff) | |
download | gsoc2013-epiphany-a64fca9e1257503b5d3b5944f2254c227775b9f9.tar gsoc2013-epiphany-a64fca9e1257503b5d3b5944f2254c227775b9f9.tar.gz gsoc2013-epiphany-a64fca9e1257503b5d3b5944f2254c227775b9f9.tar.bz2 gsoc2013-epiphany-a64fca9e1257503b5d3b5944f2254c227775b9f9.tar.lz gsoc2013-epiphany-a64fca9e1257503b5d3b5944f2254c227775b9f9.tar.xz gsoc2013-epiphany-a64fca9e1257503b5d3b5944f2254c227775b9f9.tar.zst gsoc2013-epiphany-a64fca9e1257503b5d3b5944f2254c227775b9f9.zip |
=== Release 1.9.5.1 ===Release1951
2006-01-17 Christian Persch <chpe@cvs.gnome.org>
=== Release 1.9.5.1 ===
* NEWS:
* configure.ac:
* data/Makefile.am:
* data/chrome/Makefile.am:
* po/POTFILES.in:
R src/bookmarks/ephy-new-bookmark.c:
R src/bookmarks/ephy-new-bookmark.h:
R src/bookmarks/ephy-topics-selector.c:
R src/bookmarks/ephy-topics-selector.h:
Fix the tarball.
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks/ephy-new-bookmark.c | 496 | ||||
-rw-r--r-- | src/bookmarks/ephy-new-bookmark.h | 72 | ||||
-rw-r--r-- | src/bookmarks/ephy-topics-selector.c | 353 | ||||
-rw-r--r-- | src/bookmarks/ephy-topics-selector.h | 64 |
4 files changed, 0 insertions, 985 deletions
diff --git a/src/bookmarks/ephy-new-bookmark.c b/src/bookmarks/ephy-new-bookmark.c deleted file mode 100644 index 923dd642f..000000000 --- a/src/bookmarks/ephy-new-bookmark.c +++ /dev/null @@ -1,496 +0,0 @@ -/* - * Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org> - * - * 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$ - */ - -#include "config.h" - -#include "ephy-new-bookmark.h" -#include "ephy-bookmarks.h" -#include "ephy-state.h" -#include "ephy-topics-selector.h" -#include "ephy-debug.h" -#include "ephy-stock-icons.h" -#include "ephy-gui.h" - -#include <gtk/gtktable.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkscrolledwindow.h> -#include <gtk/gtkeditable.h> -#include <gtk/gtkdialog.h> -#include <gtk/gtkmessagedialog.h> -#include <glib/gi18n.h> -#include <string.h> - -static void ephy_new_bookmark_class_init (EphyNewBookmarkClass *klass); -static void ephy_new_bookmark_init (EphyNewBookmark *editor); -static void ephy_new_bookmark_finalize (GObject *object); -static void ephy_new_bookmark_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void ephy_new_bookmark_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -#define DATA_KEY "EphyNode" - -#define EPHY_NEW_BOOKMARK_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_NEW_BOOKMARK, EphyNewBookmarkPrivate)) - -enum -{ - RESPONSE_NEW_TOPIC -}; - -struct _EphyNewBookmarkPrivate -{ - EphyBookmarks *bookmarks; - char *location; - char *icon; - guint id; - - GtkWidget *title_entry; - GtkWidget *topics_selector; -}; - -enum -{ - PROP_0, - PROP_BOOKMARKS, - PROP_LOCATION -}; - -static GObjectClass *parent_class = NULL; - -GType -ephy_new_bookmark_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) - { - static const GTypeInfo our_info = - { - sizeof (EphyNewBookmarkClass), - NULL, - NULL, - (GClassInitFunc) ephy_new_bookmark_class_init, - NULL, - NULL, - sizeof (EphyNewBookmark), - 0, - (GInstanceInitFunc) ephy_new_bookmark_init - }; - - type = g_type_register_static (GTK_TYPE_DIALOG, - "EphyNewBookmark", - &our_info, 0); - } - - return type; -} - -static void -ephy_new_bookmark_class_init (EphyNewBookmarkClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = ephy_new_bookmark_finalize; - - object_class->set_property = ephy_new_bookmark_set_property; - object_class->get_property = ephy_new_bookmark_get_property; - - g_object_class_install_property (object_class, - PROP_BOOKMARKS, - g_param_spec_object ("bookmarks", - "Bookmarks set", - "Bookmarks set", - EPHY_TYPE_BOOKMARKS, - G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, - PROP_LOCATION, - g_param_spec_string ("location", - "Bookmark location", - "Bookmark location", - "", - G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (object_class, sizeof(EphyNewBookmarkPrivate)); -} - -static void -ephy_new_bookmark_finalize (GObject *object) -{ - EphyNewBookmark *editor = EPHY_NEW_BOOKMARK (object); - - g_free (editor->priv->location); - g_free (editor->priv->icon); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -ephy_new_bookmark_add (EphyNewBookmark *new_bookmark) -{ - char *title; - 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); - node = ephy_bookmarks_add (new_bookmark->priv->bookmarks, title, - new_bookmark->priv->location); - new_bookmark->priv->id = ephy_node_get_id (node); - - ephy_topics_selector_apply (selector, node); - - if (new_bookmark->priv->icon) - { - ephy_bookmarks_set_icon (new_bookmark->priv->bookmarks, - new_bookmark->priv->location, - new_bookmark->priv->icon); - } - - g_free (title); -} - -static void -response_cb (EphyNewBookmark *new_bookmark, - int response_id, - gpointer user_data) -{ - EphyTopicsSelector *selector; - - selector = EPHY_TOPICS_SELECTOR (new_bookmark->priv->topics_selector); - - switch (response_id) - { - case GTK_RESPONSE_HELP: - ephy_gui_help (GTK_WINDOW (new_bookmark), - "epiphany", - "to-create-new-bookmark"); - break; - case RESPONSE_NEW_TOPIC: - ephy_topics_selector_new_topic (selector); - break; - /* For both OK and Cancel we want to destroy the dialog */ - case GTK_RESPONSE_OK: - ephy_new_bookmark_add (new_bookmark); - case GTK_RESPONSE_CANCEL: - default: - gtk_widget_destroy (GTK_WIDGET (new_bookmark)); - break; - } -} - -static GtkWidget * -build_editing_table (EphyNewBookmark *editor) -{ - GtkWidget *table, *label, *entry, *topics_selector, *scrolled_window; - 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), 12); - gtk_container_set_border_width (GTK_CONTAINER (GTK_TABLE (table)), 5); - gtk_widget_show (table); - - - 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); - 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_with_mnemonic (GTK_LABEL (label), str); - g_free (str); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); - gtk_widget_show (label); - 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); - - - topics_selector = ephy_topics_selector_new (editor->priv->bookmarks, NULL); - gtk_widget_show (topics_selector); - scrolled_window = g_object_new (GTK_TYPE_SCROLLED_WINDOW, - "hadjustment", NULL, - "vadjustment", NULL, - "hscrollbar_policy", GTK_POLICY_AUTOMATIC, - "vscrollbar_policy", GTK_POLICY_AUTOMATIC, - "shadow_type", GTK_SHADOW_IN, - NULL); - gtk_widget_show (scrolled_window); - gtk_container_add (GTK_CONTAINER (scrolled_window), topics_selector); - editor->priv->topics_selector = topics_selector; - label = gtk_label_new (NULL); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); - str = g_strconcat ("<b>", _("To_pics:"), "</b>", NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), str); - g_free (str); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), topics_selector); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - gtk_table_attach (GTK_TABLE (table), scrolled_window, 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - return table; -} - -static void -ephy_new_bookmark_construct (EphyNewBookmark *editor) -{ - ephy_state_add_window (GTK_WIDGET(editor), - "new_bookmark", - 280, 240, FALSE, - EPHY_STATE_WINDOW_SAVE_SIZE); - - gtk_window_set_title (GTK_WINDOW (editor), - _("Add Bookmark")); - gtk_window_set_icon_name (GTK_WINDOW (editor), STOCK_ADD_BOOKMARK); - - gtk_dialog_set_has_separator (GTK_DIALOG (editor), FALSE); - gtk_container_set_border_width (GTK_CONTAINER (editor), 5); - g_signal_connect (G_OBJECT (editor), - "response", - G_CALLBACK (response_cb), - editor); - - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (editor)->vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (editor)->vbox), - build_editing_table (editor), - TRUE, TRUE, 0); - - gtk_dialog_add_button (GTK_DIALOG (editor), - GTK_STOCK_HELP, - GTK_RESPONSE_HELP); - gtk_dialog_add_button (GTK_DIALOG (editor), - _("_New Topic"), - RESPONSE_NEW_TOPIC); - gtk_dialog_add_button (GTK_DIALOG (editor), - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL); - gtk_dialog_add_button (GTK_DIALOG (editor), - GTK_STOCK_OK, - GTK_RESPONSE_OK); - gtk_dialog_set_default_response (GTK_DIALOG (editor), GTK_RESPONSE_OK); -} - -static GtkWidget* -duplicate_dialog_construct (GtkWindow *parent, - const char *title) -{ - GtkWidget *dialog; - char *str, *tmp_str; - - tmp_str = g_markup_printf_escaped (_("You already have a bookmark titled ā%sā for this page."), - title); - str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", tmp_str, "</span>", NULL); - - dialog = gtk_message_dialog_new - (GTK_WINDOW (parent), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, NULL); - gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), str); - g_free (tmp_str); - g_free (str); - - gtk_dialog_add_button (GTK_DIALOG (dialog), - _("_View Properties"), GTK_RESPONSE_ACCEPT); - gtk_dialog_add_button (GTK_DIALOG (dialog), - GTK_STOCK_OK, GTK_RESPONSE_OK); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - gtk_window_set_title (GTK_WINDOW (dialog), _("Duplicated Bookmark")); - gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser"); - - return dialog; -} - -static void -duplicate_bookmark_response_cb (GtkWidget *dialog, - int response, - EphyBookmarks *bookmarks) -{ - if (response == GTK_RESPONSE_ACCEPT) - { - EphyNode *node; - GtkWidget *parent; - - node = g_object_get_data (G_OBJECT (dialog), DATA_KEY); - parent = GTK_WIDGET (gtk_window_get_transient_for (GTK_WINDOW (dialog))); - ephy_bookmarks_show_bookmark_properties (bookmarks, node, parent); - } - - gtk_widget_destroy (dialog); -} - -static void -duplicated_node_destroy_cb (EphyNode *node, - GtkWidget *dialog) -{ - gtk_widget_destroy (dialog); -} - -gboolean -ephy_new_bookmark_is_unique (EphyBookmarks *bookmarks, - GtkWindow *parent, - const char *address) -{ - EphyNode *node; - - node = ephy_bookmarks_find_bookmark (bookmarks, address); - if (node) - { - GtkWidget *dialog; - const char *title; - - title = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_TITLE); - dialog = duplicate_dialog_construct (parent, title); - gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); - g_object_set_data (G_OBJECT (dialog), DATA_KEY, node); - g_signal_connect (G_OBJECT (dialog), - "response", - G_CALLBACK (duplicate_bookmark_response_cb), - bookmarks); - ephy_node_signal_connect_object (node, EPHY_NODE_DESTROY, - (EphyNodeCallback) duplicated_node_destroy_cb, - G_OBJECT (dialog)); - gtk_widget_show (GTK_WIDGET (dialog)); - return FALSE; - } - - return TRUE; -} - -GtkWidget * -ephy_new_bookmark_new (EphyBookmarks *bookmarks, - GtkWindow *parent, - const char *location) -{ - EphyNewBookmark *editor; - - g_assert (bookmarks != NULL); - - editor = EPHY_NEW_BOOKMARK (g_object_new - (EPHY_TYPE_NEW_BOOKMARK, - "bookmarks", bookmarks, - "location", location, - NULL)); - if (parent) - { - gtk_window_set_transient_for (GTK_WINDOW (editor), parent); - } - - ephy_new_bookmark_construct (editor); - - return GTK_WIDGET (editor); -} - -static void -ephy_new_bookmark_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EphyNewBookmark *editor = EPHY_NEW_BOOKMARK (object); - - switch (prop_id) - { - case PROP_BOOKMARKS: - editor->priv->bookmarks = g_value_get_object (value); - break; - case PROP_LOCATION: - g_free (editor->priv->location); - editor->priv->location = g_strdup (g_value_get_string (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -ephy_new_bookmark_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EphyNewBookmark *editor = EPHY_NEW_BOOKMARK (object); - - switch (prop_id) - { - case PROP_LOCATION: - g_value_set_string (value, editor->priv->location); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -ephy_new_bookmark_init (EphyNewBookmark *editor) -{ - editor->priv = EPHY_NEW_BOOKMARK_GET_PRIVATE (editor); -} - -void -ephy_new_bookmark_set_title (EphyNewBookmark *bookmark, - const char *title) -{ - const char *real_title; - - LOG ("Setting new bookmark title to: \"%s\"", title); - - if (title == NULL || strlen (title) == 0) - { - real_title = bookmark->priv->location; - } - else - { - real_title = title; - } - - gtk_entry_set_text (GTK_ENTRY (bookmark->priv->title_entry), - real_title); -} - -void -ephy_new_bookmark_set_icon (EphyNewBookmark *bookmark, - const char *icon) -{ - g_free (bookmark->priv->icon); - bookmark->priv->icon = icon ? g_strdup (icon) : NULL; -} - -guint -ephy_new_bookmark_get_id (EphyNewBookmark *bookmark) -{ - return bookmark->priv->id; -} diff --git a/src/bookmarks/ephy-new-bookmark.h b/src/bookmarks/ephy-new-bookmark.h deleted file mode 100644 index f79f9d553..000000000 --- a/src/bookmarks/ephy-new-bookmark.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org> - * - * 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_NEW_BOOKMARK_H -#define EPHY_NEW_BOOKMARK_H - -#include <gtk/gtkdialog.h> - -#include "ephy-bookmarks.h" - -G_BEGIN_DECLS - -#define EPHY_TYPE_NEW_BOOKMARK (ephy_new_bookmark_get_type ()) -#define EPHY_NEW_BOOKMARK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_NEW_BOOKMARK, EphyNewBookmark)) -#define EPHY_NEW_BOOKMARK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_NEW_BOOKMARK, EphyNewBookmarkClass)) -#define EPHY_IS_NEW_BOOKMARK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_NEW_BOOKMARK)) -#define EPHY_IS_NEW_BOOKMARK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_NEW_BOOKMARK)) -#define EPHY_NEW_BOOKMARK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_NEW_BOOKMARK, EphyNewBookmarkClass)) - -typedef struct _EphyNewBookmarkPrivate EphyNewBookmarkPrivate; - -typedef struct -{ - GtkDialog parent; - - /*< private >*/ - EphyNewBookmarkPrivate *priv; -} EphyNewBookmark; - -typedef struct -{ - GtkDialogClass parent; -} EphyNewBookmarkClass; - -GType ephy_new_bookmark_get_type (void); - -GtkWidget *ephy_new_bookmark_new (EphyBookmarks *bookmarks, - GtkWindow *parent, - const char *location); - -gboolean ephy_new_bookmark_is_unique (EphyBookmarks *bookmarks, - GtkWindow *parent, - const char *location); - -void ephy_new_bookmark_set_title (EphyNewBookmark *bookmark, - const char *title); - -void ephy_new_bookmark_set_icon (EphyNewBookmark *bookmark, - const char *icon); - -guint ephy_new_bookmark_get_id (EphyNewBookmark *bookmark); - -G_END_DECLS - -#endif /* EPHY_NEW_BOOKMARK_H */ diff --git a/src/bookmarks/ephy-topics-selector.c b/src/bookmarks/ephy-topics-selector.c deleted file mode 100644 index 3af16331c..000000000 --- a/src/bookmarks/ephy-topics-selector.c +++ /dev/null @@ -1,353 +0,0 @@ - -/* - * Copyright (C) 2002-2004 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$ - */ - -#include "config.h" - -#include "ephy-topics-selector.h" -#include "ephy-debug.h" - -#include <glib/gi18n.h> -#include <gtk/gtktreeselection.h> - -static void ephy_topics_selector_class_init (EphyTopicsSelectorClass *klass); -static void ephy_topics_selector_init (EphyTopicsSelector *editor); - -#define EPHY_TOPICS_SELECTOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TOPICS_SELECTOR, EphyTopicsSelectorPrivate)) - -struct _EphyTopicsSelectorPrivate -{ - EphyBookmarks *bookmarks; - EphyNode *bookmark; - EphyNodeFilter *filter; - GList *topics; -}; - -enum -{ - PROP_0, - PROP_BOOKMARKS, - PROP_BOOKMARK -}; - -static GObjectClass *parent_class = NULL; - -GType -ephy_topics_selector_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (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 - }; - - type = g_type_register_static (EPHY_TYPE_NODE_VIEW, - "EphyTopicsSelector", - &our_info, 0); - } - - return type; -} - -static 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_bookmarks (EphyTopicsSelector *selector, - EphyBookmarks *bookmarks) -{ - selector->priv->bookmarks = bookmarks; -} - -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: - ephy_topics_selector_set_bookmarks - (selector, g_value_get_object (value)); - break; - case PROP_BOOKMARK: - ephy_topics_selector_set_bookmark - (selector, g_value_get_pointer (value)); - break; - 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_pointer (value, selector); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -void -ephy_topics_selector_apply (EphyTopicsSelector *selector, - EphyNode *bookmark) -{ - GList *l; - - for (l = selector->priv->topics; l != NULL; l = l->next) - { - EphyNode *node = l->data; - - ephy_bookmarks_set_keyword (selector->priv->bookmarks, - node, bookmark); - } -} - -static void -provide_toggle (EphyNode *node, - GValue *value, - gpointer data) -{ - EphyTopicsSelector *selector = EPHY_TOPICS_SELECTOR (data); - gboolean result = FALSE; - - g_value_init (value, G_TYPE_BOOLEAN); - - if (selector->priv->bookmark) - { - result = ephy_node_has_child (node, selector->priv->bookmark); - } - else - { - result = (g_list_find (selector->priv->topics, node) != NULL); - } - - g_value_set_boolean (value, result); -} - -static GObject * -ephy_topics_selector_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_params) - -{ - GObject *object; - EphyTopicsSelector *selector; - EphyTopicsSelectorPrivate *priv; - GtkTreeSelection *selection; - - object = parent_class->constructor (type, n_construct_properties, - construct_params); - selector = EPHY_TOPICS_SELECTOR (object); - priv = EPHY_TOPICS_SELECTOR_GET_PRIVATE (object); - - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (selector), FALSE); - - ephy_node_view_add_toggle (EPHY_NODE_VIEW (selector), - provide_toggle, selector); - ephy_node_view_add_column (EPHY_NODE_VIEW (selector), _("Topics"), - G_TYPE_STRING, - EPHY_NODE_KEYWORD_PROP_NAME, - EPHY_NODE_VIEW_SHOW_PRIORITY | - EPHY_NODE_VIEW_EDITABLE | - EPHY_NODE_VIEW_SEARCHABLE, NULL, NULL); - ephy_node_view_set_sort (EPHY_NODE_VIEW (selector), G_TYPE_STRING, - EPHY_NODE_KEYWORD_PROP_NAME, GTK_SORT_ASCENDING); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); - - return object; -} - -static void -topic_destroy_cb (EphyNode *node, - EphyTopicsSelector *selector) -{ - selector->priv->topics = g_list_remove - (selector->priv->topics, node); -} - -static void -toggle_topic (EphyTopicsSelector *selector, EphyNode *node, gboolean checked) -{ - if (selector->priv->bookmark) - { - if (checked) - { - ephy_bookmarks_set_keyword (selector->priv->bookmarks, - node, - selector->priv->bookmark); - } - else - { - ephy_bookmarks_unset_keyword (selector->priv->bookmarks, - node, - selector->priv->bookmark); - } - } - else - { - if (checked) - { - selector->priv->topics = g_list_prepend - (selector->priv->topics, node); - ephy_node_signal_connect_object (node, EPHY_NODE_DESTROY, - (EphyNodeCallback) topic_destroy_cb, - G_OBJECT (selector)); - } - else - { - selector->priv->topics = g_list_remove - (selector->priv->topics, node); - } - } -} - -static void -node_toggled_cb (EphyTopicsSelector *selector, EphyNode *node, - gboolean checked, gpointer data) -{ - toggle_topic (selector, node, checked); -} - -static void -ephy_topics_selector_init (EphyTopicsSelector *selector) -{ - selector->priv = EPHY_TOPICS_SELECTOR_GET_PRIVATE (selector); - - selector->priv->filter = ephy_node_filter_new (); - ephy_node_filter_add_expression (selector->priv->filter, - ephy_node_filter_expression_new (EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS, - EPHY_NODE_KEYWORD_PROP_PRIORITY, - EPHY_NODE_VIEW_NORMAL_PRIORITY), - 0); - g_object_set (selector, "filter", selector->priv->filter, NULL); - - g_signal_connect (selector, "node_toggled", - G_CALLBACK (node_toggled_cb), NULL); -} - -static void -ephy_topics_selector_finalize (GObject *object) -{ - EphyTopicsSelector *selector = EPHY_TOPICS_SELECTOR (object); - - g_list_free (selector->priv->topics); - - g_object_unref (selector->priv->filter); - - parent_class->finalize (object); -} - -GtkWidget * -ephy_topics_selector_new (EphyBookmarks *bookmarks, - EphyNode *bookmark) -{ - EphyTopicsSelector *editor; - EphyNode *root; - - g_assert (bookmarks != NULL); - - root = ephy_bookmarks_get_keywords (bookmarks); - editor = EPHY_TOPICS_SELECTOR (g_object_new - (EPHY_TYPE_TOPICS_SELECTOR, - "bookmarks", bookmarks, - "bookmark", bookmark, - "root", root, - NULL)); - - return GTK_WIDGET (editor); -} - -void -ephy_topics_selector_new_topic (EphyTopicsSelector *selector) -{ - EphyNode *node; - - node = ephy_bookmarks_add_keyword - (selector->priv->bookmarks, _("Type a topic")); - toggle_topic (selector, node, TRUE); - ephy_node_view_select_node (EPHY_NODE_VIEW (selector), node); - ephy_node_view_edit (EPHY_NODE_VIEW (selector), TRUE); -} - -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->set_property = ephy_topics_selector_set_property; - object_class->get_property = ephy_topics_selector_get_property; - object_class->constructor = ephy_topics_selector_constructor; - object_class->finalize = ephy_topics_selector_finalize; - - g_object_class_install_property (object_class, - PROP_BOOKMARKS, - g_param_spec_object ("bookmarks", - "Bookmarks set", - "Bookmarks set", - EPHY_TYPE_BOOKMARKS, - G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, - PROP_BOOKMARK, - g_param_spec_pointer ("bookmark", - "Bookmark", - "Bookmark", - G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (object_class, sizeof(EphyTopicsSelectorPrivate)); -} diff --git a/src/bookmarks/ephy-topics-selector.h b/src/bookmarks/ephy-topics-selector.h deleted file mode 100644 index 3f532cd24..000000000 --- a/src/bookmarks/ephy-topics-selector.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 "ephy-node-view.h" - -G_BEGIN_DECLS - -#define EPHY_TYPE_TOPICS_SELECTOR (ephy_topics_selector_get_type ()) -#define EPHY_TOPICS_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_TOPICS_SELECTOR, EphyTopicsSelector)) -#define EPHY_TOPICS_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_TOPICS_SELECTOR, EphyTopicsSelectorClass)) -#define EPHY_IS_TOPICS_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_TOPICS_SELECTOR)) -#define EPHY_IS_TOPICS_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_TOPICS_SELECTOR)) -#define EPHY_TOPICS_SELECTOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_TOPICS_SELECTOR, EphyTopicsSelectorClass)) - -typedef struct _EphyTopicsSelectorPrivate EphyTopicsSelectorPrivate; - -typedef struct -{ - EphyNodeView parent; - - /*< private >*/ - EphyTopicsSelectorPrivate *priv; -} EphyTopicsSelector; - -typedef struct -{ - EphyNodeViewClass parent; -} EphyTopicsSelectorClass; - -GType ephy_topics_selector_get_type (void); - -GtkWidget *ephy_topics_selector_new (EphyBookmarks *bookmarks, - EphyNode *bookmark); - -void ephy_topics_selector_new_topic (EphyTopicsSelector *selector); - -void ephy_topics_selector_apply (EphyTopicsSelector *selector, - EphyNode *bookmark); - - -G_END_DECLS - -#endif /* EPHY_TOPICS_SELECTOR_H */ |