Fix in the reference to dimming manager in hildon2 window children
[modest] / src / hildon2 / modest-msg-edit-window.c
index 1796d6e..e6241c6 100644 (file)
@@ -156,10 +156,6 @@ static void on_account_removed (TnyAccountStore *account_store,
                                TnyAccount *account,
                                gpointer user_data);
 
-static gboolean on_zoom_minus_plus_not_implemented (ModestWindow *window);
-static void set_zoom_do_nothing (ModestWindow *window, gdouble zoom);
-static gdouble get_zoom_do_nothing (ModestWindow *window);
-
 static void init_window (ModestMsgEditWindow *obj);
 
 gboolean scroll_drag_timeout (gpointer userdata);
@@ -173,17 +169,7 @@ static void text_buffer_mark_set (GtkTextBuffer *buffer,
                                  ModestMsgEditWindow *userdata);
 static void on_message_settings (GtkAction *action,
                                 ModestMsgEditWindow *window);
-static void add_to_menu (ModestMsgEditWindow *self,
-                        HildonAppMenu *menu,
-                        gchar *label,
-                        GCallback callback,
-                        ModestDimmingRulesGroup *group,
-                        GCallback dimming_callback);
-static void setup_menu (ModestMsgEditWindow *self,
-                       ModestDimmingRulesGroup *group);
-static gboolean modest_msg_edit_window_toggle_menu (HildonWindow *window,
-                                                   guint button,
-                                                   guint32 time);
+static void setup_menu (ModestMsgEditWindow *self);
 
 static void DEBUG_BUFFER (WPTextBuffer *buffer)
 {
@@ -308,6 +294,7 @@ struct _ModestMsgEditWindowPrivate {
        GtkWidget   *app_menu;
        GtkWidget   *cc_button;
        GtkWidget   *bcc_button;
+       GtkWidget   *find_toolbar_button;
 };
 
 #define MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
@@ -336,7 +323,7 @@ modest_msg_edit_window_get_type (void)
                        (GInstanceInitFunc) modest_msg_edit_window_init,
                        NULL
                };
-               my_type = g_type_register_static (MODEST_TYPE_WINDOW,
+               my_type = g_type_register_static (MODEST_TYPE_HILDON2_WINDOW,
                                                  "ModestMsgEditWindow",
                                                  &my_info, 0);
 
@@ -378,19 +365,12 @@ modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass)
 {
        GObjectClass *gobject_class;
        ModestWindowClass *modest_window_class;
-       HildonWindowClass *hildon_window_class = (HildonWindowClass *) klass;
        gobject_class = (GObjectClass*) klass;
        modest_window_class = (ModestWindowClass*) klass;
 
        parent_class            = g_type_class_peek_parent (klass);
        gobject_class->finalize = modest_msg_edit_window_finalize;
 
-       hildon_window_class->toggle_menu = modest_msg_edit_window_toggle_menu;
-
-       modest_window_class->set_zoom_func = set_zoom_do_nothing;
-       modest_window_class->get_zoom_func = get_zoom_do_nothing;
-       modest_window_class->zoom_plus_func = on_zoom_minus_plus_not_implemented;
-       modest_window_class->zoom_minus_func = on_zoom_minus_plus_not_implemented;
        modest_window_class->show_toolbar_func = modest_msg_edit_window_show_toolbar;
        modest_window_class->save_state_func = save_state;
        modest_window_class->disconnect_signals_func = modest_msg_edit_window_disconnect_signals;
@@ -1136,7 +1116,6 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich)
        TnyHeaderFlags priority_flags;
        TnyFolder *msg_folder;
        gboolean is_html = FALSE;
-       GtkAction *action;
        gboolean field_view_set;
        
        g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (self));
@@ -1155,7 +1134,6 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich)
        if (to)
                modest_recpt_editor_set_recipients (MODEST_RECPT_EDITOR (priv->to_field),  to);
 
-       action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewCcFieldMenu");
        field_view_set = TRUE;
        if (cc) {
                modest_recpt_editor_set_recipients (MODEST_RECPT_EDITOR (priv->cc_field),  cc);
@@ -1166,10 +1144,8 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich)
                gtk_widget_hide (priv->cc_caption);
                field_view_set = FALSE;
        }
-       if (action)
-               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), field_view_set);
+       hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->cc_button), field_view_set);
 
-       action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewBccFieldMenu");
        field_view_set = TRUE;
        if (bcc) {
                modest_recpt_editor_set_recipients (MODEST_RECPT_EDITOR (priv->bcc_field), bcc);
@@ -1180,8 +1156,7 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich)
                gtk_widget_hide (priv->bcc_caption);
                field_view_set = FALSE;
        }
-       if (action)
-               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), field_view_set);
+       hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->bcc_button), field_view_set);
 
 
        if (subject)
@@ -1470,7 +1445,6 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre
        GObject *obj;
        ModestWindowPrivate *parent_priv;
        ModestMsgEditWindowPrivate *priv;
