aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-11-01 22:00:06 +0800
committerChristian Persch <chpe@src.gnome.org>2004-11-01 22:00:06 +0800
commitf686d272ac4558e0ebda8f3aa873d2d9eefb17b5 (patch)
treea1acf44a816af5c379c39df916735dc2882fb1d1 /src
parenta716fbc5466f2f33a094062745f2d07b60df340d (diff)
downloadgsoc2013-epiphany-f686d272ac4558e0ebda8f3aa873d2d9eefb17b5.tar
gsoc2013-epiphany-f686d272ac4558e0ebda8f3aa873d2d9eefb17b5.tar.gz
gsoc2013-epiphany-f686d272ac4558e0ebda8f3aa873d2d9eefb17b5.tar.bz2
gsoc2013-epiphany-f686d272ac4558e0ebda8f3aa873d2d9eefb17b5.tar.lz
gsoc2013-epiphany-f686d272ac4558e0ebda8f3aa873d2d9eefb17b5.tar.xz
gsoc2013-epiphany-f686d272ac4558e0ebda8f3aa873d2d9eefb17b5.tar.zst
gsoc2013-epiphany-f686d272ac4558e0ebda8f3aa873d2d9eefb17b5.zip
Make sure there's only one bookmark properties dialogue for each bookmark.
2004-11-01 Christian Persch <chpe@cvs.gnome.org> * src/bookmarks/ephy-bookmark-action.c: (properties_activate_cb), (bookmark_destroy_cb), (ephy_bookmark_action_finalize): * src/bookmarks/ephy-bookmark-properties.c: (ephy_bookmark_properties_new): * src/bookmarks/ephy-bookmark-properties.h: * src/bookmarks/ephy-bookmarks-editor.c: (show_properties_dialog), (ephy_bookmarks_editor_finalize), (ephy_bookmarks_editor_init): * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_init), (ephy_bookmarks_finalize), (ephy_bookmarks_add_keyword), (prop_dialog_destroy_cb), (bookmark_destroyed_cb), (ephy_bookmarks_show_bookmark_properties): * src/bookmarks/ephy-bookmarks.h: Make sure there's only one bookmark properties dialogue for each bookmark. Fixes bug #148398 and also bug #155880.
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmark-action.c34
-rw-r--r--src/bookmarks/ephy-bookmark-properties.c6
-rw-r--r--src/bookmarks/ephy-bookmark-properties.h2
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c34
-rw-r--r--src/bookmarks/ephy-bookmarks.c59
-rw-r--r--src/bookmarks/ephy-bookmarks.h6
6 files changed, 80 insertions, 61 deletions
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c
index f8bc243f8..582a22fd8 100644
--- a/src/bookmarks/ephy-bookmark-action.c
+++ b/src/bookmarks/ephy-bookmark-action.c
@@ -32,7 +32,6 @@
#include "ephy-dnd.h"
#include "ephy-bookmarksbar.h"
#include "ephy-bookmarks.h"
-#include "ephy-bookmark-properties.h"
#include "ephy-favicon-cache.h"
#include "ephy-shell.h"
#include "ephy-debug.h"
@@ -57,8 +56,6 @@ struct EphyBookmarkActionPrivate
EphyNode *node;
gboolean smart_url;
guint cache_handler;
- GtkWidget *prop_dialog;
-
guint motion_handler;
gint drag_x;
gint drag_y;
@@ -523,25 +520,18 @@ move_right_activate_cb (GtkWidget *menu, GtkWidget *proxy)
}
static void
-properties_activate_cb (GtkWidget *menu, EphyBookmarkAction *action)
+properties_activate_cb (GtkWidget *menu,
+ EphyBookmarkAction *action)
{
GtkWidget *window, *proxy;
EphyBookmarks *bookmarks;
- EphyBookmarkActionPrivate *p = action->priv;
bookmarks = ephy_shell_get_bookmarks (ephy_shell);
proxy = g_object_get_data (G_OBJECT (menu), "proxy");
window = gtk_widget_get_toplevel (proxy);
- if (p->prop_dialog == NULL)
- {
- p->prop_dialog = ephy_bookmark_properties_new
- (bookmarks, p->node, GTK_WINDOW (window));
- g_object_add_weak_pointer (G_OBJECT (p->prop_dialog),
- (gpointer)&p->prop_dialog);
- }
-
- gtk_widget_show (p->prop_dialog);
+ ephy_bookmarks_show_bookmark_properties
+ (bookmarks, action->priv->node, window);
}
static void
@@ -741,11 +731,7 @@ bookmark_changed_cb (EphyNode *node,
static void
bookmark_destroy_cb (EphyNode *node, EphyBookmarkAction *action)
{
- if (action->priv->prop_dialog != NULL)
- {
- gtk_widget_destroy (action->priv->prop_dialog);
- action->priv->node = NULL;
- }
+ action->priv->node = NULL;
}
static void
@@ -831,17 +817,11 @@ ephy_bookmark_action_get_property (GObject *object,
static void
ephy_bookmark_action_finalize (GObject *object)
{
- EphyBookmarkAction *eba = EPHY_BOOKMARK_ACTION (object);
-
- if (eba->priv->prop_dialog)
- {
- g_object_remove_weak_pointer (G_OBJECT (eba->priv->prop_dialog),
- (gpointer)&eba->priv->prop_dialog);
- }
+ /* EphyBookmarkAction *eba = EPHY_BOOKMARK_ACTION (object);*/
LOG ("Bookmark action %p finalized", object)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ parent_class->finalize (object);
}
static void
diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c
index 51b15b454..878faa8e1 100644
--- a/src/bookmarks/ephy-bookmark-properties.c
+++ b/src/bookmarks/ephy-bookmark-properties.c
@@ -430,7 +430,7 @@ ephy_bookmark_properties_init (EphyBookmarkProperties *editor)
GtkWidget *
ephy_bookmark_properties_new (EphyBookmarks *bookmarks,
EphyNode *bookmark,
- GtkWindow *parent_window)
+ GtkWidget *parent_window)
{
EphyBookmarkProperties *editor;
@@ -446,7 +446,9 @@ ephy_bookmark_properties_new (EphyBookmarks *bookmarks,
if (parent_window)
{
- gtk_window_set_transient_for (GTK_WINDOW (editor), parent_window);
+ gtk_window_set_transient_for (GTK_WINDOW (editor),
+ GTK_WINDOW (parent_window));
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (editor), TRUE);
}
return GTK_WIDGET (editor);
}
diff --git a/src/bookmarks/ephy-bookmark-properties.h b/src/bookmarks/ephy-bookmark-properties.h
index 542ab3538..97b393c51 100644
--- a/src/bookmarks/ephy-bookmark-properties.h
+++ b/src/bookmarks/ephy-bookmark-properties.h
@@ -53,7 +53,7 @@ GType ephy_bookmark_properties_get_type (void);
GtkWidget *ephy_bookmark_properties_new (EphyBookmarks *bookmarks,
EphyNode *bookmark,
- GtkWindow *parent_window);
+ GtkWidget *parent_window);
EphyNode *ephy_bookmark_properties_get_node (EphyBookmarkProperties *properties);
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index be69f1dfd..ed1903cd8 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -47,7 +47,6 @@
#include <string.h>
#include "ephy-bookmarks-editor.h"
-#include "ephy-bookmark-properties.h"
#include "ephy-bookmarks-import.h"
#include "ephy-node-common.h"
#include "ephy-node-view.h"
@@ -149,7 +148,6 @@ struct EphyBookmarksEditorPrivate
GtkActionGroup *action_group;
int priority_col;
EphyBookmarksBarModel *tb_model;
- GHashTable *props_dialogs;
GtkTreeViewColumn *title_col;
GtkTreeViewColumn *address_col;
@@ -479,31 +477,11 @@ cmd_delete (GtkAction *action,
}
static void
-prop_dialog_destroy_cb (GtkWidget *dialog, EphyBookmarksEditor *editor)
+show_properties_dialog (EphyBookmarksEditor *editor,
+ EphyNode *bookmark)
{
- EphyNode *node;
-
- node = ephy_bookmark_properties_get_node (EPHY_BOOKMARK_PROPERTIES (dialog));
- g_hash_table_remove (editor->priv->props_dialogs, node);
-}
-
-static void
-show_properties_dialog (EphyBookmarksEditor *editor, EphyNode *node)
-{
- GtkWidget *dialog;
-
- dialog = g_hash_table_lookup (editor->priv->props_dialogs, node);
-
- if (!dialog)
- {
- dialog = ephy_bookmark_properties_new
- (editor->priv->bookmarks, node, GTK_WINDOW (editor));
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (prop_dialog_destroy_cb), editor);
- g_hash_table_insert (editor->priv->props_dialogs, node, dialog);
- }
-
- gtk_window_present (GTK_WINDOW (dialog));
+ ephy_bookmarks_show_bookmark_properties
+ (editor->priv->bookmarks, bookmark, GTK_WIDGET (editor));
}
static void
@@ -928,8 +906,6 @@ ephy_bookmarks_editor_finalize (GObject *object)
(gpointer *)&editor->priv->window);
}
- g_hash_table_destroy (editor->priv->props_dialogs);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -1682,8 +1658,6 @@ ephy_bookmarks_editor_init (EphyBookmarksEditor *editor)
{
editor->priv = EPHY_BOOKMARKS_EDITOR_GET_PRIVATE (editor);
- editor->priv->props_dialogs = g_hash_table_new (g_direct_hash,
- g_direct_equal);
editor->priv->tb_model = EPHY_BOOKMARKSBAR_MODEL
(ephy_bookmarks_get_toolbars_model
(ephy_shell_get_bookmarks (ephy_shell)));
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index ac2de3b28..ef4e37e47 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -34,6 +34,7 @@
#include "ephy-bookmarksbar-model.h"
#include "ephy-bookmarks-export.h"
#include "ephy-bookmarks-import.h"
+#include "ephy-bookmark-properties.h"
#include "ephy-prefs.h"
#include "eel-gconf-extensions.h"
@@ -65,7 +66,7 @@ struct EphyBookmarksPrivate
EphyNode *smartbookmarks;
EphyNode *lower_fav;
double lower_score;
-
+ GHashTable *props_dialogs;
guint disable_bookmark_editing_notifier_id;
};
@@ -689,6 +690,9 @@ ephy_bookmarks_init (EphyBookmarks *eb)
"bookmarks.rdf",
NULL);
+ eb->priv->props_dialogs = g_hash_table_new (g_direct_hash,
+ g_direct_equal);
+
/* Bookmarks */
eb->priv->bookmarks = ephy_node_new_with_id (db, BOOKMARKS_NODE_ID);
g_value_init (&value, G_TYPE_STRING);
@@ -800,6 +804,8 @@ ephy_bookmarks_finalize (GObject *object)
eel_gconf_notification_remove (eb->priv->disable_bookmark_editing_notifier_id);
+ g_hash_table_destroy (eb->priv->props_dialogs);
+
if (eb->priv->save_timeout_id != 0)
{
g_source_remove (eb->priv->save_timeout_id);
@@ -1164,6 +1170,57 @@ ephy_bookmarks_add_keyword (EphyBookmarks *eb,
return key;
}
+
+static void
+prop_dialog_destroy_cb (EphyBookmarkProperties *dialog,
+ EphyBookmarks *bookmarks)
+{
+ EphyNode *bookmark;
+
+ bookmark = ephy_bookmark_properties_get_node (dialog);
+
+ g_hash_table_remove (bookmarks->priv->props_dialogs, bookmark);
+}
+
+static void
+bookmark_destroyed_cb (EphyNode *bookmark,
+ GtkWidget *dialog)
+{
+ gtk_widget_destroy (dialog);
+}
+
+GtkWidget *
+ephy_bookmarks_show_bookmark_properties (EphyBookmarks *bookmarks,
+ EphyNode *bookmark,
+ GtkWidget *parent)
+{
+ GtkWidget *dialog = NULL;
+
+ g_return_val_if_fail (EPHY_IS_BOOKMARKS (bookmarks), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (bookmark), NULL);
+
+ dialog = g_hash_table_lookup (bookmarks->priv->props_dialogs, bookmark);
+
+ if (dialog == NULL)
+ {
+ dialog = ephy_bookmark_properties_new (bookmarks, bookmark, parent);
+
+ ephy_node_signal_connect_object (bookmark,
+ EPHY_NODE_DESTROY,
+ (EphyNodeCallback) bookmark_destroyed_cb,
+ G_OBJECT (dialog));
+
+ g_signal_connect (dialog, "destroy",
+ G_CALLBACK (prop_dialog_destroy_cb), bookmarks);
+ g_hash_table_insert (bookmarks->priv->props_dialogs,
+ bookmark, dialog);
+ }
+
+ gtk_window_present (GTK_WINDOW (dialog));
+
+ return dialog;
+}
+
void
ephy_bookmarks_remove_keyword (EphyBookmarks *eb,
EphyNode *keyword)
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index 5bf2845af..9321f3da7 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -23,6 +23,7 @@
#define EPHY_BOOKMARKS_H
#include <glib-object.h>
+#include <gtk/gtkwidget.h>
#include "ephy-node.h"
@@ -96,6 +97,11 @@ char *ephy_bookmarks_solve_smart_url (EphyBookmarks *eb,
const char *smart_url,
const char *content);
+GtkWidget *ephy_bookmarks_show_bookmark_properties (EphyBookmarks *bookmarks,
+ EphyNode *bookmark,
+ GtkWidget *parent_window);
+
+
/* Keywords */
EphyNode *ephy_bookmarks_add_keyword (EphyBookmarks *eb,