Fix modest_tny_msg_header_get_all_recipients_list (in case from is empty)
[modest] / src / maemo / modest-hildon-sort-dialog.c
1 /* Copyright (c) 2006, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include "modest-hildon-sort-dialog.h"
31 #include "widgets/modest-sort-criterium-view.h"
32
33
34 static gint    modest_hildon_sort_dialog_add_sort_key        (ModestSortCriteriumView *self,
35                                                                       const gchar *sort_key);
36 static void    modest_hildon_sort_dialog_set_sort_key (ModestSortCriteriumView *self, gint key);
37 static void    modest_hildon_sort_dialog_set_sort_order (ModestSortCriteriumView *self, GtkSortType sort_type);
38 static gint    modest_hildon_sort_dialog_get_sort_key (ModestSortCriteriumView *self);
39 static GtkSortType modest_hildon_sort_dialog_get_sort_order (ModestSortCriteriumView *self);
40 static void modest_sort_criterium_view_init (gpointer g_iface, gpointer iface_data);
41
42 G_DEFINE_TYPE_EXTENDED (ModestHildonSortDialog, 
43                         modest_hildon_sort_dialog, 
44                         HILDON_TYPE_SORT_DIALOG,
45                         0,
46                         G_IMPLEMENT_INTERFACE (MODEST_TYPE_SORT_CRITERIUM_VIEW, modest_sort_criterium_view_init));
47
48 static void
49 modest_hildon_sort_dialog_finalize (GObject *object)
50 {
51         G_OBJECT_CLASS (modest_hildon_sort_dialog_parent_class)->finalize (object);
52 }
53
54 static void
55 modest_hildon_sort_dialog_class_init (ModestHildonSortDialogClass *klass)
56 {
57         GObjectClass *object_class = G_OBJECT_CLASS (klass);
58
59         object_class->finalize = modest_hildon_sort_dialog_finalize;
60
61 }
62
63 static void
64 modest_hildon_sort_dialog_init (ModestHildonSortDialog *self)
65 {
66 }
67
68 static gint
69 modest_hildon_sort_dialog_add_sort_key        (ModestSortCriteriumView *self,
70                                                const gchar *sort_key)
71 {
72         g_return_val_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self), 0);
73
74         return hildon_sort_dialog_add_sort_key (HILDON_SORT_DIALOG (self), sort_key);
75 }
76
77 static void
78 modest_hildon_sort_dialog_set_sort_key (ModestSortCriteriumView *self, gint key)
79 {
80         g_return_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self));
81
82         hildon_sort_dialog_set_sort_key (HILDON_SORT_DIALOG (self), key);
83 }
84
85 static void
86 modest_hildon_sort_dialog_set_sort_order (ModestSortCriteriumView *self, GtkSortType sort_type)
87 {
88         g_return_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self));
89
90         hildon_sort_dialog_set_sort_order (HILDON_SORT_DIALOG (self), sort_type);
91 }
92
93 static gint
94 modest_hildon_sort_dialog_get_sort_key (ModestSortCriteriumView *self)
95 {
96         g_return_val_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self), 0);
97
98         return hildon_sort_dialog_get_sort_key (HILDON_SORT_DIALOG (self));
99 }
100
101 static GtkSortType 
102 modest_hildon_sort_dialog_get_sort_order (ModestSortCriteriumView *self)
103 {
104         g_return_val_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self), GTK_SORT_ASCENDING);
105
106         return hildon_sort_dialog_get_sort_order (HILDON_SORT_DIALOG (self));
107 }
108
109 static void
110 modest_sort_criterium_view_init (gpointer g_iface,
111                                  gpointer iface_data)
112 {
113         ModestSortCriteriumViewIface *iface = (ModestSortCriteriumViewIface *) g_iface;
114
115         iface->add_sort_key_func = modest_hildon_sort_dialog_add_sort_key;
116         iface->get_sort_key_func = modest_hildon_sort_dialog_get_sort_key;
117         iface->set_sort_key_func = modest_hildon_sort_dialog_set_sort_key;
118         iface->get_sort_order_func = modest_hildon_sort_dialog_get_sort_order;
119         iface->set_sort_order_func = modest_hildon_sort_dialog_set_sort_order;
120 }
121
122 GtkWidget*
123 modest_hildon_sort_dialog_new (GtkWindow *parent)
124 {
125         GtkWidget *result = g_object_new (MODEST_TYPE_HILDON_SORT_DIALOG, NULL);
126
127
128         if (parent)
129                 gtk_window_set_transient_for(GTK_WINDOW(result), parent);
130
131         return result;
132 }
133