diff options
author | Christian Persch <chpe@src.gnome.org> | 2008-09-25 04:02:55 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2008-09-25 04:02:55 +0800 |
commit | 659169914fa8da235b35730c688a23c3caca8b3a (patch) | |
tree | ef6977c62d09ba7094c3646eb3dfd0c10b80cb62 /src | |
parent | e1d7349c1c0191c371c11a9011eb288187e2cc9d (diff) | |
download | gsoc2013-epiphany-659169914fa8da235b35730c688a23c3caca8b3a.tar.gz gsoc2013-epiphany-659169914fa8da235b35730c688a23c3caca8b3a.tar.zst gsoc2013-epiphany-659169914fa8da235b35730c688a23c3caca8b3a.zip |
Remove libgnome and libgnomeui dependency, using EggSMClient instead of GnomeClient.
svn path=/trunk/; revision=8541
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-editor.c | 1 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 2 | ||||
-rw-r--r-- | src/bookmarks/ephy-open-tabs-action.c | 12 | ||||
-rw-r--r-- | src/ephy-find-toolbar.c | 2 | ||||
-rw-r--r-- | src/ephy-history-window.c | 1 | ||||
-rw-r--r-- | src/ephy-main.c | 75 | ||||
-rw-r--r-- | src/ephy-session.c | 161 | ||||
-rw-r--r-- | src/ephy-window.c | 1 | ||||
-rw-r--r-- | src/window-commands.c | 2 |
10 files changed, 141 insertions, 117 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 21ee1a1de..ad7ff3646 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -188,6 +188,7 @@ epiphany_CPPFLAGS = \ -I$(top_builddir)/lib \ -I$(top_srcdir)/embed \ -I$(top_srcdir)/lib \ + -I$(top_srcdir)/lib/egg \ -I$(top_srcdir)/src/bookmarks \ -DDATADIR=\""$(datadir)"\" \ -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index 8f6a5cc27..403c21f33 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -23,7 +23,6 @@ #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #include <glib/gi18n.h> -#include <libgnomeui/gnome-stock-icons.h> #include <string.h> #include "ephy-bookmarks-editor.h" diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 15f635add..54ba2be15 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -128,7 +128,7 @@ enum LAST_SIGNAL }; -static guint ephy_bookmarks_signals[LAST_SIGNAL] = { 0 }; +static guint ephy_bookmarks_signals[LAST_SIGNAL]; static void ephy_bookmarks_class_init (EphyBookmarksClass *klass); static void ephy_bookmarks_init (EphyBookmarks *tab); diff --git a/src/bookmarks/ephy-open-tabs-action.c b/src/bookmarks/ephy-open-tabs-action.c index f3ea35830..8a5cceab8 100644 --- a/src/bookmarks/ephy-open-tabs-action.c +++ b/src/bookmarks/ephy-open-tabs-action.c @@ -20,7 +20,10 @@ #include "config.h" -#include "ephy-open-tabs-action.h" +#include <string.h> + +#include <glib/gi18n.h> +#include <gtk/gtk.h> #include "ephy-bookmarks.h" #include "ephy-bookmarks-ui.h" @@ -28,12 +31,7 @@ #include "ephy-link-action.h" #include "ephy-link.h" -#include <glib/gi18n.h> -#include <gtk/gtk.h> - -#include <libgnomevfs/gnome-vfs-uri.h> - -#include <string.h> +#include "ephy-open-tabs-action.h" static void activate_cb (GtkAction *action, diff --git a/src/ephy-find-toolbar.c b/src/ephy-find-toolbar.c index 924b643fd..c118e8527 100644 --- a/src/ephy-find-toolbar.c +++ b/src/ephy-find-toolbar.c @@ -95,6 +95,7 @@ impl_scroll_pages (WebKitWebView *web_view, /* FIXME: implement! */ } +#if 0 static void impl_scroll_pixels (WebKitWebView *web_view, int dx, @@ -112,6 +113,7 @@ impl_scroll_pixels (WebKitWebView *web_view, gtk_adjustment_set_value (hadj, CLAMP (hadj->value + dx, hadj->lower, hadj->upper - hadj->page_size)); gtk_adjustment_set_value (vadj, CLAMP (vadj->value + dy, vadj->lower, vadj->upper - vadj->page_size)); } +#endif static gboolean set_status_notfound_cb (EphyFindToolbar *toolbar) diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c index 46ed4cd9f..961828067 100644 --- a/src/ephy-history-window.c +++ b/src/ephy-history-window.c @@ -23,7 +23,6 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> -#include <libgnomeui/gnome-stock-icons.h> #include <string.h> #include <time.h> diff --git a/src/ephy-main.c b/src/ephy-main.c index 1850ffbb4..d76744a9a 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -1,6 +1,6 @@ /* * Copyright © 2000-2002 Marco Pesenti Gritti - * Copyright © 2006 Christian Persch + * Copyright © 2006, 2008 Christian Persch * * 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 @@ -34,6 +34,7 @@ #include "ephy-shell.h" #include "ephy-prefs.h" #include "ephy-debug.h" +#include "eggsmclient.h" #include <libxml/xmlversion.h> @@ -42,11 +43,6 @@ #include <gdk/gdkx.h> #include <gtk/gtk.h> -#include <libgnome/gnome-program.h> -#include <libgnomeui/gnome-ui-init.h> - -#include <libgnomeui/gnome-app-helper.h> - #include <errno.h> #include <string.h> @@ -417,19 +413,52 @@ show_error_message (GError **error) gtk_dialog_run (GTK_DIALOG (dialog)); } +static gchar * +get_accels_filename (void) +{ + const char *home; + + home = g_get_home_dir(); + if (!home) + return NULL; + return g_build_filename (home, GNOME_DOT_GNOME, "accels", PACKAGE, NULL); +} + +static void +load_accels (void) +{ + char *filename; + + filename = get_accels_filename (); + if (!filename) + return; + + gtk_accel_map_load (filename); + g_free (filename); +} + +static void +save_accels (void) +{ + char *filename; + + filename = get_accels_filename (); + if (!filename) + return; + + gtk_accel_map_save (filename); + g_free (filename); +} + int main (int argc, char *argv[]) { - GnomeProgram *program; GOptionContext *option_context; GOptionGroup *option_group; DBusGProxy *proxy; GError *error = NULL; guint32 user_time; -#ifndef GNOME_PARAM_GOPTION_CONTEXT - GPtrArray *fake_argv_array; -#endif #ifdef ENABLE_NLS /* Initialize the i18n stuff */ @@ -522,6 +551,9 @@ main (int argc, g_option_context_set_main_group (option_context, option_group); + g_option_context_add_group (option_context, gtk_get_option_group (TRUE)); + g_option_context_add_group (option_context, egg_sm_client_get_option_group ()); + #ifdef GNOME_ENABLE_DEBUG option_group = g_option_group_new ("debug", "Epiphany debug options", @@ -531,17 +563,15 @@ main (int argc, g_option_context_add_group (option_context, option_group); #endif /* GNOME_ENABLE_DEBUG */ - program = gnome_program_init (PACKAGE, VERSION, - LIBGNOMEUI_MODULE, argc, argv, - GNOME_PARAM_GOPTION_CONTEXT, option_context, - GNOME_PARAM_HUMAN_READABLE_NAME, _("Web Browser"), - GNOME_PARAM_APP_DATADIR, DATADIR, - NULL); - - /* libgnome keeps a reference to the global program, so drop - * our reference here, to simplify cleanup on the many exit paths. - */ - g_object_unref (program); + if (!g_option_context_parse (option_context, &argc, &argv, &error)) + { + g_print ("Failed to parse arguments: %s\n", error->message); + g_error_free (error); + g_option_context_free (option_context); + exit (1); + } + + g_option_context_free (option_context); /* Some argument sanity checks*/ if (arguments != NULL && (session_filename != NULL || open_as_bookmarks_editor)) @@ -701,6 +731,7 @@ main (int argc, eel_gconf_monitor_add ("/apps/epiphany/general"); ephy_stock_icons_init (); + load_accels (); /* Extensions may want these, so don't initialize in window-cmds */ gtk_about_dialog_set_url_hook (handle_url, NULL, NULL); @@ -731,7 +762,7 @@ main (int argc, notify_uninit (); #endif eel_gconf_monitor_remove ("/apps/epiphany/general"); - gnome_accelerators_sync (); + save_accels (); ephy_state_save (); ephy_file_helpers_shutdown (); xmlCleanupParser (); diff --git a/src/ephy-session.c b/src/ephy-session.c index 1a3ffa2e8..3c117ad6b 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -2,7 +2,7 @@ /* * Copyright © 2002 Jorn Baayen * Copyright © 2003, 2004 Marco Pesenti Gritti - * Copyright © 2003, 2004, 2005, 2006 Christian Persch + * Copyright © 2003, 2004, 2005, 2006, 2008 Christian Persch * * 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 @@ -17,8 +17,6 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ */ #include "config.h" @@ -38,13 +36,13 @@ #include "ephy-stock-icons.h" #include "ephy-glib-compat.h" #include "ephy-notebook.h" +#include "eggdesktopfile.h" +#include "eggsmclient.h" #include <glib/gi18n.h> #include <gio/gio.h> #include <gtk/gtk.h> -#include <libgnomeui/gnome-client.h> - #include <libxml/tree.h> #include <libxml/xmlwriter.h> @@ -71,6 +69,8 @@ struct _EphySessionPrivate GQueue *queue; guint queue_idle_id; + GtkWidget *quit_interact_dialog; + guint dont_save : 1; guint quit_while_resuming : 1; }; @@ -98,12 +98,13 @@ G_DEFINE_TYPE_WITH_CODE (EphySession, ephy_session, G_TYPE_OBJECT, typedef struct { - GtkWidget *dialog; - GtkWidget *label; - guint timeout_id; - guint ticks; - int response; - int key; + EphySession *session; + EggSMClient *sm_client; + GtkWidget *dialog; + GtkWidget *label; + guint timeout_id; + guint ticks; + int response; } InteractData; static void @@ -160,13 +161,16 @@ static void confirm_shutdown_dialog_weak_ref_cb (InteractData *data, GObject *zombie) { + EphySessionPrivate *priv = data->session->priv; + EggSMClient *sm_client = data->sm_client; EphyShell *shell; GObject *dv; - int key; - gboolean cancel_shutdown; + gboolean will_quit; LOG ("confirm_shutdown_dialog_weak_ref_cb response %d", data->response); + priv->quit_interact_dialog = NULL; + shell = ephy_shell_get_default (); if (shell != NULL) { @@ -188,39 +192,32 @@ confirm_shutdown_dialog_weak_ref_cb (InteractData *data, g_source_remove (data->timeout_id); } - key = data->key; - cancel_shutdown = data->response != GTK_RESPONSE_ACCEPT; + will_quit = data->response == GTK_RESPONSE_ACCEPT; g_free (data); - gnome_interaction_key_return (key, cancel_shutdown); + egg_sm_client_will_quit (sm_client, will_quit); + g_object_unref (sm_client); } static void -confirm_shutdown_cb (GnomeClient *client, - int key, - GnomeDialogType dialog_type, - gpointer user_data) +client_quit_requested_cb (EggSMClient *sm_client, + EphySession *session) { + EphySessionPrivate *priv = session->priv; GObject *dv; GtkWidget *dialog, *box; InteractData *data; - /* FIXME: Can this happen: We already quit? */ - if (ephy_shell_get_default () == NULL) - { - gnome_interaction_key_return (key, FALSE); - return; - } - - dv = ephy_embed_shell_get_downloader_view_nocreate (ephy_embed_shell_get_default ()); - - /* Check if there are still downloads pending */ - if (dv == NULL) - { - gnome_interaction_key_return (key, FALSE); - return; - } + /* If we're shutting down, check if there are downloads + * remaining, since they can't be restarted. + */ + if (ephy_shell_get_default () == NULL || + (dv = ephy_embed_shell_get_downloader_view_nocreate (ephy_embed_shell_get_default ())) == NULL) + { + egg_sm_client_will_quit (sm_client, TRUE); + return; + } dialog = gtk_message_dialog_new (NULL, @@ -228,6 +225,7 @@ confirm_shutdown_cb (GnomeClient *client, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, _("Abort pending downloads?")); + priv->quit_interact_dialog = dialog; gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), @@ -245,9 +243,10 @@ confirm_shutdown_cb (GnomeClient *client, gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT); data = g_new (InteractData, 1); + data->sm_client = g_object_ref (sm_client); + data->session = session; data->dialog = dialog; data->response = GTK_RESPONSE_REJECT; - data->key = key; /* This isn't very exact, but it's good enough here */ data->timeout_id = g_timeout_add_seconds (1, @@ -283,14 +282,32 @@ confirm_shutdown_cb (GnomeClient *client, gtk_window_present (GTK_WINDOW (dialog)); } -static gboolean -save_yourself_cb (GnomeClient *client, - int phase, - GnomeSaveStyle save_style, - gboolean shutdown, - GnomeInteractStyle interact_style, - gboolean fast, - EphySession *session) +static void +client_quit_cancelled_cb (EggSMClient *sm_client, + EphySession *session) +{ + EphySessionPrivate *priv = session->priv; + + if (priv->quit_interact_dialog) + { + gtk_dialog_response (GTK_DIALOG (priv->quit_interact_dialog), + GTK_RESPONSE_DELETE_EVENT); + } +} + +static void +client_quit_cb (EggSMClient *sm_client, + EphySession *session) +{ + LOG ("quit-cb"); + + ephy_session_close (session); +} + +static void +client_save_state_cb (EggSMClient *sm_client, + GKeyFile *keyfile, + EphySession *session) { char *argv[] = { NULL, "--load-session", NULL }; char *discard_argv[] = { "rm", "-f", NULL }; @@ -306,40 +323,14 @@ save_yourself_cb (GnomeClient *client, argv[0] = g_get_prgname (); argv[2] = save_to; - gnome_client_set_restart_command - (client, 3, argv); + egg_sm_client_set_restart_command (sm_client, 3, (const char **) argv); discard_argv[2] = save_to; - gnome_client_set_discard_command (client, 3, - discard_argv); + egg_sm_client_set_discard_command (sm_client, 3, (const char **) discard_argv); ephy_session_save (session, save_to); g_free (save_to); - - /* If we're shutting down, check if there are downloads - * remaining, since they can't be restarted. - */ - if (shutdown && - ephy_embed_shell_get_downloader_view_nocreate (ephy_embed_shell_get_default ()) != NULL) - { - gnome_client_request_interaction (client, - GNOME_DIALOG_NORMAL, - (GnomeInteractFunction) confirm_shutdown_cb, - session); - } - - return TRUE; -} - -static void -die_cb (GnomeClient* client, - EphySession *session) - -{ - LOG ("die_cb"); - - ephy_session_close (session); } /* Helper functions */ @@ -841,7 +832,7 @@ static void ephy_session_init (EphySession *session) { EphySessionPrivate *priv; - GnomeClient *client; + EggSMClient *sm_client; LOG ("EphySession initialising"); @@ -849,11 +840,15 @@ ephy_session_init (EphySession *session) priv->queue = g_queue_new (); - client = gnome_master_client (); - g_signal_connect (client, "save-yourself", - G_CALLBACK (save_yourself_cb), session); - g_signal_connect (client, "die", - G_CALLBACK (die_cb), session); + sm_client = egg_sm_client_get (); + g_signal_connect (sm_client, "save-state", + G_CALLBACK (client_save_state_cb), session); + g_signal_connect (sm_client, "quit-requested", + G_CALLBACK (client_quit_requested_cb), session); + g_signal_connect (sm_client, "quit-cancelled", + G_CALLBACK (client_quit_cancelled_cb), session); + g_signal_connect (sm_client, "quit", + G_CALLBACK (client_quit_cb), session); } static void @@ -861,7 +856,7 @@ ephy_session_dispose (GObject *object) { EphySession *session = EPHY_SESSION (object); EphySessionPrivate *priv = session->priv; - GnomeClient *client; + EggSMClient *sm_client; LOG ("EphySession disposing"); @@ -875,11 +870,9 @@ ephy_session_dispose (GObject *object) session_command_queue_clear (session); - client = gnome_master_client (); - g_signal_handlers_disconnect_by_func - (client, G_CALLBACK (save_yourself_cb), session); - g_signal_handlers_disconnect_by_func - (client, G_CALLBACK (die_cb), session); + sm_client = egg_sm_client_get (); + g_signal_handlers_disconnect_matched (sm_client, G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, session); G_OBJECT_CLASS (ephy_session_parent_class)->dispose (object); } diff --git a/src/ephy-window.c b/src/ephy-window.c index 8fe31d1fd..d047aa462 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -62,7 +62,6 @@ #include <string.h> #include <glib/gi18n.h> #include <gio/gio.h> -#include <libgnomeui/gnome-stock-icons.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #include <webkit/webkit.h> diff --git a/src/window-commands.c b/src/window-commands.c index 65999cfb7..18a1ca98a 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -150,6 +150,7 @@ window_cmd_file_send_to (GtkAction *action, g_free (command); } +#if 0 static gboolean event_with_shift (void) { @@ -176,6 +177,7 @@ event_with_shift (void) return (state & GDK_SHIFT_MASK) != 0; } +#endif void window_cmd_go_location (GtkAction *action, |