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_show_toolbar_default (ModestWindow *window,
45 gboolean show_toolbar);
53 static GObjectClass *parent_class = NULL;
55 /* uncomment the following if you have defined any signals */
56 /* static guint signals[LAST_SIGNAL] = {0}; */
59 modest_window_get_type (void)
61 static GType my_type = 0;
62 static GType parent_type = 0;
64 static const GTypeInfo my_info = {
65 sizeof(ModestWindowClass),
67 NULL, /* base finalize */
68 (GClassInitFunc) modest_window_class_init,
69 NULL, /* class finalize */
70 NULL, /* class data */
73 (GInstanceInitFunc) modest_window_init,
76 #ifdef MODEST_PLATFORM_MAEMO
77 parent_type = HILDON_TYPE_WINDOW;
79 parent_type = GTK_TYPE_WINDOW;
81 my_type = g_type_register_static (parent_type,
84 G_TYPE_FLAG_ABSTRACT);
90 modest_window_class_init (ModestWindowClass *klass)
92 GObjectClass *gobject_class;
93 gobject_class = (GObjectClass*) klass;
95 parent_class = g_type_class_peek_parent (klass);
96 gobject_class->finalize = modest_window_finalize;
98 klass->set_zoom_func = modest_window_set_zoom_default;
99 klass->get_zoom_func = modest_window_get_zoom_default;
100 klass->zoom_plus_func = modest_window_zoom_plus_default;
101 klass->zoom_minus_func = modest_window_zoom_minus_default;
102 klass->show_toolbar_func = modest_window_show_toolbar_default;
104 g_type_class_add_private (gobject_class, sizeof(ModestWindowPrivate));
108 modest_window_init (ModestWindow *obj)
110 ModestWindowPrivate *priv;
112 priv = MODEST_WINDOW_GET_PRIVATE(obj);
114 priv->ui_manager = NULL;
115 priv->toolbar = NULL;
116 priv->menubar = NULL;
118 priv->active_account = NULL;
122 modest_window_finalize (GObject *obj)
124 ModestWindowPrivate *priv;
126 priv = MODEST_WINDOW_GET_PRIVATE(obj);
128 if (priv->ui_manager) {
129 g_object_unref (G_OBJECT(priv->ui_manager));
130 priv->ui_manager = NULL;
133 g_free (priv->active_account);
135 G_OBJECT_CLASS(parent_class)->finalize (obj);
141 modest_window_get_active_account (ModestWindow *self)
143 g_return_val_if_fail (self, NULL);
145 return MODEST_WINDOW_GET_PRIVATE(self)->active_account;
149 modest_window_set_active_account (ModestWindow *self, const gchar *active_account)
151 ModestWindowPrivate *priv;
153 priv = MODEST_WINDOW_GET_PRIVATE(self);
155 if (active_account == priv->active_account)
158 g_free (priv->active_account);
159 priv->active_account = g_strdup (active_account);
164 modest_window_set_zoom (ModestWindow *window,
167 MODEST_WINDOW_GET_CLASS (window)->set_zoom_func (window, zoom);
172 modest_window_get_zoom (ModestWindow *window)
174 return MODEST_WINDOW_GET_CLASS (window)->get_zoom_func (window);
178 modest_window_zoom_plus (ModestWindow *window)
180 return MODEST_WINDOW_GET_CLASS (window)->zoom_plus_func (window);
184 modest_window_zoom_minus (ModestWindow *window)
186 return MODEST_WINDOW_GET_CLASS (window)->zoom_minus_func (window);
190 modest_window_show_toolbar (ModestWindow *window,
191 gboolean show_toolbar)
193 MODEST_WINDOW_GET_CLASS (window)->show_toolbar_func (window,
198 /* Default implementations */
201 modest_window_set_zoom_default (ModestWindow *window,
204 g_warning ("modest: You should implement %s", __FUNCTION__);
209 modest_window_get_zoom_default (ModestWindow *window)
211 g_warning ("modest: You should implement %s", __FUNCTION__);
216 modest_window_zoom_plus_default (ModestWindow *window)
218 g_warning ("modest: You should implement %s", __FUNCTION__);
223 modest_window_zoom_minus_default (ModestWindow *window)
225 g_warning ("modest: You should implement %s", __FUNCTION__);
230 modest_window_show_toolbar_default (ModestWindow *window,
231 gboolean show_toolbar)
233 g_warning ("modest: You should implement %s", __FUNCTION__);