* some further cleanups of the help system, added:
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 2 Nov 2007 11:28:26 +0000 (11:28 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 2 Nov 2007 11:28:26 +0000 (11:28 +0000)
modest_window_mgr_register_help_id, and
modest_window_mgr_get_help_id
  which will give you the right help_id for the
  current window; windows register the help id in their
  _init. For the main window, we check what the
  selected folder is, and use modest_tny_folder_get_help_id
  to get the help_id from there.

pmo-trunk-r3617

src/maemo/modest-main-window.c
src/maemo/modest-msg-edit-window.c
src/maemo/modest-msg-view-window.c
src/modest-ui-actions.c
src/modest-ui-actions.h
src/widgets/modest-window-mgr.c
src/widgets/modest-window-mgr.h

index 999b4d3..66eddc8 100644 (file)
@@ -354,6 +354,10 @@ modest_main_window_init (ModestMainWindow *obj)
        priv->sighandlers = NULL;
        priv->updating_banner = NULL;
        priv->updating_banner_timeout = 0;
+       
+       modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(),
+                                           GTK_WINDOW(obj),
+                                           "applications_email_mainview");
 }
 
 static void
index f1885ca..657fd45 100644 (file)
@@ -381,6 +381,9 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj)
        priv->sent = FALSE;
 
        priv->last_vadj_upper = 0;
+
+       modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(),
+                                           GTK_WINDOW(obj),"applications_email_editor");
 }
 
 
index 1dfe7d2..f1cfae4 100644 (file)
@@ -345,6 +345,9 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj)
        priv->purge_timeout = 0;
        priv->remove_attachment_banner = NULL;
        priv->msg_uid = NULL;
+       
+       modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(),
+                                           GTK_WINDOW(obj),"applications_email_viewer");
 }
 
 
index 83687f4..5f7c8e3 100644 (file)
@@ -4592,34 +4592,19 @@ modest_ui_actions_on_settings (GtkAction *action,
 
 void 
 modest_ui_actions_on_help (GtkAction *action, 
-                          ModestWindow *win)
+                          GtkWindow *win)
 {
-       const gchar *help_id = NULL;
+       const gchar *help_id;
 
-       if (MODEST_IS_MAIN_WINDOW (win)) {
-               GtkWidget *folder_view;
-               TnyFolderStore *folder_store;
-               
-               /* Get selected folder */
-               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-
-               /* Switch help_id */
-               if (TNY_IS_FOLDER (folder_store)) {
-                       help_id = modest_tny_folder_get_help_id (TNY_FOLDER (folder_store));
-                       if (!help_id) {
-                               g_warning ("%s: BUG: did not get a valid help_id", __FUNCTION__);
-                               help_id = "applications_email_mainview";
-                       }
-               }
-               g_object_unref (folder_store);
-       } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
-               help_id = "applications_email_viewer";
-       } else if (MODEST_IS_MSG_EDIT_WINDOW (win))
-               help_id = "applications_email_editor";
-
-       modest_platform_show_help (GTK_WINDOW (win), help_id);
+       g_return_if_fail (action);
+       g_return_if_fail (win && GTK_IS_WINDOW(win));
+       
+       help_id = modest_window_mgr_get_help_id (modest_runtime_get_window_mgr(), win);
+       
+       if (help_id)
+               modest_platform_show_help (GTK_WINDOW (win), help_id);
+       else
+               g_warning ("%s: no help for window %p", __FUNCTION__, win);
 }
 
 void 
index 7e33ffd..ba78882 100644 (file)
@@ -94,7 +94,7 @@ void     modest_ui_actions_on_settings      (GtkAction *action, ModestWindow *wi
  * 
  * Shows the help dialog
  **/
-void     modest_ui_actions_on_help          (GtkAction *action, ModestWindow *win);
+void     modest_ui_actions_on_help          (GtkAction *action, GtkWindow *win);
 
 /**
  * modest_ui_actions_toggle_folders_view:
index 0451e9f..3b94951 100644 (file)
@@ -313,6 +313,68 @@ modest_window_mgr_unregister_header (ModestWindowMgr *self,  TnyHeader *header)
        g_free (uid);
 }
 
+
+#define MODEST_WINDOW_HELP_ID_PARAM "help-id"
+
+void
+modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const gchar* help_id)
+{
+       /* we don't need 'self', but for API consistency... */
+       g_return_if_fail (self && MODEST_IS_WINDOW_MGR(self));
+
+       g_return_if_fail (win && GTK_IS_WINDOW(win));
+       g_return_if_fail (help_id);
+       
+       g_object_set_data_full (G_OBJECT(win), MODEST_WINDOW_HELP_ID_PARAM,
+                               g_strdup(help_id), g_free);
+}
+
+
+const gchar*
+modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win)
+{
+       const gchar* help_id = NULL;
+
+       /* we don't need 'self', but for API consistency... */
+       g_return_val_if_fail (self && MODEST_IS_WINDOW_MGR(self), NULL);
+       
+       g_return_val_if_fail (win, NULL);
+       g_return_val_if_fail (GTK_IS_WINDOW(win), NULL);
+       
+       if (MODEST_IS_MAIN_WINDOW (win)) {
+               GtkWidget *folder_view;
+               TnyFolderStore *folder_store;
+               
+               /* Get selected folder */
+               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
+                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
+               folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
+
+               /* Switch help_id */
+               if (folder_store && TNY_IS_FOLDER (folder_store)) {
+                       help_id = modest_tny_folder_get_help_id (TNY_FOLDER (folder_store));
+                       if (!help_id)
+                               g_warning ("%s: BUG: did not get a valid help_id", __FUNCTION__);
+               }
+               if (folder_store)
+                       g_object_unref (folder_store);
+       }
+
+       if (!help_id)
+               help_id = g_object_get_data (G_OBJECT(win), MODEST_WINDOW_HELP_ID_PARAM);
+               
+       return help_id;
+}
+
+
+
+
+
+
+
+
+
+
 static gint
 compare_msguids (ModestWindow *win,
                 const gchar *uid)
index 642648c..24cbf54 100644 (file)
@@ -189,6 +189,34 @@ void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMg
        GtkWindow *window);
 
 
+
+/**
+ * modest_window_mgr_register_help_id
+ * @self: a #ModestWindowMgr
+ * @win: some window
+ * @help_id: the help_id for this window
+ * 
+ * register a help id for a window
+ **/
+void
+modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const gchar* help_id);
+
+
+/**
+ * modest_window_mgr_get_help_id:
+ * @self: a #ModestWindowMgr
+ * @win: some window
+ * 
+ * get the help id for a window; if the window is the main-window and some folder is
+ * selected, it will return the proper help_id for that
+ *
+ * Returns: a help _id
+ **/
+const gchar*
+modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win);
+
+
+
 /**
  * modest_window_mgr_find_registered_header
  * @self: a #ModestWindowMgr