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-gtk-details-dialog.h"
46 #include <modest-scrollable.h>
47 #include <modest-ui-constants.h>
48 #include <modest-runtime.h>
50 static void modest_gtk_details_dialog_create_container_default (ModestDetailsDialog *self);
53 G_DEFINE_TYPE (ModestGtkDetailsDialog,
54 modest_gtk_details_dialog,
55 MODEST_TYPE_DETAILS_DIALOG);
57 #define MODEST_GTK_DETAILS_DIALOG_GET_PRIVATE(o) \
58 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_DETAILS_DIALOG, ModestGtkDetailsDialogPrivate))
61 typedef struct _ModestGtkDetailsDialogPrivate ModestGtkDetailsDialogPrivate;
63 struct _ModestGtkDetailsDialogPrivate
65 GtkWidget *props_table;
69 modest_gtk_details_dialog_finalize (GObject *object)
71 G_OBJECT_CLASS (modest_gtk_details_dialog_parent_class)->finalize (object);
75 modest_gtk_details_dialog_class_init (ModestGtkDetailsDialogClass *klass)
77 GObjectClass *object_class = G_OBJECT_CLASS (klass);
79 g_type_class_add_private (klass, sizeof (ModestGtkDetailsDialogPrivate));
80 object_class->finalize = modest_gtk_details_dialog_finalize;
82 MODEST_DETAILS_DIALOG_CLASS (klass)->create_container_func =
83 modest_gtk_details_dialog_create_container_default;
87 modest_gtk_details_dialog_init (ModestGtkDetailsDialog *self)
92 modest_gtk_details_dialog_new_with_header (GtkWindow *parent,
96 ModestDetailsDialog *dialog;
98 g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
99 g_return_val_if_fail (TNY_IS_HEADER (header), NULL);
101 dialog = (ModestDetailsDialog *) (g_object_new (MODEST_TYPE_GTK_DETAILS_DIALOG,
102 "transient-for", parent,
105 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->create_container_func (dialog);
106 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->set_header_func (dialog, header, get_size);
108 return GTK_WIDGET (dialog);
112 modest_gtk_details_dialog_new_with_folder (GtkWindow *parent,
115 ModestDetailsDialog *dialog;
117 g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
118 g_return_val_if_fail (TNY_IS_FOLDER (folder), NULL);
120 dialog = (ModestDetailsDialog *) (g_object_new (MODEST_TYPE_GTK_DETAILS_DIALOG,
121 "transient-for", parent,
124 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->create_container_func (dialog);
125 MODEST_DETAILS_DIALOG_GET_CLASS (dialog)->set_folder_func (dialog, folder);
127 return GTK_WIDGET (dialog);
132 modest_gtk_details_dialog_create_container_default (ModestDetailsDialog *self)
134 ModestGtkDetailsDialogPrivate *priv;
135 GtkWidget *scrollable;
138 priv = MODEST_GTK_DETAILS_DIALOG_GET_PRIVATE (self);
140 gtk_window_set_default_size (GTK_WINDOW (self), -1, MODEST_DIALOG_WINDOW_MAX_HEIGHT);
142 priv->props_table = gtk_table_new (0, 2, FALSE);
143 gtk_table_set_col_spacings (GTK_TABLE (priv->props_table), 12);
144 gtk_table_set_row_spacings (GTK_TABLE (priv->props_table), 1);
146 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
147 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DEFAULT);
149 scrollable = modest_toolkit_factory_create_scrollable (modest_runtime_get_toolkit_factory ());
150 modest_scrollable_set_vertical_policy (MODEST_SCROLLABLE (scrollable), GTK_POLICY_AUTOMATIC);
151 modest_scrollable_set_horizontal_policy (MODEST_SCROLLABLE (scrollable), GTK_POLICY_NEVER);
153 gtk_container_add (GTK_CONTAINER (align), priv->props_table);
154 modest_scrollable_add_with_viewport (MODEST_SCROLLABLE (scrollable),
156 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self)->vbox), scrollable);
158 gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);