Drop usage of HildonCheckButton in settings dialogs.
authorJose Dapena Paz <jdapena@igalia.com>
Tue, 3 Nov 2009 16:36:35 +0000 (17:36 +0100)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 4 Nov 2009 13:45:15 +0000 (14:45 +0100)
src/hildon2/modest-default-account-settings-dialog.c
src/hildon2/modest-easysetup-wizard-dialog.c
src/hildon2/modest-hildon2-global-settings-dialog.c
src/hildon2/modest-maemo-security-options-view.c
src/hildon2/modest-signature-editor-dialog.c
src/widgets/modest-global-settings-dialog.c
src/widgets/modest-security-options-view.c
src/widgets/modest-toolkit-factory.c
src/widgets/modest-toolkit-factory.h

index c199e68..11422d9 100644 (file)
@@ -33,7 +33,6 @@
 #include <gtk/gtklabel.h>
 #include <gtk/gtkentry.h>
 #include <gtk/gtkbutton.h>
-#include <gtk/gtkcheckbutton.h>
 #include <gtk/gtkmessagedialog.h>
 #include <gtk/gtkstock.h>
 #include "modest-hildon-includes.h"
@@ -206,7 +205,7 @@ on_modified_entry_changed (GtkEditable *editable, gpointer user_data)
 }
 
 static void
-on_modified_checkbutton_toggled (GtkButton *button, gpointer user_data)
+on_modified_checkbutton_toggled (GtkWidget *button, gpointer user_data)
 {
        set_modified (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data), TRUE);
 }
@@ -243,7 +242,7 @@ connect_for_modified (ModestDefaultAccountSettingsDialog *self, GtkWidget *widge
        } else if (HILDON_IS_PICKER_BUTTON (widget)) {
                g_signal_connect (G_OBJECT (widget), "value-changed",
                                  G_CALLBACK (on_modified_picker_changed), self);
-       } else if (HILDON_IS_CHECK_BUTTON (widget)) {
+       } else if (modest_is_togglable (widget)) {
                g_signal_connect (G_OBJECT (widget), "toggled",
                        G_CALLBACK (on_modified_checkbutton_toggled), self);
        }
@@ -375,10 +374,8 @@ create_page_account_details (ModestDefaultAccountSettingsDialog *self,
        /* The leave-messages widgets: */
        if(!priv->checkbox_leave_messages) {
                priv->checkbox_leave_messages = 
-                       hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
-               gtk_button_set_label (GTK_BUTTON (priv->checkbox_leave_messages),
-                                     _("mcen_fi_advsetup_leave_on_server"));
-               gtk_button_set_alignment (GTK_BUTTON (priv->checkbox_leave_messages), 0.0, 0.5);
+                       modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
+                                                                   _("mcen_fi_advsetup_leave_on_server"));
        }
        connect_for_modified (self, priv->checkbox_leave_messages);
        gtk_box_pack_start (GTK_BOX (box), priv->checkbox_leave_messages, FALSE, FALSE, 0);
@@ -672,19 +669,19 @@ create_page_incoming (ModestDefaultAccountSettingsDialog *self,
 }
 
 static void
-on_check_button_clicked (GtkButton *button, gpointer user_data)
+on_check_button_clicked (GtkWidget *button, gpointer user_data)
 {
        GtkWidget *widget = GTK_WIDGET (user_data);
        
        /* Enable the widget only if the check button is active: */
-       const gboolean enable = hildon_check_button_get_active (HILDON_CHECK_BUTTON (button));
+       const gboolean enable = modest_togglable_get_active (button);
        gtk_widget_set_sensitive (widget, enable);
 }
 
 /* Make the sensitivity of a widget depend on a check button.
  */
 static void
