Refactor adding items to menu in hildon2. Now we have method
authorJose Dapena Paz <jdapena@igalia.com>
Tue, 3 Nov 2009 11:09:28 +0000 (12:09 +0100)
committerJose Dapena Paz <jdapena@igalia.com>
Tue, 3 Nov 2009 15:58:50 +0000 (16:58 +0100)
modest_window_add_to_menu.

src/hildon2/modest-accounts-window.c
src/hildon2/modest-folder-window.c
src/hildon2/modest-header-window.c
src/hildon2/modest-hildon2-window.c
src/hildon2/modest-hildon2-window.h
src/hildon2/modest-msg-edit-window.c
src/widgets/modest-shell.h
src/widgets/modest-window.c
src/widgets/modest-window.h

index 02937ed..feca6b2 100644 (file)
@@ -399,29 +399,29 @@ setup_menu (ModestAccountsWindow *self)
        g_return_if_fail (MODEST_IS_ACCOUNTS_WINDOW(self));
 
        /* Settings menu buttons */
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_new_account"), NULL, 
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_new_account), 
-                                          NULL);
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self),
-                                          dngettext(GETTEXT_PACKAGE,
-                                                    "mcen_me_edit_account",
-                                                    "mcen_me_edit_accounts",
-                                                    2),
-                                          NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_accounts), 
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_edit_accounts));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_globalsmtpservers"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_smtp_servers),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_tools_smtp_servers));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_sendandreceive"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_send_receive),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_send_receive_all));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_cancel_send),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_options"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_settings), 
-                                          NULL);
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_new_account"), NULL, 
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_new_account), 
+                                  NULL);
+       modest_window_add_to_menu (MODEST_WINDOW (self),
+                                  dngettext(GETTEXT_PACKAGE,
+                                            "mcen_me_edit_account",
+                                            "mcen_me_edit_accounts",
+                                            2),
+                                  NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_accounts), 
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_edit_accounts));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_globalsmtpservers"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_smtp_servers),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_tools_smtp_servers));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_sendandreceive"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_send_receive),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_send_receive_all));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_cancel_send),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_options"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_settings), 
+                                  NULL);
 }
 
 
index 641d510..359098e 100644 (file)
@@ -546,35 +546,35 @@ setup_menu (ModestFolderWindow *self)
        g_return_if_fail (MODEST_IS_FOLDER_WINDOW(self));
 
        /* folders actions */
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_new_folder"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_new_folder),
-                                          NULL);
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_rename_folder"), NULL,
-                                          APP_MENU_CALLBACK (set_rename_edit_mode),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_rename_folder));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_move_folder"), NULL,
-                                          APP_MENU_CALLBACK (set_moveto_edit_mode),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_folder_window_move_to));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_delete_folder"), NULL,
-                                          APP_MENU_CALLBACK (set_delete_edit_mode),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_folder_window_delete));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_new_folder"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_new_folder),
+                                  NULL);
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_rename_folder"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (set_rename_edit_mode),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_rename_folder));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_move_folder"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (set_moveto_edit_mode),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_folder_window_move_to));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_delete_folder"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (set_delete_edit_mode),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_folder_window_delete));
 
        /* send receive actions should be only one visible always */
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_sendandreceive"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_send_receive),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_send_receive));
-
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_cancel_send),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
-
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self),
-                                          dngettext(GETTEXT_PACKAGE,
-                                                    "mcen_me_edit_account",
-                                                    "mcen_me_edit_accounts",
-                                                    1),
-                                          NULL, APP_MENU_CALLBACK (edit_account),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_edit_accounts));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_sendandreceive"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_send_receive),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_send_receive));
+
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_cancel_send),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
+
+       modest_window_add_to_menu (MODEST_WINDOW (self),
+                                  dngettext(GETTEXT_PACKAGE,
+                                            "mcen_me_edit_account",
+                                            "mcen_me_edit_accounts",
+                                            1),
+                                  NULL, MODEST_WINDOW_MENU_CALLBACK (edit_account),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_edit_accounts));
 }
 
 static void
