Removed MainWindow dependency from widgets
authorSergio Villar Senin <svillar@igalia.com>
Tue, 20 Oct 2009 17:34:56 +0000 (19:34 +0200)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 27 Oct 2009 10:17:52 +0000 (11:17 +0100)
Added some conditionals to compilation

configure.ac
src/dbus_api/modest-dbus-callbacks.c
src/hildon2/modest-hildon2-window-mgr.c
src/modest-ui-actions.c
src/modest-utils.c
src/modest-widget-memory.c
src/widgets/Makefile.am
src/widgets/modest-folder-view.c
src/widgets/modest-window-mgr.c
src/widgets/modest-window-mgr.h

index 432af86..220edf8 100644 (file)
@@ -306,6 +306,7 @@ else
     AC_DEFINE_UNQUOTED(MODEST_HAVE_EASYSETUP, 1, ["Whether we have the easysetup feature"])
 fi
 AM_CONDITIONAL(MODEST_HAVE_EASYSETUP,test "x$have_easysetup" == "xtrue")
+AM_CONDITIONAL(MODEST_IS_TOOLKIT_HILDON1, [test "x$with_toolkit" == "xhildon1"])
 AC_SUBST(MODEST_TOOLKIT)
 AC_SUBST(MODEST_TOOLKIT_DIR)
 
index 7450644..f03629b 100644 (file)
@@ -1439,7 +1439,7 @@ on_idle_show_memory_low (gpointer user_data)
        ModestWindow *main_win = NULL;
 
        gdk_threads_enter ();
-       main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE);
+       main_win = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr ());
        modest_platform_run_information_dialog (GTK_WINDOW (main_win),
                                                dgettext("ke-recv","memr_ib_operation_disabled"),
                                                TRUE);
index e5f8a56..1d2d114 100644 (file)
@@ -72,7 +72,6 @@ static void modest_hildon2_window_mgr_show_toolbars (ModestWindowMgr *self,
                                                     GType window_type,
                                                     gboolean show_toolbars,
                                                     gboolean fullscreen);
-static ModestWindow* modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show);
 static GtkWindow *modest_hildon2_window_mgr_get_modal (ModestWindowMgr *self);
 static void modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self, 
                                                 GtkWindow *window,
@@ -164,7 +163,6 @@ modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass)
        mgr_class->set_fullscreen_mode = modest_hildon2_window_mgr_set_fullscreen_mode;
        mgr_class->get_fullscreen_mode = modest_hildon2_window_mgr_get_fullscreen_mode;
        mgr_class->show_toolbars = modest_hildon2_window_mgr_show_toolbars;
-       mgr_class->get_main_window = modest_hildon2_window_mgr_get_main_window;
        mgr_class->get_modal = modest_hildon2_window_mgr_get_modal;
        mgr_class->set_modal = modest_hildon2_window_mgr_set_modal;
        mgr_class->find_registered_header = modest_hildon2_window_mgr_find_registered_header;
@@ -261,9 +259,6 @@ modest_hildon2_window_mgr_finalize (GObject *obj)
        }
        g_mutex_free (priv->queue_lock);
 
-       /* Do not unref priv->main_window because it does not hold a
-          new reference */
-
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
@@ -823,12 +818,6 @@ modest_hildon2_window_mgr_show_toolbars (ModestWindowMgr *self,
        return;
 }
 
-static ModestWindow*
-modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show)
-{
-       return NULL;
-}
-
 static gint
 look_for_transient (gconstpointer a,
                    gconstpointer b)
index 86ef41d..ed34ece 100644 (file)
@@ -3698,8 +3698,10 @@ on_rename_folder_cb (ModestMailOperation *mail_op,
        /* Note that if the rename fails new_folder will be NULL */
        if (new_folder) {
                modest_folder_view_select_folder (folder_view, new_folder, FALSE);
+#ifndef MODEST_TOOLKIT_HILDON2
        } else {
                modest_folder_view_select_first_inbox_or_local (folder_view);
+#endif
        }
        gtk_widget_grab_focus (GTK_WIDGET (folder_view));
 }