-       ModestDimmingRulesGroup *menu_rules_group = NULL;
        ModestDimmingRulesGroup *toolbar_rules_group = NULL;
        ModestDimmingRulesGroup *clipboard_rules_group = NULL;
        ModestWindowMgr *mgr = NULL;
@@ -1506,15 +1480,9 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre
 
        priv->original_account_name = (account_name) ? g_strdup (account_name) : NULL;
 
-       parent_priv->ui_dimming_manager = modest_ui_dimming_manager_new ();
-       menu_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_MENU, FALSE);
        toolbar_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_TOOLBAR, TRUE);
        clipboard_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_CLIPBOARD, FALSE);
        /* Add common dimming rules */
-       modest_dimming_rules_group_add_rules (menu_rules_group, 
-                                             modest_msg_edit_window_menu_dimming_entries,
-                                             G_N_ELEMENTS (modest_msg_edit_window_menu_dimming_entries),
-                                             MODEST_WINDOW (obj));
        modest_dimming_rules_group_add_rules (toolbar_rules_group, 
                                              modest_msg_edit_window_toolbar_dimming_entries,
                                              G_N_ELEMENTS (modest_msg_edit_window_toolbar_dimming_entries),
@@ -1529,15 +1497,13 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre
                                                    G_CALLBACK (modest_ui_dimming_rules_on_set_style),
                                                    MODEST_WINDOW (obj));
        /* Insert dimming rules group for this window */
-       modest_ui_dimming_manager_insert_rules_group (parent_priv->ui_dimming_manager, menu_rules_group);
        modest_ui_dimming_manager_insert_rules_group (parent_priv->ui_dimming_manager, toolbar_rules_group);
        modest_ui_dimming_manager_insert_rules_group (parent_priv->ui_dimming_manager, clipboard_rules_group);
 
        /* Setup app menu */
-       setup_menu (MODEST_MSG_EDIT_WINDOW (obj), menu_rules_group);
+       setup_menu (MODEST_MSG_EDIT_WINDOW (obj));
 
         /* Checks the dimming rules */
-       g_object_unref (menu_rules_group);
        g_object_unref (toolbar_rules_group);
        g_object_unref (clipboard_rules_group);
        set_msg (MODEST_MSG_EDIT_WINDOW (obj), msg, preserve_is_rich);
@@ -3455,12 +3421,11 @@ static void
 modest_msg_edit_window_find_toolbar_close (GtkWidget *widget,
                                           ModestMsgEditWindow *window)
 {
-       GtkToggleAction *toggle;
-       ModestWindowPrivate *parent_priv;
-       parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
+       ModestMsgEditWindowPrivate *priv;
+
+       priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(window);
 
-       toggle = GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ToolsMenu/FindInMessageMenu"));
-       gtk_toggle_action_set_active (toggle, FALSE);
+       hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->find_toolbar_button), FALSE);
 }
 
 gboolean 
@@ -3623,28 +3588,6 @@ on_account_removed (TnyAccountStore *account_store,
        }
 }
 
-static gboolean
-on_zoom_minus_plus_not_implemented (ModestWindow *window)
-{
-       g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window), FALSE);
-
-       hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_cannot_zoom_here"));
-       return FALSE;
-
-}
-
-static void
-set_zoom_do_nothing (ModestWindow *window,
-                                gdouble zoom)
-{
-}
-
-static gdouble
-get_zoom_do_nothing (ModestWindow *window)
-{
-       return 1.0;
-}
-
 typedef struct _MessageSettingsHelper {
        ModestMsgEditWindow *window;
        GSList *priority_group;
@@ -3899,38 +3842,38 @@ static void on_message_settings (GtkAction *action,
        modest_msg_edit_window_show_msg_settings_dialog (window);
 }
 
+static void
+on_cc_button_toggled (HildonCheckButton *button,
+                     ModestMsgEditWindow *window)
+{
+       g_return_if_fail (MODEST_MSG_EDIT_WINDOW (window));
+
+       modest_msg_edit_window_show_cc (MODEST_MSG_EDIT_WINDOW (window),
+                                       hildon_check_button_get_active (button));
+}
 
-static void add_button_to_menu (ModestMsgEditWindow *self,
-                               HildonAppMenu *menu,
-                               GtkButton *button,
-                               ModestDimmingRulesGroup *group,
-                               GCallback dimming_callback)
+static void
+on_bcc_button_toggled (HildonCheckButton *button,
+                     ModestMsgEditWindow *window)
 {
-       if (dimming_callback)
-               modest_dimming_rules_group_add_widget_rule (group,
-                                                           GTK_WIDGET (button),
-                                                           dimming_callback,
-                                                           MODEST_WINDOW (self));
-       hildon_app_menu_append (menu, GTK_BUTTON (button));
+       g_return_if_fail (MODEST_MSG_EDIT_WINDOW (window));
+
+       modest_msg_edit_window_show_bcc (MODEST_MSG_EDIT_WINDOW (window),
+                                       hildon_check_button_get_active (button));
 }
 
-static void add_to_menu (ModestMsgEditWindow *self,
-                        HildonAppMenu *menu,
-                        gchar *label,
-                        GCallback callback,
-                        ModestDimmingRulesGroup *group,
-                        GCallback dimming_callback)
+static void
+on_find_toolbar_button_toggled (HildonCheckButton *button,
+                               ModestMsgEditWindow *window)
 {
-       GtkWidget *button;
+       g_return_if_fail (MODEST_MSG_EDIT_WINDOW (window));
+       modest_msg_edit_window_toggle_find_toolbar (MODEST_MSG_EDIT_WINDOW (window),
+                                                   hildon_check_button_get_active (button));
 
-       button = gtk_button_new_with_label (label);
-       g_signal_connect_after (G_OBJECT (button), "clicked",
-                               callback, (gpointer) self);
-       add_button_to_menu (self, menu, GTK_BUTTON (button), group, dimming_callback);
 }
 
 static void 
-setup_menu (ModestMsgEditWindow *self, ModestDimmingRulesGroup *group)
+setup_menu (ModestMsgEditWindow *self)
 {
        ModestMsgEditWindowPrivate *priv = NULL;
 
@@ -3938,58 +3881,47 @@ setup_menu (ModestMsgEditWindow *self, ModestDimmingRulesGroup *group)
 
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
 
-       priv->app_menu = hildon_app_menu_new ();
-
        /* Settings menu buttons */
-       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_editor_checknames"),
-                    G_CALLBACK (modest_ui_actions_on_check_names),
-                    group, NULL);
-       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_inbox_undo"),
-                    G_CALLBACK (modest_ui_actions_on_undo),
-                    group, NULL);
+       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_editor_checknames"),
+                                          APP_MENU_CALLBACK (modest_ui_actions_on_check_names),
+                                          NULL);
+       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_undo"),
+                                          APP_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), _("TODO: Show CC"));
+       gtk_button_set_label (GTK_BUTTON (priv->cc_button), _("mcen_me_editor_showcc"));
        hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->cc_button),
                                        FALSE);