index 8fb73fc..27a9146 100644 (file)
@@ -909,23 +909,23 @@ static void setup_menu (ModestHeaderWindow *self)
        g_return_if_fail (MODEST_IS_HEADER_WINDOW(self));
        priv = MODEST_HEADER_WINDOW_GET_PRIVATE (self);
 
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_new_message"), "<Control>n",
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_new_msg),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_new_msg));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self),
-                                          dngettext(GETTEXT_PACKAGE,
-                                                    "mcen_me_move_message",
-                                                    "mcen_me_move_messages",
-                                                    2),
-                                          NULL,
-                                          APP_MENU_CALLBACK (set_moveto_edit_mode),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_move_to));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_delete_messages"), NULL,
-                                          APP_MENU_CALLBACK (set_delete_edit_mode),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_delete));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_folder_details"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_details),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_details));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_new_message"), "<Control>n",
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_new_msg),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_new_msg));
+       modest_window_add_to_menu (MODEST_WINDOW (self),
+                                  dngettext(GETTEXT_PACKAGE,
+                                            "mcen_me_move_message",
+                                            "mcen_me_move_messages",
+                                            2),
+                                  NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (set_moveto_edit_mode),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_move_to));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_delete_messages"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (set_delete_edit_mode),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_delete));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_folder_details"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_details),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_details));
        priv->sort_button = hildon_button_new (MODEST_EDITABLE_SIZE,
                                               HILDON_BUTTON_ARRANGEMENT_VERTICAL);
        hildon_button_set_title (HILDON_BUTTON (priv->sort_button), _("mcen_me_sort"));
@@ -936,12 +936,12 @@ static void setup_menu (ModestHeaderWindow *self)
        hildon_button_set_value_alignment (HILDON_BUTTON (priv->sort_button), 0.5, 0.5);
        modest_hildon2_window_add_button_to_menu (MODEST_HILDON2_WINDOW (self), GTK_BUTTON (priv->sort_button),
                                                  modest_ui_dimming_rules_on_sort);
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_sendandreceive"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_send_receive),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_send_receive));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_cancel_send),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_sendandreceive"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_send_receive),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_send_receive));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_cancel_send),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
 }
 
 static void 
index f0e33a1..03b2b97 100644 (file)
@@ -63,6 +63,11 @@ static void modest_hildon2_window_show_toolbar (ModestWindow *self,
                                                 gboolean show_toolbar);
 static void modest_hildon2_window_add_toolbar (ModestWindow *self,
                                               GtkToolbar *toolbar);
+static void modest_hildon2_window_add_to_menu (ModestWindow *window,
+                                              const gchar *label,
+                                              const gchar *accelerator,
+                                              ModestWindowMenuCallback callback,
+                                              ModestDimmingCallback dimming_callback);
 static void modest_hildon2_window_set_title (ModestWindow *self,
                                             const gchar *title);
 static gboolean modest_hildon2_window_toggle_menu (HildonWindow *window,
@@ -167,6 +172,7 @@ modest_hildon2_window_class_init (gpointer klass, gpointer class_data)
        modest_window_class->zoom_plus_func = on_zoom_minus_plus_not_implemented;
        modest_window_class->show_toolbar_func = modest_hildon2_window_show_toolbar;
        modest_window_class->add_toolbar_func = modest_hildon2_window_add_toolbar;
+       modest_window_class->add_to_menu_func = modest_hildon2_window_add_to_menu;
        modest_window_class->set_title_func = modest_hildon2_window_set_title;
        modest_window_class->show_progress_func = modest_hildon2_window_show_progress;
 
@@ -281,11 +287,11 @@ modest_hildon2_window_add_button_to_menu (ModestHildon2Window *self,
        gtk_widget_show (GTK_WIDGET (button));
 }
 
-void 
+static void
 modest_hildon2_window_add_to_menu (ModestHildon2Window *self,
                                   gchar *label,
                                   const gchar *accelerator,
-                                  ModestHildon2AppMenuCallback callback,
+                                  ModestWindowMenuCallback callback,
                                   ModestDimmingCallback dimming_callback)
 {
        ModestHildon2WindowPrivate *priv = NULL;
index 0e41ce4..c7f1d7c 100644 (file)
@@ -59,10 +59,8 @@ struct _ModestHildon2WindowClass {
        void (*edit_mode_changed) (ModestHildon2Window *self, gint edit_mode, gboolean enabled);
 };
 
-typedef void (*ModestHildon2AppMenuCallback) (GObject *control, gpointer userdata);
 typedef gboolean (*ModestHildon2EditModeCallback) (ModestHildon2Window *self);
 
-#define APP_MENU_CALLBACK(x) ((ModestHildon2AppMenuCallback) (x))
 #define EDIT_MODE_CALLBACK(x) ((ModestHildon2EditModeCallback) (x))
 
 /* edit mode id for no edit mode */
@@ -77,23 +75,6 @@ typedef gboolean (*ModestHildon2EditModeCallback) (ModestHildon2Window *self);
  */
 GType modest_hildon2_window_get_type (void) G_GNUC_CONST;
 
-/**
- * modest_hildon2_window_add_to_menu:
- * @self: a #ModestHildon2Window
- * @label: the label of the button added to menu
- * @callback: a #ModestHildon2AppMenuCallback
- * @dimming_callback: a #ModestDimmingCallback or %NULL for no dimming rule
- *
- * creates a button in the window #HildonAppMenu, with label @label.
- * It will call @callback, and will configure @dimming_callback for
- * dimming.
- */
-void 
-modest_hildon2_window_add_to_menu (ModestHildon2Window *self,
-                                  gchar *label,
-                                  const gchar *accelerator,
-                                  ModestHildon2AppMenuCallback callback,
-                                  ModestDimmingCallback dimming_callback);
 
 /**
  * modest_hildon2_window_add_button_to_menu:
index 59c1780..fda6790 100644 (file)
@@ -4327,12 +4327,12 @@ setup_menu (ModestMsgEditWindow *self)
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
 
        /* Settings menu buttons */
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_editor_checknames"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_check_names),
-                                          NULL);
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_undo"), "<Ctrl>z",
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_undo),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_undo));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_editor_checknames"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_check_names),
+                                  NULL);
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_undo"), "<Ctrl>z",
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_undo),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_undo));
 
        priv->cc_button = hildon_check_button_new (0);
        gtk_button_set_label (GTK_BUTTON (priv->cc_button), _("mcen_me_editor_showcc"));