@@ -3895,7 +3897,9 @@ on_delete_folder_cb (gboolean canceled,
                        mail_op);
        modest_mail_operation_remove_folder (mail_op, TNY_FOLDER (info->folder), info->move_to_trash);
 
+#ifndef MODEST_TOOLKIT_HILDON2
        modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (folder_view));
+#endif
 
        g_object_unref (mail_op);
        g_object_unref (info->folder);
index eaa4455..b2bdaa3 100644 (file)
@@ -551,20 +551,21 @@ launch_sort_headers_dialog (GtkWindow *parent_window,
        gint attachments_sort_id;
        gint priority_sort_id;
        GtkTreeSortable *sortable;
-       
+
        /* Get header window */
+#ifndef MODEST_TOOLKIT_HILDON2
        if (MODEST_IS_MAIN_WINDOW (parent_window)) {
                header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(parent_window),
                                                                                      MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
-#ifdef MODEST_TOOLKIT_HILDON2
-       } else if (MODEST_IS_HEADER_WINDOW (parent_window)) {
+       }
+#else
+       if (MODEST_IS_HEADER_WINDOW (parent_window)) {
                header_view = MODEST_HEADER_VIEW (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (parent_window)));
-#endif
-
        }
+#endif
        if (!header_view)
                return;
-       
+
        /* Add sorting keys */
        cols = modest_header_view_get_columns (header_view);
        if (cols == NULL) 
index 617dfd6..b2ed82f 100644 (file)
@@ -159,6 +159,7 @@ save_settings_window (ModestConf *conf, GtkWindow *win, const gchar *name)
        modest_conf_set_int (conf, key, width, NULL);
        g_free (key);
 
+#ifndef MODEST_TOOLKIT_HILDON2
        /* Save also the main window style */
        if (MODEST_IS_MAIN_WINDOW (win)) {
                ModestMainWindowStyle style = modest_main_window_get_style (MODEST_MAIN_WINDOW (win));
@@ -167,7 +168,7 @@ save_settings_window (ModestConf *conf, GtkWindow *win, const gchar *name)
                modest_conf_set_int (conf, key, style, NULL);
                g_free (key);
        }
-       
+#endif
        return TRUE;
 }
 
@@ -200,6 +201,7 @@ restore_settings_window (ModestConf *conf, GtkWindow *win, const gchar *name)
                gtk_window_set_default_size (win, width, height);
 #endif
 
+#ifndef MODEST_TOOLKIT_HILDON2
        /* Restore also the main window style */
        if (MODEST_IS_MAIN_WINDOW (win)) {
                ModestMainWindowStyle style;
@@ -211,6 +213,7 @@ restore_settings_window (ModestConf *conf, GtkWindow *win, const gchar *name)
                        g_free (key);
                }
        }
+#endif
 
        return TRUE;
 }
index a40d264..361e5c7 100644 (file)
@@ -57,8 +57,6 @@ libmodest_widgets_la_SOURCES=          \
        modest-global-settings-dialog.h \
        modest-gtkhtml-mime-part-view.c \
        modest-gtkhtml-mime-part-view.h \
-       modest-hildon1-window-mgr.c \
-       modest-hildon1-window-mgr.h \
        modest-hbox-cell-renderer.c    \
        modest-hbox-cell-renderer.h    \
        modest-vbox-cell-renderer.c    \
@@ -118,12 +116,18 @@ libmodest_widgets_la_SOURCES=          \
        modest-zoomable.h              \
        modest-zoomable.c
 
