From: Sergio Villar Senin Date: Tue, 2 Dec 2008 16:04:33 +0000 (+0000) Subject: * Window manager mimics the way close should work if main window implements the three... X-Git-Tag: git_migration_finished~965 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=48d90b657563c7533c8c7b6e4b97db3a2200f566;hp=6da069facbb5ee7ce39aacb29dc6db713cb74101 * Window manager mimics the way close should work if main window implements the three views. * Added first release of modest folder window. * Now selecting an account in main window for viewing also opens a folder window. pmo-trunk-r6494 --- diff --git a/src/hildon2/Makefile.am b/src/hildon2/Makefile.am index d601c2d..0df3743 100644 --- a/src/hildon2/Makefile.am +++ b/src/hildon2/Makefile.am @@ -57,6 +57,8 @@ libmodest_ui_la_SOURCES= \ modest-provider-picker.h modest-provider-picker.c \ modest-serversecurity-picker.h modest-serversecurity-picker.c \ modest-servertype-picker.h modest-servertype-picker.c \ + modest-folder-window.c \ + modest-folder-window.h \ modest-icon-names.h \ modest-hildon2-global-settings-dialog.c \ modest-hildon2-global-settings-dialog.h \ diff --git a/src/hildon2/modest-folder-window.c b/src/hildon2/modest-folder-window.c new file mode 100644 index 0000000..71744be --- /dev/null +++ b/src/hildon2/modest-folder-window.c @@ -0,0 +1,269 @@ +/* Copyright (c) 2008, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* 'private'/'protected' functions */ +static void modest_folder_window_class_init (ModestFolderWindowClass *klass); +static void modest_folder_window_init (ModestFolderWindow *obj); +static void modest_folder_window_finalize (GObject *obj); + +static void connect_signals (ModestFolderWindow *self); +static void modest_folder_window_disconnect_signals (ModestWindow *self); + +static gboolean on_zoom_minus_plus_not_implemented (ModestWindow *window); + +typedef struct _ModestFolderWindowPrivate ModestFolderWindowPrivate; +struct _ModestFolderWindowPrivate { + + GtkWidget *folder_view; + + /* signals */ + GSList *sighandlers; + + /* Display state */ + osso_display_state_t display_state; +}; +#define MODEST_FOLDER_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ + MODEST_TYPE_FOLDER_WINDOW, \ + ModestFolderWindowPrivate)) + +/* globals */ +static GtkWindowClass *parent_class = NULL; + +/************************************************************************/ + +GType +modest_folder_window_get_type (void) +{ + static GType my_type = 0; + if (!my_type) { + static const GTypeInfo my_info = { + sizeof(ModestFolderWindowClass), + NULL, /* base init */ + NULL, /* base finalize */ + (GClassInitFunc) modest_folder_window_class_init, + NULL, /* class finalize */ + NULL, /* class data */ + sizeof(ModestFolderWindow), + 1, /* n_preallocs */ + (GInstanceInitFunc) modest_folder_window_init, + NULL + }; + my_type = g_type_register_static (MODEST_TYPE_WINDOW, + "ModestFolderWindow", + &my_info, 0); + } + return my_type; +} + +static void +modest_folder_window_class_init (ModestFolderWindowClass *klass) +{ + GObjectClass *gobject_class; + gobject_class = (GObjectClass*) klass; + ModestWindowClass *modest_window_class = (ModestWindowClass *) klass; + + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = modest_folder_window_finalize; + + g_type_class_add_private (gobject_class, sizeof(ModestFolderWindowPrivate)); + + modest_window_class->zoom_minus_func = on_zoom_minus_plus_not_implemented; + modest_window_class->zoom_plus_func = on_zoom_minus_plus_not_implemented; + modest_window_class->disconnect_signals_func = modest_folder_window_disconnect_signals; +} + +static void +modest_folder_window_init (ModestFolderWindow *obj) +{ + ModestFolderWindowPrivate *priv; + + priv = MODEST_FOLDER_WINDOW_GET_PRIVATE(obj); + + priv->sighandlers = NULL; + priv->display_state = OSSO_DISPLAY_ON; + + priv->folder_view = NULL; + + modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(), + GTK_WINDOW(obj), + "applications_email_folderview"); +} + +static void +modest_folder_window_finalize (GObject *obj) +{ + ModestFolderWindowPrivate *priv; + + priv = MODEST_FOLDER_WINDOW_GET_PRIVATE(obj); + + /* Sanity check: shouldn't be needed, the window mgr should + call this function before */ + modest_folder_window_disconnect_signals (MODEST_WINDOW (obj)); + + G_OBJECT_CLASS(parent_class)->finalize (obj); +} + +static void +modest_folder_window_disconnect_signals (ModestWindow *self) +{ + ModestFolderWindowPrivate *priv; + priv = MODEST_FOLDER_WINDOW_GET_PRIVATE(self); + + modest_signal_mgr_disconnect_all_and_destroy (priv->sighandlers); + priv->sighandlers = NULL; +} + +static void +connect_signals (ModestFolderWindow *self) +{ + ModestFolderWindowPrivate *priv; + + priv = MODEST_FOLDER_WINDOW_GET_PRIVATE(self); + + /* folder view */ + + /* TODO: connect folder view activate */ + + /* window */ + + /* we don't register this in sighandlers, as it should be run after disconnecting all signals, + * in destroy stage */ + + +} + +static void +osso_display_event_cb (osso_display_state_t state, + gpointer data) +{ + ModestFolderWindowPrivate *priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (data); + + priv->display_state = state; + + /* Stop blinking if the screen becomes on */ + if (priv->display_state == OSSO_DISPLAY_ON) + modest_platform_remove_new_mail_notifications (TRUE); +} + +ModestWindow * +modest_folder_window_new (TnyFolderStoreQuery *query) +{ + ModestFolderWindow *self = NULL; + ModestFolderWindowPrivate *priv = NULL; + HildonProgram *app; + GdkPixbuf *window_icon; + GtkWidget *pannable; + + self = MODEST_FOLDER_WINDOW(g_object_new(MODEST_TYPE_FOLDER_WINDOW, NULL)); + priv = MODEST_FOLDER_WINDOW_GET_PRIVATE(self); + pannable = hildon_pannable_area_new (); + priv->folder_view = modest_platform_create_folder_view (query); + + /* Set account store */ + tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view), + TNY_ACCOUNT_STORE (modest_runtime_get_account_store ())); + + gtk_container_add (GTK_CONTAINER (pannable), priv->folder_view); + gtk_container_add (GTK_CONTAINER (self), pannable); + + gtk_widget_show (priv->folder_view); + gtk_widget_show (pannable); + + connect_signals (MODEST_FOLDER_WINDOW (self)); + + /* Load previous osso state, for instance if we are being restored from + * hibernation: */ + modest_osso_load_state (); + + /* Get device name */ + modest_maemo_utils_get_device_name (); + + app = hildon_program_get_instance (); + hildon_program_add_window (app, HILDON_WINDOW (self)); + + /* Set window icon */ + window_icon = modest_platform_get_icon (MODEST_APP_ICON, MODEST_ICON_SIZE_BIG); + if (window_icon) { + gtk_window_set_icon (GTK_WINDOW (self), window_icon); + g_object_unref (window_icon); + } + + /* Listen for changes in the screen, we don't want to show a + led pattern when the display is on for example */ + osso_hw_set_display_event_cb (modest_maemo_utils_get_osso_context (), + osso_display_event_cb, + self); + + /* Dont't restore settings here, + * because it requires a gtk_widget_show(), + * and we don't want to do that until later, + * so that the UI is not visible for non-menu D-Bus activation. + */ + + return MODEST_WINDOW(self); +} + +static gboolean +on_zoom_minus_plus_not_implemented (ModestWindow *window) +{ + g_return_val_if_fail (MODEST_IS_FOLDER_WINDOW (window), FALSE); + + hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_cannot_zoom_here")); + return FALSE; + +} + +gboolean +modest_folder_window_screen_is_on (ModestFolderWindow *self) +{ + ModestFolderWindowPrivate *priv = NULL; + + g_return_val_if_fail (MODEST_IS_FOLDER_WINDOW(self), FALSE); + + priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (self); + + return (priv->display_state == OSSO_DISPLAY_ON) ? TRUE : FALSE; +} + diff --git a/src/hildon2/modest-folder-window.h b/src/hildon2/modest-folder-window.h new file mode 100644 index 0000000..a265fd2 --- /dev/null +++ b/src/hildon2/modest-folder-window.h @@ -0,0 +1,89 @@ +/* Copyright (c) 2008 Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __MODEST_FOLDER_WINDOW_H__ +#define __MODEST_FOLDER_WINDOW_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +/* convenience macros */ +#define MODEST_TYPE_FOLDER_WINDOW (modest_folder_window_get_type()) +#define MODEST_FOLDER_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_FOLDER_WINDOW,ModestFolderWindow)) +#define MODEST_FOLDER_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_FOLDER_WINDOW,ModestWindow)) + +#define MODEST_IS_FOLDER_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_FOLDER_WINDOW)) +#define MODEST_IS_FOLDER_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_FOLDER_WINDOW)) +#define MODEST_FOLDER_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_FOLDER_WINDOW,ModestFolderWindowClass)) + +typedef struct _ModestFolderWindow ModestFolderWindow; +typedef struct _ModestFolderWindowClass ModestFolderWindowClass; + +struct _ModestFolderWindow { + ModestWindow parent; +}; + +struct _ModestFolderWindowClass { + ModestWindowClass parent_class; +}; + +/** + * modest_folder_window_get_type: + * + * get the GType for the ModestFolderWindow class + * + * Returns: a GType for ModestFolderWindow + */ +GType modest_folder_window_get_type (void) G_GNUC_CONST; + + +/** + * modest_folder_window_new: + * @query: a #TnyFolderStoreQuery that specifies the folders to show + * + * instantiates a new ModestFolderWindow widget + * + * Returns: a new ModestFolderWindow, or NULL in case of error + */ +ModestWindow* modest_folder_window_new (TnyFolderStoreQuery *query); + +/** + * modest_folder_window_get_folder_view: + * @self: a #ModestFolderWindow + * + * get the folder view inside the folder window + */ +ModestFolderView *modest_folder_window_get_folder_view (ModestFolderWindow *self); + +G_END_DECLS + +#endif diff --git a/src/hildon2/modest-hildon2-window-mgr.c b/src/hildon2/modest-hildon2-window-mgr.c index 6031a59..ba1c668 100644 --- a/src/hildon2/modest-hildon2-window-mgr.c +++ b/src/hildon2/modest-hildon2-window-mgr.c @@ -491,8 +491,17 @@ on_window_destroy (ModestWindow *window, /* Specific stuff first */ if (MODEST_IS_MAIN_WINDOW (window)) { ModestHildon2WindowMgrPrivate *priv; + ModestMainWindowContentsStyle style; priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self); + /* If we're on header view, then just go to folder view and don't close */ + style = modest_main_window_get_contents_style (MODEST_MAIN_WINDOW (window)); + if (style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS) { + modest_main_window_set_contents_style (MODEST_MAIN_WINDOW (window), + MODEST_MAIN_WINDOW_CONTENTS_STYLE_FOLDERS); + return TRUE; + } + /* Do not unregister it, just hide */ gtk_widget_hide_all (GTK_WIDGET (window)); diff --git a/src/hildon2/modest-main-window.c b/src/hildon2/modest-main-window.c index 7788f35..4350e5a 100644 --- a/src/hildon2/modest-main-window.c +++ b/src/hildon2/modest-main-window.c @@ -65,6 +65,7 @@ #include "modest-text-utils.h" #include "modest-signal-mgr.h" #include +#include #define MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS "ModestMainWindowActionAdditions" @@ -2131,6 +2132,14 @@ set_account_visible(ModestMainWindow *self, const gchar *acc_name) g_object_unref (store_settings); g_object_unref (settings); } + + GtkWidget *folder_window; + + folder_window = GTK_WIDGET (modest_folder_window_new (NULL)); + modest_window_mgr_register_window (modest_runtime_get_window_mgr (), + MODEST_WINDOW (folder_window), + MODEST_WINDOW (self)); + gtk_widget_show (folder_window); } /* Make sure that at least one account is "viewed": */