@@ -4356,21 +4356,21 @@ setup_menu (ModestMsgEditWindow *self)
        gtk_button_set_alignment (GTK_BUTTON (priv->bcc_button), 0.5, 0.5);
        gtk_button_set_alignment (GTK_BUTTON (priv->bcc_button), 0.5, 0.5);
 
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_editor_attach_inlineimage"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_insert_image),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_set_style));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_editor_add_attachment"), NULL,
-                                          APP_MENU_CALLBACK (modest_msg_edit_window_add_attachment_clicked),
-                                          NULL);
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_remove_attachments"), NULL,
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_remove_attachments),
-                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_editor_remove_attachment));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_message_settings"), NULL,
-                                          APP_MENU_CALLBACK (on_message_settings),
-                                          NULL);
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_viewer_find"), "<Ctrl>f",
-                                          APP_MENU_CALLBACK (modest_ui_actions_on_toggle_find_in_page),
-                                          NULL);
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_editor_attach_inlineimage"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_insert_image),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_set_style));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_editor_add_attachment"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_msg_edit_window_add_attachment_clicked),
+                                  NULL);
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_remove_attachments"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_remove_attachments),
+                                  MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_editor_remove_attachment));
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_message_settings"), NULL,
+                                  MODEST_WINDOW_MENU_CALLBACK (on_message_settings),
+                                  NULL);
+       modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_viewer_find"), "<Ctrl>f",
+                                  MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_toggle_find_in_page),
+                                  NULL);
 }
 
 static void
index 514b6e5..156585d 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <glib-object.h>
 #include <gtk/gtk.h>
+#include <modest-shell-window.h>
 
 G_BEGIN_DECLS
  