+if MODEST_IS_TOOLKIT_HILDON1
+libmodest_widgets_la_SOURCES+=          \
+       modest-hildon1-window-mgr.c \
+       modest-hildon1-window-mgr.h
+endif
+
 if BUILD_MOZEMBED
 libmodest_widgets_la_SOURCES+=          \
        modest-mozembed-msg-view.c              \
        modest-mozembed-msg-view.h             \
        modest-mozembed-mime-part-view.cpp \
-       modest-mozembed-mime-part-view.h        
+       modest-mozembed-mime-part-view.h
 endif
 
 libmodest_widgets_la_includedir = $(includedir)/modest-plugin-1.0/widgets/
index 504a713..1d654bd 100644 (file)
@@ -144,6 +144,7 @@ static void         on_configuration_key_changed  (ModestConf* conf,
                                                   ModestConfNotificationId notification_id,
                                                   ModestFolderView *self);
 
+#ifndef MODEST_TOOLKIT_HILDON2
 /* DnD functions */
 static void         on_drag_data_get       (GtkWidget *widget,
                                            GdkDragContext *context,
@@ -168,24 +169,23 @@ static gboolean     on_drag_motion         (GtkWidget      *widget,
                                            guint           time,
                                            gpointer        user_data);
 
-static void         expand_root_items (ModestFolderView *self);
+static void         setup_drag_and_drop    (GtkTreeView *self);
+
+static void         on_row_inserted_maybe_select_folder (GtkTreeModel     *tree_model,
+                                                        GtkTreePath      *path,
+                                                        GtkTreeIter      *iter,
+                                                        ModestFolderView *self);
 
 static gint         expand_row_timeout     (gpointer data);
+#endif
 
-static void         setup_drag_and_drop    (GtkTreeView *self);
+static void         expand_root_items (ModestFolderView *self);
 
 static gboolean     _clipboard_set_selected_data (ModestFolderView *folder_view,
                                                  gboolean delete);
 
 static void         _clear_hidding_filter (ModestFolderView *folder_view);
 
-#ifndef MODEST_TOOLKIT_HILDON2
-static void         on_row_inserted_maybe_select_folder (GtkTreeModel     *tree_model,
-                                                        GtkTreePath      *path,
-                                                        GtkTreeIter      *iter,
-                                                        ModestFolderView *self);
-#endif
-
 static void         on_display_name_changed (ModestAccountMgr *self,
                                             const gchar *account,
                                             gpointer user_data);
@@ -1325,8 +1325,10 @@ modest_folder_view_init (ModestFolderView *obj)
        /* Build treeview */
        add_columns (GTK_WIDGET (obj));
 
+#ifndef MODEST_TOOLKIT_HILDON2
        /* Setup drag and drop */
        setup_drag_and_drop (GTK_TREE_VIEW(obj));
+#endif
 
        /* Connect signals */
        g_signal_connect (G_OBJECT (obj),
@@ -1513,7 +1515,9 @@ modest_folder_view_set_account_store (TnyAccountStoreView *self, TnyAccountStore
 
        modest_folder_view_update_model (MODEST_FOLDER_VIEW (self), account_store);
        priv->reselect = FALSE;
+#ifndef MODEST_TOOLKIT_HILDON2
        modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (self));
+#endif
 
        g_object_unref (G_OBJECT (device));
 }
@@ -1621,6 +1625,7 @@ same_account_selected (ModestFolderView *self,
        return same_account;
 }
 
+#ifndef MODEST_TOOLKIT_HILDON2
 /**
  *
  * Selects the first inbox or the local account in an idle
@@ -1636,6 +1641,7 @@ on_idle_select_first_inbox_or_local (gpointer user_data)
 
        return FALSE;
 }
+#endif
 
 static void
 on_account_changed (TnyAccountStore *account_store,
@@ -1680,10 +1686,12 @@ on_account_changed (TnyAccountStore *account_store,
        /* Refilter the model */
        gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model));
 
+#ifndef MODEST_TOOLKIT_HILDON2
        /* Select the first INBOX if the currently selected folder
           belongs to the account that is being deleted */
        if (same_account && !MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (tny_account))
                g_idle_add (on_idle_select_first_inbox_or_local, self);
