bea91cfbc4940241a575cb1a5672154acef575a6
[modest] / src / widgets / modest-global-settings-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 <glib/gi18n.h>
31 #include "modest-global-settings-dialog.h"
32 #include "modest-defs.h"
33 #include "modest-ui-constants.h"
34 /* include other impl specific header files */
35
36 /* 'private'/'protected' functions */
37 static void modest_global_settings_dialog_class_init (ModestGlobalSettingsDialogClass *klass);
38 static void modest_global_settings_dialog_init       (ModestGlobalSettingsDialog *obj);
39 static void modest_global_settings_dialog_finalize   (GObject *obj);
40 /* list my signals  */
41 enum {
42         /* MY_SIGNAL_1, */
43         /* MY_SIGNAL_2, */
44         LAST_SIGNAL
45 };
46
47 static GtkWidget* create_updating_page  (void);
48 static GtkWidget* create_composing_page (void);
49
50 typedef struct _ModestGlobalSettingsDialogPrivate ModestGlobalSettingsDialogPrivate;
51 struct _ModestGlobalSettingsDialogPrivate {
52         GtkWidget *notebook;
53         GtkWidget *updating_page;
54         GtkWidget *composing_page;
55         gboolean   modified;
56 };
57 #define MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
58                                                            MODEST_TYPE_GLOBAL_SETTINGS_DIALOG, \
59                                                            ModestGlobalSettingsDialogPrivate))
60 /* globals */
61 static GtkDialogClass *parent_class = NULL;
62
63 /* uncomment the following if you have defined any signals */
64 /* static guint signals[LAST_SIGNAL] = {0}; */
65
66 GType
67 modest_global_settings_dialog_get_type (void)
68 {
69         static GType my_type = 0;
70         if (!my_type) {
71                 static const GTypeInfo my_info = {
72                         sizeof(ModestGlobalSettingsDialogClass),
73                         NULL,           /* base init */
74                         NULL,           /* base finalize */
75                         (GClassInitFunc) modest_global_settings_dialog_class_init,
76                         NULL,           /* class finalize */
77                         NULL,           /* class data */
78                         sizeof(ModestGlobalSettingsDialog),
79                         1,              /* n_preallocs */
80                         (GInstanceInitFunc) modest_global_settings_dialog_init,
81                         NULL
82                 };
83                 my_type = g_type_register_static (GTK_TYPE_DIALOG,
84                                                   "ModestGlobalSettingsDialog",
85                                                   &my_info, 0);
86         }
87         return my_type;
88 }
89
90 static void
91 modest_global_settings_dialog_class_init (ModestGlobalSettingsDialogClass *klass)
92 {
93         GObjectClass *gobject_class;
94         gobject_class = (GObjectClass*) klass;
95
96         parent_class            = g_type_class_peek_parent (klass);
97         gobject_class->finalize = modest_global_settings_dialog_finalize;
98
99         g_type_class_add_private (gobject_class, sizeof(ModestGlobalSettingsDialogPrivate));
100
101         /* signal definitions go here, e.g.: */
102 /*      signals[MY_SIGNAL_1] = */
103 /*              g_signal_new ("my_signal_1",....); */
104 /*      signals[MY_SIGNAL_2] = */
105 /*              g_signal_new ("my_signal_2",....); */
106 /*      etc. */
107 }
108
109 static void
110 modest_global_settings_dialog_init (ModestGlobalSettingsDialog *self)
111 {
112         ModestGlobalSettingsDialogPrivate *priv;
113
114         priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
115
116         priv->modified = FALSE;
117         priv->notebook = gtk_notebook_new ();
118         priv->updating_page = create_updating_page ();
119         priv->composing_page = create_composing_page ();
120     
121         /* Add the notebook pages: */
122         gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), priv->updating_page, 
123                 gtk_label_new (_("mcen_ti_options_updating")));
124         gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), priv->composing_page, 
125                 gtk_label_new (_("mcen_ti_options_composing")));
126                 
127         gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self)->vbox), priv->notebook);
128         gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (self)->vbox), MODEST_MARGIN_HALF);
129         gtk_widget_show (priv->notebook);
130         
131         /* Add the buttons: */
132         gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_OK, GTK_RESPONSE_OK);
133         gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
134     
135 /*      /\* Connect to the dialog's response signal: *\/ */
136 /*      /\* We use connect-before  */
137 /*       * so we can stop the signal emission,  */
138 /*       * to stop the default signal handler from closing the dialog. */
139 /*       *\/ */
140 /*      g_signal_connect (G_OBJECT (self), "response", */
141 /*                        G_CALLBACK (on_response), self);  */
142
143         /* Set title */
144         gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_options"));
145 }
146
147 static void
148 modest_global_settings_dialog_finalize (GObject *obj)
149 {
150 /*      free/unref instance resources here */
151         G_OBJECT_CLASS(parent_class)->finalize (obj);
152 }
153
154 GtkWidget*
155 modest_global_settings_dialog_new (void)
156 {
157         return GTK_WIDGET(g_object_new(MODEST_TYPE_GLOBAL_SETTINGS_DIALOG, NULL));
158 }
159
160 /* insert many other interesting function implementations */
161 /* such as modest_global_settings_dialog_do_something, or modest_global_settings_dialog_has_foo */
162
163 static GtkWidget*
164 create_updating_page (void)
165 {
166         GtkWidget *box;
167
168         box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
169
170         return box;
171 }
172
173 static GtkWidget* 
174 create_composing_page (void)
175 {
176         GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
177
178         box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
179
180         return box;
181 }