index 3dadb68..952ac9e 100644 (file)
@@ -68,6 +68,12 @@ static void     modest_window_show_toolbar_default       (ModestWindow *window,
 static void     modest_window_add_toolbar_default       (ModestWindow *window,
                                                         GtkToolbar *toolbar);
 
+static void     modest_window_add_to_menu_default       (ModestWindow *self,
+                                                        const gchar *label,
+                                                        const gchar *accelerator,
+                                                        ModestWindowMenuCallback callback,
+                                                        ModestDimmingCallback dimming_callback);
+
 static void     modest_window_set_title_default       (ModestWindow *window,
                                                       const gchar *title);
 
@@ -142,6 +148,7 @@ modest_window_class_init (ModestWindowClass *klass)
        klass->zoom_minus_func = modest_window_zoom_minus_default;
        klass->show_toolbar_func = modest_window_show_toolbar_default;
        klass->add_toolbar_func = modest_window_add_toolbar_default;
+       klass->add_to_menu_func = modest_window_add_to_menu_default;
        klass->set_title_func = modest_window_set_title_default;
        klass->disconnect_signals_func = modest_window_disconnect_signals_default;
        klass->show_progress_func = modest_window_show_progress_default;
@@ -430,6 +437,20 @@ modest_window_add_toolbar (ModestWindow *window,
 }
 
 void 
+modest_window_add_to_menu (ModestWindow *window,
+                          const gchar *label,
+                          const gchar *accelerator,
+                          ModestWindowMenuCallback callback,
+                          ModestDimmingCallback dimming_callback);
+{
+       MODEST_WINDOW_GET_CLASS (window)->add_to_menu_func (window,
+                                                           label,
+                                                           accelerator,
+                                                           callback,
+                                                           dimming_callback);
+}
+
+void 
 modest_window_set_title (ModestWindow *window,
                         const gchar *title)
 {
@@ -496,6 +517,16 @@ modest_window_add_toolbar_default (ModestWindow *window,
 }
 
 static void 
+modest_window_add_to_menu_default (ModestWindow *window,
+                                  const gchar *label,
+                                  const gchar *accelerator,
+                                  ModestWindowMenuCallback callback,
+                                  ModestDimmingCallback dimming_callback);
+{
+       g_warning ("modest: You should implement %s", __FUNCTION__);
+}
+
+static void 
 modest_window_set_title_default (ModestWindow *window,
                                 const gchar *title)
 {
index 6ea8d7e..0a8185b 100644 (file)
 #ifndef __MODEST_WINDOW_H__
 #define __MODEST_WINDOW_H__
 
-#include <glib-object.h>
-#include <tny-account-store.h>
-
-G_BEGIN_DECLS
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif /*HAVE_CONFIG_H*/
 
+#include <glib-object.h>
 #include <gtk/gtk.h>
+#include <modest-dimming-rule.h>
+
+G_BEGIN_DECLS
+
 /* 
  * admittedly, the ifdefs for gtk and maemo are rather ugly; still
  * this way is probably the easiest to maintain
@@ -92,6 +91,9 @@ typedef struct _DimmedState {
 typedef struct _ModestWindow      ModestWindow;
 typedef struct _ModestWindowClass ModestWindowClass;
 
+typedef void (*ModestWindowMenuCallback) (GObject *control, gpointer userdata);
+#define MODEST_WINDOW_MENU_CALLBACK(x) ((ModestWindowMenuCallback) (x))
 struct _ModestWindow {
         ModestWindowParent parent;
 };
@@ -110,6 +112,11 @@ struct _ModestWindowClass {
        void (*show_progress_func) (ModestWindow *self, gboolean show);
        void (*add_toolbar_func) (ModestWindow *self, GtkToolbar *toolbar);
        void (*set_title_func) (ModestWindow *self, const gchar *title);
+       void (*add_to_menu_func) (ModestWindow *self,
+                                 const gchar *label,
+                                 const gchar *accelerator,
+                                 ModestWindowMenuCallback callback,
+                                 ModestDimmingCallback dimming_callback);
 };
 
 /**
@@ -327,6 +334,24 @@ void modest_window_add_toolbar (ModestWindow *self, GtkToolbar *toolbar);
 
 void modest_window_set_title (ModestWindow *self, const gchar *title);
 
+/**
+ * modest_window_add_to_menu:
+ * @self: a #ModestWindow
+ * @label: the label of the button added to menu
+ * @callback: a #ModestWindowMenuCallback
+ * @dimming_callback: a #ModestDimmingCallback or %NULL for no dimming rule
+ *
+ * creates a menu item in the window @self, with label @label.
+ * It will call @callback, and will configure @dimming_callback for
+ * dimming.
+ */
+void modest_window_add_to_menu (ModestWindow *self,
+                               const gchar *label,
+                               const gchar *accelerator,
+                               ModestWindowMenuCallback callback,
+                               ModestDimmingCallback dimming_callback);
+                               
+
 
 G_END_DECLS