+#endif
 }
 
 static void
@@ -1765,10 +1773,12 @@ on_account_removed (TnyAccountStore *account_store,
        /* Refilter the model */
        gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model));
 
+#ifndef MODEST_TOOLKIT_HILDON2
        /* Select the first INBOX if the currently selected folder
           belongs to the account that is being deleted */
        if (same_account)
                g_idle_add (on_idle_select_first_inbox_or_local, self);
+#endif
 }
 
 void
@@ -1809,7 +1819,9 @@ modest_folder_view_on_map (ModestFolderView *self,
                   deathlock situation */
                /* TODO: check if this is still the case */
                priv->reselect = FALSE;
+#ifndef MODEST_TOOLKIT_HILDON2
                modest_folder_view_select_first_inbox_or_local (self);
+#endif
                /* Notify the display name observers */
                g_signal_emit (G_OBJECT(self),
                               signals[FOLDER_DISPLAY_NAME_CHANGED_SIGNAL], 0,
@@ -2851,6 +2863,7 @@ cmp_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *iter2,
        return cmp;
 }
 
+#ifndef MODEST_TOOLKIT_HILDON2
 /*****************************************************************************/
 /*                        DRAG and DROP stuff                                */
 /*****************************************************************************/
@@ -2922,7 +2935,6 @@ tree_path_to_folder (GtkTreeModel *model, GtkTreePath *path)
        return folder;
 }
 
-
 /*
  * This function is used by drag_data_received_cb to manage drag and
  * drop of a header, i.e, and drag from the header view to the folder
@@ -3484,9 +3496,6 @@ setup_drag_and_drop (GtkTreeView *self)
        /* Set up the folder view as a dnd destination. Set only the
           highlight flag, otherwise gtk will have a different
           behaviour */
-#ifdef MODEST_TOOLKIT_HILDON2
-       return;
-#endif
        gtk_drag_dest_set (GTK_WIDGET (self),
                           GTK_DEST_DEFAULT_HIGHLIGHT,
                           folder_view_drag_types,
@@ -3521,6 +3530,7 @@ setup_drag_and_drop (GtkTreeView *self)
                          G_CALLBACK (drag_drop_cb),
                          NULL);
 }
+#endif
 
 /*
  * This function manages the navigation through the folders using the
@@ -3697,13 +3707,10 @@ find_inbox_iter (GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *inbox_iter
        return FALSE;
 }
 
-
-
-
+#ifndef MODEST_TOOLKIT_HILDON2
 void
 modest_folder_view_select_first_inbox_or_local (ModestFolderView *self)
 {
-#ifndef MODEST_TOOLKIT_HILDON2
        GtkTreeModel *model;
        GtkTreeIter iter, inbox_iter;
        GtkTreeSelection *sel;
@@ -3735,9 +3742,8 @@ modest_folder_view_select_first_inbox_or_local (ModestFolderView *self)
 
        /* set focus */
        gtk_widget_grab_focus (GTK_WIDGET(self));
-#endif
 }
-
+#endif
 
 /* recursive */
 static gboolean
index 87848b7..1a27e00 100644 (file)
@@ -58,7 +58,9 @@ static void modest_window_mgr_show_toolbars_default (ModestWindowMgr *self,
                                                     GType window_type,
                                                     gboolean show_toolbars,
                                                     gboolean fullscreen);
+#ifndef MODEST_TOOLKIT_HILDON2
 static ModestWindow* modest_window_mgr_get_main_window_default (ModestWindowMgr *self, gboolean show);
