modest-main-window.c \
modest-main-window-ui.h \
modest-hildon-includes.h \
+ modest-hildon-sort-dialog.c \
+ modest-hildon-sort-dialog.h \
modest-platform.c \
modest-signature-editor-dialog.c \
modest-signature-editor-dialog.h \
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "modest-hildon-sort-dialog.h"
+#include "widgets/modest-sort-criterium-view.h"
+
+
+static gint modest_hildon_sort_dialog_add_sort_key (ModestSortCriteriumView *self,
+ const gchar *sort_key);
+static void modest_hildon_sort_dialog_set_sort_key (ModestSortCriteriumView *self, gint key);
+static void modest_hildon_sort_dialog_set_sort_order (ModestSortCriteriumView *self, GtkSortType sort_type);
+static gint modest_hildon_sort_dialog_get_sort_key (ModestSortCriteriumView *self);
+static GtkSortType modest_hildon_sort_dialog_get_sort_order (ModestSortCriteriumView *self);
+static void modest_sort_criterium_view_init (gpointer g_iface, gpointer iface_data);
+
+G_DEFINE_TYPE_EXTENDED (ModestHildonSortDialog,
+ modest_hildon_sort_dialog,
+ HILDON_TYPE_SORT_DIALOG,
+ 0,
+ G_IMPLEMENT_INTERFACE (MODEST_TYPE_SORT_CRITERIUM_VIEW, modest_sort_criterium_view_init));
+
+static void
+modest_hildon_sort_dialog_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (modest_hildon_sort_dialog_parent_class)->finalize (object);
+}
+
+static void
+modest_hildon_sort_dialog_class_init (ModestHildonSortDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = modest_hildon_sort_dialog_finalize;
+
+}
+
+static void
+modest_hildon_sort_dialog_init (ModestHildonSortDialog *self)
+{
+}
+
+static gint
+modest_hildon_sort_dialog_add_sort_key (ModestSortCriteriumView *self,
+ const gchar *sort_key)
+{
+ g_return_val_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self), 0);
+
+ return hildon_sort_dialog_add_sort_key (HILDON_SORT_DIALOG (self), sort_key);
+}
+
+static void
+modest_hildon_sort_dialog_set_sort_key (ModestSortCriteriumView *self, gint key)
+{
+ g_return_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self));
+
+ hildon_sort_dialog_set_sort_key (HILDON_SORT_DIALOG (self), key);
+}
+
+static void
+modest_hildon_sort_dialog_set_sort_order (ModestSortCriteriumView *self, GtkSortType sort_type)
+{
+ g_return_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self));
+
+ hildon_sort_dialog_set_sort_order (HILDON_SORT_DIALOG (self), sort_type);
+}
+
+static gint
+modest_hildon_sort_dialog_get_sort_key (ModestSortCriteriumView *self)
+{
+ g_return_val_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self), 0);
+
+ return hildon_sort_dialog_get_sort_key (HILDON_SORT_DIALOG (self));
+}
+
+static GtkSortType
+modest_hildon_sort_dialog_get_sort_order (ModestSortCriteriumView *self)
+{
+ g_return_val_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self), GTK_SORT_ASCENDING);
+
+ return hildon_sort_dialog_get_sort_order (HILDON_SORT_DIALOG (self));
+}
+
+static void
+modest_sort_criterium_view_init (gpointer g_iface,
+ gpointer iface_data)
+{
+ ModestSortCriteriumViewIface *iface = (ModestSortCriteriumViewIface *) g_iface;
+
+ iface->add_sort_key_func = modest_hildon_sort_dialog_add_sort_key;
+ iface->get_sort_key_func = modest_hildon_sort_dialog_get_sort_key;
+ iface->set_sort_key_func = modest_hildon_sort_dialog_set_sort_key;
+ iface->get_sort_order_func = modest_hildon_sort_dialog_get_sort_order;
+ iface->set_sort_order_func = modest_hildon_sort_dialog_set_sort_order;
+}
+
+GtkWidget*
+modest_hildon_sort_dialog_new (GtkWindow *parent)
+{
+ GtkWidget *result = g_object_new (MODEST_TYPE_HILDON_SORT_DIALOG, NULL);
+
+
+ if (parent)
+ gtk_window_set_transient_for(GTK_WINDOW(result), parent);
+
+ return result;
+}
+
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __MODEST_HILDON_SORT_DIALOG
+#define __MODEST_HILDON_SORT_DIALOG
+
+#include <glib.h>
+#include <hildon/hildon-sort-dialog.h>
+#include <widgets/modest-sort-criterium-view.h>
+
+G_BEGIN_DECLS
+
+#define MODEST_TYPE_HILDON_SORT_DIALOG modest_hildon_sort_dialog_get_type()
+
+#define MODEST_HILDON_SORT_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ MODEST_TYPE_HILDON_SORT_DIALOG, ModestHildonSortDialog))
+
+#define MODEST_HILDON_SORT_DIALOG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ MODEST_TYPE_HILDON_SORT_DIALOG, ModestHildonSortDialogClass))
+
+#define MODEST_IS_HILDON_SORT_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ MODEST_TYPE_HILDON_SORT_DIALOG))
+
+#define MODEST_IS_HILDON_SORT_DIALOG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ MODEST_TYPE_HILDON_SORT_DIALOG))
+
+#define MODEST_HILDON_SORT_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ MODEST_TYPE_HILDON_SORT_DIALOG, ModestHildonSortDialogClass))
+
+typedef struct {
+ HildonSortDialog parent;
+
+} ModestHildonSortDialog;
+
+typedef struct {
+ HildonSortDialogClass parent_class;
+
+} ModestHildonSortDialogClass;
+
+GType modest_hildon_sort_dialog_get_type (void);
+
+GtkWidget* modest_hildon_sort_dialog_new (GtkWindow *parent);
+
+G_END_DECLS
+
+#endif /* __MODEST_HILDON_SORT_DIALOG */
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <modest-account-settings-dialog.h>
#include <easysetup/modest-easysetup-wizard-dialog.h>
+#include "modest-hildon-sort-dialog.h"
#include <hildon/hildon-sound.h>
#include <osso-mem.h>
g_free (chars);
}
-static guint
-checked_hildon_sort_dialog_add_sort_key (HildonSortDialog *dialog, const gchar* key, guint max)
-{
- gint sort_key;
-
- g_return_val_if_fail (dialog && HILDON_IS_SORT_DIALOG(dialog), 0);
- g_return_val_if_fail (key, 0);
-
- sort_key = hildon_sort_dialog_add_sort_key (dialog, key);
- if (sort_key < 0 || sort_key >= max) {
- g_warning ("%s: out of range (%d) for %s", __FUNCTION__, sort_key, key);
- return 0;
- } else
- return (guint)sort_key;
-}
-
-
-static void
-launch_sort_headers_dialog (GtkWindow *parent_window,
- HildonSortDialog *dialog)
-{
- ModestHeaderView *header_view = NULL;
- GList *cols = NULL;
- GtkSortType sort_type;
- gint sort_key;
- gint default_key = 0;
- gint result;
- gboolean outgoing = FALSE;
- gint current_sort_colid = -1;
- GtkSortType current_sort_type;
- gint attachments_sort_id;
- gint priority_sort_id;
- GtkTreeSortable *sortable;
-
- /* Get header window */
- if (MODEST_IS_MAIN_WINDOW (parent_window)) {
- header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(parent_window),
- MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
- }
- if (!header_view)
- return;
-
- /* Add sorting keys */
- cols = modest_header_view_get_columns (header_view);
- if (cols == NULL)
- return;
-#define SORT_ID_NUM 6
- int sort_model_ids[SORT_ID_NUM];
- int sort_ids[SORT_ID_NUM];
-
- outgoing = (GPOINTER_TO_INT (g_object_get_data(G_OBJECT(cols->data), MODEST_HEADER_VIEW_COLUMN))==
- MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT);
-
- sort_key = checked_hildon_sort_dialog_add_sort_key (dialog, _("mcen_li_sort_sender_recipient"),
- SORT_ID_NUM);
- if (outgoing) {
- sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_TO_COLUMN;
- sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT;
- } else {
- sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FROM_COLUMN;
- sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN;
- }
-
- sort_key = checked_hildon_sort_dialog_add_sort_key (dialog, _("mcen_li_sort_date"),
- SORT_ID_NUM);
- if (outgoing) {
- sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_TIME_T_COLUMN;
- sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_SENT_DATE;
- } else {
- sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_DATE_RECEIVED_TIME_T_COLUMN;
- sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_RECEIVED_DATE;
- }
- default_key = sort_key;
-
- sort_key = checked_hildon_sort_dialog_add_sort_key (dialog, _("mcen_li_sort_subject"),
- SORT_ID_NUM);
- sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_SUBJECT_COLUMN;
- if (outgoing)
- sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT;
- else
- sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN;
-
- sort_key = checked_hildon_sort_dialog_add_sort_key (dialog, _("mcen_li_sort_attachment"),
- SORT_ID_NUM);
- sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN;
- sort_ids[sort_key] = TNY_HEADER_FLAG_ATTACHMENTS;
- attachments_sort_id = sort_key;
-
- sort_key = checked_hildon_sort_dialog_add_sort_key (dialog, _("mcen_li_sort_size"),
- SORT_ID_NUM);
- sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_MESSAGE_SIZE_COLUMN;
- sort_ids[sort_key] = 0;
-
- sort_key = checked_hildon_sort_dialog_add_sort_key (dialog, _("mcen_li_sort_priority"),
- SORT_ID_NUM);
- sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN;
- sort_ids[sort_key] = TNY_HEADER_FLAG_PRIORITY_MASK;
- priority_sort_id = sort_key;
-
- sortable = GTK_TREE_SORTABLE (gtk_tree_model_filter_get_model
- (GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view)))));
- /* Launch dialogs */
- if (!gtk_tree_sortable_get_sort_column_id (sortable,
- ¤t_sort_colid, ¤t_sort_type)) {
- hildon_sort_dialog_set_sort_key (dialog, default_key);
- hildon_sort_dialog_set_sort_order (dialog, GTK_SORT_DESCENDING);
- } else {
- hildon_sort_dialog_set_sort_order (dialog, current_sort_type);
- if (current_sort_colid == TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN) {
- gpointer flags_sort_type_pointer;
- flags_sort_type_pointer = g_object_get_data (G_OBJECT (cols->data), MODEST_HEADER_VIEW_FLAG_SORT);
- if (GPOINTER_TO_INT (flags_sort_type_pointer) == TNY_HEADER_FLAG_PRIORITY_MASK)
- hildon_sort_dialog_set_sort_key (dialog, priority_sort_id);
- else
- hildon_sort_dialog_set_sort_key (dialog, attachments_sort_id);
- } else {
- gint current_sort_keyid = 0;
- while (current_sort_keyid < 6) {
- if (sort_model_ids[current_sort_keyid] == current_sort_colid)
- break;
- else
- current_sort_keyid++;
- }
- hildon_sort_dialog_set_sort_key (dialog, current_sort_keyid);
- }
- }
-
- result = gtk_dialog_run (GTK_DIALOG (dialog));
- if (result == GTK_RESPONSE_OK) {
- sort_key = hildon_sort_dialog_get_sort_key (dialog);
- if (sort_key < 0 || sort_key > SORT_ID_NUM -1) {
- g_warning ("%s: out of range (%d)", __FUNCTION__, sort_key);
- sort_key = 0;
- }
-
- sort_type = hildon_sort_dialog_get_sort_order (dialog);
- if (sort_model_ids[sort_key] == TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN) {
- g_object_set_data (G_OBJECT(cols->data), MODEST_HEADER_VIEW_FLAG_SORT,
- GINT_TO_POINTER (sort_ids[sort_key]));
- /* This is a hack to make it resort rows always when flag fields are
- * selected. If we do not do this, changing sort field from priority to
- * attachments does not work */
- modest_header_view_sort_by_column_id (header_view, 0, sort_type);
- } else {
- gtk_tree_view_column_set_sort_column_id (GTK_TREE_VIEW_COLUMN (cols->data),
- sort_model_ids[sort_key]);
- }
-
- modest_header_view_sort_by_column_id (header_view, sort_model_ids[sort_key], sort_type);
- gtk_tree_sortable_sort_column_changed (sortable);
- }
-
- modest_widget_memory_save (modest_runtime_get_conf (),
- G_OBJECT (header_view), MODEST_CONF_HEADER_VIEW_KEY);
-
- /* free */
- g_list_free(cols);
-}
-
static void
return result;
}
-void
-modest_platform_run_sort_dialog (GtkWindow *parent_window,
- ModestSortDialogType type)
+GtkWidget *
+modest_platform_create_sort_dialog (GtkWindow *parent_window)
{
- GtkWidget *dialog = NULL;
+ GtkWidget *dialog;
- /* Build dialog */
- dialog = hildon_sort_dialog_new (parent_window);
- modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
- GTK_WINDOW (dialog));
+ dialog = modest_hildon_sort_dialog_new (parent_window);
hildon_help_dialog_help_enable (GTK_DIALOG(dialog),
"applications_email_sort",
modest_maemo_utils_get_osso_context());
- /* Fill sort keys */
- switch (type) {
- case MODEST_SORT_HEADERS:
- launch_sort_headers_dialog (parent_window,
- HILDON_SORT_DIALOG(dialog));
- break;
- }
-
- /* Free */
- on_destroy_dialog (GTK_DIALOG(dialog));
+ return dialog;
}
#include <tny-device.h>
#include "widgets/modest-window.h"
#include "widgets/modest-folder-view.h"
+#include "widgets/modest-sort-criterium-view.h"
G_BEGIN_DECLS
MODEST_CONFIRMATION_DELETE_FOLDER,
} ModestConfirmationDialogType;
-typedef enum _ModestSortDialogType {
- MODEST_SORT_HEADERS,
-} ModestSortDialogType;
-
typedef enum _ModestConnectedVia {
MODEST_CONNECTED_VIA_WLAN_OR_WIMAX = 1,
MODEST_CONNECTED_VIA_ANY,
gboolean block);
/**
- * modest_platform_run_sort_dialog:
+ * modest_platform_create_sort_dialog:
* @parent_window: the parent #GtkWindow of the dialog
- * @type: the sort dialog type.
*
- * shows a sort dialog
+ * creates a proper sort dialog for the platform
+ *
+ * Returns: a #GtkDialog implementing #ModestSortCriteriumView interface
**/
-void modest_platform_run_sort_dialog (GtkWindow *parent_window,
- ModestSortDialogType type);
+GtkWidget *modest_platform_create_sort_dialog (GtkWindow *parent_window);
/*
* modest_platform_connect_and_wait:
}
/* Show sorting dialog */
- modest_platform_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);
+ modest_utils_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);
}
}
#include "modest-utils.h"
#include "modest-platform.h"
#include <modest-local-folder-info.h>
+#include "widgets/modest-header-view.h"
+#include "widgets/modest-main-window.h"
+#include "modest-widget-memory.h"
+#include "widgets/modest-sort-criterium-view.h"
GQuark
modest_utils_get_supported_secure_authentication_error_quark (void)
return (guint64) size;
}
+
+static void
+on_destroy_dialog (GtkDialog *dialog)
+{
+ gtk_widget_destroy (GTK_WIDGET(dialog));
+ if (gtk_events_pending ())
+ gtk_main_iteration ();
+}
+
+static guint
+checked_modest_sort_criterium_view_add_sort_key (ModestSortCriteriumView *view, const gchar* key, guint max)
+{
+ gint sort_key;
+
+ g_return_val_if_fail (view && MODEST_IS_SORT_CRITERIUM_VIEW(view), 0);
+ g_return_val_if_fail (key, 0);
+
+ sort_key = modest_sort_criterium_view_add_sort_key (view, key);
+ if (sort_key < 0 || sort_key >= max) {
+ g_warning ("%s: out of range (%d) for %s", __FUNCTION__, sort_key, key);
+ return 0;
+ } else
+ return (guint)sort_key;
+}
+
+static void
+launch_sort_headers_dialog (GtkWindow *parent_window,
+ GtkDialog *dialog)
+{
+ ModestHeaderView *header_view = NULL;
+ GList *cols = NULL;
+ GtkSortType sort_type;
+ gint sort_key;
+ gint default_key = 0;
+ gint result;
+ gboolean outgoing = FALSE;
+ gint current_sort_colid = -1;
+ GtkSortType current_sort_type;
+ gint attachments_sort_id;
+ gint priority_sort_id;
+ GtkTreeSortable *sortable;
+
+ /* Get header window */
+ if (MODEST_IS_MAIN_WINDOW (parent_window)) {
+ header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(parent_window),
+ MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
+ }
+ if (!header_view)
+ return;
+
+ /* Add sorting keys */
+ cols = modest_header_view_get_columns (header_view);
+ if (cols == NULL)
+ return;
+#define SORT_ID_NUM 6
+ int sort_model_ids[SORT_ID_NUM];
+ int sort_ids[SORT_ID_NUM];
+
+ outgoing = (GPOINTER_TO_INT (g_object_get_data(G_OBJECT(cols->data), MODEST_HEADER_VIEW_COLUMN))==
+ MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT);
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_sender_recipient"),
+ SORT_ID_NUM);
+ if (outgoing) {
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_TO_COLUMN;
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT;
+ } else {
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FROM_COLUMN;
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN;
+ }
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_date"),
+ SORT_ID_NUM);
+ if (outgoing) {
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_TIME_T_COLUMN;
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_SENT_DATE;
+ } else {
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_DATE_RECEIVED_TIME_T_COLUMN;
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_RECEIVED_DATE;
+ }
+ default_key = sort_key;
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_subject"),
+ SORT_ID_NUM);
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_SUBJECT_COLUMN;
+ if (outgoing)
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT;
+ else
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN;
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_attachment"),
+ SORT_ID_NUM);
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN;
+ sort_ids[sort_key] = TNY_HEADER_FLAG_ATTACHMENTS;
+ attachments_sort_id = sort_key;
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_size"),
+ SORT_ID_NUM);
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_MESSAGE_SIZE_COLUMN;
+ sort_ids[sort_key] = 0;
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_priority"),
+ SORT_ID_NUM);
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN;
+ sort_ids[sort_key] = TNY_HEADER_FLAG_PRIORITY_MASK;
+ priority_sort_id = sort_key;
+
+ sortable = GTK_TREE_SORTABLE (gtk_tree_model_filter_get_model
+ (GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view)))));
+ /* Launch dialogs */
+ if (!gtk_tree_sortable_get_sort_column_id (sortable,
+ ¤t_sort_colid, ¤t_sort_type)) {
+ modest_sort_criterium_view_set_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), default_key);
+ modest_sort_criterium_view_set_sort_order (MODEST_SORT_CRITERIUM_VIEW (dialog), GTK_SORT_DESCENDING);
+ } else {
+ modest_sort_criterium_view_set_sort_order (MODEST_SORT_CRITERIUM_VIEW (dialog), current_sort_type);
+ if (current_sort_colid == TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN) {
+ gpointer flags_sort_type_pointer;
+ flags_sort_type_pointer = g_object_get_data (G_OBJECT (cols->data), MODEST_HEADER_VIEW_FLAG_SORT);
+ if (GPOINTER_TO_INT (flags_sort_type_pointer) == TNY_HEADER_FLAG_PRIORITY_MASK)
+ modest_sort_criterium_view_set_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), priority_sort_id);
+ else
+ modest_sort_criterium_view_set_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), attachments_sort_id);
+ } else {
+ gint current_sort_keyid = 0;
+ while (current_sort_keyid < 6) {
+ if (sort_model_ids[current_sort_keyid] == current_sort_colid)
+ break;
+ else
+ current_sort_keyid++;
+ }
+ modest_sort_criterium_view_set_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), current_sort_keyid);
+ }
+ }
+
+ result = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (result == GTK_RESPONSE_OK) {
+ sort_key = modest_sort_criterium_view_get_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog));
+ if (sort_key < 0 || sort_key > SORT_ID_NUM -1) {
+ g_warning ("%s: out of range (%d)", __FUNCTION__, sort_key);
+ sort_key = 0;
+ }
+
+ sort_type = modest_sort_criterium_view_get_sort_order (MODEST_SORT_CRITERIUM_VIEW (dialog));
+ if (sort_model_ids[sort_key] == TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN) {
+ g_object_set_data (G_OBJECT(cols->data), MODEST_HEADER_VIEW_FLAG_SORT,
+ GINT_TO_POINTER (sort_ids[sort_key]));
+ /* This is a hack to make it resort rows always when flag fields are
+ * selected. If we do not do this, changing sort field from priority to
+ * attachments does not work */
+ modest_header_view_sort_by_column_id (header_view, 0, sort_type);
+ } else {
+ gtk_tree_view_column_set_sort_column_id (GTK_TREE_VIEW_COLUMN (cols->data),
+ sort_model_ids[sort_key]);
+ }
+
+ modest_header_view_sort_by_column_id (header_view, sort_model_ids[sort_key], sort_type);
+ gtk_tree_sortable_sort_column_changed (sortable);
+ }
+
+ modest_widget_memory_save (modest_runtime_get_conf (),
+ G_OBJECT (header_view), MODEST_CONF_HEADER_VIEW_KEY);
+
+ /* free */
+ g_list_free(cols);
+}
+
+void
+modest_utils_run_sort_dialog (GtkWindow *parent_window,
+ ModestSortDialogType type)
+{
+ GtkWidget *dialog = NULL;
+
+ /* Build dialog */
+ dialog = modest_platform_create_sort_dialog (parent_window);
+ modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+ GTK_WINDOW (dialog));
+
+ /* Fill sort keys */
+ switch (type) {
+ case MODEST_SORT_HEADERS:
+ launch_sort_headers_dialog (parent_window,
+ GTK_DIALOG(dialog));
+ break;
+ }
+
+ /* Free */
+ on_destroy_dialog (GTK_DIALOG(dialog));
+}
+
MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED
} ModestUtilsGetSupportedSecureAuthenticationError;
+typedef enum _ModestSortDialogType {
+ MODEST_SORT_HEADERS,
+} ModestSortDialogType;
+
GQuark modest_utils_get_supported_secure_authentication_error_quark (void);
void modest_utils_toggle_action_set_active_block_notify (GtkToggleAction *action, gboolean value);
/**
+ * modest_utils_run_sort_dialog:
+ * @parent_window: the modest window the dialog has been requested from
+ * @type: a #ModestSortDialogType
+ *
+ * raises a sort dialog for this window
+ */
+void modest_utils_run_sort_dialog (GtkWindow *parent_window, ModestSortDialogType type);
+
+
+/**
* modest_list_index:
* @list: a #TnyList
* @object: a #GObject
modest-scroll-text.h \
modest-serversecurity-combo-box.h modest-serversecurity-combo-box.c \
modest-secureauth-combo-box.h modest-secureauth-combo-box.c \
+ modest-sort-criterium-view.c \
+ modest-sort-criterium-view.h \
modest-tny-stream-gtkhtml.c \
modest-tny-stream-gtkhtml.h \
modest-ui-constants.h \
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <config.h>
+
+#include <widgets/modest-sort-criterium-view.h>
+
+gint
+modest_sort_criterium_view_add_sort_key (ModestSortCriteriumView *self, const gchar *sort_key)
+{
+ return MODEST_SORT_CRITERIUM_VIEW_GET_IFACE (self)->add_sort_key_func (self, sort_key);
+}
+
+void
+modest_sort_criterium_view_set_sort_key (ModestSortCriteriumView *self, gint key)
+{
+ MODEST_SORT_CRITERIUM_VIEW_GET_IFACE (self)->set_sort_key_func (self, key);
+}
+
+void
+modest_sort_criterium_view_set_sort_order (ModestSortCriteriumView *self, GtkSortType sort_type)
+{
+ MODEST_SORT_CRITERIUM_VIEW_GET_IFACE (self)->set_sort_order_func (self, sort_type);
+}
+
+gint
+modest_sort_criterium_view_get_sort_key (ModestSortCriteriumView *self)
+{
+ return MODEST_SORT_CRITERIUM_VIEW_GET_IFACE (self)->get_sort_key_func (self);
+}
+
+GtkSortType
+modest_sort_criterium_view_get_sort_order (ModestSortCriteriumView *self)
+{
+ return MODEST_SORT_CRITERIUM_VIEW_GET_IFACE (self)->get_sort_order_func (self);
+}
+
+
+static void
+modest_sort_criterium_view_base_init (gpointer g_class)
+{
+ static gboolean initialized = FALSE;
+
+ if (!initialized) {
+
+ initialized = TRUE;
+ }
+}
+
+GType
+modest_sort_criterium_view_get_type (void)
+{
+ static GType my_type = 0;
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestSortCriteriumViewIface),
+ modest_sort_criterium_view_base_init, /* base init */
+ NULL, /* base finalize */
+ NULL, /* class_init */
+ NULL, /* class finalize */
+ NULL, /* class data */
+ 0,
+ 0, /* n_preallocs */
+ NULL, /* instance_init */
+ NULL
+ };
+
+ my_type = g_type_register_static (G_TYPE_INTERFACE,
+ "ModestSortCriteriumView",
+ &my_info, 0);
+
+
+ }
+ return my_type;
+}
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __MODEST_SORT_CRITERIUM_VIEW_H__
+#define __MODEST_SORT_CRITERIUM_VIEW_H__
+
+#include <glib-object.h>
+#include <gtk/gtkenums.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_SORT_CRITERIUM_VIEW (modest_sort_criterium_view_get_type())
+#define MODEST_SORT_CRITERIUM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_SORT_CRITERIUM_VIEW,ModestSortCriteriumView))
+#define MODEST_IS_SORT_CRITERIUM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_SORT_CRITERIUM_VIEW))
+#define MODEST_SORT_CRITERIUM_VIEW_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj),MODEST_TYPE_SORT_CRITERIUM_VIEW,ModestSortCriteriumViewIface))
+
+typedef struct _ModestSortCriteriumView ModestSortCriteriumView;
+typedef struct _ModestSortCriteriumViewIface ModestSortCriteriumViewIface;
+
+struct _ModestSortCriteriumViewIface {
+ GTypeInterface parent;
+
+ gint (*add_sort_key_func) (ModestSortCriteriumView *self, const gchar *sort_key);
+ void (*set_sort_key_func) (ModestSortCriteriumView *self, gint key);
+ void (*set_sort_order_func) (ModestSortCriteriumView *self, GtkSortType sort_type);
+ gint (*get_sort_key_func) (ModestSortCriteriumView *self);
+ GtkSortType (*get_sort_order_func) (ModestSortCriteriumView *self);
+};
+
+
+/**
+ *
+ * modest_sort_criterium_view_get_type
+ *
+ * get the GType for the this interface
+ *
+ * Returns: the GType for this interface
+ */
+GType modest_sort_criterium_view_get_type (void) G_GNUC_CONST;
+
+
+gint modest_sort_criterium_view_add_sort_key (ModestSortCriteriumView *self, const gchar *sort_key);
+void modest_sort_criterium_view_set_sort_key (ModestSortCriteriumView *self, gint key);
+void modest_sort_criterium_view_set_sort_order (ModestSortCriteriumView *self, GtkSortType sort_type);
+gint modest_sort_criterium_view_get_sort_key (ModestSortCriteriumView *self);
+GtkSortType modest_sort_criterium_view_get_sort_order (ModestSortCriteriumView *self);
+
+G_END_DECLS
+
+#endif /* __MODEST_SORT_CRITERIUM_VIEW_H__ */