1 /* Copyright (c) 2008, 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-details-dialog.h"
32 #include <glib/gi18n.h>
33 #include <gdk/gdkkeysyms.h>
34 #include <gtk/gtkscrolledwindow.h>
35 #include <gtk/gtktable.h>
36 #include <gtk/gtkstock.h>
37 #include <gtk/gtklabel.h>
39 #include <tny-header.h>
40 #include <tny-header-view.h>
41 #include <tny-folder-store.h>
42 #include <modest-tny-folder.h>
43 #include <modest-tny-account.h>
44 #include <modest-text-utils.h>
45 #include "modest-hildon2-details-dialog.h"
46 #include <hildon/hildon-pannable-area.h>
47 #include <modest-ui-constants.h>
49 static void modest_hildon2_details_dialog_create_container_default (ModestDetailsDialog *self);
52 G_DEFINE_TYPE (ModestHildon2DetailsDialog,
53 modest_hildon2_details_dialog,
54 MODEST_TYPE_DETAILS_DIALOG);
56 #define MODEST_HILDON2_DETAILS_DIALOG_GET_PRIVATE(o) \
57 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_DETAILS_DIALOG, ModestHildon2DetailsDialogPrivate))
60 typedef struct _ModestHildon2DetailsDialogPrivate ModestHildon2DetailsDialogPrivate;
62 struct _ModestHildon2DetailsDialogPrivate
64 GtkWidget *props_table;
68 modest_hildon2_details_dialog_finalize (GObject *object)
70 G_OBJECT_CLASS (modest_hildon2_details_dialog_parent_class)->finalize (object);
74 modest_hildon2_details_dialog_class_init (ModestHildon2DetailsDialogClass *klass)
76 GObjectClass *object_class = G_OBJECT_CLASS (klass);
78 g_type_class_add_private (klass, sizeof (ModestHildon2DetailsDialogPrivate));
79 object_class->finalize = modest_hildon2_details_dialog_finalize;
81 MODEST_DETAILS_DIALOG_CLASS (klass)->create_container_func =
82 modest_hildon2_details_dialog_create_container_default;
86 modest_hildon2_details_dialog_init (ModestHildon2DetailsDialog *self)
91 modest_hildon2_details_dialog_new_with_header (GtkWindow *parent,
95 ModestDetailsDialog *dialog;
97 g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
98 g_return_val_if_fail (TNY_IS_HEADER (header), NULL);
100 dialog = (ModestDetailsDialog *) (g_object_new (MODEST_TYPE_HILDON2_DETAILS_DIALOG,
101 "transient-for", parent,
104 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->create_container_func (dialog);
105 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->set_header_func (dialog, header, get_size);
107 return GTK_WIDGET (dialog);
111 modest_hildon2_details_dialog_new_with_folder (GtkWindow *parent,
114 ModestDetailsDialog *dialog;
116 g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
117 g_return_val_if_fail (TNY_IS_FOLDER (folder), NULL);
119 dialog = (ModestDetailsDialog *) (g_object_new (MODEST_TYPE_HILDON2_DETAILS_DIALOG,
120 "transient-for", parent,
123 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->create_container_func (dialog);
124 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->set_folder_func (dialog, folder);
126 return GTK_WIDGET (dialog);
131 modest_hildon2_details_dialog_create_container_default (ModestDetailsDialog *self)
133 ModestHildon2DetailsDialogPrivate *priv;
137 priv = MODEST_HILDON2_DETAILS_DIALOG_GET_PRIVATE (self);
139 gtk_window_set_default_size (GTK_WINDOW (self), -1, MODEST_DIALOG_WINDOW_MAX_HEIGHT);
141 priv->props_table = gtk_table_new (0, 2, FALSE);
142 gtk_table_set_col_spacings (GTK_TABLE (priv->props_table), 12);
143 gtk_table_set_row_spacings (GTK_TABLE (priv->props_table), 1);
145 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
146 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DEFAULT);
148 pannable = g_object_new (HILDON_TYPE_PANNABLE_AREA, "initial-hint", TRUE, NULL);
149 gtk_container_add (GTK_CONTAINER (align), priv->props_table);
150 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable),
152 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self)->vbox), pannable);
154 gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);