+#endif
 static GtkWindow *modest_window_mgr_get_modal_default (ModestWindowMgr *self);
 static void modest_window_mgr_set_modal_default (ModestWindowMgr *self, 
                                                 GtkWindow *window,
@@ -95,11 +97,12 @@ typedef struct _ModestWindowMgrPrivate ModestWindowMgrPrivate;
 struct _ModestWindowMgrPrivate {
        guint         banner_counter;
 
+#ifndef MODEST_TOOLKIT_HILDON2
        ModestWindow *main_window;
-
+#endif
        GSList       *windows_that_prevent_hibernation;
        GSList       *preregistered_uids;
-       
+
        guint        closing_time;
 
        GtkWidget    *cached_view;
@@ -161,7 +164,9 @@ modest_window_mgr_class_init (ModestWindowMgrClass *klass)
        mgr_class->set_fullscreen_mode = modest_window_mgr_set_fullscreen_mode_default;
        mgr_class->get_fullscreen_mode = modest_window_mgr_get_fullscreen_mode_default;
        mgr_class->show_toolbars = modest_window_mgr_show_toolbars_default;
+#ifndef MODEST_TOOLKIT_HILDON2
        mgr_class->get_main_window = modest_window_mgr_get_main_window_default;
+#endif
        mgr_class->get_modal = modest_window_mgr_get_modal_default;
        mgr_class->set_modal = modest_window_mgr_set_modal_default;
        mgr_class->close_all_windows = modest_window_mgr_close_all_windows_default;
@@ -252,8 +257,9 @@ modest_window_mgr_init (ModestWindowMgr *obj)
 
        priv = MODEST_WINDOW_MGR_GET_PRIVATE(obj);
        priv->banner_counter = 0;
+#ifndef MODEST_TOOLKIT_HILDON2
        priv->main_window = NULL;
-
+#endif
        priv->preregistered_uids = NULL;
 
        priv->closing_time = 0;
@@ -568,6 +574,7 @@ modest_window_mgr_register_window_default (ModestWindowMgr *self,
                                                               self);
        }
 
+#ifndef MODEST_TOOLKIT_HILDON2
        /* Check that it's not a second main window */
        if (MODEST_IS_MAIN_WINDOW (window)) {
                if (priv->main_window) {
@@ -578,6 +585,7 @@ modest_window_mgr_register_window_default (ModestWindowMgr *self,
                        priv->main_window = window;
                }
        }
+#endif
 
        /* remove from the list of pre-registered uids */
        if (MODEST_IS_MSG_VIEW_WINDOW(window)) {
@@ -585,7 +593,7 @@ modest_window_mgr_register_window_default (ModestWindowMgr *self,
                        (MODEST_MSG_VIEW_WINDOW (window));
 
                MODEST_DEBUG_BLOCK(g_debug ("registering window for %s", uid ? uid : "<none>"););
-               
+
                if (has_uid (priv->preregistered_uids, uid)) {
                        priv->preregistered_uids = 
                                remove_uid (priv->preregistered_uids,
@@ -595,7 +603,7 @@ modest_window_mgr_register_window_default (ModestWindowMgr *self,
        } else if (MODEST_IS_MSG_EDIT_WINDOW(window)) {
                const gchar *uid = modest_msg_edit_window_get_message_uid
                        (MODEST_MSG_EDIT_WINDOW (window));
-               
+
                MODEST_DEBUG_BLOCK(g_debug ("registering window for %s", uid););
 
                priv->preregistered_uids = 
@@ -659,7 +667,7 @@ modest_window_mgr_get_fullscreen_mode_default (ModestWindowMgr *self)
        return FALSE;
 }
 
-void 
+void
 modest_window_mgr_show_toolbars (ModestWindowMgr *self,
                                 GType window_type,
                                 gboolean show_toolbars,
@@ -668,7 +676,7 @@ modest_window_mgr_show_toolbars (ModestWindowMgr *self,
        return MODEST_WINDOW_MGR_GET_CLASS (self)->show_toolbars (self, window_type, show_toolbars, fullscreen);
 }
 
-static void 
+static void
 modest_window_mgr_show_toolbars_default (ModestWindowMgr *self,
                                         GType window_type,
                                         gboolean show_toolbars,
@@ -677,35 +685,36 @@ modest_window_mgr_show_toolbars_default (ModestWindowMgr *self,
        return;
 }
 
+#ifndef MODEST_TOOLKIT_HILDON2
 void
 modest_window_mgr_set_main_window (ModestWindowMgr *self, ModestWindow *win)
 {
        ModestWindowMgrPrivate *priv;
-       
+
        g_return_if_fail (MODEST_IS_WINDOW_MGR (self));
 
        priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
        priv->main_window = win;
 }
 
-ModestWindow*  
+ModestWindow*
 modest_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show)
 {
        return MODEST_WINDOW_MGR_GET_CLASS (self)->get_main_window (self, show);
 }
 
-static ModestWindow*  
+static ModestWindow*
 modest_window_mgr_get_main_window_default (ModestWindowMgr *self, gboolean show)
 {
        ModestWindowMgrPrivate *priv;
-       
+
        g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), NULL);
 
        priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
        if (priv->main_window)
                return priv->main_window;
 
-       if (show) 
+       if (show)
                return modest_main_window_new ();
        else return NULL;
 }
@@ -715,13 +724,13 @@ gboolean
 modest_window_mgr_main_window_exists  (ModestWindowMgr *self)
 {
        ModestWindowMgrPrivate *priv;
-       
+
        g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), FALSE);
        priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
 
        return priv->main_window != NULL;
 }
-
+#endif
 
 GtkWindow *
 modest_window_mgr_get_modal (ModestWindowMgr *self)
@@ -850,9 +859,11 @@ modest_window_mgr_get_num_windows (ModestWindowMgr *self)
                g_list_free (window_list);
        }
 
+#ifndef MODEST_TOOLKIT_HILDON2
        /* Do not take into account the main window if it was hidden */
        if (num_windows && priv->main_window && !GTK_WIDGET_VISIBLE (priv->main_window))
                num_windows--;
+#endif
 
        return num_windows + priv->banner_counter;
 }
@@ -952,9 +963,13 @@ modest_window_mgr_show_initial_window (ModestWindowMgr *self)
 static ModestWindow *
 modest_window_mgr_show_initial_window_default (ModestWindowMgr *self)
 {
+#ifndef MODEST_TOOLKIT_HILDON2
        /* By default it returns the main window creating it if
           needed */
        return modest_window_mgr_get_main_window (self, TRUE);
+#else
+       return NULL;
+#endif
 }
 
 
index 6e7fa12..8266b31 100644 (file)
@@ -66,8 +66,10 @@ struct _ModestWindowMgrClass {
                                                                 GType window_type,
                                                                 gboolean show_toolbars,
                                                                 gboolean fullscreen);
+#ifndef MODEST_TOOLKIT_HILDON2
        ModestWindow *        (*get_main_window)                (ModestWindowMgr *self,
                                                                 gboolean show);
+#endif
        gboolean              (*close_all_windows)              (ModestWindowMgr *self);
        GtkWindow *           (*get_modal)                      (ModestWindowMgr *self);
        void                  (*set_modal)                      (ModestWindowMgr *self,
@@ -175,6 +177,7 @@ void           modest_window_mgr_show_toolbars         (ModestWindowMgr *self,
                                                        GType window_type,
                                                        gboolean show_toolbars,
                                                        gboolean fullscreen);
+#ifndef MODEST_TOOLKIT_HILDON2
 /**
  * modest_window_mgr_get_main_window:
  * @self: a #ModestWindowMgr
@@ -205,8 +208,7 @@ void modest_window_mgr_set_main_window (ModestWindowMgr *self, ModestWindow *mai
  * Returns: TRUE if there's a main window, FALSE otherwise
  **/
 gboolean  modest_window_mgr_main_window_exists       (ModestWindowMgr *self);
-
-
+#endif
 
 /**
  * modest_window_mgr_get_modal: