1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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.
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.
30 #include "modest-hildon-sort-dialog.h"
31 #include "widgets/modest-sort-criterium-view.h"
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);
42 G_DEFINE_TYPE_EXTENDED (ModestHildonSortDialog,
43 modest_hildon_sort_dialog,
44 HILDON_TYPE_SORT_DIALOG,
46 G_IMPLEMENT_INTERFACE (MODEST_TYPE_SORT_CRITERIUM_VIEW, modest_sort_criterium_view_init));
49 modest_hildon_sort_dialog_finalize (GObject *object)
51 G_OBJECT_CLASS (modest_hildon_sort_dialog_parent_class)->finalize (object);
55 modest_hildon_sort_dialog_class_init (ModestHildonSortDialogClass *klass)
57 GObjectClass *object_class = G_OBJECT_CLASS (klass);
59 object_class->finalize = modest_hildon_sort_dialog_finalize;
64 modest_hildon_sort_dialog_init (ModestHildonSortDialog *self)
69 modest_hildon_sort_dialog_add_sort_key (ModestSortCriteriumView *self,
70 const gchar *sort_key)
72 g_return_val_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self), 0);
74 return hildon_sort_dialog_add_sort_key (HILDON_SORT_DIALOG (self), sort_key);
78 modest_hildon_sort_dialog_set_sort_key (ModestSortCriteriumView *self, gint key)
80 g_return_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self));
82 hildon_sort_dialog_set_sort_key (HILDON_SORT_DIALOG (self), key);
86 modest_hildon_sort_dialog_set_sort_order (ModestSortCriteriumView *self, GtkSortType sort_type)
88 g_return_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self));
90 hildon_sort_dialog_set_sort_order (HILDON_SORT_DIALOG (self), sort_type);
94 modest_hildon_sort_dialog_get_sort_key (ModestSortCriteriumView *self)
96 g_return_val_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self), 0);
98 return hildon_sort_dialog_get_sort_key (HILDON_SORT_DIALOG (self));
102 modest_hildon_sort_dialog_get_sort_order (ModestSortCriteriumView *self)
104 g_return_val_if_fail (MODEST_IS_HILDON_SORT_DIALOG (self), GTK_SORT_ASCENDING);
106 return hildon_sort_dialog_get_sort_order (HILDON_SORT_DIALOG (self));
110 modest_sort_criterium_view_init (gpointer g_iface,
113 ModestSortCriteriumViewIface *iface = (ModestSortCriteriumViewIface *) g_iface;
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;
123 modest_hildon_sort_dialog_new (GtkWindow *parent)
125 GtkWidget *result = g_object_new (MODEST_TYPE_HILDON_SORT_DIALOG, NULL);
129 gtk_window_set_transient_for(GTK_WINDOW(result), parent);