From 4187293731274274e4283d9039f6e30c95578118 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 18 Aug 2008 16:18:42 +0000 Subject: Merge revisions 35993:36015 from trunk. Adapt recent "crash recovery" changes to new architecture. svn path=/branches/kill-bonobo/; revision=36018 --- shell/ChangeLog | 35 +++++ shell/apps_evolution_shell.schemas.in | 25 ---- shell/e-shell-window-private.h | 1 + shell/e-shell-window.c | 259 +++++++++------------------------ shell/e-shell-window.h | 5 +- shell/e-shell.c | 7 +- shell/e-user-creatable-items-handler.c | 13 +- shell/main.c | 98 +------------ 8 files changed, 126 insertions(+), 317 deletions(-) (limited to 'shell') diff --git a/shell/ChangeLog b/shell/ChangeLog index 1296ec35c8..0aa3bb8359 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,38 @@ +2008-08-18 Matthew Barnes + + * test/evolution-test-component.c (impl_upgradeFromVersion): + Fix the function signature to conform to the component interface. + +2008-08-18 Matthew Barnes + + ** Fixes part of bug #508732 + + * e-shell.c: + Add a "crash_recovery" flag, with accessor functions for it. + + * e-shell-window (init_view): + Check and reset the "crash_recovery" flag before creating a + new shell view. The components can use this flag to take + steps to recover from the previous crash. + + * apps_evolution_shell.schemas.in: + Remove the "skip_recovery_dialog" and "recovery" keys. + + * Evolution-Component.idl (createView): + Add a "select_item" boolean parameter. + + * main.c: + Kill the crash recovery dialog. Instead just set the crash + recovery flag in e-shell appropriately. + +2008-08-18 Milan Crha + + ** Fix for bug #416258 + + * e-user-creatable-items-handler.c (ensure_menu_items), + (free_menu_items), (new_button_change), (setup_toolbar_button): + Added icon_toolbar for default items which is used instead of menu icon. + 2008-08-08 Matthew Barnes * e-shell-importer.c: diff --git a/shell/apps_evolution_shell.schemas.in b/shell/apps_evolution_shell.schemas.in index 76ac78e8dd..1c79c6f132 100644 --- a/shell/apps_evolution_shell.schemas.in +++ b/shell/apps_evolution_shell.schemas.in @@ -41,31 +41,6 @@ - - - /schemas/apps/evolution/shell/skip_recovery_dialog - /apps/evolution/shell/skip_recovery_dialog - evolution - bool - false - - Skip recovery warning dialog - Whether the warning dialog in recovery of Evolution is skipped. - - - - - /schemas/apps/evolution/shell/recovery - /apps/evolution/shell/recovery - evolution - bool - true - - Whether crash detection should be done or not - Decides whether the crash detection should be run or not. - - - diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h index aae09b4467..e8287fc23d 100644 --- a/shell/e-shell-window-private.h +++ b/shell/e-shell-window-private.h @@ -79,6 +79,7 @@ struct _EShellWindowPrivate { /* Miscellaneous */ gboolean destroyed; /* XXX Do we still need this? */ + gboolean safe_mode; }; void e_shell_window_private_init (EShellWindow *window); diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index cc87555c47..45c1fa2637 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -39,8 +39,47 @@ #include +enum { + PROP_0, + PROP_SAFE_MODE +}; + static gpointer parent_class; +static void +shell_window_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SAFE_MODE: + e_shell_window_set_safe_mode ( + E_SHELL_WINDOW (object), + g_value_get_boolean (value)); + break; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +shell_window_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SAFE_MODE: + g_value_set_boolean ( + value, e_shell_window_get_safe_mode ( + E_SHELL_WINDOW (object))); + break; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + static void shell_window_dispose (GObject *object) { @@ -68,8 +107,21 @@ shell_window_class_init (EShellWindowClass *class) g_type_class_add_private (class, sizeof (EShellWindowPrivate)); object_class = G_OBJECT_CLASS (class); + object_class->set_property = shell_window_set_property; + object_class->get_property = shell_window_get_property; object_class->dispose = shell_window_dispose; object_class->finalize = shell_window_finalize; + + g_object_class_install_property ( + object_class, + PROP_SAFE_MODE, + g_param_spec_boolean ( + "safe-mode", + NULL, + NULL, + FALSE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); } static void @@ -114,9 +166,10 @@ e_shell_window_get_type (void) } GtkWidget * -e_shell_window_new (void) +e_shell_window_new (gboolean safe_mode) { - return g_object_new (E_TYPE_SHELL_WINDOW, NULL); + return g_object_new ( + E_TYPE_SHELL_WINDOW, "safe-mode", safe_mode, NULL); } GtkUIManager * @@ -199,203 +252,21 @@ e_shell_window_get_managed_widget (EShellWindow *window, return widget; } -#if 0 -static void -init_view (EShellWindow *window, - ComponentView *view) +gboolean +e_shell_window_get_safe_mode (EShellWindow *window) { - EShellWindowPrivate *priv = window->priv; - EComponentRegistry *registry = e_shell_peek_component_registry (window->priv->shell); - GNOME_Evolution_Component component_iface; - GNOME_Evolution_ComponentView component_view; - Bonobo_UIContainer container; - Bonobo_Control sidebar_control; - Bonobo_Control view_control; - Bonobo_Control statusbar_control; - CORBA_Environment ev; - int sidebar_notebook_page_num; - int content_notebook_page_num; - - g_return_if_fail (view->view_widget == NULL); - g_return_if_fail (view->sidebar_widget == NULL); - g_return_if_fail (view->notebook_page_num == -1); - - CORBA_exception_init (&ev); - - /* 1. Activate component. (FIXME: Shouldn't do this here.) */ - - component_iface = e_component_registry_activate (registry, view->component_id, &ev); - if (BONOBO_EX (&ev) || 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); - CORBA_exception_free (&ev); - return; - } - - /* 2. Set up view. */ - - /* 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. */ - - component_view = GNOME_Evolution_Component_createView(component_iface, BONOBO_OBJREF(priv->shell_view), &ev); - if (component_view == NULL || BONOBO_EX (&ev)) { - g_warning ("Cannot create view for %s", view->component_id); - bonobo_object_release_unref (component_iface, NULL); - CORBA_exception_free (&ev); - return; - } - - GNOME_Evolution_ComponentView_getControls(component_view, &sidebar_control, &view_control, &statusbar_control, &ev); - if (BONOBO_EX (&ev)) { - g_warning ("Cannot create view for %s", view->component_id); - bonobo_object_release_unref (component_iface, NULL); - CORBA_exception_free (&ev); - return; - } - - view->component_view = component_view; - - CORBA_exception_free (&ev); + g_return_val_if_fail (E_IS_SHELL_WINDOW (window), FALSE); - 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); - - view->statusbar_widget = bonobo_widget_new_control_from_objref (statusbar_control, container); - gtk_widget_show (view->statusbar_widget); - bonobo_object_release_unref (statusbar_control, NULL); - - gtk_notebook_append_page (GTK_NOTEBOOK (priv->sidebar_notebook), view->sidebar_widget, NULL); - gtk_notebook_append_page (GTK_NOTEBOOK (priv->content_notebook), view->view_widget, NULL); - gtk_notebook_append_page (GTK_NOTEBOOK (priv->statusbar_notebook), view->statusbar_widget, NULL); - - sidebar_notebook_page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->sidebar_notebook), view->sidebar_widget); - content_notebook_page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->content_notebook), view->view_widget); - - /* Since we always add a view page and a sidebar page at the same time... */ - g_return_if_fail (sidebar_notebook_page_num == content_notebook_page_num); - - view->notebook_page_num = content_notebook_page_num; - - /* 3. Switch to the new page. */ - - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->content_notebook), content_notebook_page_num); - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), content_notebook_page_num); - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->statusbar_notebook), content_notebook_page_num); - - priv->current_view = view; - - bonobo_object_release_unref (component_iface, NULL); + return window->priv->safe_mode; } -static void -switch_view (EShellWindow *window, ComponentView *component_view) +void +e_shell_window_set_safe_mode (EShellWindow *window, + gboolean safe_mode) { - EShellWindowPrivate *priv = window->priv; - GConfClient *gconf_client = gconf_client_get_default (); - EComponentRegistry *registry = e_shell_peek_component_registry (window->priv->shell); - EComponentInfo *info = e_component_registry_peek_info (registry, - ECR_FIELD_ID, - component_view->component_id); - char *title; - - if (component_view->sidebar_widget == NULL) { - init_view (window, component_view); - } else { - priv->current_view = component_view; - - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->content_notebook), component_view->notebook_page_num); - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), component_view->notebook_page_num); - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->statusbar_notebook), component_view->notebook_page_num); - } - - if (component_view->title == NULL) { - /* To translators: This is the window title and %s is the - component name. Most translators will want to keep it as is. */ - title = g_strdup_printf (_("%s - Evolution"), info->button_label); - gtk_window_set_title (GTK_WINDOW (window), title); - g_free (title); - } else - gtk_window_set_title (GTK_WINDOW (window), component_view->title); - - if (info->icon_name) - gtk_window_set_icon_name (GTK_WINDOW (window), info->icon_name); - - gconf_client_set_string (gconf_client, "/apps/evolution/shell/view_defaults/component_id", - (component_view->component_alias != NULL - ? component_view->component_alias - : component_view->component_id), - NULL); - - g_object_unref (gconf_client); - - /** @Event: Shell component activated or switched to. - * @Id: component.activated - * @Target: ESEventTargetComponent - * - * This event is emitted whenever the shell successfully activates component - * view. - */ - e_event_emit ((EEvent *) es_event_peek (), "component.activated", (EEventTarget *) es_event_target_new_component (es_event_peek (), component_view->component_id)); - - g_object_notify (G_OBJECT (window), "current-view"); -} -#endif - + g_return_if_fail (E_IS_SHELL_WINDOW (window)); -/* Functions to update the sensitivity of buttons and menu items depending on the status. */ + window->priv->safe_mode = safe_mode; -#if 0 -static void -update_offline_toggle_status (EShellWindow *window) -{ - EShellWindowPrivate *priv; - GtkWidget *widget; - const gchar *tooltip; - gboolean online; - gboolean sensitive; - guint32 flags = 0; - - priv = window->priv; - - switch (e_shell_get_line_status ()) { - case E_SHELL_LINE_STATUS_ONLINE: - online = TRUE; - sensitive = TRUE; - tooltip = _("Evolution is currently online.\n" - "Click on this button to work offline."); - flags = ES_MENU_SHELL_ONLINE; - break; - case E_SHELL_LINE_STATUS_GOING_OFFLINE: - online = TRUE; - sensitive = FALSE; - tooltip = _("Evolution is in the process of going offline."); - flags = ES_MENU_SHELL_OFFLINE; - break; - case E_SHELL_LINE_STATUS_OFFLINE: - case E_SHELL_LINE_STATUS_FORCED_OFFLINE: - online = FALSE; - sensitive = TRUE; - tooltip = _("Evolution is currently offline.\n" - "Click on this button to work online."); - flags = ES_MENU_SHELL_OFFLINE; - break; - default: - g_return_if_reached (); - } - - widget = window->priv->online_button; - gtk_widget_set_sensitive (widget, sensitive); - gtk_widget_set_tooltip_text (widget, tooltip); - e_online_button_set_online (E_ONLINE_BUTTON (widget), online); + g_object_notify (G_OBJECT (window), "safe-mode"); } -#endif diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index c423a43c92..e7b0d9da8d 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -59,7 +59,7 @@ struct _EShellWindowClass { }; GType e_shell_window_get_type (void); -GtkWidget * e_shell_window_new (void); +GtkWidget * e_shell_window_new (gboolean safe_mode); GtkUIManager * e_shell_window_get_ui_manager (EShellWindow *window); GtkAction * e_shell_window_get_action (EShellWindow *window, const gchar *action_name); @@ -68,6 +68,9 @@ GtkActionGroup *e_shell_window_get_action_group (EShellWindow *window, GtkWidget * e_shell_window_get_managed_widget (EShellWindow *window, const gchar *widget_path); +gboolean e_shell_window_get_safe_mode (EShellWindow *window); +void e_shell_window_set_safe_mode (EShellWindow *window, + gboolean safe_mode); G_END_DECLS diff --git a/shell/e-shell.c b/shell/e-shell.c index f617fe27ad..1d2d68b57e 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -104,8 +104,13 @@ EShellWindow * e_shell_create_window (void) { GtkWidget *shell_window; + gboolean safe_mode; - shell_window = e_shell_window_new (); + /* Put the first window into safe mode if we detect the previous + * session did not shut down cleanly, perhaps due to a crash. */ + safe_mode = (active_windows == NULL) && e_file_lock_exists (); + + shell_window = e_shell_window_new (safe_mode); active_windows = g_list_prepend (active_windows, shell_window); diff --git a/shell/e-user-creatable-items-handler.c b/shell/e-user-creatable-items-handler.c index f18deeb527..24ba4acd39 100644 --- a/shell/e-user-creatable-items-handler.c +++ b/shell/e-user-creatable-items-handler.c @@ -60,6 +60,7 @@ struct _MenuItem { char *tooltip; char *component; GdkPixbuf *icon; + GdkPixbuf *icon_toolbar; }; typedef struct _MenuItem MenuItem; @@ -258,8 +259,13 @@ ensure_menu_items (EUserCreatableItemsHandler *handler) if (corba_item->iconName == NULL || *corba_item->iconName == '\0') { item->icon = NULL; + item->icon_toolbar = NULL; } else { item->icon = e_icon_factory_get_icon (corba_item->iconName, E_ICON_SIZE_MENU); + if (item_is_default (item, component->alias)) + item->icon_toolbar = e_icon_factory_get_icon (corba_item->iconName, E_ICON_SIZE_LARGE_TOOLBAR); + else + item->icon_toolbar = NULL; } if (corba_item->type == GNOME_Evolution_CREATABLE_OBJECT) @@ -304,6 +310,9 @@ free_menu_items (GSList *menu_items) if (item->icon != NULL) g_object_unref (item->icon); + if (item->icon_toolbar != NULL) + g_object_unref (item->icon_toolbar); + g_free (item->component); g_free (item); } @@ -698,7 +707,7 @@ new_button_change (GConfClient *gconf, val = gconf_client_get_string (gconf, "/desktop/gnome/interface/toolbar_style", NULL); set_combo_button_style (E_COMBO_BUTTON (priv->new_button), - val, priv->default_menu_item->icon); + val, priv->default_menu_item->icon_toolbar ? priv->default_menu_item->icon_toolbar : priv->default_menu_item->icon); g_free (val); gtk_widget_show (priv->new_button); @@ -738,7 +747,7 @@ setup_toolbar_button (EUserCreatableItemsHandler *handler) gtk_widget_set_sensitive (priv->new_button, TRUE); set_combo_button_style (E_COMBO_BUTTON (priv->new_button), - val, priv->default_menu_item->icon); + val, priv->default_menu_item->icon_toolbar ? priv->default_menu_item->icon_toolbar : priv->default_menu_item->icon); gconf_client_notify_add(gconf,"/desktop/gnome/interface/toolbar_style", (GConfClientNotifyFunc)new_button_change, handler, NULL, NULL); diff --git a/shell/main.c b/shell/main.c index ab15fdc3db..2af41079c4 100644 --- a/shell/main.c +++ b/shell/main.c @@ -86,10 +86,6 @@ #define SKIP_WARNING_DIALOG_KEY \ "/apps/evolution/shell/skip_warning_dialog" -#define SKIP_RECOVERY_DIALOG_KEY \ - "/apps/evolution/shell/skip_recovery_dialog" -#define RECOVERY_KEY \ - "/apps/evolution/shell/recovery" /* Command-line options. */ static gboolean start_online = FALSE; @@ -268,70 +264,6 @@ destroy_config (GConfClient *client) #endif /* DEVELOPMENT */ -static int -show_recovery_warning(void) -{ - GtkWidget *vbox; - GtkWidget *label; - GtkWidget *warning_dialog; - GtkWidget *checkbox; - GtkWidget *alignment; - gboolean skip; - char *text; - int flags = 0, response; - - warning_dialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (warning_dialog), _("Evolution Crash Detection")); - gtk_window_set_modal (GTK_WINDOW (warning_dialog), TRUE); - gtk_dialog_add_button (GTK_DIALOG (warning_dialog), _("Ig_nore"), GTK_RESPONSE_CANCEL); - gtk_dialog_add_button (GTK_DIALOG (warning_dialog), _("_Recover"), GTK_RESPONSE_OK); - - gtk_dialog_set_has_separator (GTK_DIALOG (warning_dialog), FALSE); - - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (warning_dialog)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (warning_dialog)->action_area), 12); - - vbox = gtk_vbox_new (FALSE, 12); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (warning_dialog)->vbox), vbox, - TRUE, TRUE, 0); - - text = g_strdup( - /* xgettext:no-c-format */ - _("Evolution appears to have exited unexpectedly the last time it was\n" - "run. As a precautionary measure, all preview panes will be hidden.\n" - "You can restore the preview panes from the View menu.\n")); - label = gtk_label_new (text); - g_free(text); - - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); - - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); - - checkbox = gtk_check_button_new_with_mnemonic (_("_Do not show this message again")); - - alignment = gtk_alignment_new (0.0, 0.0, 0.0, 0.0); - - gtk_container_add (GTK_CONTAINER (alignment), checkbox); - gtk_box_pack_start (GTK_BOX (vbox), alignment, TRUE, TRUE, 0); - - gtk_widget_show_all (warning_dialog); - - response = gtk_dialog_run (GTK_DIALOG (warning_dialog)); - - if (response != GTK_RESPONSE_CANCEL) - flags = flags|(1<<1); - - skip = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)); - if (skip) - flags = flags|(1<<2); - - gtk_widget_destroy (warning_dialog); - - return flags; -} - static void open_uris (gchar **uris) { @@ -370,32 +302,6 @@ idle_cb (gchar **uris) open_uris (uris); else { EShellWindow *shell_window; - GConfClient *client = gconf_client_get_default (); - - if (gconf_client_get_bool (client, RECOVERY_KEY, NULL) && e_file_lock_exists ()) { - /* It should have crashed last time or a force-shutdown */ - gboolean skip = gconf_client_get_bool (client, SKIP_RECOVERY_DIALOG_KEY, NULL); - gboolean recover = TRUE; - if (!skip){ - int flags = show_recovery_warning (); - - gconf_client_set_bool (client, SKIP_RECOVERY_DIALOG_KEY, (flags & (1<<2)) ? TRUE : FALSE, NULL); - recover = (flags & (1<<1)) ? TRUE: FALSE; - } - - if (recover) { - /* Disable the previews */ - gconf_client_set_bool (client, "/apps/evolution/mail/display/show_preview", FALSE, NULL); - gconf_client_set_bool (client, "/apps/evolution/mail/display/safe_list", TRUE, NULL); - gconf_client_set_bool (client, "/apps/evolution/addressbook/display/show_preview", FALSE, NULL); - gconf_client_set_bool (client, "/apps/evolution/calendar/display/show_task_preview", FALSE, NULL); - } - /* Let us not delete and recreate a lock, instead reuse it. We don't use timestamps anyways */ - } else { - /* What great can we do, if lock creation fails ?*/ - e_file_lock_create (); - } - g_object_unref (client); shell_window = e_shell_create_window (); /* XXX Switch to default_component_id. */ @@ -710,5 +616,9 @@ main (int argc, char **argv) #ifdef G_OS_WIN32 link_shutdown (); #endif + + /* Indicates a clean shut down to the next session. */ + e_file_lock_destroy (); + return 0; } -- cgit v1.2.3