-       add_button_to_menu (self, HILDON_APP_MENU (priv->app_menu), GTK_BUTTON (priv->cc_button),
-                           group, NULL);
+       modest_hildon2_window_add_button_to_menu (MODEST_HILDON2_WINDOW (self), GTK_BUTTON (priv->cc_button),
+                                                 NULL);
+       g_signal_connect (G_OBJECT (priv->cc_button), "toggled",
+                         G_CALLBACK (on_cc_button_toggled), (gpointer) self);
        priv->bcc_button = hildon_check_button_new (0);
-       gtk_button_set_label (GTK_BUTTON (priv->bcc_button), _("TODO: Show BCC"));
+       gtk_button_set_label (GTK_BUTTON (priv->bcc_button), _("mcen_me_editor_showbcc"));
        hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->bcc_button),
                                        FALSE);
-       add_button_to_menu (self, HILDON_APP_MENU (priv->app_menu), GTK_BUTTON (priv->bcc_button),
-                           group, NULL);
-
-       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_editor_attach_inlineimage"),
-                    G_CALLBACK (modest_ui_actions_on_insert_image),
-                    group, NULL);
-       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_inbox_remove_attachments"),
-                    G_CALLBACK (modest_ui_actions_on_remove_attachments),
-                    group, NULL);
-       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("TODO: Message settings..."),
-                    G_CALLBACK (on_message_settings),
-                    group, NULL);
-
-       /* TODO: find in toolbar check button */
-
-       hildon_stackable_window_set_main_menu (HILDON_STACKABLE_WINDOW (self), 
-                                              HILDON_APP_MENU (priv->app_menu));
-}
-
-static gboolean 
-modest_msg_edit_window_toggle_menu (HildonWindow *window,
-                                   guint button,
-                                   guint32 time)
-{
-       ModestMsgEditWindowPrivate *priv = NULL;
-
-       priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
-
-       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window));
-
-       gtk_widget_queue_resize (priv->app_menu);
-
-       return HILDON_WINDOW_CLASS (parent_class)->toggle_menu (window, button, time);
+       modest_hildon2_window_add_button_to_menu (MODEST_HILDON2_WINDOW (self), GTK_BUTTON (priv->bcc_button),
+                                                 NULL);
+       g_signal_connect (G_OBJECT (priv->bcc_button), "toggled",
+                         G_CALLBACK (on_bcc_button_toggled), (gpointer) self);
+
+       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_editor_attach_inlineimage"),
+                                          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_inbox_remove_attachments"),
+                                          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), _("TODO: Message settings..."),
+                                          APP_MENU_CALLBACK (on_message_settings),
+                                          NULL);
+       priv->find_toolbar_button = hildon_check_button_new (0);
+       gtk_button_set_label (GTK_BUTTON (priv->find_toolbar_button), _("mcen_me_viewer_find"));
+       hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->find_toolbar_button),
+                                       FALSE);
+       modest_hildon2_window_add_button_to_menu (MODEST_HILDON2_WINDOW (self), GTK_BUTTON (priv->find_toolbar_button),
+                                                 NULL);
+       g_signal_connect (G_OBJECT (priv->find_toolbar_button), "toggled",
+                         G_CALLBACK (on_find_toolbar_button_toggled), (gpointer) self);
 }