GdkEvent *event,
gpointer userdata);
static void update_progress_hint (ModestFolderWindow *self);
+static void on_queue_changed (ModestMailOperationQueue *queue,
+ ModestMailOperation *mail_op,
+ ModestMailOperationQueueNotification type,
+ ModestFolderWindow *self);
typedef struct _ModestFolderWindowPrivate ModestFolderWindowPrivate;
struct _ModestFolderWindowPrivate {
gchar *current_store_account;
gboolean progress_hint;
+ guint queue_change_handler;
};
#define MODEST_FOLDER_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_FOLDER_WINDOW, \
"applications_email_folderview");
priv->progress_hint = FALSE;
priv->current_store_account = NULL;
+ priv->queue_change_handler = 0;
}
static void
ModestFolderWindowPrivate *priv;
priv = MODEST_FOLDER_WINDOW_GET_PRIVATE(self);
+ if (g_signal_handler_is_connected (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
+ priv->queue_change_handler))
+ g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
+ priv->queue_change_handler);
+
modest_signal_mgr_disconnect_all_and_destroy (priv->sighandlers);
priv->sighandlers = NULL;
}
account_id);
if (acc) {
const gchar *name;
+ const gchar *mailbox;
gchar *title = NULL;
+ ModestFolderWindowPrivate *priv;
+
+ priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (user_data);
- name = modest_tny_account_get_parent_modest_account_name_for_server_account (acc);
- title = modest_account_mgr_get_display_name (modest_runtime_get_account_mgr(),
- name);
+ mailbox = modest_folder_view_get_mailbox (MODEST_FOLDER_VIEW (priv->folder_view));
+ if (mailbox) {
+ title = g_strdup (mailbox);
+ } else {
+ name = modest_tny_account_get_parent_modest_account_name_for_server_account (acc);
+ title = modest_account_mgr_get_display_name (modest_runtime_get_account_mgr(),
+ name);
+ }
if (title) {
gtk_window_set_title (GTK_WINDOW (user_data), title);
g_free (title);
GtkWidget *pannable;
GtkWidget *action_area_box;
GdkPixbuf *new_message_pixbuf;
+ guint accel_key;
+ GdkModifierType accel_mods;
+ GtkAccelGroup *accel_group;
+ GtkWidget *top_alignment;
self = MODEST_FOLDER_WINDOW(g_object_new(MODEST_TYPE_FOLDER_WINDOW, NULL));
priv = MODEST_FOLDER_WINDOW_GET_PRIVATE(self);
pannable = hildon_pannable_area_new ();
+
+ priv->queue_change_handler =
+ g_signal_connect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
+ "queue-changed",
+ G_CALLBACK (on_queue_changed),
+ self);
+
priv->folder_view = modest_platform_create_folder_view (query);
modest_folder_view_set_cell_style (MODEST_FOLDER_VIEW (priv->folder_view),
MODEST_FOLDER_VIEW_CELL_STYLE_COMPACT);
TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
priv->top_vbox = gtk_vbox_new (0, FALSE);
+ top_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (top_alignment),
+ 0, 0,
+ HILDON_MARGIN_DOUBLE, HILDON_MARGIN_DOUBLE);
gtk_container_add (GTK_CONTAINER (pannable), priv->folder_view);
- gtk_box_pack_end (GTK_BOX (priv->top_vbox), pannable, TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (top_alignment), pannable);
+ gtk_box_pack_end (GTK_BOX (priv->top_vbox), top_alignment, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (self), priv->top_vbox);
gtk_widget_show (priv->folder_view);
gtk_widget_show (pannable);
gtk_widget_show (priv->top_vbox);
+ gtk_widget_show (top_alignment);
connect_signals (MODEST_FOLDER_WINDOW (self));
G_OBJECT (self));
update_progress_hint (self);
+ accel_group = gtk_accel_group_new ();
+ gtk_accelerator_parse ("<Control>n", &accel_key, &accel_mods);
+ gtk_widget_add_accelerator (priv->new_message_button, "clicked", accel_group,
+ accel_key, accel_mods, 0);
+ gtk_window_add_accel_group (GTK_WINDOW (self), accel_group);
+
return MODEST_WINDOW(self);
}
}
+void
+modest_folder_window_set_mailbox (ModestFolderWindow *self,
+ const gchar *mailbox)
+{
+ ModestFolderWindowPrivate *priv = NULL;
+
+ g_return_if_fail (MODEST_IS_FOLDER_WINDOW(self));
+ priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (self);
+
+ modest_folder_view_set_mailbox (MODEST_FOLDER_VIEW (priv->folder_view), mailbox);
+
+}
+
static void
setup_menu (ModestFolderWindow *self)
{
modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
APP_MENU_CALLBACK (modest_ui_actions_cancel_send),
MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
- /* new message */
- modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self),
- _("mcen_me_new_message"),
- "<Ctrl>n",
- APP_MENU_CALLBACK (modest_ui_actions_on_new_msg),
- NULL);
-
}
static void
return FALSE;
}
+static gboolean
+has_active_operations (ModestFolderWindow *self)
+{
+ GSList *operations = NULL, *node;
+ ModestMailOperationQueue *queue;
+ gboolean has_active = FALSE;
+
+ queue = modest_runtime_get_mail_operation_queue ();
+ operations = modest_mail_operation_queue_get_by_source (queue, G_OBJECT (self));
+
+ for (node = operations; node != NULL; node = g_slist_next (node)) {
+ if (!modest_mail_operation_is_finished (MODEST_MAIL_OPERATION (node->data))) {
+ has_active = TRUE;
+ break;
+ }
+ }
+
+ if (operations) {
+ g_slist_foreach (operations, (GFunc) g_object_unref, NULL);
+ g_slist_free (operations);
+ }
+
+ return has_active;
+}
+
static void
update_progress_hint (ModestFolderWindow *self)
{
ModestFolderWindowPrivate *priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (self);
- if (!priv->current_store_account)
- return;
+ if (has_active_operations (self)) {
+ priv->progress_hint = TRUE;
+ }
+
+ if (!priv->progress_hint && priv->current_store_account) {
+ priv->progress_hint = modest_window_mgr_has_progress_operation_on_account (modest_runtime_get_window_mgr (),
+ priv->current_store_account);
+ }
- priv->progress_hint = modest_window_mgr_has_progress_operation_on_account (modest_runtime_get_window_mgr (),
- priv->current_store_account);
+ modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
if (GTK_WIDGET_VISIBLE (self)) {
hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), priv->progress_hint ? 1:0);
return priv->progress_hint;
}
+
+static void
+on_mail_operation_started (ModestMailOperation *mail_op,
+ gpointer user_data)
+{
+ ModestFolderWindow *self;
+ ModestMailOperationTypeOperation op_type;
+ GObject *source = NULL;
+
+ self = MODEST_FOLDER_WINDOW (user_data);
+ op_type = modest_mail_operation_get_type_operation (mail_op);
+ source = modest_mail_operation_get_source(mail_op);
+ if (G_OBJECT (self) == source) {
+ update_progress_hint (self);
+ }
+ g_object_unref (source);
+}
+
+static void
+on_mail_operation_finished (ModestMailOperation *mail_op,
+ gpointer user_data)
+{
+ ModestFolderWindow *self;
+
+ self = MODEST_FOLDER_WINDOW (user_data);
+
+ /* Don't disable the progress hint if there are more pending
+ operations from this window */
+ update_progress_hint (self);
+
+ modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
+}
+
+static void
+on_queue_changed (ModestMailOperationQueue *queue,
+ ModestMailOperation *mail_op,
+ ModestMailOperationQueueNotification type,
+ ModestFolderWindow *self)
+{
+ ModestFolderWindowPrivate *priv;
+
+ priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (self);
+
+ /* If this operations was created by another window, do nothing */
+ if (!modest_mail_operation_is_mine (mail_op, G_OBJECT(self)))
+ return;
+
+ if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_ADDED) {
+ priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+ G_OBJECT (mail_op),
+ "operation-started",
+ G_CALLBACK (on_mail_operation_started),
+ self);
+ priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+ G_OBJECT (mail_op),
+ "operation-finished",
+ G_CALLBACK (on_mail_operation_finished),
+ self);
+ } else if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED) {
+ priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
+ G_OBJECT (mail_op),
+ "operation-started");
+ priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
+ G_OBJECT (mail_op),
+ "operation-finished");
+ }
+}
+