From 1cbf7f5f14b162826d5c016d836d8c2243986f58 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sat, 22 Mar 2003 23:59:04 +0000 Subject: Never destroy but hide the bme. Present the window on activate. Allow to 2003-03-23 Marco Pesenti Gritti * src/bookmarks/ephy-bookmarks-editor.c: (get_target_window), (cmd_open_bookmarks_in_tabs), (cmd_open_bookmarks_in_browser), (ephy_bookmarks_editor_finalize), (ephy_bookmarks_editor_node_activated_cb), (delete_event_cb), (ephy_bookmarks_editor_construct), (ephy_bookmarks_editor_set_parent), (ephy_bookmarks_editor_new): * src/bookmarks/ephy-bookmarks-editor.h: * src/window-commands.c: (window_cmd_go_bookmarks): Never destroy but hide the bme. Present the window on activate. Allow to put the editor in the background. Smarter way to choose the window where to load the bookmark. --- src/bookmarks/ephy-bookmarks-editor.c | 66 +++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 10 deletions(-) (limited to 'src/bookmarks/ephy-bookmarks-editor.c') diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index bb27fa619..7383b2477 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -76,6 +76,7 @@ struct EphyBookmarksEditorPrivate EphyNodeFilter *bookmarks_filter; GtkWidget *search_entry; GtkWidget *menu_dock; + GtkWidget *window; EggMenuMerge *ui_merge; EggActionGroup *action_group; }; @@ -140,6 +141,19 @@ cmd_rename_bookmark (EggAction *action, { } +static GtkWidget * +get_target_window (EphyBookmarksEditor *editor) +{ + if (editor->priv->window) + { + return editor->priv->window; + } + else + { + return GTK_WIDGET (ephy_shell_get_active_window (ephy_shell)); + } +} + static void cmd_open_bookmarks_in_tabs (EggAction *action, EphyBookmarksEditor *editor) @@ -148,7 +162,7 @@ cmd_open_bookmarks_in_tabs (EggAction *action, GList *selection; GList *l; - window = EPHY_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (editor))); + window = EPHY_WINDOW (get_target_window (editor)); selection = ephy_node_view_get_selection (editor->priv->bm_view); for (l = selection; l; l = l->next) @@ -177,7 +191,7 @@ cmd_open_bookmarks_in_browser (EggAction *action, GList *selection; GList *l; - window = EPHY_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (editor))); + window = EPHY_WINDOW (get_target_window (editor)); selection = ephy_node_view_get_selection (editor->priv->bm_view); for (l = selection; l; l = l->next) @@ -339,6 +353,13 @@ ephy_bookmarks_editor_finalize (GObject *object) editor->priv->action_group); g_object_unref (editor->priv->ui_merge); + if (editor->priv->window) + { + g_object_remove_weak_pointer + (G_OBJECT(editor->priv->window), + (gpointer *)&editor->priv->window); + } + g_free (editor->priv); G_OBJECT_CLASS (parent_class)->finalize (object); @@ -384,9 +405,10 @@ ephy_bookmarks_editor_node_activated_cb (GtkWidget *view, (node, EPHY_NODE_BMK_PROP_LOCATION); g_return_if_fail (location != NULL); - window = gtk_window_get_transient_for (GTK_WINDOW (editor)); + window = GTK_WINDOW (get_target_window (editor)); g_return_if_fail (IS_EPHY_WINDOW (window)); ephy_window_load_url (EPHY_WINDOW (window), location); + gtk_window_present (GTK_WINDOW (window)); } static void @@ -485,6 +507,14 @@ add_widget (EggMenuMerge *merge, GtkWidget *widget, EphyBookmarksEditor *editor) gtk_widget_show (widget); } +static gboolean +delete_event_cb (EphyBookmarksEditor *editor) +{ + gtk_widget_hide (GTK_WIDGET (editor)); + + return TRUE; +} + static void ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) { @@ -498,6 +528,9 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) EggActionGroup *action_group; int i; + g_signal_connect (editor, "delete_event", + G_CALLBACK (delete_event_cb), NULL); + for (i = 0; i < ephy_bookmark_popup_n_entries; i++) { ephy_bookmark_popup_entries[i].user_data = editor; @@ -600,9 +633,27 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) g_free (selected_id_str); } +void +ephy_bookmarks_editor_set_parent (EphyBookmarksEditor *ebe, + GtkWidget *window) +{ + if (ebe->priv->window) + { + g_object_remove_weak_pointer + (G_OBJECT(ebe->priv->window), + (gpointer *)&ebe->priv->window); + } + + ebe->priv->window = window; + + g_object_add_weak_pointer + (G_OBJECT(ebe->priv->window), + (gpointer *)&ebe->priv->window); + +} + GtkWidget * -ephy_bookmarks_editor_new (EphyBookmarks *bookmarks, - GtkWindow *parent) +ephy_bookmarks_editor_new (EphyBookmarks *bookmarks) { EphyBookmarksEditor *editor; @@ -613,11 +664,6 @@ ephy_bookmarks_editor_new (EphyBookmarks *bookmarks, "bookmarks", bookmarks, NULL)); - if (parent) - { - gtk_window_set_transient_for (GTK_WINDOW (editor), parent); - } - ephy_bookmarks_editor_construct (editor); return GTK_WIDGET (editor); -- cgit v1.2.3