diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks/ephy-bookmarks-editor.c | 22 | ||||
-rw-r--r-- | src/ephy-automation.c | 35 | ||||
-rw-r--r-- | src/ephy-main.c | 10 | ||||
-rw-r--r-- | src/ephy-shell.c | 40 | ||||
-rw-r--r-- | src/ephy-shell.h | 2 | ||||
-rw-r--r-- | src/window-commands.c | 38 |
6 files changed, 85 insertions, 62 deletions
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index 4786c9d67..7307570d6 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -25,6 +25,7 @@ #include <gtk/gtkvbox.h> #include <gdk/gdkkeysyms.h> #include <libgnome/gnome-i18n.h> +#include <libgnome/gnome-program.h> #include <string.h> #include "ephy-bookmarks-editor.h" @@ -446,17 +447,25 @@ ephy_bookmarks_editor_node_activated_cb (GtkWidget *view, EphyBookmarksEditor *editor) { const char *location; - GtkWindow *window; + EphyWindow *window; g_return_if_fail (EPHY_IS_NODE (node)); location = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION); g_return_if_fail (location != NULL); - 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)); + window = EPHY_WINDOW (get_target_window (editor)); + if (window != NULL) + { + ephy_window_load_url (EPHY_WINDOW (window), location); + gtk_window_present (GTK_WINDOW (window)); + } + else + { + /* We have to create a browser window */ + ephy_shell_new_tab (ephy_shell, NULL, NULL, location, + EPHY_NEW_TAB_IN_NEW_WINDOW); + } } static void @@ -770,7 +779,8 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) gtk_window_set_title (GTK_WINDOW (editor), _("Bookmarks")); - icon_path = ephy_file ("epiphany-bookmarks.png"); + icon_path = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP, + "epiphany-bookmarks.png", TRUE, NULL); gtk_window_set_icon_from_file (GTK_WINDOW (editor), icon_path, NULL); g_signal_connect (editor, "delete_event", diff --git a/src/ephy-automation.c b/src/ephy-automation.c index 75829d444..014702762 100644 --- a/src/ephy-automation.c +++ b/src/ephy-automation.c @@ -27,15 +27,15 @@ #include <bonobo/bonobo-main.h> #include <bonobo/bonobo-context.h> -static CORBA_boolean +static void impl_ephy_automation_add_bookmark (PortableServer_Servant _servant, const CORBA_char * url, CORBA_Environment * ev); -static CORBA_boolean +static void impl_ephy_automation_quit (PortableServer_Servant _servant, const CORBA_boolean disableServer, CORBA_Environment * ev); -static CORBA_boolean +static void impl_ephy_automation_load_session (PortableServer_Servant _servant, const CORBA_char * filename, CORBA_Environment * ev); @@ -80,7 +80,7 @@ ephy_automation_new (void) return BONOBO_OBJECT (factory); } -static CORBA_boolean +static void impl_ephy_automation_loadurl (PortableServer_Servant _servant, const CORBA_char * url, const CORBA_char * geometry, @@ -105,7 +105,7 @@ impl_ephy_automation_loadurl (PortableServer_Servant _servant, res = session_autoresume (session); /* no need to open the homepage, * we did already open session windows */ - if (res && *url == '\0') return TRUE; + if (res && *url == '\0') return; } window = ephy_shell_get_active_window (ephy_shell); @@ -113,7 +113,7 @@ impl_ephy_automation_loadurl (PortableServer_Servant _servant, if (open_in_existing_tab && window != NULL) { ephy_window_load_url (window, url); - return TRUE; + return; } if (*url == '\0') @@ -142,47 +142,43 @@ impl_ephy_automation_loadurl (PortableServer_Servant _servant, ephy_shell_new_tab (ephy_shell, window, NULL, load_page, flags); - - return TRUE; } -static CORBA_boolean +static void impl_ephy_automation_add_bookmark (PortableServer_Servant _servant, const CORBA_char * url, CORBA_Environment * ev) { - CORBA_boolean retval = TRUE; - return retval; } -static CORBA_boolean +static void impl_ephy_automation_quit (PortableServer_Servant _servant, const CORBA_boolean disableServer, CORBA_Environment * ev) { - CORBA_boolean retval = TRUE; - Session *session; session = ephy_shell_get_session (ephy_shell); session_close (session); - - return retval; } -static CORBA_boolean +static void impl_ephy_automation_load_session (PortableServer_Servant _servant, const CORBA_char * filename, CORBA_Environment * ev) { - CORBA_boolean retval = TRUE; Session *session; session = ephy_shell_get_session (ephy_shell); session_load (session, filename); +} - return retval; +static void +impl_ephy_automation_open_bookmarks_editor (PortableServer_Servant _servant, + CORBA_Environment * ev) +{ + ephy_shell_show_bookmarks_editor (ephy_shell); } static void @@ -200,6 +196,7 @@ ephy_automation_class_init (EphyAutomationClass *klass) epv->addBookmark = impl_ephy_automation_add_bookmark; epv->quit = impl_ephy_automation_quit; epv->loadSession = impl_ephy_automation_load_session; + epv->openBookmarksEditor = impl_ephy_automation_open_bookmarks_editor; } static void diff --git a/src/ephy-main.c b/src/ephy-main.c index 8408354e4..e14c4abf3 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -55,6 +55,7 @@ static gchar *bookmark_url = NULL; /* the temp bookmark to add static gboolean close_option = FALSE; /* --close */ static gboolean quit_option = FALSE; /* --quit */ static gboolean ephy_server_mode = FALSE; +static gboolean open_as_bookmarks_editor = FALSE; /* --bookmarks-editor */ static gboolean open_as_nautilus_view = FALSE; static BonoboObject *automation_object; @@ -105,6 +106,9 @@ static struct poptOption popt_options[] = { "nautilus-view", 'v', POPT_ARG_NONE, &open_as_nautilus_view, 0, N_("Used internally by the nautilus view"), NULL }, + { "bookmarks-editor", 'b', POPT_ARG_NONE, &open_as_bookmarks_editor, 0, + N_("Launch the bookmarks editor"), + NULL }, /* terminator, must be last */ { NULL, 0, 0, NULL, 0, NULL, NULL } @@ -202,6 +206,12 @@ ephy_main_start (gpointer data) { g_object_ref (G_OBJECT(ephy_shell)); } + /* Launch the bookmarks editor */ + else if (open_as_bookmarks_editor) + { + GNOME_EphyAutomation_openBookmarksEditor + (gaserver, &corba_env); + } /* load the session if requested */ else if (session_filename) { diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 4fc7e26f3..1fa250e66 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -31,6 +31,7 @@ #include "ephy-file-helpers.h" #include "ephy-thread-helpers.h" #include "ephy-bookmarks-import.h" +#include "ephy-bookmarks-editor.h" #include "ephy-debug.h" #include "toolbar.h" @@ -56,6 +57,7 @@ struct EphyShellPrivate Session *session; EphyAutocompletion *autocompletion; EphyBookmarks *bookmarks; + GtkWidget *bme; }; enum @@ -257,6 +259,7 @@ ephy_shell_init (EphyShell *gs) gs->priv = g_new0 (EphyShellPrivate, 1); gs->priv->session = NULL; gs->priv->bookmarks = NULL; + gs->priv->bme = NULL; ephy_shell = gs; g_object_add_weak_pointer (G_OBJECT(ephy_shell), @@ -315,6 +318,12 @@ ephy_shell_finalize (GObject *object) g_object_unref (gs->priv->autocompletion); } + LOG ("Unref Bookmarks Editor"); + if (gs->priv->bme) + { + gtk_widget_destroy (GTK_WIDGET (gs->priv->bme)); + } + LOG ("Unref bookmarks") if (gs->priv->bookmarks) { @@ -614,3 +623,34 @@ ephy_shell_get_bookmarks (EphyShell *gs) return gs->priv->bookmarks; } + +static void +bookmarks_hide_cb (GtkWidget *widget, gpointer data) +{ + LOG ("Unref shell for bookmarks editor") + g_object_unref (ephy_shell); +} + +void +ephy_shell_show_bookmarks_editor (EphyShell *gs) +{ + EphyBookmarks *bookmarks; + + if (gs->priv->bme == NULL) + { + bookmarks = ephy_shell_get_bookmarks (ephy_shell); + g_assert (bookmarks != NULL); + gs->priv->bme = ephy_bookmarks_editor_new (bookmarks); + g_signal_connect (gs->priv->bme, "hide", + G_CALLBACK (bookmarks_hide_cb), NULL); + } + + if (!GTK_WIDGET_VISIBLE (gs->priv->bme)) + { + LOG ("Ref shell for bookmarks editor") + g_object_ref (ephy_shell); + } + + gtk_window_present (GTK_WINDOW (gs->priv->bme)); +} + diff --git a/src/ephy-shell.h b/src/ephy-shell.h index 0acd107d1..f4ec200ed 100644 --- a/src/ephy-shell.h +++ b/src/ephy-shell.h @@ -94,6 +94,8 @@ EphyAutocompletion *ephy_shell_get_autocompletion (EphyShell *gs); EphyBookmarks *ephy_shell_get_bookmarks (EphyShell *gs); +void ephy_shell_show_bookmarks_editor (EphyShell *gs); + G_END_DECLS #endif diff --git a/src/window-commands.c b/src/window-commands.c index f9e5ecf72..4cd9c9b87 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -239,47 +239,11 @@ window_cmd_file_new_tab (EggAction *action, EPHY_NEW_TAB_JUMP); } -static void -bookmarks_hide_cb (GtkWidget *widget, gpointer data) -{ - LOG ("Unref shell for bookmarks editor") - g_object_unref (ephy_shell); -} - -static void -shell_weak_notify_cb (gpointer data, GObject *object) -{ - LOG ("Bookmarks editor destroyed") - gtk_widget_destroy (GTK_WIDGET (data)); -} - void window_cmd_go_bookmarks (EggAction *action, EphyWindow *window) { - static GtkWidget *dialog = NULL; - EphyBookmarks *bookmarks; - - if (dialog == NULL) - { - bookmarks = ephy_shell_get_bookmarks (ephy_shell); - g_assert (bookmarks != NULL); - dialog = ephy_bookmarks_editor_new (bookmarks); - g_object_weak_ref (G_OBJECT (ephy_shell), - shell_weak_notify_cb, dialog); - g_signal_connect (dialog, "hide", - G_CALLBACK (bookmarks_hide_cb), NULL); - } - - if (!GTK_WIDGET_VISIBLE (dialog)) - { - LOG ("Ref shell for bookmarks editor") - g_object_ref (ephy_shell); - } - - ephy_bookmarks_editor_set_parent (EPHY_BOOKMARKS_EDITOR (dialog), - GTK_WIDGET (window)); - gtk_window_present (GTK_WINDOW (dialog)); + ephy_shell_show_bookmarks_editor (ephy_shell); } void |