static void modest_folder_view_class_init (ModestFolderViewClass *klass);
static void modest_folder_view_init (ModestFolderView *obj);
static void modest_folder_view_finalize (GObject *obj);
+static void modest_folder_view_dispose (GObject *obj);
static void tny_account_store_view_init (gpointer g,
gpointer iface_data);
ModestConfNotificationId notification_id,
ModestFolderView *self);
+#ifndef MODEST_TOOLKIT_HILDON2
/* DnD functions */
static void on_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
guint time,
gpointer user_data);
-static void expand_root_items (ModestFolderView *self);
+static void setup_drag_and_drop (GtkTreeView *self);
+
+static void on_row_inserted_maybe_select_folder (GtkTreeModel *tree_model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ ModestFolderView *self);
static gint expand_row_timeout (gpointer data);
+#endif
-static void setup_drag_and_drop (GtkTreeView *self);
+static void expand_root_items (ModestFolderView *self);
static gboolean _clipboard_set_selected_data (ModestFolderView *folder_view,
gboolean delete);
static void _clear_hidding_filter (ModestFolderView *folder_view);
-#ifndef MODEST_TOOLKIT_HILDON2
-static void on_row_inserted_maybe_select_folder (GtkTreeModel *tree_model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- ModestFolderView *self);
-#endif
-
static void on_display_name_changed (ModestAccountMgr *self,
const gchar *account,
gpointer user_data);
GtkTreeModel **sort_model,
GtkTreeModel **tny_model);
#ifdef MODEST_TOOLKIT_HILDON2
-static void
-on_activity_changed (TnyGtkFolderListStore *store,
- gboolean activity,
- ModestFolderView *folder_view);
+static void on_activity_changed (TnyGtkFolderListStore *store,
+ gboolean activity,
+ ModestFolderView *folder_view);
#endif
enum {
ModestFolderViewFilter filter;
TnyFolderStoreQuery *query;
+ gboolean do_refresh;
guint timer_expander;
gchar *local_account_name;
gulong outbox_deleted_handler;
- guint activity_changed_handler;
+ GSList *signal_handlers;
+ GdkColor active_color;
};
#define MODEST_FOLDER_VIEW_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), \
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = modest_folder_view_finalize;
+ gobject_class->dispose = modest_folder_view_dispose;
g_type_class_add_private (gobject_class,
sizeof(ModestFolderViewPrivate));
convert_parent_folders_to_dots (gchar **item_name)
{
gint n_parents = 0;
+ gint n_inbox_parents = 0;
gchar *c;
+ gchar *path_start;
gchar *last_separator;
if (item_name == NULL)
return;
+ path_start = *item_name;
for (c = *item_name; *c != '\0'; c++) {
if (g_str_has_prefix (c, MODEST_FOLDER_PATH_SEPARATOR)) {
+ gchar *compare;
+ if (c != path_start) {
+ compare = g_strndup (path_start, c - path_start);
+ compare = g_strstrip (compare);
+ if (g_ascii_strcasecmp (compare, "inbox") == 0) {
+ n_inbox_parents++;
+ }
+ g_free (compare);
+ }
n_parents++;
+ path_start = c + 1;
}
}
gint i;
buffer = g_string_new ("");
- for (i = 0; i < n_parents; i++) {
+ for (i = 0; i < n_parents - n_inbox_parents; i++) {
buffer = g_string_append (buffer, MODEST_FOLDER_DOT);
}
buffer = g_string_append (buffer, last_separator);
/* Remove mailbox prefix if any */
gchar *prefix = g_strconcat (mailbox, MODEST_FOLDER_PATH_SEPARATOR, NULL);
if (g_str_has_prefix (*item_name, prefix)) {
- gchar *new_item_name;
-
- new_item_name = g_strdup (*item_name + strlen (prefix));
- if (!g_ascii_strcasecmp (new_item_name, "Inbox")) {
- g_free (new_item_name);
- new_item_name = g_strdup (_("mcen_me_folder_inbox"));
- }
+ gchar *new_item_name = g_strdup (*item_name + strlen (prefix));
g_free (*item_name);
*item_name = new_item_name;
}
- } else if (!g_ascii_strcasecmp (*item_name, "Inbox")) {
-
- g_free (*item_name);
- *item_name = g_strdup (_("mcen_me_folder_inbox"));
}
if (!is_special || multiaccount) {
buffer = g_string_append (buffer, *item_name);
if (concat_folder_name) {
- if (bold) buffer = g_string_append (buffer, "<span weight='bold'>");
- buffer = g_string_append (buffer, folder_name);
- if (bold) buffer = g_string_append (buffer, "</span>");
+ if (!is_special && folder_type == TNY_FOLDER_TYPE_DRAFTS) {
+ buffer = g_string_append (buffer, folder_name);
+ /* TODO: append a sensitive string to the remote drafts to
+ * be able to know it's the remote one */
+/* buffer = g_string_append (buffer, " (TODO:remote)"); */
+ } else {
+ buffer = g_string_append (buffer, folder_name);
+ }
}
g_free (*item_name);
g_object_unref (account);
*item_name = g_string_free (buffer, FALSE);
- *use_markup = bold;
+ *use_markup = FALSE;
} else {
*use_markup = FALSE;
}
if (type != TNY_FOLDER_TYPE_ROOT) {
gint number = 0;
gboolean drafts;
+ gboolean is_local;
+
+ is_local = modest_tny_folder_is_local_folder (TNY_FOLDER (instance)) ||
+ modest_tny_folder_is_memory_card_folder (TNY_FOLDER (instance));
- if (modest_tny_folder_is_local_folder (TNY_FOLDER (instance)) ||
- modest_tny_folder_is_memory_card_folder (TNY_FOLDER (instance))) {
+ if (is_local) {
type = modest_tny_folder_get_local_or_mmc_folder_type (TNY_FOLDER (instance));
if (type != TNY_FOLDER_TYPE_UNKNOWN) {
g_free (fname);
* tny_folder for some reason. Select the number to
* show: the unread or unsent messages. in case of
* outbox/drafts, show all */
- if ((type == TNY_FOLDER_TYPE_DRAFTS) ||
- (type == TNY_FOLDER_TYPE_OUTBOX) ||
- (type == TNY_FOLDER_TYPE_MERGE)) { /* _OUTBOX actually returns _MERGE... */
+ if (is_local && ((type == TNY_FOLDER_TYPE_DRAFTS) ||
+ (type == TNY_FOLDER_TYPE_OUTBOX) ||
+ (type == TNY_FOLDER_TYPE_MERGE))) { /* _OUTBOX actually returns _MERGE... */
number = tny_folder_get_all_count (TNY_FOLDER(instance));
drafts = TRUE;
} else {
}
}
+ /* Convert INBOX */
+ if (type == TNY_FOLDER_TYPE_INBOX &&
+ g_str_has_suffix (fname, "Inbox")) {
+ g_free (item_name);
+ item_name = g_strdup (_("mcen_me_folder_inbox"));
+ }
+
if (!item_name)
item_name = g_strdup ("unknown");
if (item_name && item_weight) {
/* Set the name in the treeview cell: */
- if (use_markup)
- g_object_set (rendobj, "markup", item_name, NULL);
- else
- g_object_set (rendobj, "text", item_name, "weight", item_weight, NULL);
+ if (priv->cell_style == MODEST_FOLDER_VIEW_CELL_STYLE_COMPACT && item_weight == 800 &&
+ (priv->active_color.red != 0 || priv->active_color.blue != 0 || priv->active_color.green != 0)) {
+ g_object_set (rendobj,
+ "text", item_name,
+ "weight-set", FALSE,
+ "foreground-set", TRUE,
+ "foreground-gdk", &(priv->active_color),
+ NULL);
+ } else {
+ g_object_set (rendobj,
+ "text", item_name,
+ "foreground-set", FALSE,
+ "weight-set", TRUE,
+ "weight", item_weight,
+ NULL);
+ }
/* Notify display name observers */
/* TODO: What listens for this signal, and how can it use only the new name? */
if (type != TNY_FOLDER_TYPE_ROOT) {
gint number = 0;
gboolean drafts;
+ gboolean is_local;
+
+ is_local = modest_tny_folder_is_local_folder (TNY_FOLDER (instance)) ||
+ modest_tny_folder_is_memory_card_folder (TNY_FOLDER (instance));
- if (modest_tny_folder_is_local_folder (TNY_FOLDER (instance)) ||
- modest_tny_folder_is_memory_card_folder (TNY_FOLDER (instance))) {
+ if (is_local) {
type = modest_tny_folder_get_local_or_mmc_folder_type (TNY_FOLDER (instance));
} else {
/* Sometimes an special folder is reported by the server as
* to use explicit calls on tny_folder for some reason.
*/
/* Select the number to show: the unread or unsent messages. in case of outbox/drafts, show all */
- if ((type == TNY_FOLDER_TYPE_DRAFTS) ||
- (type == TNY_FOLDER_TYPE_OUTBOX) ||
- (type == TNY_FOLDER_TYPE_MERGE)) { /* _OUTBOX actually returns _MERGE... */
+ if (is_local && ((type == TNY_FOLDER_TYPE_DRAFTS) ||
+ (type == TNY_FOLDER_TYPE_OUTBOX) ||
+ (type == TNY_FOLDER_TYPE_MERGE))) { /* _OUTBOX actually returns _MERGE... */
number = tny_folder_get_all_count (TNY_FOLDER(instance));
drafts = TRUE;
} else {
drafts = FALSE;
}
- if (priv->cell_style == MODEST_FOLDER_VIEW_CELL_STYLE_COMPACT) {
- if (number > 0) {
- item_name = g_strdup_printf (drafts?_("mcen_ti_messages"):_("mcen_ti_new_messages"),
- number);
- }
- }
-
- }
+ if ((priv->cell_style == MODEST_FOLDER_VIEW_CELL_STYLE_COMPACT) && (number > 0)) {
+ item_name =
+ g_strdup_printf (ngettext ((drafts) ? "mcen_ti_message" : "mcen_va_new_message",
+ (drafts) ? "mcen_ti_messages" : "mcen_va_new_messages",
+ number), number);
+ }
+ }
if (!item_name)
item_name = g_strdup ("");
{
ThreePixbufs *retval;
- if (!*pixbuf)
- *pixbuf = gdk_pixbuf_copy (modest_platform_get_icon (icon_code, FOLDER_ICON_SIZE));
+ if (pixbuf && !*pixbuf) {
+ GdkPixbuf *icon;
+ icon = modest_platform_get_icon (icon_code, FOLDER_ICON_SIZE);
+ if (icon) {
+ *pixbuf = gdk_pixbuf_copy (icon);
+ } else {
+ *pixbuf = NULL;
+ }
+ }
- if (!*pixbuf_open)
+ if (pixbuf_open && !*pixbuf_open && pixbuf && *pixbuf)
*pixbuf_open = get_composite_pixbuf ("qgn_list_gene_fldr_exp",
FOLDER_ICON_SIZE,
*pixbuf);
- if (!*pixbuf_close)
+ if (pixbuf_close && !*pixbuf_close && pixbuf && *pixbuf)
*pixbuf_close = get_composite_pixbuf ("qgn_list_gene_fldr_clp",
FOLDER_ICON_SIZE,
*pixbuf);
retval = g_slice_new0 (ThreePixbufs);
- if (*pixbuf)
+ if (pixbuf && *pixbuf)
retval->pixbuf = g_object_ref (*pixbuf);
- if (*pixbuf_open)
+ else
+ retval->pixbuf = NULL;
+ if (pixbuf_open && *pixbuf_open)
retval->pixbuf_open = g_object_ref (*pixbuf_open);
- if (*pixbuf_close)
+ else
+ retval->pixbuf_open = NULL;
+ if (pixbuf_close && *pixbuf_close)
retval->pixbuf_close = g_object_ref (*pixbuf_close);
+ else
+ retval->pixbuf_close = NULL;
return retval;
}
type != TNY_FOLDER_TYPE_INBOX &&
modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (instance))) {
#ifdef MODEST_TOOLKIT_HILDON2
- return get_composite_icons (MODEST_FOLDER_ICON_ACCOUNT,
+ return get_composite_icons (MODEST_FOLDER_ICON_REMOTE_FOLDER,
&anorm_pixbuf,
&anorm_pixbuf_open,
&anorm_pixbuf_close);
priv->messages_renderer = gtk_cell_renderer_text_new ();
g_object_set (priv->messages_renderer,
#ifdef MODEST_TOOLKIT_HILDON2
- "yalign", 0.0,
+ "yalign", 0.5,
"ypad", MODEST_MARGIN_DEFAULT,
"xpad", MODEST_MARGIN_DOUBLE,
#else
priv->timer_expander = 0;
priv->account_store = NULL;
priv->query = NULL;
+ priv->do_refresh = TRUE;
priv->style = MODEST_FOLDER_VIEW_STYLE_SHOW_ALL;
priv->cur_folder_store = NULL;
priv->visible_account_id = NULL;
priv->folder_to_select = NULL;
priv->outbox_deleted_handler = 0;
priv->reexpand = TRUE;
- priv->activity_changed_handler = 0;
+ priv->signal_handlers = 0;
/* Initialize the local account name */
conf = modest_runtime_get_conf();
/* Build treeview */
add_columns (GTK_WIDGET (obj));
+#ifndef MODEST_TOOLKIT_HILDON2
/* Setup drag and drop */
setup_drag_and_drop (GTK_TREE_VIEW(obj));
+#endif
/* Connect signals */
- g_signal_connect (G_OBJECT (obj),
- "key-press-event",
- G_CALLBACK (on_key_pressed), NULL);
+ g_signal_connect (G_OBJECT (obj),
+ "key-press-event",
+ G_CALLBACK (on_key_pressed), NULL);
- priv->display_name_changed_signal =
- g_signal_connect (modest_runtime_get_account_mgr (),
- "display_name_changed",
- G_CALLBACK (on_display_name_changed),
- obj);
+ priv->display_name_changed_signal =
+ g_signal_connect (modest_runtime_get_account_mgr (),
+ "display_name_changed",
+ G_CALLBACK (on_display_name_changed),
+ obj);
/*
* Track changes in the local account name (in the device it
* will be the device name)
*/
- priv->conf_key_signal = g_signal_connect (G_OBJECT(conf),
- "key_changed",
- G_CALLBACK(on_configuration_key_changed),
- obj);
-
- update_style (obj);
- g_signal_connect (G_OBJECT (obj), "notify::style", G_CALLBACK (on_notify_style), (gpointer) obj);
+ priv->conf_key_signal = g_signal_connect (G_OBJECT(conf),
+ "key_changed",
+ G_CALLBACK(on_configuration_key_changed),
+ obj);
+ gdk_color_parse ("000", &priv->active_color);
+ update_style (obj);
+ g_signal_connect (G_OBJECT (obj), "notify::style",
+ G_CALLBACK (on_notify_style), (gpointer) obj);
}
static void
}
static void
+modest_folder_view_dispose (GObject *obj)
+{
+ ModestFolderViewPrivate *priv;
+
+ priv = MODEST_FOLDER_VIEW_GET_PRIVATE (obj);
+
+#ifdef MODEST_TOOLKIT_HILDON2
+ if (priv->signal_handlers) {
+ modest_signal_mgr_disconnect_all_and_destroy (priv->signal_handlers);
+ priv->signal_handlers = NULL;
+ }
+#endif
+
+ /* Free external references */
+ if (priv->account_store) {
+ g_signal_handler_disconnect (G_OBJECT(priv->account_store),
+ priv->account_inserted_signal);
+ g_signal_handler_disconnect (G_OBJECT(priv->account_store),
+ priv->account_removed_signal);
+ g_signal_handler_disconnect (G_OBJECT(priv->account_store),
+ priv->account_changed_signal);
+ g_object_unref (G_OBJECT(priv->account_store));
+ priv->account_store = NULL;
+ }
+
+ if (priv->query) {
+ g_object_unref (G_OBJECT (priv->query));
+ priv->query = NULL;
+ }
+
+ if (priv->folder_to_select) {
+ g_object_unref (G_OBJECT(priv->folder_to_select));
+ priv->folder_to_select = NULL;
+ }
+
+ if (priv->cur_folder_store) {
+ g_object_unref (priv->cur_folder_store);
+ priv->cur_folder_store = NULL;
+ }
+
+ if (priv->list_to_move) {
+ g_object_unref (priv->list_to_move);
+ priv->list_to_move = NULL;
+ }
+
+ G_OBJECT_CLASS(parent_class)->dispose (obj);
+}
+
+static void
modest_folder_view_finalize (GObject *obj)
{
ModestFolderViewPrivate *priv;
g_object_unref (local_account);
}
- if (priv->account_store) {
- g_signal_handler_disconnect (G_OBJECT(priv->account_store),
- priv->account_inserted_signal);
- g_signal_handler_disconnect (G_OBJECT(priv->account_store),
- priv->account_removed_signal);
- g_signal_handler_disconnect (G_OBJECT(priv->account_store),
- priv->account_changed_signal);
- g_object_unref (G_OBJECT(priv->account_store));
- priv->account_store = NULL;
- }
-
if (g_signal_handler_is_connected (modest_runtime_get_account_mgr (),
priv->display_name_changed_signal)) {
g_signal_handler_disconnect (modest_runtime_get_account_mgr (),
priv->display_name_changed_signal = 0;
}
- if (priv->query) {
- g_object_unref (G_OBJECT (priv->query));
- priv->query = NULL;
- }
-
- if (priv->folder_to_select) {
- g_object_unref (G_OBJECT(priv->folder_to_select));
- priv->folder_to_select = NULL;
- }
-
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(obj));
if (sel)
g_signal_handler_disconnect (G_OBJECT(sel), priv->changed_signal);
priv->conf_key_signal = 0;
}
- if (priv->cur_folder_store) {
- g_object_unref (priv->cur_folder_store);
- priv->cur_folder_store = NULL;
- }
-
- if (priv->list_to_move) {
- g_object_unref (priv->list_to_move);
- priv->list_to_move = NULL;
- }
-
/* Clear hidding array created by cut operation */
_clear_hidding_filter (MODEST_FOLDER_VIEW (obj));
+ gdk_color_parse ("000", &priv->active_color);
+
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
modest_folder_view_update_model (MODEST_FOLDER_VIEW (self), account_store);
priv->reselect = FALSE;
+#ifndef MODEST_TOOLKIT_HILDON2
modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (self));
+#endif
g_object_unref (G_OBJECT (device));
}
return same_account;
}
+#ifndef MODEST_TOOLKIT_HILDON2
/**
*
* Selects the first inbox or the local account in an idle
return FALSE;
}
+#endif
static void
on_account_changed (TnyAccountStore *account_store,
/* Refilter the model */
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model));
+#ifndef MODEST_TOOLKIT_HILDON2
/* Select the first INBOX if the currently selected folder
belongs to the account that is being deleted */
if (same_account && !MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (tny_account))
g_idle_add (on_idle_select_first_inbox_or_local, self);
+#endif
}
static void
/* Refilter the model */
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model));
+#ifndef MODEST_TOOLKIT_HILDON2
/* Select the first INBOX if the currently selected folder
belongs to the account that is being deleted */
if (same_account)
g_idle_add (on_idle_select_first_inbox_or_local, self);
+#endif
}
void
deathlock situation */
/* TODO: check if this is still the case */
priv->reselect = FALSE;
+#ifndef MODEST_TOOLKIT_HILDON2
modest_folder_view_select_first_inbox_or_local (self);
+#endif
/* Notify the display name observers */
g_signal_emit (G_OBJECT(self),
signals[FOLDER_DISPLAY_NAME_CHANGED_SIGNAL], 0,
GtkWidget*
modest_folder_view_new (TnyFolderStoreQuery *query)
{
+ return modest_folder_view_new_full (query, TRUE);
+}
+
+GtkWidget*
+modest_folder_view_new_full (TnyFolderStoreQuery *query, gboolean do_refresh)
+{
GObject *self;
ModestFolderViewPrivate *priv;
GtkTreeSelection *sel;
if (query)
priv->query = g_object_ref (query);
+ priv->do_refresh = do_refresh;
+
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(self));
priv->changed_signal = g_signal_connect (sel, "changed",
G_CALLBACK (on_selection_changed), self);
ModestProtocolType protocol_type;
protocol_type = modest_tny_account_get_protocol_type (TNY_ACCOUNT (instance));
- retval = !modest_protocol_registry_protocol_type_has_tag
+ retval = !modest_protocol_registry_protocol_type_has_tag
(modest_runtime_get_protocol_registry (),
protocol_type,
- MODEST_PROTOCOL_REGISTRY_STORE_FORBID_MESSAGE_ADD);
+ MODEST_PROTOCOL_REGISTRY_STORE_FORBID_INCOMING_XFERS);
}
}
/* FIXME: the local accounts are not shown when the query
selects only the subscribed folders */
#ifdef MODEST_TOOLKIT_HILDON2
+ TnyGtkFolderListStoreFlags flags;
+ flags = TNY_GTK_FOLDER_LIST_STORE_FLAG_SHOW_PATH;
+ if (priv->do_refresh)
+ flags |= TNY_GTK_FOLDER_LIST_STORE_FLAG_DELAYED_REFRESH;
+ else
+ flags |= TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH;
model = tny_gtk_folder_list_store_new_with_flags (NULL,
- TNY_GTK_FOLDER_LIST_STORE_FLAG_SHOW_PATH);
+ flags);
tny_gtk_folder_list_store_set_path_separator (TNY_GTK_FOLDER_LIST_STORE (model),
MODEST_FOLDER_PATH_SEPARATOR);
#else
g_object_unref (account);
}
- /* Get the accounts: */
- tny_account_store_get_accounts (TNY_ACCOUNT_STORE(account_store),
- TNY_LIST (model),
- TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+ if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ALL) {
+ /* Get the accounts */
+ tny_account_store_get_accounts (TNY_ACCOUNT_STORE(account_store),
+ TNY_LIST (model),
+ TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+ } else {
+ if (priv->visible_account_id) {
+ TnyAccount *account;
+
+ /* Add local folders account */
+ account = modest_tny_account_store_get_local_folders_account ((ModestTnyAccountStore *) account_store);
+
+ if (account) {
+ tny_list_append (TNY_LIST (model), (GObject *) account);
+ g_object_unref (account);
+ }
+
+ account = modest_tny_account_store_get_mmc_folders_account ((ModestTnyAccountStore *) account_store);
+
+ if (account) {
+ tny_list_append (TNY_LIST (model), (GObject *) account);
+ g_object_unref (account);
+ }
+
+ /* Add visible account */
+ account = modest_tny_account_store_get_tny_account_by ((ModestTnyAccountStore *) account_store,
+ MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
+ priv->visible_account_id);
+ if (account) {
+ tny_list_append (TNY_LIST (model), (GObject *) account);
+ g_object_unref (account);
+ } else {
+ g_warning ("You need to set an account first");
+ g_object_unref (model);
+ return FALSE;
+ }
+ } else {
+ g_warning ("You need to set an account first");
+ g_object_unref (model);
+ return FALSE;
+ }
+ }
sortable = gtk_tree_model_sort_new_with_model (model);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(sortable),
self,
NULL);
- if (priv->activity_changed_handler > 0) {
- GtkTreeModel *old_tny_model;
-
- if (get_inner_models (self, NULL, NULL, &old_tny_model)) {
- g_signal_handler_disconnect (G_OBJECT (old_tny_model), priv->activity_changed_handler);
+ GtkTreeModel *old_tny_model = NULL;
+ if (get_inner_models (self, NULL, NULL, &old_tny_model)) {
+ if (priv->signal_handlers > 0) {
+ priv->signal_handlers = modest_signal_mgr_disconnect (priv->signal_handlers,
+ G_OBJECT (old_tny_model),
+ "activity-changed");
}
- priv->activity_changed_handler = 0;
}
/* Set new model */
#endif
#ifdef MODEST_TOOLKIT_HILDON2
- priv->activity_changed_handler =
- g_signal_connect (G_OBJECT (model), "activity-changed", G_CALLBACK (on_activity_changed), self);
+ priv->signal_handlers = modest_signal_mgr_connect (priv->signal_handlers,
+ G_OBJECT (model),
+ "activity-changed",
+ G_CALLBACK (on_activity_changed),
+ self);
#endif
g_object_unref (model);
cause (and it actually does it) a free of the
summary of the folder (because the main window will
clear the headers view */
+#ifndef MODEST_TOOLKIT_HILDON2
if (TNY_IS_FOLDER(priv->cur_folder_store))
tny_folder_sync_async (TNY_FOLDER(priv->cur_folder_store),
FALSE, NULL, NULL, NULL);
+#endif
g_signal_emit (G_OBJECT(tree_view), signals[FOLDER_SELECTION_CHANGED_SIGNAL], 0,
priv->cur_folder_store, FALSE);
return is_account2 - is_account1;
}
+static gint
+compare_folders (const gchar *name1, const gchar *name2)
+{
+ const gchar *separator1, *separator2;
+ const gchar *next1, *next2;
+ gchar *top1, *top2;
+ gint cmp;
+
+ if (name1 == NULL || name1[0] == '\0')
+ return -1;
+ if (name2 == NULL || name2[0] == '\0')
+ return 1;
+
+ separator1 = strstr (name1, MODEST_FOLDER_PATH_SEPARATOR);
+ if (separator1) {
+ top1 = g_strndup (name1, separator1 - name1);
+ } else {
+ top1 = g_strdup (name1);
+ }
+
+ separator2 = strstr (name2, MODEST_FOLDER_PATH_SEPARATOR);
+ if (separator2) {
+ top2 = g_strndup (name2, separator2 - name2);
+ } else {
+ top2 = g_strdup (name2);
+ }
+
+
+ cmp = modest_text_utils_utf8_strcmp (top1, top2, TRUE);
+ g_free (top1);
+ g_free (top2);
+
+ if (cmp != 0)
+ return cmp;
+
+ if (separator1 == NULL && separator2 == NULL)
+ return 0;
+
+ next1 = (separator1 != NULL)?separator1 + strlen (MODEST_FOLDER_PATH_SEPARATOR):NULL;
+ next2 = (separator2 != NULL)?separator2 + strlen (MODEST_FOLDER_PATH_SEPARATOR):NULL;
+
+ return compare_folders (next1, next2);
+}
+
+
/*
* This function orders the mail accounts according to these rules:
* 1st - remote accounts
}
/* Pure sort by name */
- cmp = modest_text_utils_utf8_strcmp (name1, name2, TRUE);
+ cmp = compare_folders (name1, name2);
finish:
if (folder1)
g_object_unref(G_OBJECT(folder1));
return cmp;
}
+#ifndef MODEST_TOOLKIT_HILDON2
/*****************************************************************************/
/* DRAG and DROP stuff */
/*****************************************************************************/
return folder;
}
-
/*
* This function is used by drag_data_received_cb to manage drag and
* drop of a header, i.e, and drag from the header view to the folder
}
/* Check if the get_data failed */
+#if GTK_CHECK_VERSION (2,14,0)
+ if ((selection_data == NULL) || (gtk_selection_data_get_length (selection_data) < 0))
+#else
if (selection_data == NULL || selection_data->length < 0)
+#endif
goto end;
/* Select the destination model */
/* Set up the folder view as a dnd destination. Set only the
highlight flag, otherwise gtk will have a different
behaviour */
-#ifdef MODEST_TOOLKIT_HILDON2
- return;
-#endif
gtk_drag_dest_set (GTK_WIDGET (self),
GTK_DEST_DEFAULT_HIGHLIGHT,
folder_view_drag_types,
G_CALLBACK (drag_drop_cb),
NULL);
}
+#endif
/*
* This function manages the navigation through the folders using the
model = gtk_tree_view_get_model (GTK_TREE_VIEW (self));
if (GTK_IS_TREE_MODEL_FILTER (model))
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model));
+ else
+ modest_folder_view_update_model(self,
+ (TnyAccountStore *) modest_runtime_get_account_store());
/* Save settings to gconf */
modest_widget_memory_save (modest_runtime_get_conf (), G_OBJECT(self),
return FALSE;
}
-
-
-
+#ifndef MODEST_TOOLKIT_HILDON2
void
modest_folder_view_select_first_inbox_or_local (ModestFolderView *self)
{
-#ifndef MODEST_TOOLKIT_HILDON2
GtkTreeModel *model;
GtkTreeIter iter, inbox_iter;
GtkTreeSelection *sel;
/* set focus */
gtk_widget_grab_focus (GTK_WIDGET(self));
-#endif
}
-
+#endif
/* recursive */
static gboolean
/* Get src model*/
if (get_inner_models (folder_view_dst, NULL, NULL, &old_tny_model)) {
- g_signal_handler_disconnect (G_OBJECT (old_tny_model), dst_priv->activity_changed_handler);
- dst_priv->activity_changed_handler = 0;
+ modest_signal_mgr_disconnect (dst_priv->signal_handlers,
+ G_OBJECT (old_tny_model),
+ "activity-changed");
}
filter_model = gtk_tree_view_get_model (GTK_TREE_VIEW (folder_view_src));
model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER(filter_model));
/* Set copied model */
gtk_tree_view_set_model (GTK_TREE_VIEW (folder_view_dst), new_filter_model);
#ifndef MODEST_TOOLKIT_HILDON2
- g_signal_connect (G_OBJECT(new_filter_model), "row-inserted",
- (GCallback) on_row_inserted_maybe_select_folder, folder_view_dst);
+ dst_priv->signal_handlers = modest_signal_mgr_connect (dst_priv->signal_handlers,
+ G_OBJECT(new_filter_model), "row-inserted",
+ (GCallback) on_row_inserted_maybe_select_folder,
+ folder_view_dst);
#endif
#ifdef MODEST_TOOLKIT_HILDON2
- if (new_tny_model)
- dst_priv->activity_changed_handler = g_signal_connect (G_OBJECT (new_tny_model), "activity-changed",
- G_CALLBACK (on_activity_changed), folder_view_dst);
+ if (new_tny_model) {
+ dst_priv->signal_handlers = modest_signal_mgr_connect (dst_priv->signal_handlers,
+ G_OBJECT (new_tny_model),
+ "activity-changed",
+ G_CALLBACK (on_activity_changed),
+ folder_view_dst);
+ }
#endif
/* Free */
update_style (ModestFolderView *self)
{
ModestFolderViewPrivate *priv;
- GdkColor style_color;
+ GdkColor style_color, style_active_color;
PangoAttrList *attr_list;
GtkStyle *style;
PangoAttribute *attr;
/* Set color */
attr_list = pango_attr_list_new ();
- if (!gtk_style_lookup_color (GTK_WIDGET (self)->style, "SecondaryTextColor", &style_color)) {
+
+ if (!gtk_style_lookup_color (gtk_widget_get_style (GTK_WIDGET (self)), "SecondaryTextColor", &style_color)) {
gdk_color_parse ("grey", &style_color);
}
attr = pango_attr_foreground_new (style_color.red, style_color.green, style_color.blue);
NULL);
pango_attr_list_unref (attr_list);
}
+
+ if (gtk_style_lookup_color (gtk_widget_get_style (GTK_WIDGET (self)), "ActiveTextColor", &style_active_color)) {
+ priv->active_color = style_active_color;
+ } else {
+ gdk_color_parse ("000", &(priv->active_color));
+ }
}
static void
activity);
}
#endif
+
+TnyList *
+modest_folder_view_get_model_tny_list (ModestFolderView *self)
+{
+ GtkTreeModel *model;
+ TnyList *ret_value;
+
+ ret_value = NULL;
+ model = NULL;
+
+ if (get_inner_models (MODEST_FOLDER_VIEW (self), NULL, NULL, (GtkTreeModel **) &model)) {
+ ret_value = TNY_LIST (model);
+ g_object_ref (ret_value);
+ }
+
+ return ret_value;
+
+}