+ /* Account description */
+ if (!strcmp (tny_account_get_id (account), MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
+ gchar *device_name;
+
+ /* Get device name */
+ device_name = modest_conf_get_string (modest_runtime_get_conf(),
+ MODEST_CONF_DEVICE_NAME, NULL);
+
+ label = g_strdup_printf ("%s: %s",
+ _("mcen_fi_localroot_description"),
+ device_name);
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+ g_free (device_name);
+ g_free (label);
+ } else if (!strcmp (tny_account_get_id (account), MODEST_MMC_ACCOUNT_ID)) {
+ /* TODO: MMC ? */
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("FIXME: MMC ?"), FALSE, FALSE, 0);
+ } else {
+ GString *proto;
+
+ /* Put proto in uppercase */
+ proto = g_string_new (tny_account_get_proto (account));
+ proto = g_string_ascii_up (proto);
+
+ label = g_strdup_printf ("%s %s: %s",
+ proto->str,
+ _("mcen_fi_remoteroot_account"),
+ tny_account_get_name (account));
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+ g_string_free (proto, TRUE);
+ g_free (label);
+ }
+
+ /* Message count */
+ label = g_strdup_printf ("%s: %d", _("mcen_fi_rootfolder_messages"),
+ modest_tny_account_get_message_count (account));
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+ g_free (label);
+
+ /* Folder count */
+ label = g_strdup_printf ("%s: %d", _("mcen_fi_rootfolder_folders"),
+ modest_tny_account_get_folder_count (account));
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+ g_free (label);
+
+ /* Size / Date */
+ if (!strcmp (tny_account_get_id (account), MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
+ /* FIXME: format size */
+ label = g_strdup_printf ("%s: %d", _("mcen_fi_rootfolder_size"),
+ modest_tny_account_get_local_size (account));
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+ g_free (label);
+ } else if (!strcmp (tny_account_get_id (account), MODEST_MMC_ACCOUNT_ID)) {
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("FIXME: MMC ?"), FALSE, FALSE, 0);
+ } else {
+ label = g_strdup_printf ("%s: %s", _("mcen_ti_lastupdated"), "08/08/08");
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+ g_free (label);
+ }
+
+ /* Set alignment */
+ gtk_container_foreach (GTK_CONTAINER (vbox), (GtkCallback) set_alignment, NULL);
+
+ return vbox;
+}
+
+void
+modest_main_window_set_contents_style (ModestMainWindow *self,
+ ModestMainWindowContentsStyle style)
+{
+ ModestMainWindowPrivate *priv;
+ GtkWidget *content;
+ TnyAccount *account;
+
+ g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ /* We allow to set the same content style than the previously
+ set if there are details, because it could happen when we're
+ selecting different accounts consecutively */
+ if ((priv->contents_style == style) &&
+ (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS))
+ return;
+
+ /* Remove previous child. Delete it if it was an account
+ details widget */
+ content = gtk_bin_get_child (GTK_BIN (priv->contents_widget));
+ if (priv->contents_style != MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS)
+ g_object_ref (content);
+ gtk_container_remove (GTK_CONTAINER (priv->contents_widget), content);
+
+ priv->contents_style = style;
+
+ switch (priv->contents_style) {
+ case MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS:
+ wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET (priv->header_view));
+ break;
+ case MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS:
+ /* TODO: show here account details */
+ account = TNY_ACCOUNT (modest_folder_view_get_selected (priv->folder_view));
+ priv->details_widget = create_details_widget (account);
+
+ wrap_in_scrolled_window (priv->contents_widget,
+ priv->details_widget);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+
+ /* Show */
+ gtk_widget_show_all (priv->contents_widget);
+}
+
+static void
+on_configuration_key_changed (ModestConf* conf,
+ const gchar *key,
+ ModestConfEvent event,
+ ModestMainWindow *self)
+{
+ ModestMainWindowPrivate *priv;
+ TnyAccount *account;
+
+ if (!key || strcmp (key, MODEST_CONF_DEVICE_NAME))
+ return;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ if (priv->contents_style != MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS)
+ return;
+
+ account = (TnyAccount *) modest_folder_view_get_selected (priv->folder_view);
+ if (TNY_IS_ACCOUNT (account) &&
+ !strcmp (tny_account_get_id (account), MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
+ GList *children;
+ GtkLabel *label;
+ const gchar *device_name;
+ gchar *new_text;
+
+ /* Get label */
+ children = gtk_container_get_children (GTK_CONTAINER (priv->details_widget));
+ label = GTK_LABEL (children->data);
+
+ device_name = modest_conf_get_string (modest_runtime_get_conf(),
+ MODEST_CONF_DEVICE_NAME, NULL);
+
+ new_text = g_strdup_printf ("%s: %s",
+ _("mcen_fi_localroot_description"),
+ device_name);
+
+ gtk_label_set_text (label, new_text);
+ gtk_widget_show (GTK_WIDGET (label));
+
+ g_free (new_text);
+ g_list_free (children);
+ }
+}
+
+static void
+set_toolbar_mode (ModestMainWindow *self,
+ ModestToolBarModes mode)
+{
+ ModestWindowPrivate *parent_priv;
+ ModestMainWindowPrivate *priv;
+ GtkAction *sort_action, *refresh_action, *cancel_action;
+
+ g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
+
+ parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ sort_action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ToolbarSort");
+ refresh_action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ToolbarSendReceive");
+ cancel_action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ToolbarCancel");
+
+ /* Sets current toolbar mode */
+ priv->current_toolbar_mode = mode;
+
+ /* Show and hide toolbar items */
+ switch (mode) {
+ case TOOLBAR_MODE_NORMAL:
+ if (sort_action)
+ gtk_action_set_visible (sort_action, TRUE);
+ if (refresh_action)
+ gtk_action_set_visible (refresh_action, TRUE);
+ if (priv->progress_toolitem) {
+ gtk_tool_item_set_expand (GTK_TOOL_ITEM (priv->progress_toolitem), FALSE);
+ gtk_widget_hide (priv->progress_toolitem);
+ }
+ if (priv->progress_bar)
+ gtk_widget_hide (priv->progress_bar);
+
+ if (cancel_action)
+ gtk_action_set_visible (cancel_action, FALSE);
+ break;
+ case TOOLBAR_MODE_TRANSFER:
+ if (sort_action)
+ gtk_action_set_visible (sort_action, FALSE);
+ if (refresh_action)
+ gtk_action_set_visible (refresh_action, FALSE);
+ if (cancel_action)
+ gtk_action_set_visible (cancel_action, TRUE);
+ if (priv->progress_toolitem) {
+ gtk_tool_item_set_expand (GTK_TOOL_ITEM (priv->progress_toolitem), TRUE);
+ gtk_widget_show (priv->progress_toolitem);
+ }
+ if (priv->progress_bar)
+ gtk_widget_show (priv->progress_bar);
+ break;
+ default:
+ g_return_if_reached ();
+ }
+
+ gtk_widget_show_all (GTK_WIDGET (self));
+}
+
+static void
+cancel_progressbar (GtkToolButton *toolbutton,
+ ModestMainWindow *self)
+{
+ GSList *tmp;
+ ModestMainWindowPrivate *priv;