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>
48 static void modest_hildon2_details_dialog_create_container_default (ModestDetailsDialog *self);
51 G_DEFINE_TYPE (ModestHildon2DetailsDialog,
52 modest_hildon2_details_dialog,
53 MODEST_TYPE_DETAILS_DIALOG);
55 #define MODEST_HILDON2_DETAILS_DIALOG_GET_PRIVATE(o) \
56 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_DETAILS_DIALOG, ModestHildon2DetailsDialogPrivate))
59 typedef struct _ModestHildon2DetailsDialogPrivate ModestHildon2DetailsDialogPrivate;
61 struct _ModestHildon2DetailsDialogPrivate
63 GtkWidget *props_table;
67 modest_hildon2_details_dialog_finalize (GObject *object)
69 G_OBJECT_CLASS (modest_hildon2_details_dialog_parent_class)->finalize (object);
73 modest_hildon2_details_dialog_class_init (ModestHildon2DetailsDialogClass *klass)
75 GObjectClass *object_class = G_OBJECT_CLASS (klass);
77 g_type_class_add_private (klass, sizeof (ModestHildon2DetailsDialogPrivate));
78 object_class->finalize = modest_hildon2_details_dialog_finalize;
80 MODEST_DETAILS_DIALOG_CLASS (klass)->create_container_func =
81 modest_hildon2_details_dialog_create_container_default;
85 modest_hildon2_details_dialog_init (ModestHildon2DetailsDialog *self)
90 modest_hildon2_details_dialog_new_with_header (GtkWindow *parent,
93 ModestDetailsDialog *dialog;
95 g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
96 g_return_val_if_fail (TNY_IS_HEADER (header), NULL);
98 dialog = (ModestDetailsDialog *) (g_object_new (MODEST_TYPE_HILDON2_DETAILS_DIALOG,
99 "transient-for", parent,
102 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->create_container_func (dialog);
103 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->set_header_func (dialog, header);
105 return GTK_WIDGET (dialog);
109 modest_hildon2_details_dialog_new_with_folder (GtkWindow *parent,
112 ModestDetailsDialog *dialog;
114 g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
115 g_return_val_if_fail (TNY_IS_FOLDER (folder), NULL);
117 dialog = (ModestDetailsDialog *) (g_object_new (MODEST_TYPE_HILDON2_DETAILS_DIALOG,
118 "transient-for", parent,
121 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->create_container_func (dialog);
122 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->set_folder_func (dialog, folder);
124 return GTK_WIDGET (dialog);
129 modest_hildon2_details_dialog_create_container_default (ModestDetailsDialog *self)
131 ModestHildon2DetailsDialogPrivate *priv;
134 priv = MODEST_HILDON2_DETAILS_DIALOG_GET_PRIVATE (self);
136 gtk_window_set_default_size (GTK_WINDOW (self), 400, 220);
138 priv->props_table = gtk_table_new (0, 2, FALSE);
139 gtk_table_set_col_spacings (GTK_TABLE (priv->props_table), 12);
140 gtk_table_set_row_spacings (GTK_TABLE (priv->props_table), 1);
142 pannable = g_object_new (HILDON_TYPE_PANNABLE_AREA, "initial-hint", TRUE, NULL);
143 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable),
144 GTK_WIDGET (priv->props_table));
145 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self)->vbox), pannable);
147 gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);