diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2003-10-22 02:28:34 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2003-10-22 02:28:34 +0800 |
commit | 0fb08f3ff81575a4749d851404233f34252dd2f2 (patch) | |
tree | 7e03befedc3a76fd104921dbbc616810d87333be /shell | |
parent | 0e19f2c16de592607a341eb9974d31e4e47e02b5 (diff) | |
download | gsoc2013-evolution-0fb08f3ff81575a4749d851404233f34252dd2f2.tar gsoc2013-evolution-0fb08f3ff81575a4749d851404233f34252dd2f2.tar.gz gsoc2013-evolution-0fb08f3ff81575a4749d851404233f34252dd2f2.tar.bz2 gsoc2013-evolution-0fb08f3ff81575a4749d851404233f34252dd2f2.tar.lz gsoc2013-evolution-0fb08f3ff81575a4749d851404233f34252dd2f2.tar.xz gsoc2013-evolution-0fb08f3ff81575a4749d851404233f34252dd2f2.tar.zst gsoc2013-evolution-0fb08f3ff81575a4749d851404233f34252dd2f2.zip |
Merge new-ui-branch to the trunk.
svn path=/trunk/; revision=22964
Diffstat (limited to 'shell')
31 files changed, 2546 insertions, 2742 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 93ba41eb4e..e0cf859b96 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,8 @@ +2003-10-21 Not Zed <NotZed@Ximian.com> + + * e-storage-browser.c (e_storage_browser_show_path): ref the view + since removing it from the hashtable will unref it. + 2003-10-09 Jeffrey Stedfast <fejj@ximian.com> * Makefile.am: INCLUDE path fixes for changes made to libical @@ -7,6 +12,12 @@ * e-shell-about-box.c: fixed encoding for Spanish translators. +2003-09-29 Ettore Perazzoli <ettore@ximian.com> + + * e-folder-selection-dialog.c, e-folder-selection-dialog.h: New + files, based on e-shell-folder-selection-dialog.[ch]. These don't + require the shell, they just need an EStorageSet to work. + 2003-09-23 Charles Zhang <charles.zhang@sun.com> * e-shell-startup-wizard.c (e_shell_startup_wizard_create): connect @@ -54,10 +65,319 @@ gtk_radio_button_new_with_label_from_widget() to gtk_radio_button_new_with_mnemonic_from_widget(). fix bug #47867 +2003-08-18 Ettore Perazzoli <ettore@ximian.com> + + * e-shell-window.c: New member current_view in struct + EShellWindowPrivate. + (init_view): Set it to the newly added view. Also, switch the + notebooks to the new page. + (component_button_clicked_callback): Set current_view here as + well, for existing views. + (component_view_activate): New. + (component_view_deactivate): New. + (init_view): Deactivate existing view, activate new selected view. + (component_button_clicked_callback): Likewise. + (init_view): Set the component_iface to CORBA_OBJECT_NIL in the + view if you cannot create the controls. + +2003-08-17 Ettore Perazzoli <ettore@ximian.com> + + * e-shell-window.c (setup_widgets): Pass TRUE for @resize to + gtk_paned_pack2() for the view notebook. + +2003-07-29 Ettore Perazzoli <ettore@ximian.com> + + * e-splash.c, e-splash.h: Removed from the build. + +2003-07-25 Ettore Perazzoli <ettore@ximian.com> + + * e-shell.c (e_shell_close_all_windows): Oops. Traverse the + window list with a local "next" variable like we did in the + original code. Otherwise, we crash because the list is being + modified at each gtk_widget_destroy(). + +2003-07-25 Ettore Perazzoli <ettore@ximian.com> + + * e-storage-browser.c (class_init): Set up "page_switched" signal. + (e_storage_browser_show_path): Emit "page_switched". + + * e-storage-browser.h: New signal "page_switched". + +2003-07-25 Ettore Perazzoli <ettore@ximian.com> + + * e-shell-window.c: Removed member ui_container from + EShellWindowPrivate. + (e_shell_window_peek_shell): New. + (e_shell_window_peek_bonobo_ui_component): New. + (e_shell_window_new): Don't set the ui_container anymore, just get + it ourselves. Also call e_shell_window_commands_setup(). + + * e-shell-window-commands.c, e-shell-window-commands.h: New files + implementing the commands for the shell windows. + + * e-shell.c (e_shell_close_all_windows): Renamed from + e_shell_destroy_all_windows(). + + * main.c (idle_cb): Create a new window using + e_shell_create_window(). + + * e-shell-importer.h: Define _E_SHELL_IMPORTER_H_ to prevent + multiple inclusion, instead of __IMPORTER_H__. Also, do not + #include <bonobo/bonobo-ui-component.h>. + + * e-shell-importer.c (e_shell_importer_start_import): Renamed from + show_import_wizard(). Don't get any args. + +2003-07-24 Ettore Perazzoli <ettore@ximian.com> + + * main.c: Remove the global evolution_directory variable. + (main): Just declare, assign and free the evolution_directory + variable here. Also, use g_idle_add() instead of gtk_idle_add(). + (idle_cb): Don't pass the evolution directory path to + e_shell_new() anymore, since that arg is gone. + + * e-shell.c: Remove member local_directory from EShellPrivate. + (impl_finalize): Don't free. + (e_shell_init): Don't NULL. + (e_shell_construct): Removed arg local_directory. + (e_shell_new): Likewise. + (e_shell_construct): Don't call e_setup_check_config() here. + (e_shell_get_local_directory): Removed. + +2003-07-24 Ettore Perazzoli <ettore@ximian.com> + + * main.c: Removed global variable "no_splash". + (idle_cb): Updated to not pass the splash argument to + e_shell_new(). + (main): Removed "--no-splash" option. + + * e-shell.c: Removed members storage_set, local_storage, + summary_storage, folder_type_registry, component_registry, + corba_storage_registry from struct EShellPrivate. + (setup_corba_storages): Removed. + (e_shell_construct): Don't invoke. + (setup_local_storage): Removed. + (e_shell_construct): Don't invoke. Also, removed initialization + for all the removed members. + (e_shell_new): No priv->storage_set anymore. + (e_shell_get_storage_set): Removed. + (e_shell_get_local_storage): Removed. + (e_shell_get_folder_type_registry): Removed. + (set_owner_on_components): Removed. + (set_interactive): Removed contents; do nothing for now. + (pop_up_activation_error_dialog): Removed. + (e_shell_construct): Removed arg show_splash. Do not create a + splash dialog at all. + (e_shell_new): Removed arg show_splash here as well. + (e_shell_construct): No folder type registry handling here + anymore. + (setup_components): Removed splash arg. + (save_settings_for_components): Removed. + (save_settings_for_component): Removed. + (save_misc_settings): Removed. + (e_shell_save_settings): Moved the code in here. + (e_shell_component_maybe_crashed): Removed. + (e_shell_send_receive): Removed. + (e_shell_get_component_registry): Removed. + (prepare_for_quit_callback): Removed. + + * evolution-storage-set-view.c: Removed from build. + * evolution-storage-set-view.h: Removed from build. + * evolution-storage-set-view-factory.c: Removed from build. + * evolution-storage-set-view-factory.h: Removed from build. + + * e-component-registry.c, e-component-registry.h: Removed from + build. + + * e-shell-folder-creation-dialog.c: Removed from build. + * e-shell-folder-creation-dialog.h: Removed from build. + + * e-shell-folder-selection-dialog.c: Removed from build. + * e-shell-folder-selection-dialog.h: Removed from build. + +2003-07-24 Ettore Perazzoli <ettore@ximian.com> + + * e-setup.c: Do not #include "e-shell-config.h". + + * main.c (idle_cb): Do not register the config factory. + + * e-shell.c: Removed members offline_handler, shortcuts and + corba_shortcuts from EShellPrivate. + (setup_shortcuts_interface): Removed. + (storage_set_moved_folder_callback): Removed. + (e_shell_construct): Don't connect. Also, no need to set up the + shortcuts either. + (e_shell_get_shortcuts): Removed. + (offline_procedure_started_cb): Removed. + (offline_procedure_finished_cb): Removed. + (e_shell_go_offline): Just assert for now. + (e_shell_go_online): Same. + + * e-shell-config-autocompletion.c: Removed. + * e-shell-config-autocompletion.h: Removed. + + * e-shell-config-default-folders.c: Removed. + * e-shell-config-default-folders.h: Removed. + + * e-shell-config-folder-settings.c: Removed. + * e-shell-config-folder-settings.h: Removed. + + * e-shell-config.c, e-shell-config.h: Removed. + + * e-corba-shortcuts.c, e-corba-shortcuts.h: Removed. + + * e-shortcuts-view-model.c, e-shortcuts-view-model.h: Removed. + + * e-shortcuts-view.c, e-shortcuts-view.h: Removed. + + * e-shortcuts.c, e-shortcuts.h: Removed. + + * e-shell-offline-handler.c, e-shell-offline-handler.h: Removed. + + * e-shell-offline-sync.c, e-shell-offline-sync.h: Removed. + + * e-shell-config-offline.c, e-shell-config-offline.h: Removed. + +2003-07-24 Ettore Perazzoli <ettore@ximian.com> + + * e-shell.c: Renamed signal "new_view_created" to + "new_window_created". Renamed "no_views_left" to + "no_windows_left". Renamed EShellPrivate member "views" to + "windows". Removed member user_creatable_items_handler. + (notify_no_windows_left_idle_cb): Renamed from + notify_no_views_left_idle_cb. Emit "no_windows_left". + (impl_Shell_createNewView): Raise an InternalError exception. + (window_delete_event_cb): Renamed from view_delete_event_cb. + (window_weak_notify): Renamed from view_weak_notify. + (create_view): Removed. + (create_window): New. Creates a new EShellWindow. + (e_shell_create_view): Removed. + (e_shell_create_window): New. + (e_shell_request_close_view): Removed. + (e_shell_request_close_window): New. + (e_shell_destroy_all_windows): Renamed from + e_shell_destroy_all_views. + (e_shell_component_maybe_crashed): Get an EShellWindow parameter, + instead of an EShellView. + (e_shell_go_offline): Likewise. + (e_shell_go_online): Likewise. + (e_shell_show_settings): Likewise. + (get_icon_path_for_component_info): Removed. + (setup_components): Do not do the user_creatable_items_handler + stuff here. + (e_shell_construct): Don't create the EUserCreatableItemsHandler + here. + (e_shell_get_user_creatable_items_handler): Crash when you get + here. + + * e-shell-user-creatable-items-handler.c: Removed. + * e-shell-user-creatable-items-handler.h: Removed. + * e-shell-shared-folder-picker-dialog.c: Removed. + * e-shell-shared-folder-picker-dialog.h: Removed. + * e-shell-view.c, e-shell-view.h: Removed. + * e-shell-view-menu.c, e-shell-view-menu.h: Removed. + * e-shell-folder-commands.c, e-shell-folder-commands.h: Removed. + * e-shell-importer.c, e-shell-importer.h: Removed. + + * main.c (new_window_created_callback): Renamed from + new_view_created_callback. + (window_map_callback): Renamed from view_map_callback. + (idle_cb): Connect to "new_window_created" instead of + "new_view_created". + (no_windows_left_cb): Renamed from no_views_left_cb. + (idle_cb): Connect to "no_windows_left" instead of + "no_views_left". + + * e-shell-offline-handler.c: Changed the type of the + parent_shell_view member of EShellOfflineHandlerPrivate to + GtkWindow and renamed it to parent_window. + (e_shell_offline_handler_put_components_offline): Just get a + GtkWindow arg instead of an EShellView arg. + +2003-07-24 Ettore Perazzoli <ettore@ximian.com> + + * evolution-shell-client.c + (evolution_shell_client_create_storage_set_view): Just crash when + you get here. + (evolution_shell_client_get_pixbuf_for_type): Likewise. + (evolution_shell_client_set_line_status): Likewise. + (evolution_shell_client_get_local_storage): Likewise. + (evolution_shell_client_get_shortcuts_interface): Likewise. + (evolution_shell_client_get_storage_registry_interface): Likewise. + (evolution_shell_client_get_activity_interface): Likewise. + (evolution_shell_client_user_select_folder): Likewise. + (evolution_shell_client_new): Likewise. + (evolution_shell_client_construct): Likewise. + (query_shell_interface): Removed. + (init): Do nothing. + (class_init): Do nothing. + (unref_pixbuf): Removed. + (impl_dispose): Removed. + (impl_finalize): Removed. + (user_select_folder): Removed. + (count_string_items): Removed. + (create_folder_selection_listener_interface): Removed. + (init_FolderSelectionListener_vtables): Removed. + (impl_FolderSelectionListener_cancel): Removed. + (impl_FolderSelectionListener_selected): Removed. + (query_shell_interface): Removed. + + * e-shell.c (impl_Shell_getLocalStorage): Removed. + (impl_Shell_createStorageSetView): Removed. + (impl_Shell_getIconByType): Removed. + (impl_Shell_getComponentByType): Removed. + (impl_Shell_selectUserFolder): Removed. + (e_shell_class_init): Do not install removed method impls. + (folder_selection_dialog_cancelled_cb): Removed. + (folder_selection_dialog_folder_selected_cb): Removed. + + * Evolution-Shell.idl (getLocalStorage): Removed + (createStorageSetView): Removed. + (selectUserFolder): Removed. + (getIconByType): Removed. + (getComponentByType): Removed. + (FolderSelectionListener): Removed. + + * Evolution-Component.idl (requestQuit, interactive): New methods. + +2003-07-24 Ettore Perazzoli <ettore@ximian.com> + + * e-shell.c: Removed activity_handler member from EShellPrivate. + (setup_activity_interface): Removed. + (e_shell_construct): Don't call. + (create_view): Do not call e_activity_handler_attach_task_bar + here. + + * e-activity-handler.c, e-activity-handler.h: Removed. + 2003-07-24 Yuedong Du <yuedong.du@sun.com> - * e-shell-offline-handler.c: (dialog_response_cb): fix crash when user escape the - dialog. see bug #46700. + * e-shell-offline-handler.c: (dialog_response_cb): fix crash when + user escape the dialog. see bug #46700. + +2003-07-23 Ettore Perazzoli <ettore@ximian.com> + + * e-folder.c (e_folder_new): Accept a NULL description. + + * main.c (idle_cb): Create a new EShellWindow and show it. + + * e-storage.c: New signal "async_open_folder". + (impl_async_open_folder): Removed. + (class_init): Declare new signal. + + * e-shell.c (setup_components): Don't actually activate any + components. + + * e-storage-browser.c, e-storage-browser.h: New. + + * e-shell-window.c, e-shell-window.h: New. + + * e-shell-marshal.list: Add an entry for + NONE:STRING,POINTER,POINTER. + + * Evolution.idl: Include Evolution-Component.idl. + + * Evolution-Component.idl: New interface for Evolution components. 2003-07-23 Dan Winship <danw@ximian.com> diff --git a/shell/Evolution-Component.idl b/shell/Evolution-Component.idl new file mode 100644 index 0000000000..52d86387db --- /dev/null +++ b/shell/Evolution-Component.idl @@ -0,0 +1,37 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Interface for the Evolution components. + * + * Authors: + * Ettore Perazzoli <ettore@ximian.com> + * + * Copyright (C) 2003 Ximian, Inc. + */ + +#include <Bonobo.idl> + +module GNOME { +module Evolution { + + interface Component : Bonobo::Unknown { + /* Create the controls for embedding in the shell. */ + void createControls (out Bonobo::Control sidebar_control, + out Bonobo::Control view_control); + + /* Request the component to quit. The component will reply + with an event named "quit", with a boolean value of TRUE if + the component agrees to quit and FALSE if it doesn't want + to. */ + void requestQuit (in Bonobo::Listener listener); + + /* Notify the component of whether the shell is currently + running in interactive mode or not. (I.e. basically, + whether there are any Evolution windows on the screen.) + @new_view_xid is an X Window ID ("None" if @now_interactive + is FALSE) */ + void interactive (in boolean now_interactive, + in unsigned long new_view_xid); + }; + +}; +}; diff --git a/shell/Evolution-Shell.idl b/shell/Evolution-Shell.idl index 20960ce029..dd3f44838c 100644 --- a/shell/Evolution-Shell.idl +++ b/shell/Evolution-Shell.idl @@ -12,10 +12,6 @@ module GNOME { module Evolution { - interface ShellComponent; - - interface FolderSelectionListener; - interface Shell : Bonobo::Unknown { exception NotReady {}; exception NotFound {}; @@ -24,34 +20,6 @@ module Evolution { exception InternalError {}; exception Busy {}; - typedef sequence<string> FolderTypeNameList; - - /** - * getComponentByType: - * @type: name of a valid folder type - * - * Get the shell component associated with a specific folder type. - * - * Return value: the Evolution::ShellComponent interface for the component that - * handles @type. - */ - ShellComponent getComponentByType (in string type) - raises (NotReady, NotFound); - - /** - * getIconByType: - * @type: name of a valid folder type - * @mini: whether or not to get a mini (16x16) icon - * - * Get an icon associated with a specific folder type. - * - * Return value: an Evolution::Icon interface for the - * component that handles @type. - */ - Icon getIconByType (in string type, - in boolean mini) - raises (NotReady, NotFound); - /** * createNewView: * @uri: URI for the view to open @@ -74,51 +42,6 @@ module Evolution { raises (NotReady, NotFound, UnsupportedSchema, InvalidURI, InternalError); /** - * selectUserFolder: - * @parent_xid: XID for the parent window (or zero if no parent window). - * @listener: a listener interface to report the answer of the user. - * @title: title for the folder selector dialog - * @default_folder: physical or `evolution:' URI for the folder that must be - * selected by default, when the dialog is popped up - * @possible_types: list of the names of the types of folders that are allowed - * - * Pop up a folder selection dialog from which the user can select a folder. - * Initially, the @default_folder is selected. The user can also create a new - * folder by using the "New..." button. The dialog only lets the user choose - * a folder whose type is listed in @possible_types. - */ - void selectUserFolder (in long long parent_xid, - in FolderSelectionListener listener, - in string title, - in string default_folder, - in FolderTypeNameList possible_types) - raises (NotReady, Busy); - - /** - * getLocalStorage: - * - * Get the interface to the local storage. - * - * FIXME: Probably we just want to be able to request this to - * the StorageRegistry. This is an ugly kludge. - * - * Return value: the `Evolution::LocalStorage' interface for - * the local storage. */ - Storage getLocalStorage () - raises (NotReady); - - /** - * createStorageSetView: - * - * Create a control for the storage set view. This control - * will also implement the `Evolution::StorageSetView' interface. - * - * Return value: the newly created control. - */ - Bonobo::Control createStorageSetView () - raises (NotReady); - - /** * setLineStatus: * * Set the shell into on-line or off-line mode. @@ -126,10 +49,5 @@ module Evolution { void setLineStatus (in boolean online) raises (NotReady); }; - - interface FolderSelectionListener { - void notifySelected (in Folder folder); - void notifyCanceled (); - }; }; }; diff --git a/shell/Evolution-ShellComponent.idl b/shell/Evolution-ShellComponent.idl index 90cd6fa57d..88a594853d 100644 --- a/shell/Evolution-ShellComponent.idl +++ b/shell/Evolution-ShellComponent.idl @@ -97,7 +97,7 @@ module Evolution { /* Send debugging output to the file specified. */ void debug (in string log_path); - /* Create a view for the specified @physical URI. */ + /* Create a view for the specified @physical URI. FIXME */ Bonobo::Control createView (in string physical_uri, in string type, in string view_info) diff --git a/shell/Evolution.idl b/shell/Evolution.idl index 6692bd028d..01ce673724 100644 --- a/shell/Evolution.idl +++ b/shell/Evolution.idl @@ -13,6 +13,7 @@ #include <Evolution-common.idl> #include <Evolution-Activity.idl> +#include <Evolution-Component.idl> #include <Evolution-ConfigControl.idl> #include <Evolution-Session.idl> #include <Evolution-ShellComponent.idl> diff --git a/shell/Makefile.am b/shell/Makefile.am index 097e8a8c87..a427d280d9 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -28,6 +28,7 @@ noinst_PROGRAMS = evolution evolution-test-component IDLS = \ Evolution-Activity.idl \ Evolution-ConfigControl.idl \ + Evolution-Component.idl \ Evolution-Offline.idl \ Evolution-Session.idl \ Evolution-Shell.idl \ @@ -112,19 +113,29 @@ eshellincludedir = $(privincludedir)/shell eshellinclude_HEADERS = \ Evolution.h \ - e-folder.h \ + e-corba-storage.h \ + e-folder-dnd-bridge.h \ e-folder-list.h \ + e-folder-selection-dialog.h \ e-folder-tree.h \ + e-folder-type-registry.h \ + e-folder.h \ + e-icon-factory.h \ e-shell-corba-icon-utils.h \ + e-shell-utils.h \ + e-storage-browser.h \ + e-storage-set-view.h \ + e-storage-set.h \ + e-storage.h \ evolution-activity-client.h \ evolution-config-control.h \ evolution-folder-selector-button.h \ evolution-session.h \ evolution-shell-client.h \ evolution-shell-component-client.h \ - evolution-shell-component.h \ evolution-shell-component-dnd.h \ evolution-shell-component-utils.h \ + evolution-shell-component.h \ evolution-shell-view.h \ evolution-storage-listener.h \ evolution-storage-set-view-listener.h \ @@ -133,25 +144,35 @@ eshellinclude_HEADERS = \ libeshell_la_SOURCES = \ $(IDL_GENERATED) \ - e-folder.c \ + e-corba-storage.c \ + e-folder-dnd-bridge.c \ e-folder-list.c \ + e-folder-selection-dialog.c \ e-folder-tree.c \ + e-folder-type-registry.c \ + e-folder.c \ + e-icon-factory.c \ e-shell-corba-icon-utils.c \ + e-shell-marshal.c \ + e-shell-utils.c \ + e-storage-browser.c \ + e-storage-set-view.c \ + e-storage-set.c \ + e-storage.c \ evolution-activity-client.c \ evolution-config-control.c \ evolution-folder-selector-button.c \ evolution-session.c \ evolution-shell-client.c \ evolution-shell-component-client.c \ - evolution-shell-component.c \ evolution-shell-component-dnd.c \ evolution-shell-component-utils.c \ + evolution-shell-component.c \ evolution-shell-view.c \ evolution-storage-listener.c \ evolution-storage-set-view-listener.c \ evolution-storage.c \ evolution-wizard.c \ - e-shell-marshal.c \ $(eshellinclude_HEADERS) libeshell_la_LIBADD = \ @@ -162,30 +183,18 @@ libeshell_la_LIBADD = \ evolution_SOURCES = \ $(SELECT_NAMES_IDL_GENERATED) \ $(WOMBAT_IDL_GENERATED) \ - e-activity-handler.c \ - e-activity-handler.h \ e-component-info.c \ e-component-info.h \ - e-component-registry.c \ - e-component-registry.h \ e-config-upgrade.c \ e-config-upgrade.h \ e-corba-config-page.c \ e-corba-config-page.h \ - e-corba-shortcuts.c \ - e-corba-shortcuts.h \ e-corba-storage-registry.c \ e-corba-storage-registry.h \ e-corba-storage.c \ e-corba-storage.h \ - e-folder-dnd-bridge.c \ - e-folder-dnd-bridge.h \ - e-folder-type-registry.c \ - e-folder-type-registry.h \ e-history.c \ e-history.h \ - e-icon-factory.c \ - e-icon-factory.h \ e-local-folder.c \ e-local-folder.h \ e-local-storage.c \ @@ -194,71 +203,27 @@ evolution_SOURCES = \ e-setup.h \ e-shell-about-box.c \ e-shell-about-box.h \ - e-shell-config.c \ - e-shell-config.h \ - e-shell-config-autocompletion.c \ - e-shell-config-autocompletion.h \ - e-shell-config-offline.c \ - e-shell-config-offline.h \ - e-shell-config-default-folders.c \ - e-shell-config-default-folders.h \ - e-shell-config-folder-settings.c \ - e-shell-config-folder-settings.h \ e-shell-constants.h \ - e-shell-folder-commands.c \ - e-shell-folder-commands.h \ - e-shell-folder-creation-dialog.c \ - e-shell-folder-creation-dialog.h \ - e-shell-folder-selection-dialog.c \ - e-shell-folder-selection-dialog.h \ e-shell-folder-title-bar.c \ e-shell-folder-title-bar.h \ - e-shell-importer.c \ - e-shell-importer.h \ - e-shell-offline-handler.c \ - e-shell-offline-handler.h \ - e-shell-offline-sync.c \ - e-shell-offline-sync.h \ e-shell-settings-dialog.c \ e-shell-settings-dialog.h \ - e-shell-shared-folder-picker-dialog.c \ - e-shell-shared-folder-picker-dialog.h \ e-shell-startup-wizard.c \ e-shell-startup-wizard.h \ - e-shell-user-creatable-items-handler.c \ - e-shell-user-creatable-items-handler.h \ e-shell-utils.c \ e-shell-utils.h \ - e-shell-view-menu.c \ - e-shell-view-menu.h \ - e-shell-view.c \ - e-shell-view.h \ + e-shell-window-commands.c \ + e-shell-window-commands.h \ + e-shell-window.c \ + e-shell-window.h \ e-shell.c \ e-shell.h \ - e-shortcuts-view-model.c \ - e-shortcuts-view-model.h \ - e-shortcuts-view.c \ - e-shortcuts-view.h \ - e-shortcuts.c \ - e-shortcuts.h \ - e-splash.c \ - e-splash.h \ - e-storage-set-view.c \ - e-storage-set-view.h \ - e-storage-set.c \ - e-storage-set.h \ - e-storage.c \ - e-storage.h \ e-task-bar.c \ e-task-bar.h \ e-task-widget.c \ e-task-widget.h \ e-uri-schema-registry.c \ e-uri-schema-registry.h \ - evolution-storage-set-view.c \ - evolution-storage-set-view.h \ - evolution-storage-set-view-factory.c \ - evolution-storage-set-view-factory.h \ main.c evolution_LDADD = \ diff --git a/shell/e-activity-handler.c b/shell/e-activity-handler.c deleted file mode 100644 index 023ff59cd5..0000000000 --- a/shell/e-activity-handler.c +++ /dev/null @@ -1,588 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-activity-handler.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-activity-handler.h" - -#include "e-shell-corba-icon-utils.h" - -#include <gtk/gtksignal.h> -#include <gdk-pixbuf/gdk-pixbuf.h> - -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-popup-menu.h> - -#include <gal/util/e-util.h> -#include <gal/widgets/e-popup-menu.h> - -#include <bonobo/bonobo-exception.h> - - -#define PARENT_TYPE bonobo_object_get_type () -static BonoboObjectClass *parent_class = NULL; - - -#define ICON_SIZE 16 - - -struct _ActivityInfo { - char *component_id; - GdkPixbuf *icon_pixbuf; - GNOME_Evolution_Activity_ActivityId id; - CORBA_char *information; - CORBA_boolean cancellable; - Bonobo_Listener event_listener; - CORBA_float progress; - GtkWidget *menu; -}; -typedef struct _ActivityInfo ActivityInfo; - -struct _EActivityHandlerPrivate { - GNOME_Evolution_Activity_ActivityId next_activity_id; - GList *activity_infos; - GSList *task_bars; -}; - - -/* Utility functions. */ - -static unsigned int -get_new_activity_id (EActivityHandler *activity_handler) -{ - EActivityHandlerPrivate *priv; - - priv = activity_handler->priv; - - return priv->next_activity_id ++; -} - -static GList * -lookup_activity (GList *list, - GNOME_Evolution_Activity_ActivityId activity_id, - int *order_number_return) -{ - GList *p; - int i; - - for (p = list, i = 0; p != NULL; p = p->next, i ++) { - ActivityInfo *activity_info; - - activity_info = (ActivityInfo *) p->data; - if (activity_info->id == activity_id) { - *order_number_return = i; - return p; - } - } - - *order_number_return = -1; - return NULL; -} - -#if 0 -static const CORBA_any * -get_corba_null_value (void) -{ - static CORBA_any *null_value = NULL; - - if (null_value == NULL) { - null_value = CORBA_any__alloc (); - null_value->_type = TC_null; - } - - return null_value; -} - -static void -report_task_event (ActivityInfo *activity_info, - const char *event_name) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - Bonobo_Listener_event (activity_info->event_listener, event_name, get_corba_null_value (), &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("EActivityHandler: Cannot event `%s' -- %s", event_name, ev._repo_id); - - CORBA_exception_free (&ev); -} -#endif - - -/* ETaskWidget actions. */ - -#if 0 -static void -task_widget_cancel_callback (GtkWidget *widget, - void *data) -{ - ActivityInfo *activity_info; - - activity_info = (ActivityInfo *) data; - report_task_event (activity_info, "Cancel"); -} - -static void -task_widget_show_details_callback (GtkWidget *widget, - void *data) -{ - ActivityInfo *activity_info; - - activity_info = (ActivityInfo *) data; - report_task_event (activity_info, "ShowDetails"); -} - -static void -show_cancellation_popup (ActivityInfo *activity_info, - GtkWidget *task_widget, - GdkEventButton *button_event) -{ - GtkMenu *popup; - EPopupMenu items[] = { - E_POPUP_MENU (N_("Show Details"), task_widget_show_details_callback, 0), - E_POPUP_SEPARATOR, - E_POPUP_MENU (N_("Cancel Operation"), task_widget_cancel_callback, 0), - E_POPUP_TERMINATOR - }; - - /* FIXME: We should gray out things properly here. */ - popup = e_popup_menu_create (items, 0, 0, activity_info); - - g_assert (activity_info->menu == NULL); - activity_info->menu = GTK_WIDGET (popup); - - gnome_popup_menu_do_popup_modal (GTK_WIDGET (popup), NULL, NULL, button_event, activity_info); - - activity_info->menu = NULL; -} -#endif - -static int -task_widget_button_press_event_callback (GtkWidget *widget, - GdkEventButton *button_event, - void *data) -{ - CORBA_Environment ev; - ActivityInfo *activity_info; - CORBA_any *null_value; - - activity_info = (ActivityInfo *) data; - - if (button_event->button == 3) { - if (! activity_info->cancellable) { - return FALSE; - } else { - /* show_cancellation_popup (activity_info, widget, button_event); */ - /* return TRUE; */ - return TRUE; - } - } - - if (button_event->button != 1) - return FALSE; - - CORBA_exception_init (&ev); - - null_value = CORBA_any__alloc (); - null_value->_type = TC_null; - - Bonobo_Listener_event (activity_info->event_listener, "Clicked", null_value, &ev); - if (BONOBO_EX (&ev) != CORBA_NO_EXCEPTION) - g_warning ("EActivityHandler: Cannot report `Clicked' event -- %s", - BONOBO_EX_REPOID (&ev)); - - CORBA_free (null_value); - - CORBA_exception_free (&ev); - - return TRUE; -} - - -/* Creating and destroying ActivityInfos. */ - -static ActivityInfo * -activity_info_new (const char *component_id, - GNOME_Evolution_Activity_ActivityId id, - GdkPixbuf *icon, - const CORBA_char *information, - CORBA_boolean cancellable, - const Bonobo_Listener event_listener) -{ - ActivityInfo *info; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - info = g_new (ActivityInfo, 1); - info->component_id = g_strdup (component_id); - info->id = id; - info->icon_pixbuf = g_object_ref (icon); - info->information = CORBA_string_dup (information); - info->cancellable = cancellable; - info->event_listener = CORBA_Object_duplicate (event_listener, &ev); - info->progress = -1.0; /* (Unknown) */ - info->menu = NULL; - - CORBA_exception_free (&ev); - - return info; -} - -static void -activity_info_free (ActivityInfo *info) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - g_free (info->component_id); - - g_object_unref (info->icon_pixbuf); - CORBA_free (info->information); - CORBA_Object_release (info->event_listener, &ev); - - if (info->menu != NULL) - gtk_widget_destroy (info->menu); - - g_free (info); - - CORBA_exception_free (&ev); -} - -static ETaskWidget * -task_widget_new_from_activity_info (ActivityInfo *activity_info) -{ - GtkWidget *widget; - - widget = e_task_widget_new (activity_info->icon_pixbuf, - activity_info->component_id, - activity_info->information); - gtk_widget_show (widget); - - g_signal_connect (widget, "button_press_event", - G_CALLBACK (task_widget_button_press_event_callback), - activity_info); - - return E_TASK_WIDGET (widget); -} - - -/* Task Bar handling. */ - -static void -setup_task_bar (EActivityHandler *activity_handler, - ETaskBar *task_bar) -{ - EActivityHandlerPrivate *priv; - GList *p; - - priv = activity_handler->priv; - - for (p = g_list_last (priv->activity_infos); p != NULL; p = p->prev) { - e_task_bar_prepend_task (task_bar, - task_widget_new_from_activity_info ((ActivityInfo *) p->data)); - } -} - -static void -task_bar_destroy_notify (void *data, - GObject *task_bar_instance) -{ - EActivityHandler *activity_handler; - EActivityHandlerPrivate *priv; - - activity_handler = E_ACTIVITY_HANDLER (data); - priv = activity_handler->priv; - - priv->task_bars = g_slist_remove (priv->task_bars, task_bar_instance); -} - - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - EActivityHandler *handler; - EActivityHandlerPrivate *priv; - GList *p; - GSList *sp; - - handler = E_ACTIVITY_HANDLER (object); - priv = handler->priv; - - for (p = priv->activity_infos; p != NULL; p = p->next) { - ActivityInfo *info; - - info = (ActivityInfo *) p->data; - activity_info_free (info); - } - - g_list_free (priv->activity_infos); - priv->activity_infos = NULL; - - for (sp = priv->task_bars; sp != NULL; sp = sp->next) - g_object_weak_unref (G_OBJECT (sp->data), task_bar_destroy_notify, sp->data); - priv->task_bars = NULL; - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EActivityHandler *handler; - EActivityHandlerPrivate *priv; - - handler = E_ACTIVITY_HANDLER (object); - priv = handler->priv; - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* CORBA methods. */ - -static void -impl_operationStarted (PortableServer_Servant servant, - const CORBA_char *component_id, - const GNOME_Evolution_AnimatedIcon *icon, - const CORBA_char *information, - const CORBA_boolean cancellable, - const Bonobo_Listener event_listener, - GNOME_Evolution_Activity_ActivityId *activity_id_return, - CORBA_boolean *suggest_display_return, - CORBA_Environment *ev) -{ - EActivityHandler *activity_handler; - EActivityHandlerPrivate *priv; - ActivityInfo *activity_info; - GdkPixbuf *icon_pixbuf; - unsigned int activity_id; - GSList *p; - - activity_handler = E_ACTIVITY_HANDLER (bonobo_object_from_servant (servant)); - - priv = activity_handler->priv; - - if (icon->_length == 0) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Activity_InvalidIcon, NULL); - return; - } - - if (icon->_length > 1) - g_warning ("Animated icons are not supported for activities (yet)."); - - icon_pixbuf = e_new_gdk_pixbuf_from_corba_icon (icon->_buffer, ICON_SIZE, ICON_SIZE); - - activity_id = get_new_activity_id (activity_handler); - - activity_info = activity_info_new (component_id, activity_id, icon_pixbuf, information, - cancellable, event_listener); - - for (p = priv->task_bars; p != NULL; p = p->next) - e_task_bar_prepend_task (E_TASK_BAR (p->data), - task_widget_new_from_activity_info (activity_info)); - - g_object_unref (icon_pixbuf); - - priv->activity_infos = g_list_prepend (priv->activity_infos, activity_info); - - *activity_id_return = activity_id; -} - -static void -impl_operationProgressing (PortableServer_Servant servant, - const GNOME_Evolution_Activity_ActivityId activity_id, - const CORBA_char *information, - const CORBA_float progress, - CORBA_Environment *ev) -{ - EActivityHandler *activity_handler; - EActivityHandlerPrivate *priv; - ActivityInfo *activity_info; - GList *p; - GSList *sp; - int order_number; - - /* FIXME? The complexity in this function sucks. */ - - activity_handler = E_ACTIVITY_HANDLER (bonobo_object_from_servant (servant)); - - priv = activity_handler->priv; - - p = lookup_activity (priv->activity_infos, activity_id, &order_number); - if (p == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Activity_IdNotFound, NULL); - return; - } - - activity_info = (ActivityInfo *) p->data; - - CORBA_free (activity_info->information); - activity_info->information = CORBA_string_dup (information); - - activity_info->progress = progress; - - for (sp = priv->task_bars; sp != NULL; sp = sp->next) { - ETaskBar *task_bar; - ETaskWidget *task_widget; - - task_bar = E_TASK_BAR (sp->data); - task_widget = e_task_bar_get_task_widget (task_bar, order_number); - - e_task_widget_update (task_widget, information, progress); - } -} - -static void -impl_operationFinished (PortableServer_Servant servant, - const GNOME_Evolution_Activity_ActivityId activity_id, - CORBA_Environment *ev) -{ - EActivityHandler *activity_handler; - EActivityHandlerPrivate *priv; - GList *p; - GSList *sp; - int order_number; - - activity_handler = E_ACTIVITY_HANDLER (bonobo_object_from_servant (servant)); - - priv = activity_handler->priv; - - p = lookup_activity (priv->activity_infos, activity_id, &order_number); - - activity_info_free ((ActivityInfo *) p->data); - priv->activity_infos = g_list_remove_link (priv->activity_infos, p); - - for (sp = priv->task_bars; sp != NULL; sp = sp->next) { - ETaskBar *task_bar; - - task_bar = E_TASK_BAR (sp->data); - e_task_bar_remove_task (task_bar, order_number); - } -} - -static GNOME_Evolution_Activity_DialogAction -impl_requestDialog (PortableServer_Servant servant, - const GNOME_Evolution_Activity_ActivityId activity_id, - const GNOME_Evolution_Activity_DialogType dialog_type, - CORBA_Environment *ev) -{ - EActivityHandler *activity_handler; - - activity_handler = E_ACTIVITY_HANDLER (bonobo_object_from_servant (servant)); - - /* FIXME implement. */ - g_warning ("Evolution::Activity::requestDialog not implemented"); - - return GNOME_Evolution_Activity_DIALOG_ACTION_DISPLAY; -} - - -/* GTK+ type stuff. */ - -static void -e_activity_handler_class_init (GObjectClass *object_class) -{ - EActivityHandlerClass *handler_class; - - parent_class = g_type_class_ref(PARENT_TYPE); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - handler_class = E_ACTIVITY_HANDLER_CLASS (object_class); - handler_class->epv.operationStarted = impl_operationStarted; - handler_class->epv.operationProgressing = impl_operationProgressing; - handler_class->epv.operationFinished = impl_operationFinished; - handler_class->epv.requestDialog = impl_requestDialog; -} - -static void -e_activity_handler_init (EActivityHandler *activity_handler) -{ - EActivityHandlerPrivate *priv; - - priv = g_new (EActivityHandlerPrivate, 1); - priv->next_activity_id = 0; - priv->activity_infos = NULL; - priv->task_bars = NULL; - - activity_handler->priv = priv; -} - - -void -e_activity_handler_construct (EActivityHandler *activity_handler) -{ - g_return_if_fail (activity_handler != NULL); - g_return_if_fail (E_IS_ACTIVITY_HANDLER (activity_handler)); - - /* Nothing to do here. */ -} - -EActivityHandler * -e_activity_handler_new (void) -{ - EActivityHandler *activity_handler; - - activity_handler = g_object_new (e_activity_handler_get_type (), 0); - e_activity_handler_construct (activity_handler); - - return activity_handler; -} - - -void -e_activity_handler_attach_task_bar (EActivityHandler *activity_handler, - ETaskBar *task_bar) -{ - EActivityHandlerPrivate *priv; - - g_return_if_fail (activity_handler != NULL); - g_return_if_fail (E_IS_ACTIVITY_HANDLER (activity_handler)); - g_return_if_fail (task_bar != NULL); - g_return_if_fail (E_IS_TASK_BAR (task_bar)); - - priv = activity_handler->priv; - - g_object_weak_ref (G_OBJECT (task_bar), task_bar_destroy_notify, activity_handler); - - priv->task_bars = g_slist_prepend (priv->task_bars, task_bar); - - setup_task_bar (activity_handler, task_bar); -} - - -BONOBO_TYPE_FUNC_FULL (EActivityHandler, - GNOME_Evolution_Activity, - PARENT_TYPE, - e_activity_handler) diff --git a/shell/e-activity-handler.h b/shell/e-activity-handler.h deleted file mode 100644 index b69c360765..0000000000 --- a/shell/e-activity-handler.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-activity-handler.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli <ettore@ximian.com> - */ - -#ifndef _E_ACTIVITY_HANDLER_H_ -#define _E_ACTIVITY_HANDLER_H_ - -#include "Evolution.h" - -#include "e-task-bar.h" - -#include <bonobo/bonobo-object.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_ACTIVITY_HANDLER (e_activity_handler_get_type ()) -#define E_ACTIVITY_HANDLER(obj) (GTK_CHECK_CAST ((obj), E_TYPE_ACTIVITY_HANDLER, EActivityHandler)) -#define E_ACTIVITY_HANDLER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_ACTIVITY_HANDLER, EActivityHandlerClass)) -#define E_IS_ACTIVITY_HANDLER(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_ACTIVITY_HANDLER)) -#define E_IS_ACTIVITY_HANDLER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_ACTIVITY_HANDLER)) - - -typedef struct _EActivityHandler EActivityHandler; -typedef struct _EActivityHandlerPrivate EActivityHandlerPrivate; -typedef struct _EActivityHandlerClass EActivityHandlerClass; - -struct _EActivityHandler { - BonoboObject parent; - - EActivityHandlerPrivate *priv; -}; - -struct _EActivityHandlerClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Activity__epv epv; -}; - - -GtkType e_activity_handler_get_type (void); -void e_activity_handler_construct (EActivityHandler *activity_hanlder); -EActivityHandler *e_activity_handler_new (void); - -void e_activity_handler_attach_task_bar (EActivityHandler *activity_hanlder, - ETaskBar *task_bar); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_ACTIVITY_HANDLER_H_ */ diff --git a/shell/e-component-registry.c b/shell/e-component-registry.c index d0a8cc146a..0935eed1e8 100644 --- a/shell/e-component-registry.c +++ b/shell/e-component-registry.c @@ -37,6 +37,7 @@ #include "e-shell-utils.h" #include "evolution-shell-component-client.h" +#include "e-folder-type-registry.h" #define PARENT_TYPE G_TYPE_OBJECT diff --git a/shell/e-folder-selection-dialog.c b/shell/e-folder-selection-dialog.c new file mode 100644 index 0000000000..42a881e113 --- /dev/null +++ b/shell/e-folder-selection-dialog.c @@ -0,0 +1,479 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-folder-selection-dialog.c + * + * Copyright (C) 2000, 2001, 2002, 2003 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ettore Perazzoli + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "e-folder-selection-dialog.h" + +#include "e-shell-marshal.h" +#include "e-storage-set-view.h" +#include "e-storage-set.h" + +#include <libgnome/gnome-i18n.h> + +#include <gal/util/e-util.h> +#include <gal/widgets/e-gui-utils.h> + +#include <gtk/gtkbox.h> +#include <gtk/gtklabel.h> +#include <gtk/gtkscrolledwindow.h> +#include <gtk/gtksignal.h> +#include <gtk/gtkstock.h> + +#include <string.h> + + +#define PARENT_TYPE (gtk_dialog_get_type ()) +static GtkDialogClass *parent_class = NULL; + +struct _EFolderSelectionDialogPrivate { + GList *allowed_types; + EStorageSet *storage_set; + GtkWidget *storage_set_view; + + gboolean allow_creation; +}; + +enum { + FOLDER_SELECTED, + CANCELLED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +enum { + RESPONSE_NEW +}; + + +/* Utility functions. */ + +static gboolean +check_folder_type_valid (EFolderSelectionDialog *folder_selection_dialog) +{ + EFolderSelectionDialogPrivate *priv; + const char *selected_path; + EFolder *folder; + const char *folder_type; + GList *p; + + priv = folder_selection_dialog->priv; + if (priv->allowed_types == NULL) + return TRUE; + + selected_path = e_folder_selection_dialog_get_selected_path (folder_selection_dialog); + if (selected_path == NULL) + return FALSE; + + folder = e_storage_set_get_folder (priv->storage_set, selected_path); + if (folder == NULL) + return FALSE; + + folder_type = e_folder_get_type_string (folder); + + for (p = priv->allowed_types; p != NULL; p = p->next) { + const char *type, *slash; + + type = (const char *) p->data; + if (strcmp (folder_type, type) == 0) + return TRUE; + slash = strchr (type, '/'); + if (slash && slash[1] == '*' && strncmp (folder_type, type, slash - type) == 0) + return TRUE; + } + + return FALSE; +} + + +/* Folder creation dialog callback. */ + +#if 0 /* EPFIXME */ +static void +folder_creation_dialog_result_cb (EShell *shell, + EShellFolderCreationDialogResult result, + const char *path, + void *data) +{ + EFolderSelectionDialog *dialog; + EFolderSelectionDialogPrivate *priv; + + dialog = E_FOLDER_SELECTION_DIALOG (data); + priv = dialog->priv; + + if (priv == NULL) { + g_warning ("dialog->priv is NULL, and should not be"); + return; + } + + if (result == E_SHELL_FOLDER_CREATION_DIALOG_RESULT_SUCCESS) + e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), + path); +} +#endif + + +/* GtkObject methods. */ + +static void +impl_dispose (GObject *object) +{ + EFolderSelectionDialog *folder_selection_dialog; + EFolderSelectionDialogPrivate *priv; + + folder_selection_dialog = E_FOLDER_SELECTION_DIALOG (object); + priv = folder_selection_dialog->priv; + + if (priv->storage_set != NULL) { + g_object_unref (priv->storage_set); + priv->storage_set = NULL; + } + + (* G_OBJECT_CLASS (parent_class)->dispose) (object); +} + +static void +impl_finalize (GObject *object) +{ + EFolderSelectionDialog *folder_selection_dialog; + EFolderSelectionDialogPrivate *priv; + + folder_selection_dialog = E_FOLDER_SELECTION_DIALOG (object); + priv = folder_selection_dialog->priv; + + e_free_string_list (priv->allowed_types); + + g_free (priv); + + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + + +/* GtkDialog methods. */ + +static void +impl_response (GtkDialog *dialog, + int response) +{ + EFolderSelectionDialog *folder_selection_dialog; + EFolderSelectionDialogPrivate *priv; + EStorageSetView *storage_set_view; + const char *default_parent_folder; + const char *default_subtype; + char *default_type; + + folder_selection_dialog = E_FOLDER_SELECTION_DIALOG (dialog); + priv = folder_selection_dialog->priv; + + switch (response) { + case GTK_RESPONSE_OK: + if (check_folder_type_valid (folder_selection_dialog)) { + g_signal_emit (folder_selection_dialog, signals[FOLDER_SELECTED], 0, + e_folder_selection_dialog_get_selected_path (folder_selection_dialog)); + } + break; + + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_DELETE_EVENT: + g_signal_emit (folder_selection_dialog, signals[CANCELLED], 0); + break; + + case RESPONSE_NEW: + storage_set_view = E_STORAGE_SET_VIEW (priv->storage_set_view); + default_parent_folder = e_storage_set_view_get_current_folder (storage_set_view); + + /* The default type in the folder creation dialog will be the + first of the allowed types. If all types are allowed, + hardcode to "mail". */ + if (priv->allowed_types == NULL) + default_type = g_strdup ("mail"); + else { + default_subtype = (const char *) priv->allowed_types->data; + default_type = g_strndup (default_subtype, + strcspn (default_subtype, "/")); + } + +#if 0 /* EPFIXME */ + e_shell_show_folder_creation_dialog (priv->shell, GTK_WINDOW (dialog), + default_parent_folder, + default_type, + folder_creation_dialog_result_cb, + dialog); +#endif + + g_free (default_type); + + break; + } +} + + +/* GTK+ type initialization. */ + +static void +class_init (EFolderSelectionDialogClass *klass) +{ + GObjectClass *object_class; + GtkDialogClass *dialog_class; + + parent_class = g_type_class_ref(PARENT_TYPE); + object_class = G_OBJECT_CLASS (klass); + dialog_class = GTK_DIALOG_CLASS (klass); + + object_class->dispose = impl_dispose; + object_class->finalize = impl_finalize; + + dialog_class->response = impl_response; + + signals[FOLDER_SELECTED] + = g_signal_new ("folder_selected", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EFolderSelectionDialogClass, folder_selected), + NULL, NULL, + e_shell_marshal_NONE__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); + + signals[CANCELLED] + = g_signal_new ("cancelled", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EFolderSelectionDialogClass, cancelled), + NULL, NULL, + e_shell_marshal_NONE__NONE, + G_TYPE_NONE, 0); +} + +static void +init (EFolderSelectionDialog *folder_selection_dialog) +{ + EFolderSelectionDialogPrivate *priv; + + priv = g_new (EFolderSelectionDialogPrivate, 1); + priv->storage_set = NULL; + priv->storage_set_view = NULL; + priv->allowed_types = NULL; + priv->allow_creation = TRUE; + + folder_selection_dialog->priv = priv; +} + + +/* ETable callbacks. */ + +static void +folder_selected_cb (EStorageSetView *storage_set_view, + const char *path, + void *data) +{ + EFolderSelectionDialog *dialog; + + dialog = E_FOLDER_SELECTION_DIALOG (data); + + if (check_folder_type_valid (dialog)) + gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE); + else + gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); +} + +static void +double_click_cb (EStorageSetView *essv, + int row, + ETreePath path, + int col, + GdkEvent *event, + EFolderSelectionDialog *folder_selection_dialog) +{ + g_return_if_fail (folder_selection_dialog != NULL); + + if (check_folder_type_valid (folder_selection_dialog)) { + g_signal_emit (folder_selection_dialog, signals[FOLDER_SELECTED], 0, + e_folder_selection_dialog_get_selected_path (folder_selection_dialog)); + } +} + + +/** + * e_folder_selection_dialog_construct: + * @folder_selection_dialog: A folder selection dialog widget + * @storage_set: The storage set this folder selection dialog is for + * @title: Title of the window + * @caption: A brief text to be put on top of the storage view + * @default_path: The path of the folder to be selected by default + * @allowed_types: List of the names of the allowed types + * + * Construct @folder_selection_dialog. + **/ +/* EPFIXME: Should be allowed to get the expanded state from a model + EStorageSetView. */ +void +e_folder_selection_dialog_construct (EFolderSelectionDialog *folder_selection_dialog, + EStorageSet *storage_set, + const char *title, + const char *caption, + const char *default_path, + const char *allowed_types[], + gboolean allow_creation) +{ + EFolderSelectionDialogPrivate *priv; + GtkWidget *scrolled_window; + GtkWidget *caption_label; + int i; + + g_return_if_fail (E_IS_FOLDER_SELECTION_DIALOG (folder_selection_dialog)); + g_return_if_fail (E_IS_STORAGE_SET (storage_set)); + + priv = folder_selection_dialog->priv; + + /* Basic dialog setup. */ + + gtk_window_set_default_size (GTK_WINDOW (folder_selection_dialog), 350, 300); + gtk_window_set_modal (GTK_WINDOW (folder_selection_dialog), TRUE); + gtk_window_set_title (GTK_WINDOW (folder_selection_dialog), title); + gtk_container_set_border_width (GTK_CONTAINER (folder_selection_dialog), 6); + + if (allow_creation) + gtk_dialog_add_buttons (GTK_DIALOG (folder_selection_dialog), + GTK_STOCK_NEW, RESPONSE_NEW, + NULL); + + gtk_dialog_add_buttons (GTK_DIALOG (folder_selection_dialog), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + + gtk_dialog_set_response_sensitive (GTK_DIALOG (folder_selection_dialog), GTK_RESPONSE_OK, FALSE); + gtk_dialog_set_default_response (GTK_DIALOG (folder_selection_dialog), GTK_RESPONSE_OK); + + /* Set up the label. */ + + if (caption != NULL) { + caption_label = gtk_label_new (caption); + gtk_label_set_justify (GTK_LABEL (caption_label), GTK_JUSTIFY_LEFT); + gtk_widget_show (caption_label); + + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), + caption_label, FALSE, TRUE, 6); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), + 6); + + + } + + /* Set up the storage set and its view. */ + + priv->storage_set = storage_set; + g_object_ref (storage_set); + + priv->storage_set_view = e_storage_set_create_new_view (priv->storage_set, NULL); + e_storage_set_view_set_allow_dnd (E_STORAGE_SET_VIEW (priv->storage_set_view), FALSE); + e_storage_set_view_enable_search (E_STORAGE_SET_VIEW (priv->storage_set_view), TRUE); + + g_signal_connect (priv->storage_set_view, "double_click", G_CALLBACK (double_click_cb), folder_selection_dialog); + g_signal_connect (priv->storage_set_view, "folder_selected", G_CALLBACK (folder_selected_cb), folder_selection_dialog); + + g_assert (priv->allowed_types == NULL); + if (allowed_types != NULL) { + for (i = 0; allowed_types[i] != NULL; i++) + priv->allowed_types = g_list_prepend (priv->allowed_types, + g_strdup (allowed_types[i])); + + /* Preserve the order so we can use the first type listed as + the default for the folder creation dialog invoked by the + "New..." button. */ + priv->allowed_types = g_list_reverse (priv->allowed_types); + } + + if (default_path != NULL) + e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), default_path); + + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + + gtk_container_add (GTK_CONTAINER (scrolled_window), priv->storage_set_view); + + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), + scrolled_window, TRUE, TRUE, 6); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), 6); + + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (folder_selection_dialog)->vbox), 6); + + gtk_widget_show (priv->storage_set_view); + gtk_widget_show (scrolled_window); + + GTK_WIDGET_SET_FLAGS (priv->storage_set_view, GTK_CAN_FOCUS); + gtk_widget_grab_focus (priv->storage_set_view); +} + +/** + * e_folder_selection_dialog_new: + * @storage_set: The storage set this folder selection dialog is for + * @title: Title of the window + * @caption: A brief text to be put on top of the storage view + * @default_path: The path of the folder to be selected by default + * @allowed_types: List of the names of the allowed types + * + * Create a new folder selection dialog widget. + * + * Return value: + **/ +GtkWidget * +e_folder_selection_dialog_new (EStorageSet *storage_set, + const char *title, + const char *caption, + const char *default_path, + const char *allowed_types[], + gboolean allow_creation) +{ + EFolderSelectionDialog *folder_selection_dialog; + + g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); + + folder_selection_dialog = g_object_new (e_folder_selection_dialog_get_type (), NULL); + e_folder_selection_dialog_construct (folder_selection_dialog, storage_set, + title, caption, default_path, allowed_types, + allow_creation); + + return GTK_WIDGET (folder_selection_dialog); +} + + +const char * +e_folder_selection_dialog_get_selected_path (EFolderSelectionDialog *folder_selection_dialog) +{ + EFolderSelectionDialogPrivate *priv; + + g_return_val_if_fail (E_IS_FOLDER_SELECTION_DIALOG (folder_selection_dialog), NULL); + + priv = folder_selection_dialog->priv; + + return e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view)); +} + + +E_MAKE_TYPE (e_folder_selection_dialog, "EFolderSelectionDialog", EFolderSelectionDialog, class_init, init, PARENT_TYPE) diff --git a/shell/e-folder-selection-dialog.h b/shell/e-folder-selection-dialog.h new file mode 100644 index 0000000000..bc263d46a8 --- /dev/null +++ b/shell/e-folder-selection-dialog.h @@ -0,0 +1,82 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-folder-selection-dialog.h + * + * Copyright (C) 2000, 2001, 2002, 2003 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ettore Perazzoli + */ + +#ifndef E_FOLDER_SELECTION_DIALOG_H +#define E_FOLDER_SELECTION_DIALOG_H + +#include "e-storage-set.h" + +#include <gtk/gtkdialog.h> + +#ifdef cplusplus +extern "C" { +#pragma } +#endif /* cplusplus */ + +#define E_TYPE_FOLDER_SELECTION_DIALOG (e_folder_selection_dialog_get_type ()) +#define E_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_CAST ((obj), E_TYPE_FOLDER_SELECTION_DIALOG, EFolderSelectionDialog)) +#define E_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_FOLDER_SELECTION_DIALOG, EFolderSelectionDialogClass)) +#define E_IS_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_FOLDER_SELECTION_DIALOG)) +#define E_IS_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_FOLDER_SELECTION_DIALOG)) + + +typedef struct _EFolderSelectionDialog EFolderSelectionDialog; +typedef struct _EFolderSelectionDialogPrivate EFolderSelectionDialogPrivate; +typedef struct _EFolderSelectionDialogClass EFolderSelectionDialogClass; + +struct _EFolderSelectionDialog { + GtkDialog parent; + + EFolderSelectionDialogPrivate *priv; +}; + +struct _EFolderSelectionDialogClass { + GtkDialogClass parent_class; + + void (* folder_selected) (EFolderSelectionDialog *folder_selection_dialog, + const char *path); + void (* cancelled) (EFolderSelectionDialog *folder_selection_dialog); +}; + + +GtkType e_folder_selection_dialog_get_type (void); +void e_folder_selection_dialog_construct (EFolderSelectionDialog *folder_selection_dialog, + EStorageSet *storage_set, + const char *title, + const char *caption, + const char *default_path, + const char *allowed_types[], + gboolean allow_creation); +GtkWidget *e_folder_selection_dialog_new (EStorageSet *storage_set, + const char *title, + const char *caption, + const char *default_path, + const char *allowed_types[], + gboolean allow_creation); + +const char *e_folder_selection_dialog_get_selected_path (EFolderSelectionDialog *folder_selection_dialog); + +#ifdef cplusplus +} +#endif /* cplusplus */ + +#endif /* E_FOLDER_SELECTION_DIALOG_H */ diff --git a/shell/e-folder.c b/shell/e-folder.c index 8226170e92..adaa31f465 100644 --- a/shell/e-folder.c +++ b/shell/e-folder.c @@ -220,7 +220,6 @@ e_folder_new (const char *name, g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (type != NULL, NULL); - g_return_val_if_fail (description != NULL, NULL); folder = g_object_new (E_TYPE_FOLDER, NULL); diff --git a/shell/e-setup.c b/shell/e-setup.c index ce9389b781..b152afb5ac 100644 --- a/shell/e-setup.c +++ b/shell/e-setup.c @@ -28,7 +28,6 @@ #include "e-setup.h" #include "e-local-folder.h" -#include "e-shell-config.h" #include "e-shell-constants.h" #include "e-util/e-dialog-utils.h" diff --git a/shell/e-shell-importer.c b/shell/e-shell-importer.c index adbd5efae4..5cd53cb447 100644 --- a/shell/e-shell-importer.c +++ b/shell/e-shell-importer.c @@ -1162,9 +1162,7 @@ dialog_weak_notify (void *data, } void -show_import_wizard (BonoboUIComponent *component, - gpointer user_data, - const char *cname) +e_shell_importer_start_import (void) { ImportData *data = g_new0 (ImportData, 1); GtkWidget *html; diff --git a/shell/e-shell-importer.h b/shell/e-shell-importer.h index 4e9b91ff26..3e139dc846 100644 --- a/shell/e-shell-importer.h +++ b/shell/e-shell-importer.h @@ -20,13 +20,9 @@ * Author: Iain Holmes <iain@ximian.com> */ -#include <bonobo/bonobo-ui-component.h> +#ifndef _E_SHELL_IMPORTER_H_ +#define _E_SHELL_IMPORTER_H_ -#ifndef __IMPORTER_H__ -#define __IMPORTER_H__ - -void show_import_wizard (BonoboUIComponent *component, - gpointer user_data, - const char *cname); +void e_shell_importer_start_import (void); #endif diff --git a/shell/e-shell-marshal.list b/shell/e-shell-marshal.list index f1ae29622d..d4076e2a6c 100644 --- a/shell/e-shell-marshal.list +++ b/shell/e-shell-marshal.list @@ -23,6 +23,7 @@ NONE:STRING,BOOL NONE:STRING,INT NONE:STRING,INT,INT NONE:STRING,POINTER +NONE:STRING,POINTER,POINTER NONE:STRING,STRING NONE:STRING,STRING,STRING NONE:STRING,STRING,STRING,STRING diff --git a/shell/e-shell-offline-handler.c b/shell/e-shell-offline-handler.c index 298421b1a8..3554705f9f 100644 --- a/shell/e-shell-offline-handler.c +++ b/shell/e-shell-offline-handler.c @@ -94,7 +94,7 @@ typedef struct _ComponentInfo ComponentInfo; struct _EShellOfflineHandlerPrivate { EShell *shell; - EShellView *parent_shell_view; + GtkWindow *parent_window; GladeXML *dialog_gui; @@ -755,7 +755,7 @@ init (EShellOfflineHandler *shell_offline_handler) priv = g_new (EShellOfflineHandlerPrivate, 1); priv->shell = NULL; - priv->parent_shell_view = NULL; + priv->parent_window = NULL; priv->dialog_gui = NULL; @@ -824,18 +824,18 @@ e_shell_offline_handler_new (EShell *shell) **/ void e_shell_offline_handler_put_components_offline (EShellOfflineHandler *offline_handler, - EShellView *parent_shell_view) + GtkWindow *parent_window) { EShellOfflineHandlerPrivate *priv; g_return_if_fail (offline_handler != NULL); g_return_if_fail (E_IS_SHELL_OFFLINE_HANDLER (offline_handler)); - g_return_if_fail (parent_shell_view == NULL || E_IS_SHELL_VIEW (parent_shell_view)); + g_return_if_fail (parent_window == NULL || GTK_IS_WINDOW (parent_window)); priv = offline_handler->priv; priv->procedure_in_progress = TRUE; - priv->parent_shell_view = parent_shell_view; + priv->parent_window = parent_window; /* Add an extra ref here as the signal handlers might want to unref us. */ @@ -855,11 +855,10 @@ e_shell_offline_handler_put_components_offline (EShellOfflineHandler *offline_ha return; } - if (priv->num_total_connections > 0 && priv->parent_shell_view != NULL) { + if (priv->num_total_connections > 0 && priv->parent_window != NULL) { pop_up_confirmation_dialog (offline_handler); } else { - e_shell_offline_sync_all_folders (priv->shell, - parent_shell_view ? GTK_WINDOW (parent_shell_view) : NULL); + e_shell_offline_sync_all_folders (priv->shell, parent_window); finalize_offline (offline_handler); } diff --git a/shell/e-shell-offline-handler.h b/shell/e-shell-offline-handler.h index ce58dd73a9..4a7f60ebf3 100644 --- a/shell/e-shell-offline-handler.h +++ b/shell/e-shell-offline-handler.h @@ -24,9 +24,10 @@ #define _E_SHELL_OFFLINE_HANDLER_H_ #include <gtk/gtkobject.h> +#include <gtk/gtkwindow.h> #include "e-component-registry.h" -#include "e-shell-view.h" + #ifdef __cplusplus extern "C" { @@ -72,7 +73,7 @@ void e_shell_offline_handler_construct (EShellOfflineHandler * EShellOfflineHandler *e_shell_offline_handler_new (EShell *shell); void e_shell_offline_handler_put_components_offline (EShellOfflineHandler *offline_handler, - EShellView *parent_shell_view); + GtkWindow *parent_window); #ifdef __cplusplus } diff --git a/shell/e-shell-window-commands.c b/shell/e-shell-window-commands.c new file mode 100644 index 0000000000..b75fc998a4 --- /dev/null +++ b/shell/e-shell-window-commands.c @@ -0,0 +1,353 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-window-commands.c + * + * Copyright (C) 2003 Ettore Perazzoli + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ettore Perazzoli <ettore@ximian.com> + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "e-shell-window-commands.h" + +#include "e-shell-about-box.h" +#include "e-shell-window.h" + +#include "evolution-shell-component-utils.h" + +#include "e-util/e-dialog-utils.h" + +#include <libgnome/gnome-exec.h> +#include <libgnome/gnome-url.h> +#include <libgnome/gnome-i18n.h> + +#include <bonobo/bonobo-ui-component.h> + + +/* Utility functions. */ + +static void +launch_pilot_settings (const char *extra_arg) +{ + char *args[] = { + "gpilotd-control-applet", + (char *) extra_arg, + NULL + }; + int pid; + + args[0] = g_find_program_in_path ("gpilotd-control-applet"); + if (!args[0]) { + e_notice (NULL, GTK_MESSAGE_ERROR, + _("The GNOME Pilot tools do not appear to be installed on this system.")); + return; + } + + pid = gnome_execute_async (NULL, extra_arg ? 2 : 1, args); + g_free (args[0]); + + if (pid == -1) + e_notice (NULL, GTK_MESSAGE_ERROR, _("Error executing %s."), args[0]); +} + + +/* Command callbacks. */ + +static void +command_import (BonoboUIComponent *uih, + EShellWindow *window, + const char *path) +{ + g_warning ("Import not implemented!"); + + /* e_shell_importer_start_import (); FIXME TODO */ +} + +static void +command_close (BonoboUIComponent *uih, + EShellWindow *window, + const char *path) +{ + if (e_shell_request_close_window (e_shell_window_peek_shell (window), window)) + gtk_widget_destroy (GTK_WIDGET (window)); +} + +static void +command_quit (BonoboUIComponent *uih, + EShellWindow *window, + const char *path) +{ + EShell *shell = e_shell_window_peek_shell (window); + + e_shell_window_save_defaults (window); + + if (e_shell_prepare_for_quit (shell)) + e_shell_close_all_windows (shell); +} + +static void +command_submit_bug (BonoboUIComponent *uih, + EShellWindow *window, + const char *path) +{ + int pid; + char *args[] = { + "bug-buddy", + "--sm-disable", + "--package=evolution", + "--package-ver="VERSION, + NULL + }; + + args[0] = g_find_program_in_path ("bug-buddy"); + if (!args[0]) { + e_notice (NULL, GTK_MESSAGE_ERROR, _("Bug buddy is not installed.")); + return; + } + + pid = gnome_execute_async (NULL, 4, args); + g_free (args[0]); + + if (pid == -1) + e_notice (NULL, GTK_MESSAGE_ERROR, _("Bug buddy could not be run.")); +} + +static int +about_box_event_callback (GtkWidget *widget, + GdkEvent *event, + GtkWidget **widget_pointer) +{ + gtk_widget_destroy (GTK_WIDGET (*widget_pointer)); + *widget_pointer = NULL; + + return TRUE; +} + +static void +command_about_box (BonoboUIComponent *uih, + EShellWindow *window, + const char *path) +{ + static GtkWidget *about_box_window = NULL; + GtkWidget *about_box; + + if (about_box_window != NULL) { + gdk_window_raise (about_box_window->window); + return; + } + + about_box = e_shell_about_box_new (); + gtk_widget_show (about_box); + + about_box_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_type_hint (GTK_WINDOW (about_box_window), GDK_WINDOW_TYPE_HINT_DIALOG); + + gtk_window_set_resizable (GTK_WINDOW (about_box_window), FALSE); + g_signal_connect (about_box_window, "key_press_event", + G_CALLBACK (about_box_event_callback), &about_box_window); + g_signal_connect (about_box_window, "button_press_event", + G_CALLBACK (about_box_event_callback), &about_box_window); + g_signal_connect (about_box_window, "delete_event", + G_CALLBACK (about_box_event_callback), &about_box_window); + + gtk_window_set_transient_for (GTK_WINDOW (about_box_window), GTK_WINDOW (window)); + gtk_window_set_title (GTK_WINDOW (about_box_window), _("About Ximian Evolution")); + gtk_container_add (GTK_CONTAINER (about_box_window), about_box); + gtk_widget_show (about_box_window); +} + +static void +command_help_faq (BonoboUIComponent *uih, + EShellWindow *window, + const char *path) +{ + gnome_url_show ("http://www.ximian.com/apps/evolution-faq.html", NULL); /* FIXME use the error */ +} + + +static void +command_work_offline (BonoboUIComponent *uih, + EShellWindow *window, + const char *path) +{ + e_shell_go_offline (e_shell_window_peek_shell (window), window); +} + +static void +command_work_online (BonoboUIComponent *uih, + EShellWindow *window, + const char *path) +{ + e_shell_go_online (e_shell_window_peek_shell (window), window); +} + + +/* Tools menu. */ + +static void +command_settings (BonoboUIComponent *uih, + EShellWindow *window, + const char *path) +{ + e_shell_window_show_settings (window); +} + +static void +command_pilot_settings (BonoboUIComponent *uih, + EShellWindow *window, + const char *path) +{ + launch_pilot_settings (NULL); +} + + +static BonoboUIVerb file_verbs [] = { + BONOBO_UI_VERB ("FileImporter", (BonoboUIVerbFn) command_import), + BONOBO_UI_VERB ("FileClose", (BonoboUIVerbFn) command_close), + BONOBO_UI_VERB ("FileExit", (BonoboUIVerbFn) command_quit), + + BONOBO_UI_VERB ("WorkOffline", (BonoboUIVerbFn) command_work_offline), + BONOBO_UI_VERB ("WorkOnline", (BonoboUIVerbFn) command_work_online), + + BONOBO_UI_VERB_END +}; + +static BonoboUIVerb tools_verbs[] = { + BONOBO_UI_VERB ("Settings", (BonoboUIVerbFn) command_settings), + BONOBO_UI_VERB ("PilotSettings", (BonoboUIVerbFn) command_pilot_settings), + + BONOBO_UI_VERB_END +}; + +static BonoboUIVerb help_verbs [] = { + BONOBO_UI_VERB ("HelpFAQ", (BonoboUIVerbFn) command_help_faq), + BONOBO_UI_VERB ("HelpSubmitBug", (BonoboUIVerbFn) command_submit_bug), + BONOBO_UI_VERB ("HelpAbout", (BonoboUIVerbFn) command_about_box), + + BONOBO_UI_VERB_END +}; + +static EPixmap pixmaps [] = { + E_PIXMAP ("/menu/File/FileImporter", "import.xpm"), + E_PIXMAP ("/menu/File/ToggleOffline", "work_offline.xpm"), + E_PIXMAP ("/menu/Tools/Settings", "settings-16.png"), + + E_PIXMAP_END +}; + +static EPixmap offline_pixmaps [] = { + E_PIXMAP ("/menu/File/ToggleOffline", "work_offline.xpm"), + E_PIXMAP_END +}; + +static EPixmap online_pixmaps [] = { + E_PIXMAP ("/menu/File/ToggleOffline", "work_online-16.png"), + E_PIXMAP_END +}; + + +/* The Work Online / Work Offline menu item. */ + +static void +update_offline_menu_item (EShellWindow *shell_window, + EShellLineStatus line_status) +{ + BonoboUIComponent *ui_component; + + ui_component = e_shell_window_peek_bonobo_ui_component (shell_window); + + switch (line_status) { + case E_SHELL_LINE_STATUS_OFFLINE: + bonobo_ui_component_set_prop (ui_component, + "/menu/File/ToggleOffline", + "label", _("_Work Online"), NULL); + bonobo_ui_component_set_prop (ui_component, + "/menu/File/ToggleOffline", + "verb", "WorkOnline", NULL); + bonobo_ui_component_set_prop (ui_component, + "/commands/ToggleOffline", + "sensitive", "1", NULL); + e_pixmaps_update (ui_component, online_pixmaps); + break; + + case E_SHELL_LINE_STATUS_ONLINE: + bonobo_ui_component_set_prop (ui_component, + "/menu/File/ToggleOffline", + "label", _("_Work Offline"), NULL); + bonobo_ui_component_set_prop (ui_component, + "/menu/File/ToggleOffline", + "verb", "WorkOffline", NULL); + bonobo_ui_component_set_prop (ui_component, + "/commands/ToggleOffline", + "sensitive", "1", NULL); + e_pixmaps_update (ui_component, offline_pixmaps); + break; + + case E_SHELL_LINE_STATUS_GOING_OFFLINE: + bonobo_ui_component_set_prop (ui_component, + "/menu/File/ToggleOffline", + "label", _("Work Offline"), NULL); + bonobo_ui_component_set_prop (ui_component, + "/menu/File/ToggleOffline", + "verb", "WorkOffline", NULL); + bonobo_ui_component_set_prop (ui_component, + "/commands/ToggleOffline", + "sensitive", "0", NULL); + e_pixmaps_update (ui_component, offline_pixmaps); + break; + + default: + g_assert_not_reached (); + } +} + +static void +shell_line_status_changed_cb (EShell *shell, + EShellLineStatus new_status, + EShellWindow *shell_window) +{ + update_offline_menu_item (shell_window, new_status); +} + + +/* Public API. */ + +void +e_shell_window_commands_setup (EShellWindow *shell_window) +{ + BonoboUIComponent *uic; + EShell *shell; + + g_return_if_fail (shell_window != NULL); + g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); + + uic = e_shell_window_peek_bonobo_ui_component (shell_window); + shell = e_shell_window_peek_shell (shell_window); + + bonobo_ui_component_add_verb_list_with_data (uic, file_verbs, shell_window); + bonobo_ui_component_add_verb_list_with_data (uic, tools_verbs, shell_window); + bonobo_ui_component_add_verb_list_with_data (uic, help_verbs, shell_window); + + e_pixmaps_update (uic, pixmaps); + + /* Set up the work online / work offline menu item. */ + g_signal_connect_object (shell, "line_status_changed", + G_CALLBACK (shell_line_status_changed_cb), shell_window, 0); + update_offline_menu_item (shell_window, e_shell_get_line_status (shell)); +} diff --git a/shell/e-shell-window-commands.h b/shell/e-shell-window-commands.h new file mode 100644 index 0000000000..b27b611f74 --- /dev/null +++ b/shell/e-shell-window-commands.h @@ -0,0 +1,30 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-window-commands.h + * + * Copyright (C) 2003 Ettore Perazzoli + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ettore Perazzoli <ettore@ximian.com> + */ + +#ifndef _E_SHELL_WINDOW_COMMANDS_H_ +#define _E_SHELL_WINDOW_COMMANDS_H_ + +#include "e-shell-window.h" + +void e_shell_window_commands_setup (EShellWindow *window); + +#endif /* _E_SHELL_WINDOW_COMMANDS_H_ */ diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c new file mode 100644 index 0000000000..123a6175c7 --- /dev/null +++ b/shell/e-shell-window.c @@ -0,0 +1,481 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-window.c + * + * Copyright (C) 2003 Ettore Perazzoli + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ettore Perazzoli <ettore@ximian.com> + */ + +/* TODO + + - e_shell_component_maybe_crashed() replacement. + +*/ + +#include <config.h> + +#include "e-shell-window.h" + +#include "Evolution.h" + +#include "e-shell-window-commands.h" + +#include <gal/util/e-util.h> + +#include <gtk/gtkbutton.h> +#include <gtk/gtkhpaned.h> +#include <gtk/gtknotebook.h> +#include <gtk/gtkvbox.h> + +#include <bonobo/bonobo-exception.h> +#include <bonobo/bonobo-object.h> +#include <bonobo/bonobo-ui-util.h> +#include <bonobo/bonobo-widget.h> + +#include <string.h> + + +#define PARENT_TYPE gtk_window_get_type () +static GtkWindowClass *parent_class = NULL; + + +/* A view for each component. These are all created when EShellWindow is + instantiated, but with the widget pointers to NULL and the page number set + to -1. When the views are created the first time, the widget pointers as + well as the notebook page value get set. */ +struct _ComponentView { + char *component_id; + + GNOME_Evolution_Component component_iface; + + GtkWidget *sidebar_widget; + GtkWidget *view_widget; + + int notebook_page_num; +}; +typedef struct _ComponentView ComponentView; + + +struct _EShellWindowPrivate { + EShell *shell; + + /* All the ComponentViews. */ + GSList *component_views; + + /* Notebooks used to switch between components. */ + GtkWidget *sidebar_notebook; + GtkWidget *view_notebook; + + /* Bonobo foo. */ + BonoboUIComponent *ui_component; + + /* The current view (can be NULL initially). */ + ComponentView *current_view; +}; + + +/* ComponentView handling. */ + +static ComponentView * +component_view_new (const char *id) +{ + ComponentView *view = g_new0 (ComponentView, 1); + + view->component_id = g_strdup (id); + view->notebook_page_num = -1; + + return view; +} + +static void +component_view_free (ComponentView *view) +{ + g_free (view->component_id); + bonobo_object_release_unref (view->component_iface, NULL); + g_free (view); +} + +static void +component_view_deactivate (ComponentView *view) +{ + BonoboControlFrame *view_control_frame; + BonoboControlFrame *sidebar_control_frame; + + g_return_if_fail (view->sidebar_widget != NULL); + g_return_if_fail (view->view_widget != NULL); + + view_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->view_widget)); + bonobo_control_frame_control_deactivate (view_control_frame); + + sidebar_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->sidebar_widget)); + bonobo_control_frame_control_deactivate (sidebar_control_frame); +} + +static void +component_view_activate (ComponentView *view) +{ + BonoboControlFrame *view_control_frame; + BonoboControlFrame *sidebar_control_frame; + + g_return_if_fail (view->sidebar_widget != NULL); + g_return_if_fail (view->view_widget != NULL); + + view_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->view_widget)); + bonobo_control_frame_control_activate (view_control_frame); + + sidebar_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->sidebar_widget)); + bonobo_control_frame_control_activate (sidebar_control_frame); +} + + +/* Utility functions. */ + +static void +init_view (EShellWindow *window, + ComponentView *view) +{ + EShellWindowPrivate *priv = window->priv; + Bonobo_UIContainer container; + Bonobo_Control sidebar_control; + Bonobo_Control view_control; + CORBA_Environment ev; + int sidebar_notebook_page_num; + int view_notebook_page_num; + + g_assert (view->component_iface == CORBA_OBJECT_NIL); + g_assert (view->view_widget == NULL); + g_assert (view->sidebar_widget == NULL); + g_assert (view->notebook_page_num == -1); + + CORBA_exception_init (&ev); + + /* 1. Activate component. (FIXME: Shouldn't do this here.) */ + + view->component_iface = bonobo_activation_activate_from_id (view->component_id, 0, NULL, &ev); + if (BONOBO_EX (&ev) || view->component_iface == CORBA_OBJECT_NIL) { + char *ex_text = bonobo_exception_get_text (&ev); + g_warning ("Cannot activate component %s: %s", view->component_id, ex_text); + g_free (ex_text); + + view->component_iface = CORBA_OBJECT_NIL; + CORBA_exception_free (&ev); + return; + } + + /* 2. Set up view. */ + + GNOME_Evolution_Component_createControls (view->component_iface, &sidebar_control, &view_control, &ev); + if (BONOBO_EX (&ev)) { + g_warning ("Cannot create view for %s", view->component_id); + + /* The rest of the code assumes that the component is valid and can create + controls; if this fails something is really wrong in the component + (e.g. methods not implemented)... So handle it as if there was no + component at all. */ + bonobo_object_release_unref (view->component_iface, NULL); + view->component_iface = CORBA_OBJECT_NIL; + + CORBA_exception_free (&ev); + return; + } + + CORBA_exception_free (&ev); + + container = bonobo_ui_component_get_container (priv->ui_component); + + view->sidebar_widget = bonobo_widget_new_control_from_objref (sidebar_control, container); + gtk_widget_show (view->sidebar_widget); + bonobo_object_release_unref (sidebar_control, NULL); + + view->view_widget = bonobo_widget_new_control_from_objref (view_control, container); + gtk_widget_show (view->view_widget); + bonobo_object_release_unref (view_control, NULL); + + gtk_notebook_append_page (GTK_NOTEBOOK (priv->sidebar_notebook), view->sidebar_widget, NULL); + gtk_notebook_append_page (GTK_NOTEBOOK (priv->view_notebook), view->view_widget, NULL); + + sidebar_notebook_page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->sidebar_notebook), view->sidebar_widget); + view_notebook_page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->view_notebook), view->view_widget); + + /* Since we always add a view page and a sidebar page at the same time... */ + g_assert (sidebar_notebook_page_num == view_notebook_page_num); + + view->notebook_page_num = view_notebook_page_num; + + /* 3. Switch to the new page. */ + + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->view_notebook), view_notebook_page_num); + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), view_notebook_page_num); + + if (priv->current_view != NULL) + component_view_deactivate (priv->current_view); + priv->current_view = view; + component_view_activate (view); +} + + +/* Callbacks. */ + +static void +component_button_clicked_callback (GtkButton *button, + EShellWindow *window) +{ + ComponentView *component_view = g_object_get_data (G_OBJECT (button), "ComponentView"); + EShellWindowPrivate *priv = window->priv; + + g_assert (component_view != NULL); + + if (component_view->sidebar_widget == NULL) { + init_view (window, component_view); + } else { + if (priv->current_view != NULL) + component_view_deactivate (priv->current_view); + priv->current_view = component_view; + component_view_activate (component_view); + + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->view_notebook), component_view->notebook_page_num); + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), component_view->notebook_page_num); + } +} + + +/* Widget layout. */ + +static GtkWidget * +create_component_button (EShellWindow *window, + ComponentView *component_view) +{ + GtkWidget *button; + const char *id = component_view->component_id; + const char *p, *q; + char *label; + + /* FIXME: Need a "name" property on the component or somesuch. */ + + p = strrchr (id, '_'); + if (p == NULL || p == id) { + label = g_strdup (id); + } else { + for (q = p - 1; q != id; q--) { + if (*q == '_') + break; + } + + if (*q != '_') { + label = g_strdup (id); + } else { + label = g_strndup (q + 1, p - q - 1); + } + } + + button = gtk_button_new_with_label (label); + + g_object_set_data (G_OBJECT (button), "ComponentView", component_view); + g_signal_connect (button, "clicked", G_CALLBACK (component_button_clicked_callback), window); + + g_free (label); + + return button; +} + +static void +setup_widgets (EShellWindow *window) +{ + EShellWindowPrivate *priv = window->priv; + Bonobo_ServerInfoList *info_list; + CORBA_Environment ev; + GtkWidget *paned; + GtkWidget *sidebar_vbox; + GtkWidget *button_box; + int i; + + paned = gtk_hpaned_new (); + bonobo_window_set_contents (BONOBO_WINDOW (window), paned); + + sidebar_vbox = gtk_vbox_new (FALSE, 6); + gtk_paned_pack1 (GTK_PANED (paned), sidebar_vbox, FALSE, FALSE); + + priv->sidebar_notebook = gtk_notebook_new (); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->sidebar_notebook), FALSE); + gtk_box_pack_start (GTK_BOX (sidebar_vbox), priv->sidebar_notebook, TRUE, TRUE, 0); + + priv->view_notebook = gtk_notebook_new (); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->view_notebook), FALSE); + gtk_paned_pack2 (GTK_PANED (paned), priv->view_notebook, TRUE, FALSE); + + button_box = gtk_hbox_new (FALSE, 6); + gtk_box_pack_start (GTK_BOX (sidebar_vbox), button_box, FALSE, FALSE, 0); + + CORBA_exception_init (&ev); + + /* FIXME: Shouldn't be doing this here. */ + + info_list = bonobo_activation_query ("repo_ids.has ('IDL:GNOME/Evolution/Component:1.0')", NULL, &ev); + if (BONOBO_EX (&ev)) { + char *ex_text = bonobo_exception_get_text (&ev); + g_warning ("Cannot query for components: %s\n", ex_text); + g_free (ex_text); + CORBA_exception_free (&ev); + return; + } + + for (i = 0; i < info_list->_length; i++) { + ComponentView *component_view = component_view_new (info_list->_buffer[i].iid); + GtkWidget *component_button = create_component_button (window, component_view); + + priv->component_views = g_slist_prepend (priv->component_views, component_view); + + gtk_box_pack_start (GTK_BOX (button_box), component_button, FALSE, FALSE, 0); + } + + CORBA_free (info_list); + CORBA_exception_free (&ev); + + gtk_widget_show_all (paned); +} + + +/* GObject methods. */ + +static void +impl_dispose (GObject *object) +{ + EShellWindowPrivate *priv = E_SHELL_WINDOW (object)->priv; + + if (priv->shell != NULL) { + g_object_remove_weak_pointer (G_OBJECT (priv->shell), (void **) &priv->shell); + priv->shell = NULL; + } + + if (priv->ui_component != NULL) { + bonobo_object_unref (BONOBO_OBJECT (priv->ui_component)); + priv->ui_component = NULL; + } + + (* G_OBJECT_CLASS (parent_class)->dispose) (object); +} + +static void +impl_finalize (GObject *object) +{ + EShellWindowPrivate *priv = E_SHELL_WINDOW (object)->priv; + + g_slist_foreach (priv->component_views, (GFunc) component_view_free, NULL); + g_slist_free (priv->component_views); + + g_free (priv); + + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + + +/* Initialization. */ + +static void +class_init (EShellWindowClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->dispose = impl_dispose; + object_class->finalize = impl_finalize; + + parent_class = g_type_class_peek_parent (class); +} + +static void +init (EShellWindow *shell_window) +{ + EShellWindowPrivate *priv = g_new0 (EShellWindowPrivate, 1); + + shell_window->priv = priv; +} + + +/* Instantiation. */ + +GtkWidget * +e_shell_window_new (EShell *shell) +{ + EShellWindow *window = g_object_new (e_shell_window_get_type (), NULL); + EShellWindowPrivate *priv = window->priv; + BonoboUIContainer *ui_container; + + if (bonobo_window_construct (BONOBO_WINDOW (window), + bonobo_ui_container_new (), + "evolution", "Ximian Evolution") == NULL) { + g_object_unref (window); + return NULL; + } + + window->priv->shell = shell; + g_object_add_weak_pointer (G_OBJECT (shell), (void **) &window->priv->shell); + + /* FIXME TODO: Add system_exception signal handling and all the other + stuff from e_shell_view_construct(). */ + + ui_container = bonobo_window_get_ui_container (BONOBO_WINDOW (window)); + + priv->ui_component = bonobo_ui_component_new ("evolution"); + bonobo_ui_component_set_container (priv->ui_component, + bonobo_object_corba_objref (BONOBO_OBJECT (ui_container)), + NULL); + + bonobo_ui_util_set_ui (priv->ui_component, + PREFIX, + EVOLUTION_UIDIR "/evolution.xml", + "evolution-1.4", NULL); + + e_shell_window_commands_setup (window); + + setup_widgets (window); + + gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); + + return GTK_WIDGET (window); +} + + +EShell * +e_shell_window_peek_shell (EShellWindow *window) +{ + return window->priv->shell; +} + + +BonoboUIComponent * +e_shell_window_peek_bonobo_ui_component (EShellWindow *window) +{ + return window->priv->ui_component; +} + +void +e_shell_window_save_defaults (EShellWindow *window) +{ + /* FIXME */ + g_warning ("e_shell_window_save_defaults() unimplemented"); +} + +void +e_shell_window_show_settings (EShellWindow *window) +{ + g_return_if_fail (E_IS_SHELL_WINDOW (window)); + + e_shell_show_settings (window->priv->shell, NULL, window); +} + + +E_MAKE_TYPE (e_shell_window, "EShellWindow", EShellWindow, class_init, init, BONOBO_TYPE_WINDOW) diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h new file mode 100644 index 0000000000..f23ac67d31 --- /dev/null +++ b/shell/e-shell-window.h @@ -0,0 +1,63 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-window.h + * + * Copyright (C) 2003 Ettore Perazzoli + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ettore Perazzoli <ettore@ximian.com> + */ + +#ifndef _E_SHELL_WINDOW_H_ +#define _E_SHELL_WINDOW_H_ + +#include <bonobo/bonobo-window.h> + +#define E_TYPE_SHELL_WINDOW (e_shell_window_get_type ()) +#define E_SHELL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SHELL_WINDOW, EShellWindow)) +#define E_SHELL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_WINDOW, EShellWindowClass)) +#define E_IS_SHELL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SHELL_WINDOW)) +#define E_IS_SHELL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_WINDOW)) + + +typedef struct _EShellWindow EShellWindow; +typedef struct _EShellWindowPrivate EShellWindowPrivate; +typedef struct _EShellWindowClass EShellWindowClass; + +struct _EShellWindow { + BonoboWindow parent; + + EShellWindowPrivate *priv; +}; + +struct _EShellWindowClass { + BonoboWindowClass parent_class; +}; + + +#include "e-shell.h" + + +GType e_shell_window_get_type (void); + +GtkWidget *e_shell_window_new (EShell *shell); + +EShell *e_shell_window_peek_shell (EShellWindow *window); +BonoboUIComponent *e_shell_window_peek_bonobo_ui_component (EShellWindow *window); + +void e_shell_window_save_defaults (EShellWindow *window); +void e_shell_window_show_settings (EShellWindow *window); + +#endif /* _E_SHELL_WINDOW_H_ */ diff --git a/shell/e-shell.c b/shell/e-shell.c index 5dbf9f8666..9e221584fe 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -28,30 +28,16 @@ #include "e-util/e-dialog-utils.h" -#include "e-activity-handler.h" -#include "e-component-registry.h" -#include "e-corba-shortcuts.h" -#include "e-corba-storage-registry.h" -#include "e-folder-type-registry.h" -#include "e-local-storage.h" #include "e-setup.h" #include "e-shell-constants.h" -#include "e-shell-corba-icon-utils.h" -#include "e-shell-folder-selection-dialog.h" -#include "e-shell-offline-handler.h" #include "e-shell-settings-dialog.h" #include "e-shell-startup-wizard.h" -#include "e-shell-view.h" -#include "e-shortcuts.h" -#include "e-storage-set.h" -#include "e-splash.h" #include "e-uri-schema-registry.h" #include "e-shell-marshal.h" #include "evolution-shell-component-client.h" #include "evolution-shell-component-utils.h" -#include "evolution-storage-set-view-factory.h" #include "importer/intelligent.h" @@ -81,7 +67,7 @@ #include "Evolution.h" - + #define PARENT_TYPE bonobo_object_get_type () static BonoboObjectClass *parent_class = NULL; @@ -89,36 +75,12 @@ struct _EShellPrivate { /* IID for registering the object on OAF. */ char *iid; - char *local_directory; - - GList *views; - - EStorageSet *storage_set; - ELocalStorage *local_storage; - EStorage *summary_storage; + GList *windows; - EShortcuts *shortcuts; - EFolderTypeRegistry *folder_type_registry; EUriSchemaRegistry *uri_schema_registry; - EComponentRegistry *component_registry; - - EShellUserCreatableItemsHandler *user_creatable_items_handler; - - /* ::StorageRegistry interface handler. */ - ECorbaStorageRegistry *corba_storage_registry; /* <aggregate> */ - - /* ::Activity interface handler. */ - EActivityHandler *activity_handler; /* <aggregate> */ - - /* ::Shortcuts interface handler. */ - ECorbaShortcuts *corba_shortcuts; /* <aggregate> */ - - /* This object handles going off-line. If the pointer is not NULL, it - means we have a going-off-line process in progress. */ - EShellOfflineHandler *offline_handler; - /* Names for the types of the folders that have maybe crashed. */ + /* FIXME TODO */ GList *crash_type_names; /* char * */ /* Line status. */ @@ -142,42 +104,20 @@ struct _EShellPrivate { unsigned int preparing_to_quit : 1; }; - -/* Constants. */ -/* FIXME: We need a component repository instead. */ +/* Signals. */ -#define SHORTCUTS_FILE_NAME "shortcuts.xml" -#define LOCAL_STORAGE_DIRECTORY "local" - - enum { - NO_VIEWS_LEFT, + NO_WINDOWS_LEFT, LINE_STATUS_CHANGED, - NEW_VIEW_CREATED, + NEW_WINDOW_CREATED, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; - -/* Utility functions. */ -static void -pop_up_activation_error_dialog (ESplash *splash, - const char *id, - CORBA_Environment *ev) -{ - char *error_message; - - error_message = e_get_activation_failure_msg (ev); - e_notice (splash, GTK_MESSAGE_ERROR, - _("Cannot activate component %s :\n" - "The error from the activation system is:\n" - "%s"), - id, error_message); - g_free (error_message); -} +/* Utility functions. */ static gboolean get_config_start_offline (void) @@ -194,130 +134,17 @@ get_config_start_offline (void) return value; } - + /* Interactivity handling. */ static void set_interactive (EShell *shell, gboolean interactive) { - EShellPrivate *priv; - GList *id_list, *p; - Window new_view_xid; - - priv = shell->priv; - - if (!! priv->is_interactive == !! interactive) - return; - - priv->is_interactive = interactive; - - if (interactive) { - GtkWidget *new_view; - - g_return_if_fail (priv->views && priv->views->data); - new_view = priv->views->data; - - new_view_xid = GDK_WINDOW_XWINDOW (new_view->window); - } else - new_view_xid = None; - - id_list = e_component_registry_get_id_list (priv->component_registry); - for (p = id_list; p != NULL; p = p->next) { - EvolutionShellComponentClient *shell_component_client; - GNOME_Evolution_ShellComponent shell_component_objref; - const char *id; - CORBA_Environment ev; - - id = (const char *) p->data; - shell_component_client = e_component_registry_get_component_by_id (priv->component_registry, id); - shell_component_objref = evolution_shell_component_client_corba_objref (shell_component_client); - - CORBA_exception_init (&ev); - - GNOME_Evolution_ShellComponent_interactive (shell_component_objref, interactive, new_view_xid, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("Error changing interactive status of component %s to %s -- %s\n", - id, interactive ? "TRUE" : "FALSE", BONOBO_EX_REPOID (&ev)); - - CORBA_exception_free (&ev); - } - - e_free_string_list (id_list); -} - - -/* Callback for the folder selection dialog. */ - -static void -folder_selection_dialog_cancelled_cb (EShellFolderSelectionDialog *folder_selection_dialog, - void *data) -{ - GNOME_Evolution_FolderSelectionListener listener; - CORBA_Environment ev; - - listener = g_object_get_data (G_OBJECT (folder_selection_dialog), "corba_listener"); - - CORBA_exception_init (&ev); - - GNOME_Evolution_FolderSelectionListener_notifyCanceled (listener, &ev); - - CORBA_exception_free (&ev); - - gtk_widget_destroy (GTK_WIDGET (folder_selection_dialog)); + /* FIXME TODO */ } -static void -folder_selection_dialog_folder_selected_cb (EShellFolderSelectionDialog *folder_selection_dialog, - const char *path, - void *data) -{ - CORBA_Environment ev; - EShell *shell; - GNOME_Evolution_FolderSelectionListener listener; - EStorageSet *storage_set; - EFolder *folder; - GNOME_Evolution_Folder corba_folder; - shell = E_SHELL (data); - listener = g_object_get_data (G_OBJECT (folder_selection_dialog), "corba_listener"); - - CORBA_exception_init (&ev); - - storage_set = e_shell_get_storage_set (shell); - folder = e_storage_set_get_folder (storage_set, path); - - if (folder == NULL) { - corba_folder.type = ""; - corba_folder.description = ""; - corba_folder.displayName = ""; - corba_folder.physicalUri = ""; - corba_folder.evolutionUri = ""; - corba_folder.unreadCount = -1; - corba_folder.customIconName = ""; - } else { - corba_folder.type = (CORBA_char *)e_folder_get_type_string (folder); - corba_folder.description = (CORBA_char *)e_folder_get_description (folder); - if (corba_folder.description == NULL) - corba_folder.description = ""; - corba_folder.displayName = (CORBA_char *)e_folder_get_name (folder); - corba_folder.physicalUri = (CORBA_char *)e_folder_get_physical_uri (folder); - if (corba_folder.physicalUri == NULL) - corba_folder.physicalUri = ""; - corba_folder.evolutionUri = (CORBA_char *)g_strconcat (E_SHELL_URI_PREFIX, path, NULL); - corba_folder.unreadCount = e_folder_get_unread_count (folder); - corba_folder.customIconName = (CORBA_char *)e_folder_get_custom_icon_name (folder); - if (corba_folder.customIconName == NULL) - corba_folder.customIconName = ""; - } - - GNOME_Evolution_FolderSelectionListener_notifySelected (listener, &corba_folder, &ev); - g_free (corba_folder.evolutionUri); - - CORBA_exception_free (&ev); -} - - /* CORBA interface implementation. */ static gboolean @@ -337,75 +164,20 @@ raise_exception_if_not_ready (PortableServer_Servant servant, return FALSE; } -static GNOME_Evolution_ShellComponent -impl_Shell_getComponentByType (PortableServer_Servant servant, - const CORBA_char *type, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - EvolutionShellComponentClient *handler; - EFolderTypeRegistry *folder_type_registry; - GNOME_Evolution_ShellComponent corba_component; - EShell *shell; - - if (raise_exception_if_not_ready (servant, ev)) - return CORBA_OBJECT_NIL; - - bonobo_object = bonobo_object_from_servant (servant); - shell = E_SHELL (bonobo_object); - folder_type_registry = shell->priv->folder_type_registry; - - handler = e_folder_type_registry_get_handler_for_type (folder_type_registry, type); - - if (handler == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_NotFound, NULL); - return CORBA_OBJECT_NIL; - } - - corba_component = evolution_shell_component_client_corba_objref (handler); - Bonobo_Unknown_ref (corba_component, ev); - - return CORBA_Object_duplicate (corba_component, ev); -} - -static GNOME_Evolution_Icon * -impl_Shell_getIconByType (PortableServer_Servant servant, - const CORBA_char *type, - const CORBA_boolean mini, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - EFolderTypeRegistry *folder_type_registry; - GdkPixbuf *pixbuf; - GNOME_Evolution_Icon *icon; - EShell *shell; - - if (raise_exception_if_not_ready (servant, ev)) - return CORBA_OBJECT_NIL; - - bonobo_object = bonobo_object_from_servant (servant); - shell = E_SHELL (bonobo_object); - folder_type_registry = shell->priv->folder_type_registry; - - pixbuf = e_folder_type_registry_get_icon_for_type (folder_type_registry, type, mini); - - if (pixbuf == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_NotFound, NULL); - return CORBA_OBJECT_NIL; - } - - icon = e_new_corba_icon_from_pixbuf (pixbuf); - return icon; -} - static GNOME_Evolution_ShellView impl_Shell_createNewView (PortableServer_Servant servant, const CORBA_char *uri, CORBA_Environment *ev) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_GNOME_Evolution_Shell_InternalError, NULL); + + return CORBA_OBJECT_NIL; + +#if 0 /* FIXME */ BonoboObject *bonobo_object; EShell *shell; - EShellView *shell_view; + EShellWindow *shell_window; GNOME_Evolution_ShellView shell_view_interface; if (raise_exception_if_not_ready (servant, ev)) @@ -421,22 +193,23 @@ impl_Shell_createNewView (PortableServer_Servant servant, return CORBA_OBJECT_NIL; } - shell_view = e_shell_create_view (shell, uri, NULL); - if (shell_view == NULL) { + shell_window = e_shell_create_window (shell, uri, NULL); + if (shell_window == NULL) { CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_NotFound, NULL); return CORBA_OBJECT_NIL; } - shell_view_interface = e_shell_view_get_corba_interface (shell_view); - if (shell_view_interface == CORBA_OBJECT_NIL) { + shell_window_interface = e_shell_window_get_corba_interface (shell_window); + if (shell_window_interface == CORBA_OBJECT_NIL) { CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_InternalError, NULL); return CORBA_OBJECT_NIL; } - Bonobo_Unknown_ref (shell_view_interface, ev); - return CORBA_Object_duplicate ((CORBA_Object) shell_view_interface, ev); + Bonobo_Unknown_ref (shell_window_interface, ev); + return CORBA_Object_duplicate ((CORBA_Object) shell_window_interface, ev); +#endif } static void @@ -458,7 +231,7 @@ impl_Shell_handleURI (PortableServer_Servant servant, if (strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0 || strncmp (uri, E_SHELL_DEFAULTURI_PREFIX, E_SHELL_DEFAULTURI_PREFIX_LEN) == 0) { - e_shell_create_view (shell, uri, NULL); + e_shell_create_window (shell, NULL); return; } @@ -491,157 +264,6 @@ impl_Shell_handleURI (PortableServer_Servant servant, } static void -corba_listener_destroy_notify (void *data) -{ - CORBA_Environment ev; - GNOME_Evolution_FolderSelectionListener listener_interface; - - listener_interface = (GNOME_Evolution_FolderSelectionListener) data; - - CORBA_exception_init (&ev); - CORBA_Object_release (listener_interface, &ev); - CORBA_exception_free (&ev); -} - -static void -impl_Shell_selectUserFolder (PortableServer_Servant servant, - const CORBA_long_long parent_xid, - const GNOME_Evolution_FolderSelectionListener listener, - const CORBA_char *title, - const CORBA_char *default_folder, - const GNOME_Evolution_Shell_FolderTypeNameList *corba_allowed_type_names, - CORBA_Environment *ev) -{ - GtkWidget *folder_selection_dialog; - BonoboObject *bonobo_object; - GNOME_Evolution_FolderSelectionListener listener_duplicate; - EShell *shell; - const char **allowed_type_names; - int i; - - if (raise_exception_if_not_ready (servant, ev)) - return; - - bonobo_object = bonobo_object_from_servant (servant); - shell = E_SHELL (bonobo_object); - - allowed_type_names = alloca (sizeof (allowed_type_names[0]) * (corba_allowed_type_names->_length + 1)); - for (i = 0; i < corba_allowed_type_names->_length; i++) - allowed_type_names[i] = corba_allowed_type_names->_buffer[i]; - allowed_type_names[corba_allowed_type_names->_length] = NULL; - - /* CORBA doesn't allow you to pass a NULL pointer. */ - if (!*default_folder) - default_folder = NULL; - folder_selection_dialog = e_shell_folder_selection_dialog_new (shell, - title, - NULL, - default_folder, - allowed_type_names, - TRUE); - - - listener_duplicate = CORBA_Object_duplicate (listener, ev); - g_object_set_data_full (G_OBJECT (folder_selection_dialog), "corba_listener", - listener_duplicate, corba_listener_destroy_notify); - - g_signal_connect (folder_selection_dialog, "folder_selected", - G_CALLBACK (folder_selection_dialog_folder_selected_cb), shell); - g_signal_connect (folder_selection_dialog, "cancelled", - G_CALLBACK (folder_selection_dialog_cancelled_cb), shell); - - if (parent_xid) - e_dialog_set_transient_for_xid (GTK_WINDOW (folder_selection_dialog), parent_xid); - -#if NASTY_HACK_FOR_OUT_OF_PROC_COMPONENTS - if (parent_xid == 0) { - gtk_widget_show (folder_selection_dialog); - } else { - XClassHint class_hints; - XWMHints *parent_wm_hints; - - /* Set the WM class and the WindowGroup hint to be the same as - the foreign parent window's. This way smartass window - managers like Sawfish don't get confused. */ - - if (XGetClassHint (GDK_DISPLAY (), (Window) parent_xid, &class_hints)) { - gtk_window_set_wmclass (GTK_WINDOW (folder_selection_dialog), - class_hints.res_name, class_hints.res_class); - XFree (class_hints.res_name); - XFree (class_hints.res_class); - } - - gtk_widget_show (folder_selection_dialog); - - while (folder_selection_dialog->window == NULL) - gtk_main_iteration (); - - parent_wm_hints = XGetWMHints (GDK_DISPLAY (), (Window) parent_xid); - - if (parent_wm_hints != NULL && (parent_wm_hints->flags & WindowGroupHint)) { - XWMHints *wm_hints; - - wm_hints = XAllocWMHints (); - wm_hints->flags = WindowGroupHint; - wm_hints->window_group = parent_wm_hints->window_group; - XSetWMHints (GDK_DISPLAY (), GDK_WINDOW_XWINDOW (folder_selection_dialog->window), wm_hints); - XFree (wm_hints); - XFree (parent_wm_hints); - } - } -#else - gtk_widget_show (folder_selection_dialog); -#endif -} - -static GNOME_Evolution_Storage -impl_Shell_getLocalStorage (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - GNOME_Evolution_Storage local_storage_interface; - EShell *shell; - EShellPrivate *priv; - - bonobo_object = bonobo_object_from_servant (servant); - shell = E_SHELL (bonobo_object); - priv = shell->priv; - - if (priv->local_storage == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Shell_NotReady, NULL); - return CORBA_OBJECT_NIL; - } - - local_storage_interface = e_local_storage_get_corba_interface (priv->local_storage); - - bonobo_object_dup_ref (local_storage_interface, ev); - - return local_storage_interface; -} - -static Bonobo_Control -impl_Shell_createStorageSetView (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - BonoboControl *control; - CORBA_Object dup_objref; - EShell *shell; - - if (raise_exception_if_not_ready (servant, ev)) - return CORBA_OBJECT_NIL; - - bonobo_object = bonobo_object_from_servant (servant); - shell = E_SHELL (bonobo_object); - - control = evolution_storage_set_view_factory_new_view (shell); - dup_objref = CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (control)), ev); - - return dup_objref; -} - -static void impl_Shell_setLineStatus (PortableServer_Servant servant, CORBA_boolean online, CORBA_Environment *ev) @@ -661,130 +283,11 @@ impl_Shell_setLineStatus (PortableServer_Servant servant, e_shell_go_offline (shell, NULL); } - -/* Set up the ::Activity interface. */ - -static void -setup_activity_interface (EShell *shell) -{ - EActivityHandler *activity_handler; - EShellPrivate *priv; - - priv = shell->priv; - - activity_handler = e_activity_handler_new (); - - bonobo_object_add_interface (BONOBO_OBJECT (shell), BONOBO_OBJECT (activity_handler)); - priv->activity_handler = activity_handler; -} - - -/* Set up the ::Shortcuts interface. */ - -static void -setup_shortcuts_interface (EShell *shell) -{ - ECorbaShortcuts *corba_shortcuts; - EShellPrivate *priv; - - priv = shell->priv; - - g_assert (priv->shortcuts != NULL); - - corba_shortcuts = e_corba_shortcuts_new (priv->shortcuts); - - bonobo_object_add_interface (BONOBO_OBJECT (shell), BONOBO_OBJECT (corba_shortcuts)); - priv->corba_shortcuts = corba_shortcuts; -} - - -/* Initialization of the storages. */ - -static gboolean -setup_corba_storages (EShell *shell) -{ - EShellPrivate *priv; - ECorbaStorageRegistry *corba_storage_registry; - priv = shell->priv; - - g_assert (priv->storage_set != NULL); - corba_storage_registry = e_corba_storage_registry_new (priv->storage_set); - - if (corba_storage_registry == NULL) - return FALSE; - - bonobo_object_add_interface (BONOBO_OBJECT (shell), - BONOBO_OBJECT (corba_storage_registry)); - - priv->corba_storage_registry = corba_storage_registry; - - return TRUE; -} - -static gboolean -setup_local_storage (EShell *shell) -{ - EStorage *local_storage; - EShellPrivate *priv; - gchar *local_storage_path; - EFolder *summary_folder; - - priv = shell->priv; - - g_assert (priv->folder_type_registry != NULL); - g_assert (priv->local_storage == NULL); - - local_storage_path = g_build_filename (priv->local_directory, LOCAL_STORAGE_DIRECTORY, NULL); - local_storage = e_local_storage_open (priv->folder_type_registry, local_storage_path); - if (local_storage == NULL) { - g_warning (_("Cannot set up local storage -- %s"), local_storage_path); - g_free (local_storage_path); - return FALSE; - } - g_free (local_storage_path); - - e_storage_set_add_storage (priv->storage_set, local_storage); - priv->local_storage = E_LOCAL_STORAGE (local_storage); - - summary_folder = e_folder_new (_("Summary"), "summary", ""); - e_folder_set_physical_uri (summary_folder, "/"); - e_folder_set_is_stock (summary_folder, TRUE); - priv->summary_storage = e_storage_new (E_SUMMARY_STORAGE_NAME, - summary_folder); - e_storage_set_add_storage (priv->storage_set, priv->summary_storage); - - return TRUE; -} - - /* Initialization of the components. */ -static char * -get_icon_path_for_component_info (const Bonobo_ServerInfo *info) -{ - Bonobo_ActivationProperty *property; - const char *shell_component_icon_value; - - property = bonobo_server_info_prop_find ((Bonobo_ServerInfo *) info, - "evolution:shell_component_icon"); - - if (property == NULL || property->v._d != Bonobo_ACTIVATION_P_STRING) - return gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, "gnome-question.png", - TRUE, NULL); - - shell_component_icon_value = property->v._u.value_string; - - if (g_path_is_absolute (shell_component_icon_value)) - return g_strdup (shell_component_icon_value); - - else - return g_build_filename (EVOLUTION_IMAGES, shell_component_icon_value, NULL); -} - static void -setup_components (EShell *shell, - ESplash *splash) +setup_components (EShell *shell) { EShellPrivate *priv; char *const selection_order[] = { "0-evolution:shell_component_launch_order", NULL }; @@ -795,8 +298,8 @@ setup_components (EShell *shell, CORBA_exception_init (&ev); priv = shell->priv; - priv->component_registry = e_component_registry_new (shell); +#if 0 /* FIXME */ info_list = bonobo_activation_query ("repo_ids.has ('IDL:GNOME/Evolution/ShellComponent:1.0')", selection_order, &ev); if (ev._major != CORBA_NO_EXCEPTION) @@ -835,14 +338,8 @@ setup_components (EShell *shell, CORBA_exception_init (&ev); - if (! e_component_registry_register_component (priv->component_registry, info->iid, &ev)) { + if (! e_component_registry_register_component (priv->component_registry, info->iid, &ev)) pop_up_activation_error_dialog (splash, info->iid, &ev); - } else { - e_shell_user_creatable_items_handler_add_component - (priv->user_creatable_items_handler, - info->iid, - e_component_registry_get_component_by_id (priv->component_registry, info->iid)); - } CORBA_exception_free (&ev); @@ -852,114 +349,30 @@ setup_components (EShell *shell, while (gtk_events_pending ()) gtk_main_iteration (); } - CORBA_free (info_list); +#endif CORBA_exception_free (&ev); } -/* FIXME what if anything fails here? */ -static void -set_owner_on_components (EShell *shell, - ESplash *splash) -{ - GNOME_Evolution_Shell corba_shell; - EShellPrivate *priv; - const char *local_directory; - GList *id_list; - GList *p; - - priv = shell->priv; - local_directory = e_shell_get_local_directory (shell); - - corba_shell = BONOBO_OBJREF (shell); - id_list = e_component_registry_get_id_list (priv->component_registry); - for (p = id_list; p != NULL; p = p->next) { - EvolutionShellComponentClient *component_client; - EvolutionShellComponentResult result; - const char *id; - - id = (const char *) p->data; - component_client = e_component_registry_get_component_by_id (priv->component_registry, id); - - result = evolution_shell_component_client_set_owner (component_client, corba_shell, local_directory); - if (result != EVOLUTION_SHELL_COMPONENT_OK) { - g_warning ("Error setting owner on component %s -- %s", - id, evolution_shell_component_result_to_string (result)); - - if (result == EVOLUTION_SHELL_COMPONENT_OLDOWNERHASDIED) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - component_client = e_component_registry_restart_component (priv->component_registry, - id, &ev); - - if (component_client == NULL) { - pop_up_activation_error_dialog (splash, id, &ev); - } else { - result = evolution_shell_component_client_set_owner (component_client, corba_shell, - local_directory); - if (result != EVOLUTION_SHELL_COMPONENT_OK) { - g_warning ("Error re-setting owner on component %s -- %s", - id, evolution_shell_component_result_to_string (result)); - /* (At this point, we give up.) */ - } - } - - CORBA_exception_free (&ev); - } - } - } - - e_free_string_list (id_list); -} - - -/* EStorageSet callbacks. */ - -static void -storage_set_moved_folder_callback (EStorageSet *storage_set, - const char *source_path, - const char *destination_path, - void *data) -{ - EShell *shell; - char *source_uri; - char *destination_uri; - - shell = E_SHELL (data); - - source_uri = g_strconcat (E_SHELL_URI_PREFIX, source_path, NULL); - destination_uri = g_strconcat (E_SHELL_URI_PREFIX, destination_path, NULL); - - e_shortcuts_update_shortcuts_for_changed_uri (e_shell_get_shortcuts (shell), - source_uri, - destination_uri); - - g_free (source_uri); - g_free (destination_uri); -} - - -/* EShellView handling and bookkeeping. */ +/* EShellWindow handling and bookkeeping. */ static int -view_delete_event_cb (GtkWidget *widget, +window_delete_event_cb (GtkWidget *widget, GdkEventAny *ev, void *data) { EShell *shell; - g_assert (E_IS_SHELL_VIEW (widget)); + g_assert (E_IS_SHELL_WINDOW (widget)); shell = E_SHELL (data); - return ! e_shell_request_close_view (shell, E_SHELL_VIEW (widget)); + return ! e_shell_request_close_window (shell, E_SHELL_WINDOW (widget)); } static gboolean -notify_no_views_left_idle_cb (void *data) +notify_no_windows_left_idle_cb (void *data) { EShell *shell; @@ -967,7 +380,7 @@ notify_no_views_left_idle_cb (void *data) set_interactive (shell, FALSE); - g_signal_emit (shell, signals [NO_VIEWS_LEFT], 0); + g_signal_emit (shell, signals [NO_WINDOWS_LEFT], 0); bonobo_object_unref (BONOBO_OBJECT (shell)); @@ -975,67 +388,52 @@ notify_no_views_left_idle_cb (void *data) } static void -view_weak_notify (void *data, - GObject *where_the_object_was) +window_weak_notify (void *data, + GObject *where_the_object_was) { EShell *shell; - int num_views; + int num_windows; shell = E_SHELL (data); - num_views = g_list_length (shell->priv->views); + num_windows = g_list_length (shell->priv->windows); - /* If this is our last view, save settings now because in the callback - for no_views_left shell->priv->views will be NULL and settings won't + /* If this is our last window, save settings now because in the callback + for no_windows_left shell->priv->windows will be NULL and settings won't be saved because of that. */ - if (num_views == 1) + if (num_windows == 1) e_shell_save_settings (shell); - shell->priv->views = g_list_remove (shell->priv->views, where_the_object_was); + shell->priv->windows = g_list_remove (shell->priv->windows, where_the_object_was); - if (shell->priv->views == NULL) { + if (shell->priv->windows == NULL) { bonobo_object_ref (BONOBO_OBJECT (shell)); - g_idle_add (notify_no_views_left_idle_cb, shell); + g_idle_add (notify_no_windows_left_idle_cb, shell); } } -static EShellView * -create_view (EShell *shell, - const char *uri, - EShellView *template_view) +static EShellWindow * +create_window (EShell *shell, + EShellWindow *template_window) { EShellPrivate *priv; - EShellView *view; - ETaskBar *task_bar; + EShellWindow *window; priv = shell->priv; - view = e_shell_view_new (shell, uri); + window = E_SHELL_WINDOW (e_shell_window_new (shell)); - g_signal_connect (view, "delete_event", - G_CALLBACK (view_delete_event_cb), shell); + g_signal_connect (window, "delete_event", G_CALLBACK (window_delete_event_cb), shell); + g_object_weak_ref (G_OBJECT (window), window_weak_notify, shell); - g_object_weak_ref (G_OBJECT (view), view_weak_notify, shell); + shell->priv->windows = g_list_prepend (shell->priv->windows, window); - if (uri != NULL) - e_shell_view_display_uri (E_SHELL_VIEW (view), uri, TRUE); + g_signal_emit (shell, signals[NEW_WINDOW_CREATED], 0, window); - shell->priv->views = g_list_prepend (shell->priv->views, view); - - task_bar = e_shell_view_get_task_bar (view); - e_activity_handler_attach_task_bar (priv->activity_handler, task_bar); - - if (template_view != NULL) { - e_shell_view_show_folder_bar (view, e_shell_view_folder_bar_shown (template_view)); - e_shell_view_show_shortcut_bar (view, e_shell_view_shortcut_bar_shown (template_view)); - } - - g_signal_emit (shell, signals[NEW_VIEW_CREATED], 0, view); - - return view; + return window; } - + /* GObject methods. */ static void @@ -1050,71 +448,27 @@ impl_dispose (GObject *object) priv->is_initialized = FALSE; - if (priv->storage_set != NULL) { - g_object_unref (priv->storage_set); - priv->storage_set = NULL; - } - - if (priv->local_storage != NULL) { - g_object_unref (priv->local_storage); - priv->local_storage = NULL; - } - - if (priv->summary_storage != NULL) { - g_object_unref (priv->summary_storage); - priv->summary_storage = NULL; - } - - if (priv->shortcuts != NULL) { - g_object_unref (priv->shortcuts); - priv->shortcuts = NULL; - } - - if (priv->folder_type_registry != NULL) { - g_object_unref (priv->folder_type_registry); - priv->folder_type_registry = NULL; - } - if (priv->uri_schema_registry != NULL) { g_object_unref (priv->uri_schema_registry); priv->uri_schema_registry = NULL; } - if (priv->component_registry != NULL) { - g_object_unref (priv->component_registry); - priv->component_registry = NULL; - } - - if (priv->user_creatable_items_handler != NULL) { - g_object_unref (priv->user_creatable_items_handler); - priv->user_creatable_items_handler = NULL; - } - - for (p = priv->views; p != NULL; p = p->next) { - EShellView *view; - - view = E_SHELL_VIEW (p->data); + for (p = priv->windows; p != NULL; p = p->next) { + EShellWindow *window; - g_signal_handlers_disconnect_by_func (view, G_CALLBACK (view_delete_event_cb), shell); + window = E_SHELL_WINDOW (p->data); - g_object_weak_unref (G_OBJECT (view), view_weak_notify, shell); + g_signal_handlers_disconnect_by_func (window, G_CALLBACK (window_delete_event_cb), shell); + g_object_weak_unref (G_OBJECT (window), window_weak_notify, shell); - gtk_object_destroy (GTK_OBJECT (view)); + gtk_object_destroy (GTK_OBJECT (window)); } - g_list_free (priv->views); - priv->views = NULL; + g_list_free (priv->windows); + priv->windows = NULL; /* No unreffing for these as they are aggregate. */ /* bonobo_object_unref (BONOBO_OBJECT (priv->corba_storage_registry)); */ - /* bonobo_object_unref (BONOBO_OBJECT (priv->activity_handler)); */ - /* bonobo_object_unref (BONOBO_OBJECT (priv->corba_shortcuts)); */ - - /* FIXME. Maybe we should do something special here. */ - if (priv->offline_handler != NULL) { - g_object_unref (priv->offline_handler); - priv->offline_handler = NULL; - } if (priv->settings_dialog != NULL) { gtk_widget_destroy (priv->settings_dialog); @@ -1137,8 +491,6 @@ impl_finalize (GObject *object) bonobo_activation_active_server_unregister (priv->iid, bonobo_object_corba_objref (BONOBO_OBJECT (shell))); - g_free (priv->local_directory); - e_free_string_list (priv->crash_type_names); g_free (priv); @@ -1146,7 +498,7 @@ impl_finalize (GObject *object) (* G_OBJECT_CLASS (parent_class)->finalize) (object); } - + /* Initialization. */ static void @@ -1161,11 +513,11 @@ e_shell_class_init (EShellClass *klass) object_class->dispose = impl_dispose; object_class->finalize = impl_finalize; - signals[NO_VIEWS_LEFT] = - g_signal_new ("no_views_left", + signals[NO_WINDOWS_LEFT] = + g_signal_new ("no_windows_left", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EShellClass, no_views_left), + G_STRUCT_OFFSET (EShellClass, no_windows_left), NULL, NULL, e_shell_marshal_NONE__NONE, G_TYPE_NONE, 0); @@ -1180,24 +532,19 @@ e_shell_class_init (EShellClass *klass) G_TYPE_NONE, 1, G_TYPE_INT); - signals[NEW_VIEW_CREATED] = - g_signal_new ("new_view_created", + signals[NEW_WINDOW_CREATED] = + g_signal_new ("new_window_created", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EShellClass, new_view_created), + G_STRUCT_OFFSET (EShellClass, new_window_created), NULL, NULL, e_shell_marshal_NONE__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); epv = & klass->epv; - epv->getComponentByType = impl_Shell_getComponentByType; - epv->getIconByType = impl_Shell_getIconByType; epv->createNewView = impl_Shell_createNewView; epv->handleURI = impl_Shell_handleURI; - epv->selectUserFolder = impl_Shell_selectUserFolder; - epv->getLocalStorage = impl_Shell_getLocalStorage; - epv->createStorageSetView = impl_Shell_createStorageSetView; epv->setLineStatus = impl_Shell_setLineStatus; } @@ -1208,22 +555,10 @@ e_shell_init (EShell *shell) priv = g_new (EShellPrivate, 1); - priv->views = NULL; + priv->windows = NULL; priv->iid = NULL; - priv->local_directory = NULL; - priv->storage_set = NULL; - priv->local_storage = NULL; - priv->summary_storage = NULL; - priv->shortcuts = NULL; - priv->component_registry = NULL; - priv->user_creatable_items_handler = NULL; - priv->folder_type_registry = NULL; priv->uri_schema_registry = NULL; - priv->corba_storage_registry = NULL; - priv->activity_handler = NULL; - priv->corba_shortcuts = NULL; - priv->offline_handler = NULL; priv->crash_type_names = NULL; priv->line_status = E_SHELL_LINE_STATUS_OFFLINE; priv->settings_dialog = NULL; @@ -1234,70 +569,37 @@ e_shell_init (EShell *shell) shell->priv = priv; } - + /** * e_shell_construct: * @shell: An EShell object to construct * @iid: OAFIID for registering the shell into the name server - * @local_directory: Local directory for storing local information and folders - * @show_splash: Whether to display a splash screen. * @startup_line_mode: How to set up the line mode (online or offline) initally. * - * Construct @shell so that it uses the specified @local_directory and - * @corba_object. + * Construct @shell so that it uses the specified @corba_object. * * Return value: The result of the operation. **/ EShellConstructResult e_shell_construct (EShell *shell, const char *iid, - const char *local_directory, - gboolean show_splash, EShellStartupLineMode startup_line_mode) { GtkWidget *splash = NULL; EShellPrivate *priv; CORBA_Object corba_object; - gchar *shortcut_path; gboolean start_online; g_return_val_if_fail (shell != NULL, E_SHELL_CONSTRUCT_RESULT_INVALIDARG); g_return_val_if_fail (E_IS_SHELL (shell), E_SHELL_CONSTRUCT_RESULT_INVALIDARG); - g_return_val_if_fail (local_directory != NULL, E_SHELL_CONSTRUCT_RESULT_INVALIDARG); - g_return_val_if_fail (g_path_is_absolute (local_directory), E_SHELL_CONSTRUCT_RESULT_INVALIDARG); g_return_val_if_fail (startup_line_mode == E_SHELL_STARTUP_LINE_MODE_CONFIG || startup_line_mode == E_SHELL_STARTUP_LINE_MODE_ONLINE || startup_line_mode == E_SHELL_STARTUP_LINE_MODE_OFFLINE, E_SHELL_CONSTRUCT_RESULT_INVALIDARG); priv = shell->priv; + priv->iid = g_strdup (iid); - priv->iid = g_strdup (iid); - priv->local_directory = g_strdup (local_directory); - priv->folder_type_registry = e_folder_type_registry_new (); - priv->uri_schema_registry = e_uri_schema_registry_new (); - priv->storage_set = e_storage_set_new (priv->folder_type_registry); - - g_signal_connect_object (priv->storage_set, "moved_folder", - G_CALLBACK (storage_set_moved_folder_callback), - shell, 0); - - e_folder_type_registry_register_type (priv->folder_type_registry, - "noselect", "empty.gif", - "noselect", "", FALSE, - 0, NULL, 0, NULL); - e_folder_type_registry_register_type (priv->folder_type_registry, - "working", "working-16.png", - "working", "", FALSE, - 0, NULL, 0, NULL); - - /* CORBA storages must be set up before the components, because otherwise components - cannot register their own storages. */ - if (! setup_corba_storages (shell)) - return FALSE; - - e_setup_check_config (local_directory); - /* Now we can register into OAF. Notice that we shouldn't be registering into OAF until we are sure we can complete. */ @@ -1306,46 +608,10 @@ e_shell_construct (EShell *shell, if (bonobo_activation_active_server_register (iid, corba_object) != Bonobo_ACTIVATION_REG_SUCCESS) return E_SHELL_CONSTRUCT_RESULT_CANNOTREGISTER; - if (show_splash - && (splash = e_splash_new ())) { - g_signal_connect (splash, "delete_event", - G_CALLBACK (gtk_widget_hide_on_delete), NULL); - gtk_widget_show (splash); - } - while (gtk_events_pending ()) gtk_main_iteration (); - priv->user_creatable_items_handler = e_shell_user_creatable_items_handler_new (); - - setup_components (shell, (ESplash *)splash); - - /* Set up the shortcuts. */ - - shortcut_path = g_build_filename (local_directory, "shortcuts.xml", NULL); - priv->shortcuts = e_shortcuts_new_from_file (shell, shortcut_path); - g_assert (priv->shortcuts != NULL); - - if (e_shortcuts_get_num_groups (priv->shortcuts) == 0) - e_shortcuts_add_default_group (priv->shortcuts); - - g_free (shortcut_path); - - /* The local storage depends on the component registry. */ - setup_local_storage (shell); - - /* Set up the ::Activity interface. This must be done before we notify - the components, as they might want to use it. */ - setup_activity_interface (shell); - - /* Set up the shortcuts interface. This has to be done after the - shortcuts are actually initialized. */ - - setup_shortcuts_interface (shell); - - /* Now that we have a local storage and all the interfaces set up, we - can tell the components we are here. */ - set_owner_on_components (shell, (ESplash *)splash); + setup_components (shell); if (splash) gtk_widget_destroy (splash); @@ -1382,8 +648,6 @@ e_shell_construct (EShell *shell, /** * e_shell_new: - * @local_directory: Local directory for storing local information and folders. - * @show_splash: Whether to display a splash screen. * @start_online: Whether to start in on-line mode or not. * @construct_result_return: A pointer to an EShellConstructResult variable into * which the result of the operation will be stored. @@ -1393,25 +657,16 @@ e_shell_construct (EShell *shell, * Return value: **/ EShell * -e_shell_new (const char *local_directory, - gboolean show_splash, - EShellStartupLineMode startup_line_mode, +e_shell_new (EShellStartupLineMode startup_line_mode, EShellConstructResult *construct_result_return) { EShell *new; EShellPrivate *priv; EShellConstructResult construct_result; - g_return_val_if_fail (local_directory != NULL, NULL); - g_return_val_if_fail (*local_directory != '\0', NULL); - new = g_object_new (e_shell_get_type (), NULL); - construct_result = e_shell_construct (new, - E_SHELL_OAFIID, - local_directory, - show_splash, - startup_line_mode); + construct_result = e_shell_construct (new, E_SHELL_OAFIID, startup_line_mode); if (construct_result != E_SHELL_CONSTRUCT_RESULT_OK) { *construct_result_return = construct_result; @@ -1421,71 +676,64 @@ e_shell_new (const char *local_directory, priv = new->priv; - if (priv->shortcuts == NULL || priv->storage_set == NULL) { - /* FIXME? */ - *construct_result_return = E_SHELL_CONSTRUCT_RESULT_GENERICERROR; - bonobo_object_unref (BONOBO_OBJECT (new)); - return NULL; - } - *construct_result_return = E_SHELL_CONSTRUCT_RESULT_OK; return new; } - + /** - * e_shell_create_view: - * @shell: The shell for which to create a new view. - * @uri: URI for the new view. - * @template_view: Window from which to copy the view settings (can be %NULL). + * e_shell_create_window: + * @shell: The shell for which to create a new window. + * @template_window: Window from which to copy the window settings (can be %NULL). * - * Create a new view for @uri. + * Create a new window for @uri. * - * Return value: The new view. + * Return value: The new window. **/ -EShellView * -e_shell_create_view (EShell *shell, - const char *uri, - EShellView *template_view) +EShellWindow * +e_shell_create_window (EShell *shell, + EShellWindow *template_window) { - EShellView *view; + EShellWindow *window; EShellPrivate *priv; + /* FIXME need to actually copy settings from template_window. */ + g_return_val_if_fail (shell != NULL, NULL); g_return_val_if_fail (E_IS_SHELL (shell), NULL); priv = shell->priv; - view = create_view (shell, uri, template_view); + window = create_window (shell, template_window); - gtk_widget_show (GTK_WIDGET (view)); + gtk_widget_show (GTK_WIDGET (window)); set_interactive (shell, TRUE); - return view; + return window; } gboolean -e_shell_request_close_view (EShell *shell, - EShellView *shell_view) +e_shell_request_close_window (EShell *shell, + EShellWindow *shell_window) { g_return_val_if_fail (E_IS_SHELL (shell), FALSE); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE); + g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), FALSE); e_shell_save_settings (shell); - if (g_list_length (shell->priv->views) != 1) { - /* Not the last view. */ + if (g_list_length (shell->priv->windows) != 1) { + /* Not the last window. */ return TRUE; } if (shell->priv->preparing_to_quit) return FALSE; - /* If it's the last view, save settings and ask for confirmation before + /* If it's the last window, save settings and ask for confirmation before quitting. */ - e_shell_view_save_defaults (shell_view); + e_shell_window_save_defaults (shell_window); if (e_shell_prepare_for_quit (shell)) return TRUE; @@ -1493,74 +741,6 @@ e_shell_request_close_view (EShell *shell, return FALSE; } - -/** - * e_shell_get_local_directory: - * @shell: An EShell object. - * - * Get the local directory associated with @shell. - * - * Return value: A pointer to the path of the local directory. - **/ -const char * -e_shell_get_local_directory (EShell *shell) -{ - g_return_val_if_fail (shell != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - return shell->priv->local_directory; -} - -/** - * e_shell_get_shortcuts: - * @shell: An EShell object. - * - * Get the shortcuts associated to @shell. - * - * Return value: A pointer to the EShortcuts associated to @shell. - **/ -EShortcuts * -e_shell_get_shortcuts (EShell *shell) -{ - g_return_val_if_fail (shell != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - return shell->priv->shortcuts; -} - -/** - * e_shell_get_storage_set: - * @shell: An EShell object. - * - * Get the storage set associated to @shell. - * - * Return value: A pointer to the EStorageSet associated to @shell. - **/ -EStorageSet * -e_shell_get_storage_set (EShell *shell) -{ - g_return_val_if_fail (shell != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - return shell->priv->storage_set; -} - -/** - * e_shell_get_folder_type_registry: - * @shell: An EShell object. - * - * Get the folder type registry associated to @shell. - * - * Return value: A pointer to the EFolderTypeRegistry associated to @shell. - **/ -EFolderTypeRegistry * -e_shell_get_folder_type_registry (EShell *shell) -{ - g_return_val_if_fail (shell != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - return shell->priv->folder_type_registry; -} /** * e_shell_get_uri_schema_registry: @@ -1579,111 +759,6 @@ e_shell_get_uri_schema_registry (EShell *shell) return shell->priv->uri_schema_registry; } -/** - * e_shell_get_local_storage: - * @shell: An EShell object. - * - * Get the local storage associated to @shell. - * - * Return value: A pointer to the ELocalStorage associated to @shell. - **/ -ELocalStorage * -e_shell_get_local_storage (EShell *shell) -{ - g_return_val_if_fail (shell != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - return shell->priv->local_storage; -} - - -static gboolean -save_settings_for_component (EShell *shell, - const char *id, - EvolutionShellComponentClient *client) -{ - Bonobo_Unknown unknown_interface; - GNOME_Evolution_Session session_interface; - CORBA_Environment ev; - char *prefix; - gboolean retval; - - unknown_interface = evolution_shell_component_client_corba_objref (client); - g_assert (unknown_interface != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - session_interface = Bonobo_Unknown_queryInterface (unknown_interface, - "IDL:GNOME/Evolution/Session:1.0", &ev); - if (ev._major != CORBA_NO_EXCEPTION || CORBA_Object_is_nil (session_interface, &ev)) { - CORBA_exception_free (&ev); - return TRUE; - } - - prefix = g_strconcat ("/apps/evolution/shell/components/", id, NULL); - GNOME_Evolution_Session_saveConfiguration (session_interface, prefix, &ev); - - if (ev._major == CORBA_NO_EXCEPTION) - retval = TRUE; - else - retval = FALSE; - - g_free (prefix); - - CORBA_exception_free (&ev); - - bonobo_object_release_unref (session_interface, NULL); - - return retval; -} - -static gboolean -save_settings_for_components (EShell *shell) -{ - EShellPrivate *priv; - GList *component_ids; - GList *p; - gboolean retval; - - priv = shell->priv; - - g_assert (priv->component_registry); - component_ids = e_component_registry_get_id_list (priv->component_registry); - - retval = TRUE; - for (p = component_ids; p != NULL; p = p->next) { - EvolutionShellComponentClient *client; - const char *id; - - id = p->data; - client = e_component_registry_get_component_by_id (priv->component_registry, id); - - if (! save_settings_for_component (shell, id, client)) - retval = FALSE; - } - - e_free_string_list (component_ids); - - return retval; -} - -static gboolean -save_misc_settings (EShell *shell) -{ - GConfClient *client; - EShellPrivate *priv; - gboolean is_offline; - - priv = shell->priv; - - is_offline = ( e_shell_get_line_status (shell) == E_SHELL_LINE_STATUS_OFFLINE ); - - client = gconf_client_get_default (); - gconf_client_set_bool (client, "/apps/evolution/shell/start_offline", is_offline, NULL); - g_object_unref (client); - - return TRUE; -} /** * e_shell_save_settings: @@ -1692,32 +767,35 @@ save_misc_settings (EShell *shell) * Save the settings for this shell. * * Return value: %TRUE if it worked, %FALSE otherwise. Even if %FALSE is - * returned, it is possible that at least part of the settings for the views + * returned, it is possible that at least part of the settings for the windows * have been saved. **/ gboolean e_shell_save_settings (EShell *shell) { - gboolean components_saved; - gboolean misc_saved; + GConfClient *client; + EShellPrivate *priv; + gboolean is_offline; - g_return_val_if_fail (shell != NULL, FALSE); - g_return_val_if_fail (E_IS_SHELL (shell), FALSE); + priv = shell->priv; - components_saved = save_settings_for_components (shell); - misc_saved = save_misc_settings (shell); + is_offline = ( e_shell_get_line_status (shell) == E_SHELL_LINE_STATUS_OFFLINE ); - return components_saved && misc_saved; + client = gconf_client_get_default (); + gconf_client_set_bool (client, "/apps/evolution/shell/start_offline", is_offline, NULL); + g_object_unref (client); + + return TRUE; } /** - * e_shell_destroy_all_views: + * e_shell_close_all_windows: * @shell: * - * Destroy all the views in @shell. + * Destroy all the windows in @shell. **/ void -e_shell_destroy_all_views (EShell *shell) +e_shell_close_all_windows (EShell *shell) { EShellPrivate *priv; GList *p, *pnext; @@ -1725,131 +803,19 @@ e_shell_destroy_all_views (EShell *shell) g_return_if_fail (shell != NULL); g_return_if_fail (E_IS_SHELL (shell)); - if (shell->priv->views) + if (shell->priv->windows) e_shell_save_settings (shell); priv = shell->priv; - - for (p = priv->views; p != NULL; p = pnext) { - EShellView *shell_view; - + for (p = priv->windows; p != NULL; p = pnext) { pnext = p->next; - shell_view = E_SHELL_VIEW (p->data); - gtk_widget_destroy (GTK_WIDGET (shell_view)); + /* Note that this will also remove the window from the list... Hence the + need for the pnext variable. */ + gtk_widget_destroy (GTK_WIDGET (p->data)); } } - -/** - * e_shell_component_maybe_crashed: - * @shell: A pointer to an EShell object - * @uri: URI that caused the crash - * @type_name: The type of the folder that caused the crash - * @shell_view: Pointer to the EShellView over which we want the modal dialog - * to appear. - * - * Report that a maybe crash happened when trying to display a folder of type - * @type_name. The shell will pop up a crash dialog whose parent will be the - * @shell_view. - **/ -void -e_shell_component_maybe_crashed (EShell *shell, - const char *uri, - const char *type_name, - EShellView *shell_view) -{ - EShellPrivate *priv; - EvolutionShellComponentClient *component; - GList *p; - - g_return_if_fail (shell != NULL); - g_return_if_fail (E_IS_SHELL (shell)); - g_return_if_fail (type_name != NULL); - g_return_if_fail (shell_view != NULL); - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - - priv = shell->priv; - - if (strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0) { - const char *path; - - path = uri + E_SHELL_URI_PREFIX_LEN; - if (e_storage_set_get_folder (priv->storage_set, path) == NULL) - return; - } - - component = e_folder_type_registry_get_handler_for_type (priv->folder_type_registry, type_name); - if (component != NULL - && bonobo_unknown_ping (evolution_shell_component_client_corba_objref (component), NULL)) - return; - - /* See if that type has caused a crash already. */ - - for (p = priv->crash_type_names; p != NULL; p = p->next) { - const char *crash_type_name; - - crash_type_name = (const char *) p->data; - if (strcmp (type_name, crash_type_name) == 0) { - /* This type caused a crash already. */ - return; - } - } - - /* New crash. */ - - priv->crash_type_names = g_list_prepend (priv->crash_type_names, g_strdup (type_name)); - - e_notice (shell_view, GTK_MESSAGE_ERROR, - _("The Evolution component that handles folders of type \"%s\"\n" - "has unexpectedly quit. You will need to quit Evolution and restart\n" - "in order to access that data again."), - type_name); - - if (shell_view) - bonobo_ui_engine_deregister_dead_components (bonobo_window_get_ui_engine (BONOBO_WINDOW (shell_view))); - - /* FIXME: we should probably re-start the component here */ -} - - -/* Offline/online handling. */ - -static void -offline_procedure_started_cb (EShellOfflineHandler *offline_handler, - void *data) -{ - EShell *shell; - EShellPrivate *priv; - - shell = E_SHELL (data); - priv = shell->priv; - - priv->line_status = E_SHELL_LINE_STATUS_GOING_OFFLINE; - g_signal_emit (shell, signals[LINE_STATUS_CHANGED], 0, priv->line_status); -} - -static void -offline_procedure_finished_cb (EShellOfflineHandler *offline_handler, - gboolean now_offline, - void *data) -{ - EShell *shell; - EShellPrivate *priv; - - shell = E_SHELL (data); - priv = shell->priv; - - if (now_offline) - priv->line_status = E_SHELL_LINE_STATUS_OFFLINE; - else - priv->line_status = E_SHELL_LINE_STATUS_ONLINE; - - g_object_unref (priv->offline_handler); - priv->offline_handler = NULL; - - g_signal_emit (shell, signals[LINE_STATUS_CHANGED], 0, priv->line_status); -} /** * e_shell_get_line_status: @@ -1871,56 +837,58 @@ e_shell_get_line_status (EShell *shell) /** * e_shell_go_offline: * @shell: - * @action_view: + * @action_window: * * Make the shell go into off-line mode. **/ void e_shell_go_offline (EShell *shell, - EShellView *action_view) + EShellWindow *action_window) { EShellPrivate *priv; g_return_if_fail (shell != NULL); g_return_if_fail (E_IS_SHELL (shell)); - g_return_if_fail (action_view != NULL); - g_return_if_fail (action_view == NULL || E_IS_SHELL_VIEW (action_view)); + g_return_if_fail (action_window != NULL); + g_return_if_fail (action_window == NULL || E_IS_SHELL_WINDOW (action_window)); priv = shell->priv; if (priv->line_status != E_SHELL_LINE_STATUS_ONLINE) return; - g_assert (priv->offline_handler == NULL); - +#if 0 priv->offline_handler = e_shell_offline_handler_new (shell); + /* FIXME TODO */ g_signal_connect (priv->offline_handler, "offline_procedure_started", G_CALLBACK (offline_procedure_started_cb), shell); g_signal_connect (priv->offline_handler, "offline_procedure_finished", G_CALLBACK (offline_procedure_finished_cb), shell); - e_shell_offline_handler_put_components_offline (priv->offline_handler, action_view); + e_shell_offline_handler_put_components_offline (priv->offline_handler, GTK_WINDOW (action_window)); +#endif } /** * e_shell_go_online: * @shell: - * @action_view: + * @action_window: * * Make the shell go into on-line mode. **/ void e_shell_go_online (EShell *shell, - EShellView *action_view) + EShellWindow *action_window) { +#if 0 /* FIXME TODO */ EShellPrivate *priv; GList *component_ids; GList *p; g_return_if_fail (shell != NULL); g_return_if_fail (E_IS_SHELL (shell)); - g_return_if_fail (action_view == NULL || E_IS_SHELL_VIEW (action_view)); + g_return_if_fail (action_window == NULL || E_IS_SHELL_WINDOW (action_window)); priv = shell->priv; @@ -1955,46 +923,14 @@ e_shell_go_online (EShell *shell, priv->line_status = E_SHELL_LINE_STATUS_ONLINE; g_signal_emit (shell, signals[LINE_STATUS_CHANGED], 0, priv->line_status); +#endif } - -void -e_shell_send_receive (EShell *shell) -{ - EShellPrivate *priv; - GList *id_list; - GList *p; - - g_return_if_fail (E_IS_SHELL (shell)); - - priv = shell->priv; - - id_list = e_component_registry_get_id_list (priv->component_registry); - - for (p = id_list; p != NULL; p = p->next) { - EvolutionShellComponentClient *component_client; - CORBA_Environment ev; - const char *id; - - id = (const char *) p->data; - component_client = e_component_registry_get_component_by_id (priv->component_registry, id); - - CORBA_exception_init (&ev); - - GNOME_Evolution_ShellComponent_sendReceive - (evolution_shell_component_client_corba_objref (component_client), TRUE, &ev); - - if (BONOBO_EX (&ev)) - g_warning ("Error invoking Send/Receive on %s -- %s", id, BONOBO_EX_REPOID (&ev)); - - CORBA_exception_free (&ev); - } - - e_free_string_list (id_list); -} void -e_shell_show_settings (EShell *shell, const char *type, EShellView *shell_view) +e_shell_show_settings (EShell *shell, + const char *type, + EShellWindow *shell_window) { EShellPrivate *priv; @@ -2019,26 +955,15 @@ e_shell_show_settings (EShell *shell, const char *type, EShellView *shell_view) gtk_widget_show (priv->settings_dialog); } - -EComponentRegistry * -e_shell_get_component_registry (EShell *shell) -{ - g_return_val_if_fail (shell != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - return shell->priv->component_registry; -} EShellUserCreatableItemsHandler * e_shell_get_user_creatable_items_handler (EShell *shell) { - g_return_val_if_fail (shell != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - return shell->priv->user_creatable_items_handler; + g_assert_not_reached (); /* FIXME */ + return NULL; } - + /* FIXME: These are ugly hacks, they really should not be needed. */ void @@ -2051,14 +976,10 @@ e_shell_unregister_all (EShell *shell) /* FIXME: This really really sucks. */ priv = shell->priv; - priv->is_initialized = FALSE; - - g_object_unref (priv->component_registry); - priv->component_registry = NULL; } - + const char * e_shell_construct_result_to_string (EShellConstructResult result) { @@ -2078,21 +999,15 @@ e_shell_construct_result_to_string (EShellConstructResult result) } } - -static void -prepare_for_quit_callback (EvolutionShellComponentClient *client, - EvolutionShellComponentResult result, - void *data) -{ - GNOME_Evolution_ShellComponentListener_Result *result_return; - - result_return = (GNOME_Evolution_ShellComponentListener_Result *) data; - *result_return = result; -} gboolean e_shell_prepare_for_quit (EShell *shell) { + /* FIXME TODO */ + + return TRUE; + +#if 0 EShellPrivate *priv; GList *component_ids; GList *p; @@ -2103,9 +1018,9 @@ e_shell_prepare_for_quit (EShell *shell) priv = shell->priv; priv->preparing_to_quit = TRUE; - /* Make all the views insensitive so we have some modal-like + /* Make all the windows insensitive so we have some modal-like behavior. */ - for (p = priv->views; p != NULL; p = p->next) + for (p = priv->windows; p != NULL; p = p->next) gtk_widget_set_sensitive (GTK_WIDGET (p->data), FALSE); component_ids = e_component_registry_get_id_list (priv->component_registry); @@ -2134,16 +1049,17 @@ e_shell_prepare_for_quit (EShell *shell) retval = TRUE; end: - /* Restore all the views to be sensitive. */ - for (p = priv->views; p != NULL; p = p->next) + /* Restore all the windows to be sensitive. */ + for (p = priv->windows; p != NULL; p = p->next) gtk_widget_set_sensitive (GTK_WIDGET (p->data), TRUE); priv->preparing_to_quit = FALSE; e_free_string_list (component_ids); return retval; +#endif } - + /* URI parsing. */ static gboolean @@ -2252,8 +1168,5 @@ e_shell_parse_uri (EShell *shell, return FALSE; } - -BONOBO_TYPE_FUNC_FULL (EShell, - GNOME_Evolution_Shell, - PARENT_TYPE, - e_shell) + +BONOBO_TYPE_FUNC_FULL (EShell, GNOME_Evolution_Shell, PARENT_TYPE, e_shell) diff --git a/shell/e-shell.h b/shell/e-shell.h index 4f1b1aaf7b..afd1f33e1b 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -37,20 +37,18 @@ typedef struct _EShellClass EShellClass; #include "Evolution.h" -#include "e-component-registry.h" -#include "e-shell-view.h" -#include "e-uri-schema-registry.h" #include "e-shell-user-creatable-items-handler.h" -#include "e-local-storage.h" +#include "e-uri-schema-registry.h" +#include "e-shell-window.h" + - #define E_TYPE_SHELL (e_shell_get_type ()) #define E_SHELL(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SHELL, EShell)) #define E_SHELL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL, EShellClass)) #define E_IS_SHELL(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHELL)) #define E_IS_SHELL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL)) - + enum _EShellLineStatus { E_SHELL_LINE_STATUS_ONLINE, E_SHELL_LINE_STATUS_GOING_OFFLINE, @@ -76,13 +74,12 @@ struct _EShellClass { POA_GNOME_Evolution_Shell__epv epv; - void (* no_views_left) (EShell *shell); + void (* no_windows_left) (EShell *shell); void (* line_status_changed) (EShell *shell, EShellLineStatus status); - void (* new_view_created) (EShell *shell, EShellView *view); - + void (* new_window_created) (EShell *shell, EShellWindow *window); }; - + /* ID for registering the shell in the OAF name service. */ #define E_SHELL_OAFIID "OAFIID:GNOME_Evolution_Shell" @@ -95,69 +92,46 @@ enum _EShellConstructResult { }; typedef enum _EShellConstructResult EShellConstructResult; - -#include "e-shortcuts.h" - GtkType e_shell_get_type (void); EShellConstructResult e_shell_construct (EShell *shell, const char *iid, - const char *local_directory, - gboolean show_splash, EShellStartupLineMode startup_line_mode); -EShell *e_shell_new (const char *local_directory, - gboolean show_splash, - EShellStartupLineMode startup_line_mode, +EShell *e_shell_new (EShellStartupLineMode startup_line_mode, EShellConstructResult *construct_result_return); -EShellView *e_shell_create_view (EShell *shell, - const char *uri, - EShellView *template_view); -EShellView *e_shell_create_view_from_uri_and_settings (EShell *shell, - const char *uri, - int view_num); -gboolean e_shell_request_close_view (EShell *shell, - EShellView *view); - - -const char *e_shell_get_local_directory (EShell *shell); -EShortcuts *e_shell_get_shortcuts (EShell *shell); -EStorageSet *e_shell_get_storage_set (EShell *shell); -ELocalStorage *e_shell_get_local_storage (EShell *shell); -EFolderTypeRegistry *e_shell_get_folder_type_registry (EShell *shell); +EShellWindow *e_shell_create_window (EShell *shell, + EShellWindow *template_window); +gboolean e_shell_request_close_window (EShell *shell, + EShellWindow *window); + + EUriSchemaRegistry *e_shell_get_uri_schema_registry (EShell *shell); gboolean e_shell_save_settings (EShell *shell); -void e_shell_destroy_all_views (EShell *shell); +void e_shell_close_all_windows (EShell *shell); void e_shell_unregister_all (EShell *shell); -void e_shell_component_maybe_crashed (EShell *shell, - const char *uri, - const char *type_name, - EShellView *shell_view); - -EShellLineStatus e_shell_get_line_status (EShell *shell); -void e_shell_go_offline (EShell *shell, - EShellView *action_view); -void e_shell_go_online (EShell *shell, - EShellView *action_view); +EShellLineStatus e_shell_get_line_status (EShell *shell); +void e_shell_go_offline (EShell *shell, + EShellWindow *action_window); +void e_shell_go_online (EShell *shell, + EShellWindow *action_window); -void e_shell_send_receive (EShell *shell); void e_shell_show_settings (EShell *shell, const char *type, - EShellView *shell_view); + EShellWindow *shell_window); -EComponentRegistry *e_shell_get_component_registry (EShell *shell); EShellUserCreatableItemsHandler *e_shell_get_user_creatable_items_handler (EShell *shell); gboolean e_shell_prepare_for_quit (EShell *shell); - + const char *e_shell_construct_result_to_string (EShellConstructResult result); - + gboolean e_shell_parse_uri (EShell *shell, const char *uri, char **path_return, diff --git a/shell/e-storage-browser.c b/shell/e-storage-browser.c new file mode 100644 index 0000000000..a5452d80c1 --- /dev/null +++ b/shell/e-storage-browser.c @@ -0,0 +1,331 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-storage-browser.c + * + * Copyright (C) 2003 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ettore Perazzoli <ettore@ximian.com> + */ + +/* TODO: + + - Currently it assumes that the starting path always exists, and you + can't remove it. It might be a limitation, but it makes the logic + very simple and robust. + + - Doesn't save expansion state for nodes. + + - Context menu handling? + +*/ + +#include <config.h> + +#include "e-storage-browser.h" + +#include "e-shell-marshal.h" +#include "e-storage-set-view.h" + +#include <gal/util/e-util.h> + +#include <gtk/gtknotebook.h> +#include <string.h> + + +#define PARENT_TYPE G_TYPE_OBJECT +static GObjectClass *parent_class = NULL; + + +struct _EStorageBrowserPrivate { + char *starting_path; + char *current_path; + + GtkWidget *view_notebook; + GtkWidget *storage_set_view; + + GHashTable *path_to_view; /* (char *, GtkWidget *) */ + + EStorageBrowserCreateViewCallback create_view_callback; + void *create_view_callback_data; +}; + + +enum { + WIDGETS_GONE, + PAGE_SWITCHED, + NUM_SIGNALS +}; + +static unsigned int signals[NUM_SIGNALS] = { 0 }; + + +/* Callbacks. */ + +static void +storage_set_view_folder_selected_callback (EStorageSetView *storage_set_view, + const char *path, + EStorageBrowser *browser) +{ + if (! e_storage_browser_show_path (browser, path)) { + /* Make the selection go back to where it was. */ + e_storage_browser_show_path (browser, browser->priv->current_path); + } +} + +static void +storage_set_removed_folder_callback (EStorageSet *storage_set, + const char *path, + EStorageBrowser *browser) +{ + if (g_hash_table_lookup (browser->priv->path_to_view, path) != NULL) + e_storage_browser_remove_view_for_path (browser, path); +} + +static void +view_notebook_weak_notify (EStorageBrowser *browser) +{ + browser->priv->view_notebook = NULL; + + if (browser->priv->storage_set_view == NULL) + g_signal_emit (browser, signals[WIDGETS_GONE], 0); +} + +static void +storage_set_view_weak_notify (EStorageBrowser *browser) +{ + browser->priv->storage_set_view = NULL; + + if (browser->priv->view_notebook == NULL) + g_signal_emit (browser, signals[WIDGETS_GONE], 0); +} + + +/* GObject methods. */ + +static void +impl_dispose (GObject *object) +{ + EStorageBrowserPrivate *priv = E_STORAGE_BROWSER (object)->priv; + + if (priv->view_notebook != NULL) { + g_object_weak_unref (G_OBJECT (priv->view_notebook), + (GWeakNotify) view_notebook_weak_notify, + object); + priv->view_notebook = NULL; + } + + if (priv->storage_set_view != NULL) { + g_object_weak_unref (G_OBJECT (priv->storage_set_view), + (GWeakNotify) storage_set_view_weak_notify, + object); + priv->storage_set_view = NULL; + } + + (* G_OBJECT_CLASS (parent_class)->dispose) (object); +} + +static void +impl_finalize (GObject *object) +{ + EStorageBrowserPrivate *priv = E_STORAGE_BROWSER (object)->priv; + + g_free (priv->starting_path); + g_free (priv->current_path); + + g_hash_table_destroy (priv->path_to_view); + + g_free (priv); + + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + + +/* Initialization. */ + +static void +class_init (EStorageBrowserClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->dispose = impl_dispose; + object_class->finalize = impl_finalize; + + parent_class = g_type_class_peek_parent (class); + + signals[WIDGETS_GONE] + = g_signal_new ("widgets_gone", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EStorageBrowserClass, widgets_gone), + NULL, NULL, + e_shell_marshal_NONE__NONE, + G_TYPE_NONE, 0); + + signals[PAGE_SWITCHED] + = g_signal_new ("page_switched", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EStorageBrowserClass, page_switched), + NULL, NULL, + e_shell_marshal_NONE__POINTER_POINTER, + G_TYPE_NONE, 2, + G_TYPE_POINTER, G_TYPE_POINTER); +} + +static void +init (EStorageBrowser *browser) +{ + EStorageBrowserPrivate *priv; + + priv = g_new0 (EStorageBrowserPrivate, 1); + + priv->path_to_view = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_object_unref); + + priv->view_notebook = gtk_notebook_new (); + g_object_weak_ref (G_OBJECT (priv->view_notebook), (GWeakNotify) view_notebook_weak_notify, browser); + + gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->view_notebook), FALSE); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->view_notebook), FALSE); + + browser->priv = priv; +} + + +EStorageBrowser * +e_storage_browser_new (EStorageSet *storage_set, + const char *starting_path, + EStorageBrowserCreateViewCallback create_view_callback, + void *callback_data) +{ + EStorageBrowser *new; + + g_return_val_if_fail (create_view_callback != NULL, NULL); + + new = g_object_new (e_storage_browser_get_type (), NULL); + + new->priv->create_view_callback = create_view_callback; + new->priv->create_view_callback_data = callback_data; + new->priv->starting_path = g_strdup (starting_path); + new->priv->storage_set_view = e_storage_set_create_new_view (storage_set, NULL); + + g_object_weak_ref (G_OBJECT (new->priv->storage_set_view), (GWeakNotify) storage_set_view_weak_notify, new); + + g_signal_connect_object (new->priv->storage_set_view, + "folder_selected", G_CALLBACK (storage_set_view_folder_selected_callback), + G_OBJECT (new), 0); + g_signal_connect_object (e_storage_set_view_get_storage_set (E_STORAGE_SET_VIEW (new->priv->storage_set_view)), + "removed_folder", G_CALLBACK (storage_set_removed_folder_callback), + G_OBJECT (new), 0); + + if (! e_storage_browser_show_path (new, starting_path)) { + g_object_unref (new); + return NULL; + } + + return new; +} + + +GtkWidget * +e_storage_browser_peek_tree_widget (EStorageBrowser *browser) +{ + return browser->priv->storage_set_view; +} + +GtkWidget * +e_storage_browser_peek_view_widget (EStorageBrowser *browser) +{ + return browser->priv->view_notebook; +} + +EStorageSet * +e_storage_browser_peek_storage_set (EStorageBrowser *browser) +{ + return e_storage_set_view_get_storage_set (E_STORAGE_SET_VIEW (browser->priv->storage_set_view)); +} + +gboolean +e_storage_browser_show_path (EStorageBrowser *browser, + const char *path) +{ + EStorageBrowserPrivate *priv = browser->priv; + GtkWidget *current_view; + GtkWidget *existing_view; + GtkWidget *new_view; + GtkNotebook *notebook; + + notebook = GTK_NOTEBOOK (priv->view_notebook); + + current_view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->view_notebook), + gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->view_notebook))); + + existing_view = g_hash_table_lookup (priv->path_to_view, path); + if (existing_view != NULL) { + gtk_notebook_set_current_page (notebook, gtk_notebook_page_num (notebook, existing_view)); + g_print ("page switched\n"); + g_signal_emit (browser, signals[PAGE_SWITCHED], 0, current_view, existing_view); + return TRUE; + } + + new_view = (* priv->create_view_callback) (browser, path, priv->create_view_callback_data); + if (new_view == NULL) + return FALSE; + + gtk_widget_show (new_view); + gtk_notebook_append_page (notebook, new_view, NULL); + gtk_notebook_set_current_page (notebook, gtk_notebook_page_num (notebook, new_view)); + + g_print ("page switched\n"); + g_signal_emit (browser, signals[PAGE_SWITCHED], 0, current_view, new_view); + + g_object_ref(new_view); + g_hash_table_insert (priv->path_to_view, g_strdup (path), new_view); + + g_free (priv->current_path); + priv->current_path = g_strdup (path); + + e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), path); + + return TRUE; +} + +void +e_storage_browser_remove_view_for_path (EStorageBrowser *browser, + const char *path) +{ + GtkWidget *view; + + if (strcmp (path, browser->priv->starting_path) == 0) { + g_warning (G_GNUC_FUNCTION ": cannot remove starting view"); + return; + } + + view = g_hash_table_lookup (browser->priv->path_to_view, path); + if (view == NULL) { + g_warning (G_GNUC_FUNCTION ": no view for %s", path); + return; + } + + g_hash_table_remove (browser->priv->path_to_view, path); + gtk_widget_destroy (view); + + e_storage_browser_show_path (browser, browser->priv->starting_path); +} + + +E_MAKE_TYPE (e_storage_browser, "EStorageBrowser", EStorageBrowser, class_init, init, PARENT_TYPE) diff --git a/shell/e-storage-browser.h b/shell/e-storage-browser.h new file mode 100644 index 0000000000..fa9b3a121d --- /dev/null +++ b/shell/e-storage-browser.h @@ -0,0 +1,83 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-storage-browser.h + * + * Copyright (C) 2003 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ettore Perazzoli <ettore@ximian.com> + */ + +#ifndef _E_STORAGE_BROWSER_H_ +#define _E_STORAGE_BROWSER_H_ + +#include "e-storage-set.h" + +#include <glib-object.h> +#include <gtk/gtkwidget.h> + + +#define E_TYPE_STORAGE_BROWSER (e_storage_browser_get_type ()) +#define E_STORAGE_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_STORAGE_BROWSER, EStorageBrowser)) +#define E_STORAGE_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_STORAGE_BROWSER, EStorageBrowserClass)) +#define E_IS_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_STORAGE_BROWSER)) +#define E_IS_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_STORAGE_BROWSER)) + + +typedef struct _EStorageBrowser EStorageBrowser; +typedef struct _EStorageBrowserPrivate EStorageBrowserPrivate; +typedef struct _EStorageBrowserClass EStorageBrowserClass; + +/* FIXME: Use a GClosure instead of void *? */ +typedef GtkWidget * (* EStorageBrowserCreateViewCallback) (EStorageBrowser *browser, + const char *path, + void *data); + + +struct _EStorageBrowser { + GObject parent; + + EStorageBrowserPrivate *priv; +}; + +struct _EStorageBrowserClass { + GObjectClass parent_class; + + void (* widgets_gone) (EStorageBrowser *browser); + + void (* page_switched) (EStorageBrowser *browser, + GtkWidget *old_page, + GtkWidget *new_page); +}; + + +GType e_storage_browser_get_type (void); + +EStorageBrowser *e_storage_browser_new (EStorageSet *storage_set, + const char *starting_path, + EStorageBrowserCreateViewCallback create_view_callback, + void *create_view_callback_data); + +GtkWidget *e_storage_browser_peek_tree_widget (EStorageBrowser *browser); +GtkWidget *e_storage_browser_peek_view_widget (EStorageBrowser *browser); +EStorageSet *e_storage_browser_peek_storage_set (EStorageBrowser *browser); + +gboolean e_storage_browser_show_path (EStorageBrowser *browser, + const char *path); +void e_storage_browser_remove_view_for_path (EStorageBrowser *browser, + const char *path); + + +#endif /* _E_STORAGE_BROWSER_H_ */ diff --git a/shell/e-storage.c b/shell/e-storage.c index f4a8e5ff26..0a56e3569f 100644 --- a/shell/e-storage.c +++ b/shell/e-storage.c @@ -61,6 +61,7 @@ enum { NEW_FOLDER, UPDATED_FOLDER, REMOVED_FOLDER, + ASYNC_OPEN_FOLDER, LAST_SIGNAL }; @@ -212,15 +213,6 @@ impl_async_xfer_folder (EStorage *storage, (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data); } -static void -impl_async_open_folder (EStorage *storage, - const char *path, - EStorageDiscoveryCallback callback, - void *data) -{ - (*callback) (storage, E_STORAGE_NOTIMPLEMENTED, path, data); -} - static gboolean impl_supports_shared_folders (EStorage *storage) { @@ -265,7 +257,6 @@ class_init (EStorageClass *class) class->async_create_folder = impl_async_create_folder; class->async_remove_folder = impl_async_remove_folder; class->async_xfer_folder = impl_async_xfer_folder; - class->async_open_folder = impl_async_open_folder; class->supports_shared_folders = impl_supports_shared_folders; class->async_discover_shared_folder = impl_async_discover_shared_folder; @@ -298,6 +289,17 @@ class_init (EStorageClass *class) e_shell_marshal_NONE__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + signals[ASYNC_OPEN_FOLDER] = + g_signal_new ("async_open_folder", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EStorageClass, async_open_folder), + NULL, NULL, + e_shell_marshal_NONE__STRING_POINTER_POINTER, + G_TYPE_NONE, 3, + G_TYPE_STRING, + G_TYPE_POINTER, + G_TYPE_POINTER); } static void @@ -328,7 +330,7 @@ e_storage_construct (EStorage *storage, priv = storage->priv; - priv->name = g_strdup (name); + priv->name = g_strdup (name); e_storage_new_folder (storage, "/", root_folder); @@ -500,7 +502,8 @@ e_storage_async_open_folder (EStorage *storage, return; } - (* ES_CLASS (storage)->async_open_folder) (storage, path, callback, data); + g_signal_emit (storage, signals[ASYNC_OPEN_FOLDER], 0, + path, callback, data); } diff --git a/shell/e-storage.h b/shell/e-storage.h index bd0cc5da22..1015290b6a 100644 --- a/shell/e-storage.h +++ b/shell/e-storage.h @@ -82,7 +82,12 @@ struct _EStorageClass { void (* new_folder) (EStorage *storage, const char *path); void (* updated_folder) (EStorage *storage, const char *path); void (* removed_folder) (EStorage *storage, const char *path); - void (* close_folder) (EStorage *storage, const char *path); + + /* FIXME: This should NOT be a signal. */ + void (* async_open_folder) (EStorage *storage, + const char *path, + EStorageDiscoveryCallback callback, + void *data); /* Virtual methods. */ @@ -111,11 +116,6 @@ struct _EStorageClass { EStorageResultCallback callback, void *data); - void (* async_open_folder) (EStorage *storage, - const char *path, - EStorageDiscoveryCallback callback, - void *data); - gboolean (* supports_shared_folders) (EStorage *storage); void (* async_discover_shared_folder) (EStorage *storage, const char *owner, @@ -194,7 +194,8 @@ void e_storage_async_remove_shared_folder (EStorage *s char *e_storage_get_path_for_physical_uri (EStorage *storage, const char *physical_uri); -/* Protected. C++ anyone? */ +/* FIXME: Need to rename these. */ + gboolean e_storage_new_folder (EStorage *storage, const char *path, EFolder *folder); diff --git a/shell/evolution-shell-client.c b/shell/evolution-shell-client.c index f21e9860b6..46908f79b2 100644 --- a/shell/evolution-shell-client.c +++ b/shell/evolution-shell-client.c @@ -24,441 +24,47 @@ #include <config.h> #endif -#include <gdk/gdkx.h> -#include <gtk/gtkmain.h> - -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-object.h> -#include <bonobo/bonobo-widget.h> - #include <gal/util/e-util.h> #include "evolution-shell-client.h" #include "e-shell-corba-icon-utils.h" - -struct _EvolutionShellClientPrivate { - GNOME_Evolution_Shell corba_objref; - - GNOME_Evolution_Activity activity_interface; - GNOME_Evolution_Shortcuts shortcuts_interface; - GNOME_Evolution_StorageRegistry storage_registry_interface; - GHashTable *icons; -}; - #define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class = NULL; - - -/* Easy-to-use wrapper for Evolution::user_select_folder. */ - -static PortableServer_ServantBase__epv FolderSelectionListener_base_epv; -static POA_GNOME_Evolution_FolderSelectionListener__epv FolderSelectionListener_epv; -static POA_GNOME_Evolution_FolderSelectionListener__vepv FolderSelectionListener_vepv; -static gboolean FolderSelectionListener_vtables_initialized = FALSE; - -struct _FolderSelectionListenerServant { - POA_GNOME_Evolution_FolderSelectionListener servant; - GNOME_Evolution_Folder **folder_return; -}; -typedef struct _FolderSelectionListenerServant FolderSelectionListenerServant; - - -/* Helper functions. */ - -static CORBA_Object -query_shell_interface (EvolutionShellClient *shell_client, - const char *interface_name) -{ - CORBA_Environment ev; - CORBA_Object interface_object; - EvolutionShellClientPrivate *priv; - - priv = shell_client->priv; - - CORBA_exception_init (&ev); - - interface_object = Bonobo_Unknown_queryInterface (evolution_shell_client_corba_objref (shell_client), - interface_name, &ev); - - if (BONOBO_EX (&ev)) { - g_warning ("EvolutionShellClient: Error querying interface %s on %p -- %s", - interface_name, shell_client, BONOBO_EX_REPOID (&ev)); - interface_object = CORBA_OBJECT_NIL; - } else if (CORBA_Object_is_nil (interface_object, &ev)) { - g_warning ("No interface %s for ShellClient %p", interface_name, shell_client); - } - - CORBA_exception_free (&ev); - - return interface_object; -} - - -static void -impl_FolderSelectionListener_selected (PortableServer_Servant servant, - const GNOME_Evolution_Folder *folder, - CORBA_Environment *ev) -{ - FolderSelectionListenerServant *listener_servant; - - listener_servant = (FolderSelectionListenerServant *) servant; - - if (listener_servant->folder_return != NULL) { - GNOME_Evolution_Folder *ret_folder = GNOME_Evolution_Folder__alloc (); - - ret_folder->type = CORBA_string_dup (folder->type); - ret_folder->description = CORBA_string_dup (folder->description); - ret_folder->displayName = CORBA_string_dup (folder->displayName); - ret_folder->physicalUri = CORBA_string_dup (folder->physicalUri); - ret_folder->customIconName = CORBA_string_dup (folder->customIconName); - ret_folder->evolutionUri = CORBA_string_dup (folder->evolutionUri); - ret_folder->unreadCount = folder->unreadCount; - ret_folder->sortingPriority = folder->sortingPriority; - - * (listener_servant->folder_return) = ret_folder; - } - - gtk_main_quit (); -} - -static void -impl_FolderSelectionListener_cancel (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - FolderSelectionListenerServant *listener_servant; - - listener_servant = (FolderSelectionListenerServant *) servant; - - if (listener_servant->folder_return != NULL) - * (listener_servant->folder_return) = NULL; - - gtk_main_quit (); -} - -static void -init_FolderSelectionListener_vtables (void) -{ - FolderSelectionListener_base_epv._private = NULL; - FolderSelectionListener_base_epv.finalize = NULL; - FolderSelectionListener_base_epv.default_POA = NULL; - - FolderSelectionListener_epv.notifySelected = impl_FolderSelectionListener_selected; - FolderSelectionListener_epv.notifyCanceled = impl_FolderSelectionListener_cancel; - - FolderSelectionListener_vepv._base_epv = &FolderSelectionListener_base_epv; - FolderSelectionListener_vepv.GNOME_Evolution_FolderSelectionListener_epv = &FolderSelectionListener_epv; - - FolderSelectionListener_vtables_initialized = TRUE; -} - -static GNOME_Evolution_FolderSelectionListener -create_folder_selection_listener_interface (char **result, - GNOME_Evolution_Folder **folder_return) -{ - GNOME_Evolution_FolderSelectionListener corba_interface; - CORBA_Environment ev; - FolderSelectionListenerServant *servant; - PortableServer_Servant listener_servant; - - if (! FolderSelectionListener_vtables_initialized) - init_FolderSelectionListener_vtables (); - - servant = g_new0 (FolderSelectionListenerServant, 1); - servant->servant.vepv = &FolderSelectionListener_vepv; - servant->folder_return = folder_return; - - listener_servant = (PortableServer_Servant) servant; - - CORBA_exception_init (&ev); - - POA_GNOME_Evolution_FolderSelectionListener__init (listener_servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free(servant); - return CORBA_OBJECT_NIL; - } - - CORBA_free (PortableServer_POA_activate_object (bonobo_poa (), listener_servant, &ev)); - - corba_interface = PortableServer_POA_servant_to_reference (bonobo_poa (), listener_servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - corba_interface = CORBA_OBJECT_NIL; - - CORBA_exception_free (&ev); - - return corba_interface; -} - -static int -count_string_items (const char **list) -{ - int i; - - if (list == NULL) - return 0; - - for (i = 0; list[i] != NULL; i++) - ; - - return i; -} - -static void -user_select_folder (EvolutionShellClient *shell_client, - GtkWindow *parent, - const char *title, - const char *default_folder, - const char **possible_types, - GNOME_Evolution_Folder **folder_return) -{ - GNOME_Evolution_FolderSelectionListener listener_interface; - GNOME_Evolution_Shell corba_shell; - CORBA_Environment ev; - GNOME_Evolution_Shell_FolderTypeNameList corba_type_name_list; - CORBA_long_long parent_xid; - int num_possible_types; - char *result; - - result = NULL; - - listener_interface = create_folder_selection_listener_interface (&result, - folder_return); - if (listener_interface == CORBA_OBJECT_NIL) - return; - - CORBA_exception_init (&ev); - - corba_shell = evolution_shell_client_corba_objref (shell_client); - - num_possible_types = count_string_items (possible_types); - - corba_type_name_list._length = num_possible_types; - corba_type_name_list._maximum = num_possible_types; - corba_type_name_list._buffer = (CORBA_char **) possible_types; - - parent_xid = (CORBA_long_long) GDK_WINDOW_XWINDOW (GTK_WIDGET (parent)->window); - - GNOME_Evolution_Shell_selectUserFolder (corba_shell, parent_xid, - listener_interface, - title, - default_folder, - &corba_type_name_list, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - CORBA_exception_free (&ev); - return; - } - - gtk_main(); - - CORBA_Object_release (listener_interface, &ev); - - CORBA_exception_free (&ev); -} - -/* GObject methods. */ - -static void -unref_pixbuf (gpointer name, gpointer pixbuf, gpointer data) -{ - g_free (name); - g_object_unref (pixbuf); -} - -static void -impl_dispose (GObject *object) -{ - EvolutionShellClient *shell_client; - EvolutionShellClientPrivate *priv; - CORBA_Environment ev; - - shell_client = EVOLUTION_SHELL_CLIENT (object); - priv = shell_client->priv; - - CORBA_exception_init (&ev); - - if (priv->corba_objref != CORBA_OBJECT_NIL) { - Bonobo_Unknown_unref (priv->corba_objref, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("EvolutionShellClient::destroy: " - "Error unreffing the ::Shell interface -- %s\n", - BONOBO_EX_REPOID (&ev)); - CORBA_Object_release (priv->corba_objref, &ev); - priv->corba_objref = CORBA_OBJECT_NIL; - } - - if (priv->activity_interface != CORBA_OBJECT_NIL) { - Bonobo_Unknown_unref (priv->activity_interface, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("EvolutionShellClient::destroy: " - "Error unreffing the ::Activity interface -- %s\n", - BONOBO_EX_REPOID (&ev)); - CORBA_Object_release (priv->activity_interface, &ev); - priv->activity_interface = CORBA_OBJECT_NIL; - } - - if (priv->shortcuts_interface != CORBA_OBJECT_NIL) { - Bonobo_Unknown_unref (priv->shortcuts_interface, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("EvolutionShellClient::destroy: " - "Error unreffing the ::Shortcuts interface -- %s\n", - BONOBO_EX_REPOID (&ev)); - CORBA_Object_release (priv->shortcuts_interface, &ev); - priv->shortcuts_interface = CORBA_OBJECT_NIL; - } - - if (priv->storage_registry_interface != CORBA_OBJECT_NIL) { - Bonobo_Unknown_unref (priv->storage_registry_interface, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("EvolutionShellClient::destroy: " - "Error unreffing the ::StorageRegistry interface -- %s\n", - BONOBO_EX_REPOID (&ev)); - CORBA_Object_release (priv->storage_registry_interface, &ev); - priv->storage_registry_interface = CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&ev); - - g_hash_table_foreach (priv->icons, unref_pixbuf, NULL); - g_hash_table_destroy (priv->icons); - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EvolutionShellClient *shell_client; - EvolutionShellClientPrivate *priv; - - shell_client = EVOLUTION_SHELL_CLIENT (object); - priv = shell_client->priv; - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - static void class_init (EvolutionShellClientClass *klass) { - GObjectClass *object_class; - - parent_class = g_type_class_ref(PARENT_TYPE); - - object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; } static void init (EvolutionShellClient *shell_client) { - EvolutionShellClientPrivate *priv; - - priv = g_new (EvolutionShellClientPrivate, 1); - priv->corba_objref = CORBA_OBJECT_NIL; - priv->activity_interface = CORBA_OBJECT_NIL; - priv->shortcuts_interface = CORBA_OBJECT_NIL; - priv->storage_registry_interface = CORBA_OBJECT_NIL; - priv->icons = g_hash_table_new (g_str_hash, g_str_equal); - - shell_client->priv = priv; } -/** - * evolution_shell_client_construct: - * @shell_client: - * @corba_shell: - * - * Construct @shell_client associating it to @corba_shell. - **/ void evolution_shell_client_construct (EvolutionShellClient *shell_client, GNOME_Evolution_Shell corba_shell) { - EvolutionShellClientPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (shell_client != NULL); - g_return_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client)); - g_return_if_fail (corba_shell != CORBA_OBJECT_NIL); - - priv = shell_client->priv; - g_return_if_fail (priv->activity_interface == CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - priv->corba_objref = CORBA_Object_duplicate (corba_shell, &ev); - Bonobo_Unknown_ref (priv->corba_objref, &ev); - - CORBA_exception_free (&ev); - - priv->activity_interface = query_shell_interface (shell_client, "IDL:GNOME/Evolution/Activity:1.0"); - priv->shortcuts_interface = query_shell_interface (shell_client, "IDL:GNOME/Evolution/Shortcuts:1.0"); - priv->storage_registry_interface = query_shell_interface (shell_client, "IDL:GNOME/Evolution/StorageRegistry:1.0"); + g_assert_not_reached (); } -/** - * evolution_shell_client_new: - * @corba_shell: A pointer to the CORBA Evolution::Shell interface. - * - * Create a new client object for @corba_shell. - * - * Return value: A pointer to the Evolution::Shell client BonoboObject. - **/ EvolutionShellClient * evolution_shell_client_new (GNOME_Evolution_Shell corba_shell) { - EvolutionShellClient *shell_client; - - shell_client = g_object_new (evolution_shell_client_get_type (), NULL); - - evolution_shell_client_construct (shell_client, corba_shell); - - if (evolution_shell_client_corba_objref (shell_client) == CORBA_OBJECT_NIL) { - g_object_unref (shell_client); - return NULL; - } - - return shell_client; + g_assert_not_reached (); + return NULL; } -/** - * evolution_shell_client_corba_objref: - * @shell_client: - * - * Return value: Return the CORBA objref associated with this shell client. - **/ GNOME_Evolution_Shell evolution_shell_client_corba_objref (EvolutionShellClient *shell_client) { g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), CORBA_OBJECT_NIL); - - return shell_client->priv->corba_objref; + return CORBA_OBJECT_NIL; } -/** - * evolution_shell_client_user_select_folder: - * @shell_client: A EvolutionShellClient object - * @parent: Parent window for the dialog (must be realized when invoking) - * @title: The title for the folder selection dialog - * @default_folder: URI (physical or evolution:) of the folder initially selected on the dialog - * @folder_return: - * - * Pop up the shell's folder selection dialog with the specified - * @title and @default_folder as the initially selected folder. On - * return, set *@folder_return to the folder structure for the - * selected folder (or %NULL if the user cancelled the dialog). (The - * dialog is modal.) - **/ void evolution_shell_client_user_select_folder (EvolutionShellClient *shell_client, GtkWindow *parent, @@ -467,142 +73,44 @@ evolution_shell_client_user_select_folder (EvolutionShellClient *shell_client, const char **possible_types, GNOME_Evolution_Folder **folder_return) { - /* Do this first so it can be checked as a return value, even - * if we g_return_if_fail. - */ - if (folder_return) - *folder_return = CORBA_OBJECT_NIL; - - g_return_if_fail (shell_client != NULL); - g_return_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client)); - g_return_if_fail (title != NULL); - g_return_if_fail (default_folder != NULL); - g_return_if_fail (parent == NULL || GTK_WIDGET_REALIZED (parent)); - - user_select_folder (shell_client, parent, title, default_folder, - possible_types, folder_return); + g_assert_not_reached (); } -/** - * evolution_shell_client_get_activity_interface: - * @shell_client: An EvolutionShellClient object - * - * Get the GNOME::Evolution::Activity for the shell associated with - * @shell_client. - * - * Return value: A CORBA Object represeting the GNOME::Evolution::Activity - * interface. - **/ GNOME_Evolution_Activity evolution_shell_client_get_activity_interface (EvolutionShellClient *shell_client) { - g_return_val_if_fail (shell_client != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), CORBA_OBJECT_NIL); - - return shell_client->priv->activity_interface; + g_assert_not_reached (); + return CORBA_OBJECT_NIL; } -/** - * evolution_shell_client_get_shortcuts_interface: - * @shell_client: An EvolutionShellClient object - * - * Get the GNOME::Evolution::Shortcuts for the shell associated with - * @shell_client. - * - * Return value: A CORBA Object represeting the GNOME::Evolution::Shortcuts - * interface. - **/ GNOME_Evolution_Shortcuts evolution_shell_client_get_shortcuts_interface (EvolutionShellClient *shell_client) { - g_return_val_if_fail (shell_client != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), CORBA_OBJECT_NIL); - - return shell_client->priv->shortcuts_interface; + g_assert_not_reached (); + return CORBA_OBJECT_NIL; } -/** - * evolution_shell_client_get_storage_registry_interface: - * @shell_client: An EvolutionShellClient object - * - * Get the GNOME::Evolution::StorageRegistry for the shell associated - * with @shell_client. - * - * Return value: A CORBA Object represeting the - * GNOME::Evolution::StorageRegistry interface. - **/ GNOME_Evolution_StorageRegistry evolution_shell_client_get_storage_registry_interface (EvolutionShellClient *shell_client) { - g_return_val_if_fail (shell_client != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), CORBA_OBJECT_NIL); - - return shell_client->priv->storage_registry_interface; + g_assert_not_reached (); + return CORBA_OBJECT_NIL; } -/** - * evolution_shell_client_get_local_storage: - * @shell_client: An EvolutionShellClient object - * - * Retrieve the local storage interface for this shell. - * - * Return value: a pointer to the CORBA object implementing the local storage - * in the shell associated with @shell_client. - **/ GNOME_Evolution_Storage evolution_shell_client_get_local_storage (EvolutionShellClient *shell_client) { - GNOME_Evolution_Shell corba_shell; - GNOME_Evolution_Storage corba_local_storage; - CORBA_Environment ev; - - g_return_val_if_fail (shell_client != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - corba_shell = evolution_shell_client_corba_objref (shell_client); - if (corba_shell == CORBA_OBJECT_NIL) { - g_warning ("evolution_shell_client_get_local_storage() invoked on an " - "EvolutionShellClient that doesn't have a CORBA objref???"); - CORBA_exception_free (&ev); - return CORBA_OBJECT_NIL; - } - - corba_local_storage = GNOME_Evolution_Shell_getLocalStorage (corba_shell, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("evolution_shell_client_get_local_storage() failing -- %s ???", - BONOBO_EX_REPOID (&ev)); - CORBA_exception_free (&ev); - return CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&ev); - - return corba_local_storage; + g_assert_not_reached (); + return CORBA_OBJECT_NIL; } void evolution_shell_client_set_line_status (EvolutionShellClient *shell_client, gboolean line_status) { - GNOME_Evolution_Shell corba_shell; - CORBA_Environment ev; - - g_return_if_fail (shell_client != NULL); - g_return_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client)); - - CORBA_exception_init (&ev); - - corba_shell = evolution_shell_client_corba_objref (shell_client); - if (corba_shell == CORBA_OBJECT_NIL) - return; - - GNOME_Evolution_Shell_setLineStatus (corba_shell, line_status, &ev); - - CORBA_exception_free (&ev); + g_assert_not_reached (); } @@ -611,42 +119,8 @@ evolution_shell_client_get_pixbuf_for_type (EvolutionShellClient *shell_client, const char *folder_type, gboolean mini) { - GNOME_Evolution_Shell corba_shell; - CORBA_Environment ev; - GNOME_Evolution_Icon *icon; - GdkPixbuf *pixbuf; - char *hash_name; - - g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), NULL); - - hash_name = g_strdup_printf ("%s/%s", folder_type, - mini ? "mini" : "large"); - pixbuf = g_hash_table_lookup (shell_client->priv->icons, hash_name); - if (!pixbuf) { - corba_shell = evolution_shell_client_corba_objref (shell_client); - g_return_val_if_fail (corba_shell != CORBA_OBJECT_NIL, NULL); - - CORBA_exception_init (&ev); - icon = GNOME_Evolution_Shell_getIconByType (corba_shell, - folder_type, mini, - &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (hash_name); - return NULL; - } - CORBA_exception_free (&ev); - - pixbuf = e_new_gdk_pixbuf_from_corba_icon (icon, icon->width, - icon->height); - CORBA_free (icon); - - g_hash_table_insert (shell_client->priv->icons, - hash_name, pixbuf); - } else - g_free (hash_name); - - g_object_ref (pixbuf); - return pixbuf; + g_assert_not_reached (); + return NULL; } @@ -657,41 +131,8 @@ evolution_shell_client_create_storage_set_view (EvolutionShellClient *shell_clie GNOME_Evolution_StorageSetView *storage_set_view_iface_return, CORBA_Environment *ev) { - GNOME_Evolution_Shell corba_shell; - CORBA_Environment my_ev; - Bonobo_Control control; - GtkWidget *control_widget; - - g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), NULL); - - CORBA_exception_init (&my_ev); - if (ev == NULL) - ev = &my_ev; - - corba_shell = evolution_shell_client_corba_objref (shell_client); - - control = GNOME_Evolution_Shell_createStorageSetView (corba_shell, ev); - if (BONOBO_EX (ev)) { - g_warning ("Cannot create StorageSetView -- %s", BONOBO_EX_REPOID (ev)); - CORBA_exception_free (&my_ev); - return NULL; - } - - if (bonobo_control_iface_return != NULL) - *bonobo_control_iface_return = control; - - control_widget = bonobo_widget_new_control_from_objref (control, uic); - - if (storage_set_view_iface_return != NULL) { - *storage_set_view_iface_return = Bonobo_Unknown_queryInterface (control, - "IDL:GNOME/Evolution/StorageSetView:1.0", - ev); - if (BONOBO_EX (ev)) - *storage_set_view_iface_return = NULL; - } - - CORBA_exception_free (&my_ev); - return control_widget; + g_assert_not_reached (); + return NULL; } diff --git a/shell/evolution-shell-client.h b/shell/evolution-shell-client.h index 18fe144929..864d33c9e7 100644 --- a/shell/evolution-shell-client.h +++ b/shell/evolution-shell-client.h @@ -20,6 +20,8 @@ * Author: Ettore Perazzoli */ +/* FIXME: This file will have to go away. */ + #ifndef __EVOLUTION_SHELL_CLIENT_H__ #define __EVOLUTION_SHELL_CLIENT_H__ @@ -48,8 +50,6 @@ typedef struct _EvolutionShellClientClass EvolutionShellClientClass; struct _EvolutionShellClient { GObject base; - - EvolutionShellClientPrivate *priv; }; struct _EvolutionShellClientClass { diff --git a/shell/main.c b/shell/main.c index 740eb091ca..a7ed51eb1a 100644 --- a/shell/main.c +++ b/shell/main.c @@ -28,7 +28,7 @@ #include "e-icon-factory.h" #include "e-shell-constants.h" -#include "e-shell-config.h" +#include "e-shell-window.h" /* FIXME */ #include "e-setup.h" #include "e-shell.h" @@ -80,10 +80,8 @@ static EShell *shell = NULL; -static char *evolution_directory = NULL; /* Command-line options. */ -static gboolean no_splash = FALSE; static gboolean start_online = FALSE; static gboolean start_offline = FALSE; static gboolean setup_only = FALSE; @@ -141,7 +139,7 @@ quit_box_new (void) } static void -no_views_left_cb (EShell *shell, gpointer data) +no_windows_left_cb (EShell *shell, gpointer data) { GtkWidget *quit_box; @@ -323,22 +321,22 @@ show_development_warning (GtkWindow *parent) soon as the first view is created. */ static void -view_map_callback (GtkWidget *widget, - void *data) +window_map_callback (GtkWidget *widget, + void *data) { - g_signal_handlers_disconnect_by_func (widget, G_CALLBACK (view_map_callback), data); + g_signal_handlers_disconnect_by_func (widget, G_CALLBACK (window_map_callback), data); show_development_warning (GTK_WINDOW (widget)); } static void -new_view_created_callback (EShell *shell, - EShellView *view, - void *data) +new_window_created_callback (EShell *shell, + EShellWindow *window, + void *data) { - g_signal_handlers_disconnect_by_func (shell, G_CALLBACK (new_view_created_callback), data); + g_signal_handlers_disconnect_by_func (shell, G_CALLBACK (new_window_created_callback), data); - g_signal_connect (view, "map", G_CALLBACK (view_map_callback), NULL); + g_signal_connect (window, "map", G_CALLBACK (window_map_callback), NULL); } #endif /* DEVELOPMENT_WARNING */ @@ -374,20 +372,17 @@ idle_cb (void *data) else startup_line_mode = E_SHELL_STARTUP_LINE_MODE_OFFLINE; - shell = e_shell_new (evolution_directory, ! no_splash, startup_line_mode, &result); - g_free (evolution_directory); + shell = e_shell_new (startup_line_mode, &result); switch (result) { case E_SHELL_CONSTRUCT_RESULT_OK: - e_shell_config_factory_register (shell); - - g_signal_connect (shell, "no_views_left", G_CALLBACK (no_views_left_cb), NULL); + g_signal_connect (shell, "no_windows_left", G_CALLBACK (no_windows_left_cb), NULL); g_object_weak_ref (G_OBJECT (shell), shell_weak_notify, NULL); #ifdef DEVELOPMENT_WARNING if (!getenv ("EVOLVE_ME_HARDER")) - g_signal_connect (shell, "new_view_created", - G_CALLBACK (new_view_created_callback), NULL); + g_signal_connect (shell, "new_window_created", + G_CALLBACK (new_window_created_callback), NULL); #endif corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell)); @@ -439,7 +434,7 @@ idle_cb (void *data) view, AND we can't load the user's previous settings, then show the default URI. */ if (! have_evolution_uri) { - e_shell_create_view (shell, NULL, NULL); + e_shell_create_window (shell, NULL); display_default = TRUE; displayed_any = TRUE; } else { @@ -538,8 +533,6 @@ int main (int argc, char **argv) { struct poptOption options[] = { - { "no-splash", '\0', POPT_ARG_NONE, &no_splash, 0, - N_("Disable splash screen"), NULL }, { "offline", '\0', POPT_ARG_NONE, &start_offline, 0, N_("Start in offline mode"), NULL }, { "online", '\0', POPT_ARG_NONE, &start_online, 0, @@ -560,6 +553,7 @@ main (int argc, char **argv) GnomeProgram *program; poptContext popt_context; const char **args; + char *evolution_directory; /* Make ElectricFence work. */ free (malloc (10)); @@ -609,12 +603,13 @@ main (int argc, char **argv) /* FIXME */ evolution_directory = g_build_filename (g_get_home_dir (), "evolution", NULL); - if (! e_setup (evolution_directory)) exit (1); if (setup_only) exit (0); + g_free (evolution_directory); + uri_list = NULL; g_value_init (&popt_context_value, G_TYPE_POINTER); @@ -630,9 +625,9 @@ main (int argc, char **argv) uri_list = g_slist_reverse (uri_list); g_value_unset (&popt_context_value); - e_config_upgrade(evolution_directory); + e_config_upgrade (evolution_directory); - gtk_idle_add (idle_cb, uri_list); + g_idle_add (idle_cb, uri_list); bonobo_main (); |