From 3d386b57d1682ad0f5fb0b9a60f0d65906f578b7 Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli <ettore@src.gnome.org> Date: Wed, 15 May 2002 21:41:51 +0000 Subject: Check with e_shell_prepare_for_quit() before quitting. * e-shell-view-menu.c (command_quit): Check with e_shell_prepare_for_quit() before quitting. * e-shell.c (e_shell_prepare_for_quit): New. * evolution-test-component.c (request_quit_fn): New function asking for confirmation to quit. * evolution-shell-component.c (evolution_shell_component_new): New arg @request_quit_fn. (impl_requestQuit): New, implementation for EvolutionShellComponent::requestQuit. (evolution_shell_component_result_to_string): Handle EVOLUTION_SHELL_COMPONENT_CANCEL. (evolution_shell_component_client_request_quit): New. * Evolution-ShellComponent.idl (requestQuit): New. * component-factory.c (create_component): Pass NULL as @request_quit_fn. * component-factory.c (create_component): Pass NULL as @request_quit_fn. * gui/component-factory.c (create_object): Pass NULL as @request_quit_fn. * gui/component/addressbook-component.c (create_component): Pass NULL as @request_quit_fn. svn path=/trunk/; revision=16925 --- shell/evolution-shell-component.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'shell/evolution-shell-component.c') diff --git a/shell/evolution-shell-component.c b/shell/evolution-shell-component.c index b1eab010de..b3383b742f 100644 --- a/shell/evolution-shell-component.c +++ b/shell/evolution-shell-component.c @@ -64,6 +64,7 @@ struct _EvolutionShellComponentPrivate { EvolutionShellComponentXferFolderFn xfer_folder_fn; EvolutionShellComponentPopulateFolderContextMenuFn populate_folder_context_menu_fn; EvolutionShellComponentGetDndSelectionFn get_dnd_selection_fn; + EvolutionShellComponentRequestQuitFn request_quit_fn; EvolutionShellClient *owner_client; @@ -670,6 +671,32 @@ impl_sendReceive (PortableServer_Servant servant, gtk_signal_emit (GTK_OBJECT (shell_component), signals[SEND_RECEIVE], show_dialog); } +static void +impl_requestQuit (PortableServer_Servant servant, + const GNOME_Evolution_ShellComponentListener listener, + CORBA_Environment *ev) +{ + EvolutionShellComponent *shell_component; + gboolean allow_quit; + + shell_component = EVOLUTION_SHELL_COMPONENT (bonobo_object_from_servant (servant)); + + if (shell_component->priv->request_quit_fn == NULL) + allow_quit = TRUE; + else + allow_quit = (* shell_component->priv->request_quit_fn) (shell_component, + shell_component->priv->closure); + + if (allow_quit) + GNOME_Evolution_ShellComponentListener_notifyResult (listener, + GNOME_Evolution_ShellComponentListener_OK, + ev); + else + GNOME_Evolution_ShellComponentListener_notifyResult (listener, + GNOME_Evolution_ShellComponentListener_CANCEL, + ev); +} + /* GtkObject methods. */ @@ -872,6 +899,7 @@ class_init (EvolutionShellComponentClass *klass) epv->populateFolderContextMenu = impl_populateFolderContextMenu; epv->userCreateNewItem = impl_userCreateNewItem; epv->sendReceive = impl_sendReceive; + epv->requestQuit = impl_requestQuit; shell_component_class = EVOLUTION_SHELL_COMPONENT_CLASS (object_class); shell_component_class->owner_died = impl_owner_died; @@ -914,6 +942,7 @@ evolution_shell_component_construct (EvolutionShellComponent *shell_component, EvolutionShellComponentXferFolderFn xfer_folder_fn, EvolutionShellComponentPopulateFolderContextMenuFn populate_folder_context_menu_fn, EvolutionShellComponentGetDndSelectionFn get_dnd_selection_fn, + EvolutionShellComponentRequestQuitFn request_quit_fn, void *closure) { EvolutionShellComponentPrivate *priv; @@ -931,6 +960,7 @@ evolution_shell_component_construct (EvolutionShellComponent *shell_component, priv->xfer_folder_fn = xfer_folder_fn; priv->populate_folder_context_menu_fn = populate_folder_context_menu_fn; priv->get_dnd_selection_fn = get_dnd_selection_fn; + priv->request_quit_fn = request_quit_fn; priv->closure = closure; @@ -976,6 +1006,7 @@ evolution_shell_component_new (const EvolutionShellComponentFolderType folder_ty EvolutionShellComponentXferFolderFn xfer_folder_fn, EvolutionShellComponentPopulateFolderContextMenuFn populate_folder_context_menu_fn, EvolutionShellComponentGetDndSelectionFn get_dnd_selection_fn, + EvolutionShellComponentRequestQuitFn request_quit_fn, void *closure) { EvolutionShellComponent *new; @@ -993,6 +1024,7 @@ evolution_shell_component_new (const EvolutionShellComponentFolderType folder_ty xfer_folder_fn, populate_folder_context_menu_fn, get_dnd_selection_fn, + request_quit_fn, closure); return new; @@ -1041,6 +1073,8 @@ evolution_shell_component_result_to_string (EvolutionShellComponentResult result switch (result) { case EVOLUTION_SHELL_COMPONENT_OK: return _("Success"); + case EVOLUTION_SHELL_COMPONENT_CANCEL: + return _("Cancel"); case EVOLUTION_SHELL_COMPONENT_CORBAERROR: return _("CORBA error"); case EVOLUTION_SHELL_COMPONENT_INTERRUPTED: -- cgit v1.2.3