-enable_widget_for_checkbutton (GtkWidget *widget, GtkButton* button)
+enable_widget_for_checkbutton (GtkWidget *widget, GtkWidget* button)
 {
        g_signal_connect (G_OBJECT (button), "clicked",
                G_CALLBACK (on_check_button_clicked), widget);
@@ -766,12 +763,11 @@ create_page_outgoing (ModestDefaultAccountSettingsDialog *self,
 
        /* connection-specific checkbox: */
        if (!priv->checkbox_outgoing_smtp_specific) {
-               priv->checkbox_outgoing_smtp_specific = hildon_check_button_new (MODEST_EDITABLE_SIZE);
-               hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific), 
-                       FALSE);
-               gtk_button_set_label (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
-                                     _("mcen_fi_advsetup_connection_smtp"));
-               gtk_button_set_alignment (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific), 0.0, 0.5);
+               priv->checkbox_outgoing_smtp_specific = 
+                       modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
+                                                                   _("mcen_fi_advsetup_connection_smtp"));
+               modest_togglable_set_active (priv->checkbox_outgoing_smtp_specific,
+                                            FALSE);
        }
        gtk_widget_show (priv->checkbox_outgoing_smtp_specific);
        gtk_box_pack_start (GTK_BOX (box), priv->checkbox_outgoing_smtp_specific, 
@@ -788,7 +784,7 @@ create_page_outgoing (ModestDefaultAccountSettingsDialog *self,
 
        /* Only enable the button when the checkbox is checked: */
        enable_widget_for_checkbutton (priv->button_outgoing_smtp_servers, 
-               GTK_BUTTON (priv->checkbox_outgoing_smtp_specific));
+               priv->checkbox_outgoing_smtp_specific);
 
        g_signal_connect (G_OBJECT (priv->button_outgoing_smtp_servers), "clicked",
                G_CALLBACK (on_button_outgoing_smtp_servers), self);
@@ -1169,8 +1165,8 @@ modest_default_account_settings_dialog_load_settings (ModestAccountSettingsDialo
        gtk_entry_set_text( GTK_ENTRY (priv->entry_user_email), 
                            null_means_empty (modest_account_settings_get_email_address (settings)));
 
-       hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_leave_messages), 
-                                       modest_account_settings_get_leave_messages_on_server (settings));
+       modest_togglable_set_active (priv->checkbox_leave_messages,
+                                    modest_account_settings_get_leave_messages_on_server (settings));
 
        incoming_account = modest_account_settings_get_store_settings (settings);
        if (incoming_account) {
@@ -1247,9 +1243,8 @@ modest_default_account_settings_dialog_load_settings (ModestAccountSettingsDialo
 
                const gboolean has_specific = 
                        modest_account_settings_get_use_connection_specific_smtp (settings);
-               hildon_check_button_set_active (
-                       HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific), 
-                       has_specific);
+               modest_togglable_set_active (priv->checkbox_outgoing_smtp_specific,
+                                            has_specific);
                g_object_unref (outgoing_account);
        }
 
@@ -1308,7 +1303,7 @@ save_configuration (ModestDefaultAccountSettingsDialog *dialog)
                modest_account_settings_set_signature (priv->settings, signature);
        }
 
-       leave_on_server = hildon_check_button_get_active (HILDON_CHECK_BUTTON (priv->checkbox_leave_messages));
+       leave_on_server = modest_togglable_get_active (priv->checkbox_leave_messages);
        modest_account_settings_set_leave_messages_on_server (priv->settings, leave_on_server); 
 
        store_settings = modest_account_settings_get_store_settings (priv->settings);
@@ -1353,7 +1348,7 @@ save_configuration (ModestDefaultAccountSettingsDialog *dialog)
        /* Save connection-specific SMTP server accounts: */
        modest_account_settings_set_use_connection_specific_smtp 
                (priv->settings, 
-                hildon_check_button_get_active(HILDON_CHECK_BUTTON(priv->checkbox_outgoing_smtp_specific)));
+                modest_togglable_get_active(priv->checkbox_outgoing_smtp_specific));
 
        /* this configuration is not persistent, we should not save */
        if (account_name != NULL)
index 2861ff7..42474d1 100644 (file)
@@ -36,7 +36,6 @@
 #include <gtk/gtklabel.h>
 #include <gtk/gtkentry.h>
 #include <gtk/gtkbutton.h>
-#include <gtk/gtkcheckbutton.h>
 #include <gtk/gtkmessagedialog.h>
 #include <gtk/gtkseparator.h>
 #include "modest-country-picker.h"
@@ -1022,19 +1021,19 @@ create_page_custom_incoming (ModestEasysetupWizardDialog *self)
 }
 
 static void
-on_check_button_changed (HildonCheckButton *button, gpointer user_data)
+on_check_button_changed (GtkWidget *button, gpointer user_data)
 {
        GtkWidget *widget = GTK_WIDGET (user_data);
 
        /* Enable the widget only if the check button is active: */
-       const gboolean enable = hildon_check_button_get_active (button);
+       const gboolean enable = modest_togglable_get_active (button);
        gtk_widget_set_sensitive (widget, enable);
 }
 
 /* Make the sensitivity of a widget depend on a check button.
  */
 static void
