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-window.h"
31 #include "modest-window-priv.h"
32 #include "modest-tny-platform-factory.h"
34 /* 'private'/'protected' functions */
35 static void modest_window_class_init (ModestWindowClass *klass);
36 static void modest_window_init (ModestWindow *obj);
37 static void modest_window_finalize (GObject *obj);
39 static void modest_window_set_zoom_default (ModestWindow *window,
41 static gdouble modest_window_get_zoom_default (ModestWindow *window);
42 static gboolean modest_window_zoom_plus_default (ModestWindow *window);
43 static gboolean modest_window_zoom_minus_default (ModestWindow *window);
44 static void modest_window_create_toolbar_default (ModestWindow *window);
45 static void modest_window_show_toolbar_default (ModestWindow *window,
46 gboolean show_toolbar);
54 static GObjectClass *parent_class = NULL;
56 /* uncomment the following if you have defined any signals */
57 /* static guint signals[LAST_SIGNAL] = {0}; */
60 modest_window_get_type (void)
62 static GType my_type = 0;
63 static GType parent_type = 0;
65 static const GTypeInfo my_info = {
66 sizeof(ModestWindowClass),
68 NULL, /* base finalize */
69 (GClassInitFunc) modest_window_class_init,
70 NULL, /* class finalize */
71 NULL, /* class data */
74 (GInstanceInitFunc) modest_window_init,
77 #ifdef MODEST_PLATFORM_MAEMO
78 parent_type = HILDON_TYPE_WINDOW;
80 parent_type = GTK_TYPE_WINDOW;
82 my_type = g_type_register_static (parent_type,
85 G_TYPE_FLAG_ABSTRACT);
91 modest_window_class_init (ModestWindowClass *klass)
93 GObjectClass *gobject_class;
94 gobject_class = (GObjectClass*) klass;
96 parent_class = g_type_class_peek_parent (klass);
97 gobject_class->finalize = modest_window_finalize;
99 klass->set_zoom_func = modest_window_set_zoom_default;
100 klass->get_zoom_func = modest_window_get_zoom_default;
101 klass->zoom_plus_func = modest_window_zoom_plus_default;
102 klass->zoom_minus_func = modest_window_zoom_minus_default;
103 klass->create_toolbar_func = modest_window_create_toolbar_default;
104 klass->show_toolbar_func = modest_window_show_toolbar_default;
106 g_type_class_add_private (gobject_class, sizeof(ModestWindowPrivate));
110 modest_window_init (ModestWindow *obj)
112 ModestWindowPrivate *priv;
114 priv = MODEST_WINDOW_GET_PRIVATE(obj);
116 priv->ui_manager = NULL;
117 priv->toolbar = NULL;
118 priv->menubar = NULL;
120 priv->active_account = NULL;
124 modest_window_finalize (GObject *obj)
126 ModestWindowPrivate *priv;
128 priv = MODEST_WINDOW_GET_PRIVATE(obj);
130 if (priv->ui_manager) {
131 g_object_unref (G_OBJECT(priv->ui_manager));
132 priv->ui_manager = NULL;
135 g_free (priv->active_account);
137 G_OBJECT_CLASS(parent_class)->finalize (obj);
143 modest_window_get_active_account (ModestWindow *self)
145 g_return_val_if_fail (self, NULL);
147 return MODEST_WINDOW_GET_PRIVATE(self)->active_account;
151 modest_window_set_active_account (ModestWindow *self, const gchar *active_account)
153 ModestWindowPrivate *priv;
155 priv = MODEST_WINDOW_GET_PRIVATE(self);
157 if (active_account == priv->active_account)
160 g_free (priv->active_account);
161 priv->active_account = g_strdup (active_account);
166 modest_window_set_zoom (ModestWindow *window,
169 MODEST_WINDOW_GET_CLASS (window)->set_zoom_func (window, zoom);
174 modest_window_get_zoom (ModestWindow *window)
176 return MODEST_WINDOW_GET_CLASS (window)->get_zoom_func (window);
180 modest_window_zoom_plus (ModestWindow *window)
182 return MODEST_WINDOW_GET_CLASS (window)->zoom_plus_func (window);
186 modest_window_zoom_minus (ModestWindow *window)
188 return MODEST_WINDOW_GET_CLASS (window)->zoom_minus_func (window);
192 modest_window_create_toolbar (ModestWindow *window)
194 MODEST_WINDOW_GET_CLASS (window)->create_toolbar_func (window);
198 modest_window_show_toolbar (ModestWindow *window,
199 gboolean show_toolbar)
201 MODEST_WINDOW_GET_CLASS (window)->show_toolbar_func (window,
206 modest_window_view_toolbar (ModestWindow *window,
207 gboolean show_toolbar)
209 ModestWindowPrivate *priv;
211 priv = MODEST_WINDOW_GET_PRIVATE(window);
213 /* Lazy strategy, we create the toolbar just when there is no
214 toolbar and we want to show it */
215 if (!priv->toolbar && show_toolbar)
216 modest_window_create_toolbar (window);
219 modest_window_show_toolbar (window, show_toolbar);
223 /* Default implementations */
226 modest_window_set_zoom_default (ModestWindow *window,
229 g_warning ("modest: You should implement %s", __FUNCTION__);
234 modest_window_get_zoom_default (ModestWindow *window)
236 g_warning ("modest: You should implement %s", __FUNCTION__);
241 modest_window_zoom_plus_default (ModestWindow *window)
243 g_warning ("modest: You should implement %s", __FUNCTION__);
248 modest_window_zoom_minus_default (ModestWindow *window)
250 g_warning ("modest: You should implement %s", __FUNCTION__);
255 modest_window_create_toolbar_default (ModestWindow *window)
257 g_warning ("modest: You should implement %s", __FUNCTION__);
261 modest_window_show_toolbar_default (ModestWindow *window,
262 gboolean show_toolbar)
264 g_warning ("modest: You should implement %s", __FUNCTION__);