* Added support to better handle online/offline status
authorSergio Villar Senin <svillar@igalia.com>
Fri, 15 Dec 2006 10:28:21 +0000 (10:28 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Fri, 15 Dec 2006 10:28:21 +0000 (10:28 +0000)
pmo-trunk-r560

src/modest-widget-factory.c
src/widgets/Makefile.am
src/widgets/modest-header-view-priv.h [new file with mode: 0644]
src/widgets/modest-header-view.c
src/widgets/modest-header-view.h

index 1d8128d..b51b749 100644 (file)
 
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
-#include "modest-widget-factory.h"
-#include <modest-widget-memory.h>
-#include <modest-protocol-mgr.h>
 #include <tny-gtk-account-list-model.h>
 #include <tny-gtk-folder-store-tree-model.h>
 #include <tny-account-store.h>
 #include <tny-device.h>
 #include <tny-folder-store-query.h>
-
+#include "modest-widget-factory.h"
+#include "modest-widget-memory.h"
+#include "modest-protocol-mgr.h"
 #include "modest-tny-platform-factory.h"
 #include "modest-account-mgr.h"
 #include "modest-mail-operation.h"
-
+#include "widgets/modest-header-view-priv.h"
 
 /* 'private'/'protected' functions */
 static void modest_widget_factory_class_init    (ModestWidgetFactoryClass *klass);
@@ -675,6 +674,7 @@ on_connection_changed (TnyDevice *device, gboolean online,
                       ModestWidgetFactory *self)
 {
        ModestWidgetFactoryPrivate *priv;
+
        priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(self);
 
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(priv->online_toggle),
@@ -683,6 +683,15 @@ on_connection_changed (TnyDevice *device, gboolean online,
                              online ? _("Online") : _("Offline"));
 
        statusbar_push (self, 0, online ? _("Modest went online") : _("Modest went offline"));
+
+       /* If Modest has became online and the header view has a
+          header selected then show it */
+       if (online) {
+               GtkTreeSelection *selected;
+
+               selected = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->header_view));
+               _modest_header_view_change_selection (selected, priv->header_view);
+       }
 }
 
 
index 294d0f0..d6ee292 100644 (file)
@@ -21,6 +21,7 @@ libmodest_widgets_la_SOURCES=   \
        modest-folder-view.h    \
        modest-header-view.c    \
        modest-header-view.h    \
+       modest-header-view-priv.h \
        modest-msg-view.c       \
        modest-msg-view.h       \
        modest-toolbar.h        \
diff --git a/src/widgets/modest-header-view-priv.h b/src/widgets/modest-header-view-priv.h
new file mode 100644 (file)
index 0000000..82b6e4f
--- /dev/null
@@ -0,0 +1,43 @@
+/* Copyright (c) 2006, 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_HEADER_VIEW_PRIV_H__
+#define __MODEST_HEADER_VIEW_PRIV_H__
+
+#include <gtk/gtktreeview.h>
+#include "modest-header-view.h"
+
+G_BEGIN_DECLS
+
+void _modest_header_view_change_selection (GtkTreeSelection *selection,
+                                          gpointer user_data);
+
+G_END_DECLS
+
+#endif /* __MODEST_HEADER_VIEW_PRIV_H__ */
index 0a8dcbe..9b4449c 100644 (file)
@@ -959,3 +959,18 @@ on_selection_changed (GtkTreeSelection *sel, gpointer user_data)
        /* Frees */
        g_object_unref (G_OBJECT (folder));
 }
+
+
+/* PROTECTED method. It's useful when we want to force a given
+   selection to reload a msg. For example if we have selected a header
+   in offline mode, when Modest become online, we want to reload the
+   message automatically without an user click over the header */
+void 
+_modest_header_view_change_selection (GtkTreeSelection *selection,
+                                     gpointer user_data)
+{
+       g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
+       g_return_if_fail (MODEST_IS_HEADER_VIEW (user_data));
+
+       on_selection_changed (selection, user_data);
+}
index a24e6b4..a8d854a 100644 (file)
@@ -200,6 +200,14 @@ gboolean   modest_header_view_set_style (ModestHeaderView *self,
  */
 ModestHeaderViewStyle   modest_header_view_get_style (ModestHeaderView *self);
 
+/**
+ * modest_header_view_get_selected_headers:
+ * @self: a ModestHeaderView instance
+ * 
+ * get the list of the currently selected TnyHeader's
+ *  
+ * Returns: the list with the currently selected headers
+ */
 TnyList* modest_header_view_get_selected_headers (ModestHeaderView *self);
 
 G_END_DECLS