-enable_widget_for_checkbutton (GtkWidget *widget, HildonCheckButton* button)
+enable_widget_for_checkbutton (GtkWidget *widget, GtkWidget* button)
 {
        g_signal_connect (G_OBJECT (button), "toggled",
                          G_CALLBACK (on_check_button_changed), widget);
@@ -1117,13 +1116,11 @@ create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
        gtk_widget_show (separator);
 
        /* connection-specific checkbox: */
-       priv->checkbox_outgoing_smtp_specific = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
-       hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific),
-                                       FALSE);
-       gtk_button_set_label (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
-                             _("mcen_fi_advsetup_connection_smtp"));
-       gtk_button_set_alignment (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
-                                 0.0, 0.5);
+       priv->checkbox_outgoing_smtp_specific = modest_toolkit_factory_create_check_button 
+               (modest_runtime_get_toolkit_factory (),
+                _("mcen_fi_advsetup_connection_smtp"));
+       modest_togglable_set_active (priv->checkbox_outgoing_smtp_specific,
+                                    FALSE);
 
        gtk_widget_show (priv->checkbox_outgoing_smtp_specific);
        gtk_box_pack_start (GTK_BOX (box), priv->checkbox_outgoing_smtp_specific,
@@ -1139,7 +1136,7 @@ create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
 
        /* Only enable the button when the checkbox is checked: */
        enable_widget_for_checkbutton (priv->button_outgoing_smtp_servers,
-                                      HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific));
+                                      priv->checkbox_outgoing_smtp_specific);
 
        g_signal_connect (G_OBJECT (priv->button_outgoing_smtp_servers), "clicked",
                          G_CALLBACK (on_button_outgoing_smtp_servers), self);
@@ -2433,7 +2430,7 @@ save_to_settings (ModestEasysetupWizardDialog *self)
        if (priv->checkbox_outgoing_smtp_specific) {
                modest_account_settings_set_use_connection_specific_smtp
                        (priv->settings,
-                        hildon_check_button_get_active(HILDON_CHECK_BUTTON(priv->checkbox_outgoing_smtp_specific)));
+                        modest_togglable_get_active(priv->checkbox_outgoing_smtp_specific));
        }
 
        display_name = get_entered_account_title (self);
index 54062fd..98f772b 100644 (file)
@@ -252,9 +252,8 @@ create_updating_page (ModestHildon2GlobalSettingsDialog *self)
        gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, MODEST_MARGIN_DEFAULT);
 
        /* Auto update */
-       ppriv->auto_update = hildon_check_button_new (MODEST_EDITABLE_SIZE);
-       gtk_button_set_label (GTK_BUTTON (ppriv->auto_update), _("mcen_fi_options_autoupdate"));
-       gtk_button_set_alignment (GTK_BUTTON (ppriv->auto_update), 0.0, 0.5);
+       ppriv->auto_update = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
+                                                                        _("mcen_fi_options_autoupdate"));
        gtk_box_pack_start (GTK_BOX (vbox), ppriv->auto_update, FALSE, FALSE, 0);
        g_signal_connect (ppriv->auto_update, "clicked", G_CALLBACK (on_auto_update_clicked), self);
 
@@ -307,7 +306,7 @@ update_sensitive (ModestGlobalSettingsDialog *dialog)
        g_return_if_fail (MODEST_IS_GLOBAL_SETTINGS_DIALOG (dialog));
        ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (dialog);
 
