From 7cfacb2f84e3189bed138326e788ea09bdb25eb8 Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Thu, 3 May 2001 23:03:18 +0000 Subject: Initial implementation for the "warning, some connections are still active" dialog. svn path=/trunk/; revision=9661 --- shell/ChangeLog | 43 +++++++ shell/e-shell-offline-handler.c | 174 +++++++++++++++++++++++++- shell/e-shell-view-menu.c | 33 ++++- shell/e-shell-view.c | 21 +++- shell/e-shell.c | 88 +++++++++++-- shell/e-shell.h | 17 ++- shell/glade/Makefile.am | 4 +- shell/glade/e-active-connection-dialog.glade | 179 +++++++++++++++++++++++++++ 8 files changed, 537 insertions(+), 22 deletions(-) create mode 100644 shell/glade/e-active-connection-dialog.glade (limited to 'shell') diff --git a/shell/ChangeLog b/shell/ChangeLog index cf928b274b..15540ce9f8 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,46 @@ +2001-05-03 Ettore Perazzoli + + * e-shell-offline-handler.c: New member `dialog_gui' in + `EShellOfflineHandlerPrivate'. + (impl_destroy): Unref here if not NULL. + (init): Init to NULL. + (update_dialog_clist_hash_foreach): New. + (update_dialog_clist): New. + (dialog_clicked_cb): New, callback for the "clicked" signal on the + active connection dialog. + (pop_up_confirmation_dialog): Implemented. + (init): Init `procedure_in_progress' to `FALSE' instead of `TRUE'. + (cancel_offline): Emit `offline_procedure_finished'. + (impl_OfflineProgressListener_updateProgress): Call + `update_dialog_clist()'. + + * glade/e-active-connection-dialog.glade: New. + + * e-shell-view-menu.c: Update to use the `WorkOffline' verb + instead of the `WorkOffLine' one. + (command_work_offline): New, temporary implementation for the + "WorkOffline" verb. + + * e-shell-view.c (shell_line_status_changed_cb): New, callback for + the shell's `line_status_changed' signal. + (e_shell_view_construct): Connect it. + + * e-shell.c: New member `line_status' in `EShellPrivate'. + (init): Init to `E_SHELL_LINE_STATUS_ONLINE'. + (class_init): Set up the `line_status_changed' signal. + (e_shell_is_offline): Removed. + (e_shell_get_line_status): New. + (e_shell_go_online): Set the `line_status' member to + `E_SHELL_LINE_STATUS_ONLINE' and emit `line_status_changed'. + (offline_procedure_started_cb): New, signal for the + `offline_procedure_started' signal in EShellOfflineHandler. + (offline_procedure_finished_cb): New, signal for the + `offline_procedure_finished' signal in EShellOfflineHandler. + (e_shell_go_offline): Implemented. + + * e-shell.h: New enum `EShellLineStatus'. New signal + `line_status_changed'. + 2001-05-03 Ettore Perazzoli * e-shell-offline-handler.c (e_shell_offline_handler_construct): diff --git a/shell/e-shell-offline-handler.c b/shell/e-shell-offline-handler.c index 9b591f5ef2..4a6ea1bb64 100644 --- a/shell/e-shell-offline-handler.c +++ b/shell/e-shell-offline-handler.c @@ -28,13 +28,22 @@ #include #include #include +#include #include +#include +#include + +#include + #include #include "e-shell-offline-handler.h" + +#define GLADE_DIALOG_FILE_NAME EVOLUTION_GLADEDIR "/e-active-connection-dialog.glade" + #define PARENT_TYPE GTK_TYPE_OBJECT static GtkObjectClass *parent_class = NULL; @@ -76,6 +85,8 @@ struct _EShellOfflineHandlerPrivate { EShellView *parent_shell_view; + GladeXML *dialog_gui; + int num_total_connections; GHashTable *id_to_component_info; @@ -93,6 +104,11 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; + +/* Forward declarations for the dialog handling. */ + +static void update_dialog_clist (EShellOfflineHandler *offline_handler); + /* Implementation for the OfflineProgressListener interface. */ @@ -178,7 +194,7 @@ impl_OfflineProgressListener_updateProgress (PortableServer_Servant servant, if (priv->num_total_connections == 0) gtk_signal_emit (GTK_OBJECT (offline_handler), signals[OFFLINE_PROCEDURE_FINISHED], TRUE); - /* TODO: update the dialog. */ + update_dialog_clist (offline_handler); } static gboolean @@ -335,6 +351,8 @@ cancel_offline (EShellOfflineHandler *offline_handler) e_free_string_list (component_ids); priv->num_total_connections = 0; + + gtk_signal_emit (GTK_OBJECT (offline_handler), signals[OFFLINE_PROCEDURE_FINISHED], FALSE); } @@ -472,17 +490,147 @@ finalize_offline (EShellOfflineHandler *offline_handler) /* The confirmation dialog. */ static void -pop_up_confirmation_dialog (EShellOfflineHandler *offline_handler) +update_dialog_clist_hash_foreach (void *key, + void *data, + void *user_data) +{ + ComponentInfo *component_info; + const GNOME_Evolution_Connection *p; + GtkWidget *clist; + int i; + + clist = GTK_WIDGET (user_data); + + component_info = (ComponentInfo *) data; + for (i = 0, p = component_info->active_connection_list->_buffer; + i < component_info->active_connection_list->_length; + i++, p++) { + char *columns[3]; + + columns[0] = p->hostName; + columns[1] = g_strdup_printf ("%d", p->portNumber); + columns[2] = NULL; + + gtk_clist_prepend (GTK_CLIST (clist), columns); + + g_free (columns[1]); + } +} + +static void +update_dialog_clist (EShellOfflineHandler *offline_handler) +{ + EShellOfflineHandlerPrivate *priv; + GtkWidget *clist; + + priv = offline_handler->priv; + + clist = glade_xml_get_widget (priv->dialog_gui, "active_connection_clist"); + + gtk_clist_set_auto_sort (GTK_CLIST (clist), TRUE); + + gtk_clist_freeze (GTK_CLIST (clist)); + + /* Populate the GtkCList. */ + gtk_clist_clear (GTK_CLIST (clist)); + g_hash_table_foreach (priv->id_to_component_info, update_dialog_clist_hash_foreach, clist); + + gtk_clist_thaw (GTK_CLIST (clist)); +} + +static void +dialog_handle_ok (GnomeDialog *dialog, + EShellOfflineHandler *offline_handler) { EShellOfflineHandlerPrivate *priv; + GtkWidget *instruction_label; priv = offline_handler->priv; - g_warning ("Should pop up dialog here"); + gnome_dialog_set_sensitive (dialog, 0, FALSE); + + instruction_label = glade_xml_get_widget (priv->dialog_gui, "instruction_label"); + g_assert (instruction_label != NULL); + g_assert (GTK_IS_LABEL (instruction_label)); + + gtk_label_set_text (GTK_LABEL (instruction_label), _("Closing connections...")); finalize_offline (offline_handler); } +static void +dialog_handle_cancel (GnomeDialog *dialog, + EShellOfflineHandler *offline_handler) +{ + EShellOfflineHandlerPrivate *priv; + + priv = offline_handler->priv; + + gtk_widget_destroy (GTK_WIDGET (dialog)); + + gtk_object_unref (GTK_OBJECT (priv->dialog_gui)); + priv->dialog_gui = NULL; + + cancel_offline (offline_handler); +} + +static void +dialog_clicked_cb (GnomeDialog *dialog, + int button_number, + void *data) +{ + EShellOfflineHandler *offline_handler; + + offline_handler = E_SHELL_OFFLINE_HANDLER (data); + + switch (button_number) { + case 0: /* OK */ + dialog_handle_ok (dialog, offline_handler); + break; + + case 1: /* Cancel */ + dialog_handle_cancel (dialog, offline_handler); + break; + + default: + g_assert_not_reached (); + } +} + +static void +pop_up_confirmation_dialog (EShellOfflineHandler *offline_handler) +{ + EShellOfflineHandlerPrivate *priv; + GtkWidget *dialog; + + priv = offline_handler->priv; + + if (priv->dialog_gui == NULL) { + priv->dialog_gui = glade_xml_new (GLADE_DIALOG_FILE_NAME, NULL); + if (priv->dialog_gui == NULL) { + g_warning ("Cannot load the active connection dialog (installation problem?) -- %s", + GLADE_DIALOG_FILE_NAME); + finalize_offline (offline_handler); + return; + } + } + + dialog = glade_xml_get_widget (priv->dialog_gui, "active_connection_dialog"); + + /* FIXME: do we really want this? */ + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (priv->parent_shell_view)); + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + gnome_dialog_set_default (GNOME_DIALOG (dialog), 1); + + update_dialog_clist (offline_handler); + + gtk_signal_connect (GTK_OBJECT (dialog), "clicked", + GTK_SIGNAL_FUNC (dialog_clicked_cb), offline_handler); + + gtk_widget_show (dialog); +} + /* GtkObject methods. */ @@ -501,6 +649,16 @@ impl_destroy (GtkObject *object) g_hash_table_foreach (priv->id_to_component_info, hash_foreach_free_component_info, NULL); g_hash_table_destroy (priv->id_to_component_info); + if (priv->dialog_gui != NULL) { + GtkWidget *dialog; + + dialog = glade_xml_get_widget (priv->dialog_gui, "active_connection_dialog"); + gtk_widget_destroy (dialog); + + gtk_object_unref (GTK_OBJECT (priv->dialog_gui)); + priv->dialog_gui = NULL; + } + if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -548,11 +706,14 @@ init (EShellOfflineHandler *shell_offline_handler) priv->component_registry = NULL; priv->parent_shell_view = NULL; - priv->procedure_in_progress = TRUE; + + priv->dialog_gui = NULL; priv->num_total_connections = 0; priv->id_to_component_info = g_hash_table_new (g_str_hash, g_str_equal); + priv->procedure_in_progress = FALSE; + shell_offline_handler->priv = priv; } @@ -576,6 +737,8 @@ e_shell_offline_handler_construct (EShellOfflineHandler *offline_handler, g_return_if_fail (component_registry != NULL); g_return_if_fail (E_IS_COMPONENT_REGISTRY (component_registry)); + priv = offline_handler->priv; + g_assert (priv->component_registry == NULL); GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (offline_handler), GTK_FLOATING); @@ -638,6 +801,9 @@ e_shell_offline_handler_put_components_offline (EShellOfflineHandler *offline_ha return; } + pop_up_confirmation_dialog (offline_handler); + return; + if (priv->num_total_connections == 0 && priv->parent_shell_view != NULL) pop_up_confirmation_dialog (offline_handler); else diff --git a/shell/e-shell-view-menu.c b/shell/e-shell-view-menu.c index a84a913051..1c4def05c5 100644 --- a/shell/e-shell-view-menu.c +++ b/shell/e-shell-view-menu.c @@ -417,6 +417,35 @@ command_xml_dump (gpointer dummy, bonobo_window_dump (BONOBO_WINDOW (view), "On demand"); } + +static void +command_work_offline (BonoboUIComponent *uih, + void *data, + const char *path) +{ + EShellView *shell_view; + EShell *shell; + + shell_view = E_SHELL_VIEW (data); + shell = e_shell_view_get_shell (shell_view); + + switch (e_shell_get_line_status (shell)) { + case E_SHELL_LINE_STATUS_ONLINE: + g_warning ("Putting the shell offline"); + e_shell_go_offline (shell, shell_view); + break; + case E_SHELL_LINE_STATUS_OFFLINE: + g_warning ("Putting the shell online"); + e_shell_go_online (shell, shell_view); + break; + case E_SHELL_LINE_STATUS_GOING_OFFLINE: + g_warning ("The shell is going off-line already; not doing anything."); + break; + default: + g_assert_not_reached (); + } +} + /* Unimplemented commands. */ @@ -468,6 +497,8 @@ BonoboUIVerb file_verbs [] = { BONOBO_UI_VERB ("FileClose", command_close), BONOBO_UI_VERB ("FileExit", command_quit), + BONOBO_UI_VERB ("WorkOffline", command_work_offline), + BONOBO_UI_VERB_END }; @@ -485,7 +516,7 @@ static EPixmap pixmaps [] = { E_PIXMAP ("/menu/File/New/Folder", "folder.xpm"), E_PIXMAP ("/menu/File/Folder/Folder", "folder.xpm"), E_PIXMAP ("/menu/File/FileImporter", "import.xpm"), - E_PIXMAP ("/menu/File/WorkOffLine", "work_offline.xpm"), + E_PIXMAP ("/menu/File/WorkOffline", "work_offline.xpm"), E_PIXMAP_END }; diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index bc8dd1531d..f96daac3dc 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -170,6 +170,23 @@ bonobo_widget_is_dead (BonoboWidget *bonobo_widget) return is_dead; } + +/* Shell signal handling. */ + +static void +shell_line_status_changed_cb (EShell *shell, + EShellLineStatus new_status, + void *data) +{ + EShellView *shell_view; + EShellViewPrivate *priv; + + shell_view = E_SHELL_VIEW (data); + priv = shell_view->priv; + + g_warning ("Shell status changed -- %d", new_status); +} + /* Folder bar pop-up handling. */ @@ -1020,13 +1037,15 @@ e_shell_view_construct (EShellView *shell_view, bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (BONOBO_WINDOW (shell_view)), "/evolution/UIConf/kvps"); - e_shell_view_menu_setup (shell_view); e_shell_view_set_folder_bar_mode (shell_view, E_SHELL_VIEW_SUBWINDOW_HIDDEN); bonobo_ui_component_thaw (priv->ui_component, NULL); + gtk_signal_connect (GTK_OBJECT (shell), "line_status_changed", + GTK_SIGNAL_FUNC (shell_line_status_changed_cb), view); + return view; } diff --git a/shell/e-shell.c b/shell/e-shell.c index c2c5f39893..e94b1e2cbe 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -82,8 +82,8 @@ struct _EShellPrivate { /* Names for the types of the folders that have maybe crashed. */ GList *crash_type_names; /* char * */ - /* Whether the shell is off-line or not. */ - guint is_offline : 1; + /* Line status. */ + EShellLineStatus line_status; }; @@ -97,6 +97,7 @@ struct _EShellPrivate { enum { NO_VIEWS_LEFT, + LINE_STATUS_CHANGED, LAST_SIGNAL }; @@ -671,6 +672,15 @@ class_init (EShellClass *klass) gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); + signals[LINE_STATUS_CHANGED] = + gtk_signal_new ("line_status_changed", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EShellClass, line_status_changed), + gtk_marshal_NONE__ENUM, + GTK_TYPE_NONE, 1, + GTK_TYPE_ENUM); + gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); corba_class_init (); @@ -694,7 +704,7 @@ init (EShell *shell) priv->corba_storage_registry = NULL; priv->offline_handler = NULL; priv->crash_type_names = NULL; - priv->is_offline = FALSE; + priv->line_status = E_SHELL_LINE_STATUS_ONLINE; shell->priv = priv; } @@ -1271,22 +1281,59 @@ e_shell_component_maybe_crashed (EShell *shell, } +/* 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; + gtk_signal_emit (GTK_OBJECT (shell), signals[LINE_STATUS_CHANGED], 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; + + gtk_object_unref (GTK_OBJECT (priv->offline_handler)); + priv->offline_handler = NULL; + + gtk_signal_emit (GTK_OBJECT (shell), signals[LINE_STATUS_CHANGED], priv->line_status); +} + /** - * e_shell_is_offline: + * e_shell_get_line_status: * @shell: A pointer to an EShell object. * - * Return whether @shell is working in off-line mode. + * Get the line status for @shell. * - * Return value: %TRUE if the @shell is working in off-line mode, %FALSE - * otherwise. + * Return value: The current line status for @shell. **/ -gboolean -e_shell_is_offline (EShell *shell) +EShellLineStatus +e_shell_get_line_status (EShell *shell) { - g_return_val_if_fail (shell != NULL, FALSE); - g_return_val_if_fail (E_IS_SHELL (shell), FALSE); + g_return_val_if_fail (shell != NULL, E_SHELL_LINE_STATUS_OFFLINE); + g_return_val_if_fail (E_IS_SHELL (shell), E_SHELL_LINE_STATUS_OFFLINE); - return shell->priv->is_offline; + return shell->priv->line_status; } /** @@ -1308,6 +1355,20 @@ e_shell_go_offline (EShell *shell, g_return_if_fail (action_view == NULL || E_IS_SHELL_VIEW (action_view)); priv = shell->priv; + + if (priv->line_status != E_SHELL_LINE_STATUS_ONLINE) + return; + + g_assert (priv->offline_handler == NULL); + + priv->offline_handler = e_shell_offline_handler_new (priv->component_registry); + + gtk_signal_connect (GTK_OBJECT (priv->offline_handler), "offline_procedure_started", + GTK_SIGNAL_FUNC (offline_procedure_started_cb), shell); + gtk_signal_connect (GTK_OBJECT (priv->offline_handler), "offline_procedure_finished", + GTK_SIGNAL_FUNC (offline_procedure_finished_cb), shell); + + e_shell_offline_handler_put_components_offline (priv->offline_handler, action_view); } /** @@ -1359,6 +1420,9 @@ e_shell_go_online (EShell *shell, } e_free_string_list (component_ids); + + priv->line_status = E_SHELL_LINE_STATUS_ONLINE; + gtk_signal_emit (GTK_OBJECT (shell), signals[LINE_STATUS_CHANGED], priv->line_status); } diff --git a/shell/e-shell.h b/shell/e-shell.h index b3226b50d6..674ce24148 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -49,6 +49,13 @@ typedef struct _EShellClass EShellClass; #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, + E_SHELL_LINE_STATUS_OFFLINE +}; +typedef enum _EShellLineStatus EShellLineStatus; + struct _EShell { BonoboObject parent; @@ -59,6 +66,8 @@ struct _EShellClass { BonoboObjectClass parent_class; void (* no_views_left) (EShell *shell); + + void (* line_status_changed) (EShell *shell, EShellLineStatus status); }; @@ -94,9 +103,11 @@ void e_shell_component_maybe_crashed (EShell *shell, const char *type_name, EShellView *shell_view); -gboolean e_shell_is_offline (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, + EShellView *action_view); +void e_shell_go_online (EShell *shell, + EShellView *action_view); #ifdef __cplusplus } diff --git a/shell/glade/Makefile.am b/shell/glade/Makefile.am index 9ef3238360..9a29a07b2c 100644 --- a/shell/glade/Makefile.am +++ b/shell/glade/Makefile.am @@ -1,5 +1,7 @@ gladedir = $(datadir)/evolution/glade -glade_DATA = e-shell-folder-creation-dialog.glade +glade_DATA = \ + e-active-connection-dialog.glade \ + e-shell-folder-creation-dialog.glade EXTRA_DIST = $(glade_DATA) diff --git a/shell/glade/e-active-connection-dialog.glade b/shell/glade/e-active-connection-dialog.glade new file mode 100644 index 0000000000..16cb88cf81 --- /dev/null +++ b/shell/glade/e-active-connection-dialog.glade @@ -0,0 +1,179 @@ + + + + + e-active-connection-dialog + + src + pixmaps + C + True + True + + + + GnomeDialog + active_connection_dialog + Active connections + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + False + False + + + GtkVBox + GnomeDialog:vbox + dialog-vbox1 + False + 0 + + 0 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + ok_button + True + True + GNOME_STOCK_BUTTON_OK + + + + GtkButton + cancel_button + True + True + GNOME_STOCK_BUTTON_CANCEL + + + + + GtkVBox + vbox1 + False + 0 + + 0 + True + True + + + + GtkLabel + label1 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 10 + False + False + + + + + GtkScrolledWindow + scrolledwindow1 + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkCList + active_connection_clist + 250 + True + 2 + 154,80 + GTK_SELECTION_BROWSE + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + label2 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkEventBox + CList:title + eventbox1 + + + GtkLabel + CList:title + label3 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + + GtkLabel + instruction_label + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 10 + False + False + + + + + + + -- cgit v1.2.3