-       if (hildon_check_button_get_active (HILDON_CHECK_BUTTON (ppriv->auto_update))) {
+       if (modest_togglable_get_active (ppriv->auto_update)) {
                gtk_widget_set_sensitive (ppriv->connect_via, TRUE);
                gtk_widget_set_sensitive (ppriv->update_interval, TRUE);
        } else {
@@ -420,7 +419,7 @@ modest_hildon2_global_settings_dialog_load_settings (ModestGlobalSettingsDialog
                error = NULL;
                checked = FALSE;
        }
-       hildon_check_button_set_active (HILDON_CHECK_BUTTON (ppriv->auto_update), checked);
+       modest_togglable_set_active (ppriv->auto_update, checked);
        ppriv->initial_state.auto_update = checked;
 
        /* Connected by */
index dca4460..a9d7d4e 100644 (file)
@@ -39,7 +39,6 @@
 #include "modest-secureauth-picker.h"
 #include "modest-maemo-utils.h"
 #include <modest-number-editor.h>
-#include <hildon/hildon-check-button.h>
 #include "modest-hildon-includes.h"
 
 #define PORT_MIN 1
@@ -89,8 +88,8 @@ on_security_changed (GtkWidget *widget,
 
        if (MODEST_SECURITY_OPTIONS_VIEW (self)->type == MODEST_SECURITY_OPTIONS_INCOMING) {
                /* Activate and dim checkbutton if it's secure */
-               hildon_check_button_set_active (HILDON_CHECK_BUTTON (ppriv->auth_view), 
-                                               is_secure);
+               modest_togglable_set_active (ppriv->auth_view,
+                                            is_secure);
                gtk_widget_set_sensitive (ppriv->auth_view, !is_secure);
        } else {
 
@@ -158,9 +157,8 @@ create_incoming_security (ModestSecurityOptionsView* self,
                                               _("mcen_li_emailsetup_secure_connection"), 
                                               ppriv->security_view);
 
-       ppriv->auth_view = hildon_check_button_new (MODEST_EDITABLE_SIZE);
-       gtk_button_set_label (GTK_BUTTON (ppriv->auth_view), _("mcen_li_emailsetup_secure_authentication"));
-       gtk_button_set_alignment (GTK_BUTTON (ppriv->auth_view), 0.0, 0.5);
+       ppriv->auth_view = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
+                                                                      _("mcen_li_emailsetup_secure_authentication"));
 
        /* Track changes in UI */
        g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
@@ -228,8 +226,8 @@ on_entry_changed (GtkEditable *editable,
                auth_proto = modest_secureauth_picker_get_active_secureauth (picker);
                is_secure = modest_protocol_registry_protocol_type_is_secure (protocol_registry,
                                                                              auth_proto);
-       } else if (HILDON_IS_CHECK_BUTTON (ppriv->auth_view)) {
-               is_secure = hildon_check_button_get_active (HILDON_CHECK_BUTTON (ppriv->auth_view));
+       } else if (modest_is_togglable (ppriv->auth_view)) {
+               is_secure = modest_togglable_get_active (ppriv->auth_view);
        }
 
        if (is_secure &&
index aad2be5..bcb1ef6 100644 (file)
@@ -125,14 +125,14 @@ enable_widgets (ModestSignatureEditorDialog *self)
        ModestSignatureEditorDialogPrivate *priv = 
                SIGNATURE_EDITOR_DIALOG_GET_PRIVATE (self);
                
-       const gboolean enable = hildon_check_button_get_active (HILDON_CHECK_BUTTON (priv->checkbox_use));
+       const gboolean enable = modest_togglable_get_active (priv->checkbox_use);
        gtk_widget_set_sensitive (priv->label, enable);
        gtk_widget_set_sensitive (priv->textview, enable);
        gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->textview), enable);
 }
 
 static void
-on_toggle_button_changed (GtkToggleButton *togglebutton, gpointer user_data)
+on_toggle_button_changed (GtkWidget *togglebutton, gpointer user_data)
 {
        ModestSignatureEditorDialog *self = MODEST_SIGNATURE_EDITOR_DIALOG (user_data);
        enable_widgets (self);
@@ -150,10 +150,8 @@ modest_signature_editor_dialog_init (ModestSignatureEditorDialog *self)
        GtkWidget *box = GTK_DIALOG(self)->vbox; /* gtk_vbox_new (FALSE, MODEST_MARGIN_HALF); */
        top_box = gtk_vbox_new (FALSE, 0);
 
-       priv->checkbox_use = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
-       gtk_button_set_label (GTK_BUTTON (priv->checkbox_use), 
-                             _("mcen_fi_email_signatures_use_signature"));
-       gtk_button_set_alignment (GTK_BUTTON (priv->checkbox_use), 0.0, 0.5);
+       priv->checkbox_use = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
+                                                                        _("mcen_fi_email_signatures_use_signature"));
        gtk_box_pack_start (GTK_BOX (top_box), priv->checkbox_use, FALSE, FALSE, 0);
        gtk_widget_show (priv->checkbox_use);
        
@@ -224,7 +222,7 @@ modest_signature_editor_dialog_set_settings (
        gtk_label_set_ellipsize (GTK_LABEL (priv->label),  PANGO_ELLIPSIZE_END);
        g_free (label_text);
        
-       hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_use), use_signature);
+       modest_togglable_set_active (priv->checkbox_use, use_signature);
        
        GtkTextBuffer *buffer = hildon_text_view_get_buffer (HILDON_TEXT_VIEW (priv->textview));
        if (signature && signature[0] != '\0')
@@ -246,7 +244,7 @@ modest_signature_editor_dialog_get_settings (
                
        g_assert(use_signature);
        
-       *use_signature = hildon_check_button_get_active (HILDON_CHECK_BUTTON (priv->checkbox_use));
+       *use_signature = modest_togglable_get_active (priv->checkbox_use);
                        
        GtkTextBuffer *buffer = hildon_text_view_get_buffer (HILDON_TEXT_VIEW (priv->textview));
        
index 47434fe..5641555 100644 (file)
@@ -250,13 +250,12 @@ get_current_settings (ModestGlobalSettingsDialogPrivate *priv,
        gint *id;
 
        /* Get values from UI */
+       state->auto_update = modest_togglable_get_active (priv->auto_update);
 #ifdef MODEST_TOOLKIT_HILDON2
        id = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->connect_via));
-       state->auto_update = hildon_check_button_get_active (HILDON_CHECK_BUTTON (priv->auto_update));
        state->default_account = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->default_account_selector));
 #else
        id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->connect_via));
-       state->auto_update = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auto_update));
        state->default_account = NULL;
 #endif
        state->connect_via = *id;
index c7552f6..c3cd853 100644 (file)
@@ -105,13 +105,8 @@ modest_security_options_view_load_settings (ModestSecurityOptionsView* self,
                /* Active the authentication checkbox */
                if (modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (), 
                                                                      secure_auth))
-#ifdef MODEST_TOOLKIT_HILDON2
-                       hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->auth_view),
-                                                       TRUE);
-#else
-                       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->auth_view),
-                                                     TRUE);
-#endif
+                       modest_togglable_set_active (priv->auth_view,
+                                                    TRUE);
        } else {
 #ifdef MODEST_TOOLKIT_HILDON2
                modest_secureauth_picker_set_active_secureauth (
@@ -157,11 +152,7 @@ modest_security_options_view_save_settings (ModestSecurityOptionsView* self,
 #endif
 
        if (self->type == MODEST_SECURITY_OPTIONS_INCOMING) {
-#ifdef MODEST_TOOLKIT_HILDON2
-               if (hildon_check_button_get_active (HILDON_CHECK_BUTTON (priv->auth_view))) {
-#else
-               if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view))) {
-#endif
+               if (modest_togglable_get_active (priv->auth_view)) {
                        if (!modest_protocol_registry_protocol_type_is_secure (proto_registry,
                                                                               security_proto)) {
                                /* TODO */
@@ -255,11 +246,7 @@ get_current_state (ModestSecurityOptionsView* self,
                if (priv->full) {
                }
        } else {
-#ifdef MODEST_TOOLKIT_HILDON2
-               if (hildon_check_button_get_active (HILDON_CHECK_BUTTON (priv->auth_view)))
-#else
-               if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view)))
-#endif
+               if (modest_togglable_get_active (priv->auth_view))
                        state->auth = priv->initial_state.auth;
                else
                        state->auth = MODEST_PROTOCOLS_AUTH_NONE;
@@ -334,13 +321,8 @@ modest_security_options_view_auth_check (ModestSecurityOptionsView* self)
                modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
 #endif
 
-#ifdef MODEST_TOOLKIT_HILDON2
        auth_active = 
-               hildon_check_button_get_active (HILDON_CHECK_BUTTON (priv->auth_view));
-#else
-       auth_active = 
-               gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view));
-#endif
+               modest_togglable_get_active (priv->auth_view);
        is_secure = 
                modest_protocol_registry_protocol_type_has_tag (protocol_registry, 
                                                                security_incoming_type, 
index 686355b..89e5b7c 100644 (file)
@@ -155,3 +155,13 @@ modest_togglable_set_active (GtkWidget *widget, gboolean active)
        }
 #endif
 }
+
+gboolean
+modest_is_togglable (GtkWidget *widget)
+{
+#ifdef MODEST_TOOLKIT_HILDON2
+       return HILDON_IS_CHECK_BUTTON (widget);
+#else
+       return GTK_IS_CHECK_MENU_ITEM (widget) || GTK_IS_TOGGLE_BUTTON (widget);
+#endif
+}
index c6ed13e..605c7a4 100644 (file)
@@ -67,6 +67,9 @@ modest_togglable_get_active (GtkWidget *widget);
 void
 modest_togglable_set_active (GtkWidget *widget, gboolean active);
 
+gboolean
+modest_is_togglable (GtkWidget *widget);
+
 G_END_DECLS
 
 #endif /* __MODEST_WP_TEXT_VIEW_H__ */