2007-04-05 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Thu, 5 Apr 2007 20:18:06 +0000 (20:18 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Thu, 5 Apr 2007 20:18:06 +0000 (20:18 +0000)
* src/maemo/easysetup/Makefile.am:
        * src/maemo/easysetup/modest-easysetup-country-combo-box.c:
        (load_from_file):
        * src/maemo/easysetup/modest-easysetup-wizard.c:
        (modest_easysetup_wizard_dialog_init):
        Try to get the source directory from the build system,
        instead of hard-coding ./ into the source code, when opening our local
        copies of the configuration files.
        But this still fails when opening the wizard from the Accounts window,
        maybe because the working directory seems to change at runtime.
        So the wizard will fail the second time unless you copy the files into their
        proper locations - see the stdout warnings for the paths.

        (create_page_account_details),(on_before_next):
        Check for existing non-server accounts instead of server accounts,
        so the default account name is useful again, and to prevent trying to
        recreate accounts.

        * src/maemo/modest-account-view-window.c: (on_new_button_clicked):
        Show the wizard when New is clicked.

        * src/widgets/modest-account-view.c: (on_account_default_toggled),
        (init_view): Show the column headers, and show the columns that are
        specified in the UI specs. However, something in Maemo's GTK+ prevents
        us from handling the GtkCellRendererToggle::toggled signal, so we cannot
        change the default account. This is despite unsetting the special properties.

pmo-trunk-r1517

ChangeLog2
src/maemo/easysetup/Makefile.am
src/maemo/easysetup/modest-easysetup-country-combo-box.c
src/maemo/easysetup/modest-easysetup-wizard.c
src/maemo/modest-account-view-window.c
src/modest-ui-actions.c
src/widgets/modest-account-view.c

index 85f3e78..e46701d 100644 (file)
@@ -1,5 +1,34 @@
 2007-04-05  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/maemo/easysetup/Makefile.am:
+       * src/maemo/easysetup/modest-easysetup-country-combo-box.c:
+       (load_from_file): 
+       * src/maemo/easysetup/modest-easysetup-wizard.c:
+       (modest_easysetup_wizard_dialog_init):
+       Try to get the source directory from the build system,
+       instead of hard-coding "./" into the source code, when opening our local 
+       copies of the configuration files.
+       But this still fails when opening the wizard from the Accounts window, 
+       maybe because the working directory seems to change at runtime.
+       So the wizard will fail the second time unless you copy the files into their 
+       proper locations - see the stdout warnings for the paths.
+       
+       (create_page_account_details),(on_before_next): 
+       Check for existing non-server accounts instead of server accounts, 
+       so the default account name is useful again, and to prevent trying to 
+       recreate accounts.
+       
+       * src/maemo/modest-account-view-window.c: (on_new_button_clicked): 
+       Show the wizard when New is clicked.
+       
+       * src/widgets/modest-account-view.c: (on_account_default_toggled),
+       (init_view): Show the column headers, and show the columns that are 
+       specified in the UI specs. However, something in Maemo's GTK+ prevents 
+       us from handling the GtkCellRendererToggle::toggled signal, so we cannot 
+       change the default account. This is despite unsetting the special properties.
+
+2007-04-05  Murray Cumming  <murrayc@murrayc.com>
+
        * docs/reference/modest-design.sgml: Corrected spelling mistake.
        * src/maemo/easysetup/modest-easysetup-wizard.c: (create_account): 
        Create the 2 server accounts and then create the account, using the names of the 2 server accounts.
index 56b9044..7af8ebe 100644 (file)
@@ -26,7 +26,8 @@
 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-
+# HACK_TOP_SRCDIR is temporary and should be remove.
+       
 INCLUDES=\
        $(MODEST_GSTUFF_CFLAGS) \
        $(MODEST_LIBTINYMAIL_MAEMO_CFLAGS) \
@@ -37,6 +38,7 @@ INCLUDES=\
        -DMAEMO_CHANGES \
        -DPIXMAP_PREFIX=\"${datadir}/pixmaps/modest/\" \
        -DMODEST_UIDIR=\""$(datadir)/modest/ui/"\" \
+       -DHACK_TOP_SRCDIR=\"${top_srcdir}/\"  \
        -Wall
 
 noinst_LTLIBRARIES=\
index 511d8d9..90083b9 100644 (file)
@@ -155,7 +155,7 @@ static void load_from_file (EasysetupCountryComboBox *self)
        FILE *file = fopen(filepath, "r");
        if (!file)
        {
-               const gchar* filepath_hack = "./src/maemo/easysetup/mcc_mapping";
+               const gchar* filepath_hack = HACK_TOP_SRCDIR "src/maemo/easysetup/mcc_mapping";
                g_warning ("Could not locate the official mcc_mapping countries list file from %s, "
                        "so attempting to load it instead from %s", filepath, filepath_hack);
                file = fopen(filepath_hack, "r");
index e29dad5..9567a88 100644 (file)
@@ -317,7 +317,7 @@ create_page_account_details (ModestEasysetupWizardDialog *self)
        /* Set a default account title, choosing one that does not already exist: */
        gchar* default_acount_name = g_strdup (_("mcen_ia_emailsetup_defaultname"));
        while (modest_account_mgr_account_exists (self->account_manager, 
-               default_acount_name, TRUE /*  server_account */)) {
+               default_acount_name, FALSE /*  server_account */)) {
                        
                gchar * default_account_name2 = util_increment_name (default_acount_name);
                g_free (default_acount_name);
@@ -724,7 +724,7 @@ modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self)
        priv->presets = modest_presets_new (filepath); /* TODO: the actual filepath. */
        if (!(priv->presets))
        {
-               const gchar* filepath_hack = "./src/maemo/easysetup/provider-data-test.keyfile";
+               const gchar* filepath_hack = HACK_TOP_SRCDIR "src/maemo/easysetup/provider-data-test.keyfile";
                g_warning ("Could not locate the official provider data keyfile from %s, "
                        "so attempting to load it instead from %s", filepath, filepath_hack);
                priv->presets = modest_presets_new (filepath_hack); /* TODO: the actual filepath. */
@@ -1010,7 +1010,7 @@ on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *
                        
                gboolean name_in_use = FALSE;
                name_in_use = modest_account_mgr_account_exists (account_wizard->account_manager,
-                       account_name, TRUE /*  server_account */);
+                       account_name, FALSE /*  server_account */);
                
                if (name_in_use) {
                        /* Warn the user via a dialog: */
index 9f86675..e958221 100644 (file)
@@ -38,6 +38,7 @@
 #include <string.h>
 #include "modest-account-assistant.h"
 #include "modest-tny-platform-factory.h"
+#include "maemo/easysetup/modest-easysetup-wizard.h"
 
 /* 'private'/'protected' functions */
 static void                            modest_account_view_window_class_init   (ModestAccountViewWindowClass *klass);
@@ -201,21 +202,11 @@ on_edit_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
 static void
 on_new_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
 {
-       GtkWidget *notebook, *assistant;
-       ModestAccountViewWindowPrivate *priv;
-
-       /* TODO: */
-       modest_runtime_not_implemented (GTK_WINDOW(self));
-       return;
-
-       priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
-
-       notebook = modest_account_assistant_new (modest_runtime_get_account_mgr());
-       assistant = hildon_wizard_dialog_new (GTK_WINDOW(self), _("Account setup wizard"),
-                                             GTK_NOTEBOOK(notebook));
-       
-       gtk_dialog_run (GTK_DIALOG(assistant));
-       gtk_widget_destroy (assistant);
+       /* Show the easy-setup wizard: */
+       ModestEasysetupWizardDialog *wizard = modest_easysetup_wizard_dialog_new ();
+       gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (self));
+       gtk_dialog_run (GTK_DIALOG (wizard));
+       gtk_widget_destroy (GTK_WIDGET (wizard));
 }
 
 
index 460c7b0..2bd91be 100644 (file)
@@ -206,14 +206,6 @@ void
 modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win)
 {
        GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr());
-       
-#if 0
-       GSList *account_names = modest_account_mgr_search_server_accounts (
-               modest_runtime_get_account_mgr(),
-               NULL /* account_name, any */,
-               MODEST_PROTOCOL_TYPE_UNKNOWN /* type */,
-               MODEST_PROTOCOL_UNKNOWN /* proto */);
-#endif
                                                     
        gboolean accounts_exist = account_names != NULL;
        g_slist_free (account_names);
@@ -224,7 +216,6 @@ modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win)
 #ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
        /* To test, while modest_account_mgr_account_names() is broken: accounts_exist = TRUE; */
        if (!accounts_exist) {
-               printf ("debug: modest_account_mgr_account_names() returned NULL.\n");
                /* If there are no accounts yet, just show the easy-setup wizard, as per the UI spec: */
                ModestEasysetupWizardDialog *wizard = modest_easysetup_wizard_dialog_new ();
                gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
index 9c4f9e6..aa0b06e 100644 (file)
@@ -231,9 +231,7 @@ on_account_removed (ModestAccountMgr *account_mgr,
        on_account_changed (account_mgr, account, NULL, server_account, self);
 }
 
-
-
-
+#if 0
 static void
 on_account_enable_toggled (GtkCellRendererToggle *cell_renderer, gchar *path,
                           ModestAccountView *self)
@@ -259,7 +257,48 @@ on_account_enable_toggled (GtkCellRendererToggle *cell_renderer, gchar *path,
        modest_account_mgr_set_enabled (priv->account_mgr, account_name, !enabled);
        g_free (account_name);
 }
+#endif
+
+static void
+on_account_default_toggled (GtkCellRendererToggle *cell_renderer, gchar *path,
+                          ModestAccountView *self)
+{
+       printf ("debug: on_account_default_toggled\n");
+       gboolean is_default = gtk_cell_renderer_toggle_get_active (cell_renderer);
+       printf ("debug: is_default: %d\n", is_default);
+       if (!is_default) {
+               /* Do not allow an account to be marked non-default.
+                * Only allow this to be changed by setting another account to default: */
+               gtk_cell_renderer_toggle_set_active (cell_renderer, TRUE);
+               return;
+       }
+
+       ModestAccountViewPrivate *priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self);
+       GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW(self));
+       
+       GtkTreeIter iter;
+       if (!gtk_tree_model_get_iter_from_string (model, &iter, path)) {
+               g_printerr ("modest: cannot find iterator\n");
+               return;
+       }
+       
+       gchar *account_name = NULL;
+       gtk_tree_model_get (model, &iter, MODEST_ACCOUNT_VIEW_NAME_COLUMN, &account_name,
+                           -1);
+       
+       /* toggle:  */
+       if (is_default) {
+               printf ("debug2: is_default: %d\n", is_default);
+               /* TODO: Will the model will be updated  */
+               modest_account_mgr_set_default_account (priv->account_mgr, account_name);
+       }
+       
+       /* toggle:  */
+       if (is_default)
+               modest_account_mgr_set_default_account (priv->account_mgr, account_name);
 
+       g_free (account_name);
+}
 
 void
 bold_if_default_cell_data  (GtkTreeViewColumn *column,  GtkCellRenderer *renderer,
@@ -298,35 +337,45 @@ init_view (ModestAccountView *self)
        toggle_renderer = gtk_cell_renderer_toggle_new ();
        text_renderer = gtk_cell_renderer_text_new ();
 
-       /* the is_enabled column */
-       g_object_set (G_OBJECT(toggle_renderer), "activatable", TRUE,"radio", FALSE, NULL);
-       g_signal_connect (G_OBJECT(toggle_renderer), "toggled", G_CALLBACK(on_account_enable_toggled),
-                         self);
+       /* the is_default column */
+       g_object_set (G_OBJECT(toggle_renderer), "activatable", TRUE, "radio", FALSE, NULL);
+       printf("debug: connecting to toggled signal.\n");
        gtk_tree_view_append_column (GTK_TREE_VIEW(self),
                                     gtk_tree_view_column_new_with_attributes (
-                                            _("Enabled"), toggle_renderer,
-                                            "active", MODEST_ACCOUNT_VIEW_IS_ENABLED_COLUMN, NULL));
+                                            _(" mcen_ti_default"), toggle_renderer,
+                                            "active", MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, NULL));
+                                       
+       /* Disable the Maemo GtkTreeView::allow-checkbox-mode Maemo modification, 
+        * which causes the model column to be updated automatically when the row is clicked.
+        * Making this the default in Maemo's GTK+ is obviously a bug:
+        * https://maemo.org/bugzilla/show_bug.cgi?id=146
+        * 
+        *  This also stops the application's own signal handler from being called,
+        *  though unsetting the Maemo properties does not seem to fix that:
+        */     
+       g_object_set(G_OBJECT(self), "allow-checkbox-mode", FALSE, NULL);
+       g_object_set(G_OBJECT(toggle_renderer), "checkbox-mode", FALSE, NULL);
+       g_signal_connect (G_OBJECT(toggle_renderer), "toggled", G_CALLBACK(on_account_default_toggled),
+                         self);
        
        /* account name */
-       column =  gtk_tree_view_column_new_with_attributes (_("Account"), text_renderer,"text",
+       column =  gtk_tree_view_column_new_with_attributes (_("mcen_ti_account"), text_renderer, "text",
                                                            MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, NULL);
-       gtk_tree_view_append_column (GTK_TREE_VIEW(self),column);
-       gtk_tree_view_column_set_cell_data_func(column, text_renderer, bold_if_default_cell_data,
-                                               NULL, NULL);
-
-       /* account type */
-       column =  gtk_tree_view_column_new_with_attributes (_("Type"), text_renderer,"text",
-                                                           MODEST_ACCOUNT_VIEW_PROTO_COLUMN, NULL);
-       gtk_tree_view_append_column (GTK_TREE_VIEW(self),column);
+       gtk_tree_view_append_column (GTK_TREE_VIEW(self), column);
        gtk_tree_view_column_set_cell_data_func(column, text_renderer, bold_if_default_cell_data,
                                                NULL, NULL);
 
        /* last update for this account */
-       column =  gtk_tree_view_column_new_with_attributes (_("Last update"), text_renderer,"text",
+       column =  gtk_tree_view_column_new_with_attributes (_("mcen_ti_lastupdated"), text_renderer,"text",
                                                            MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, NULL);
        gtk_tree_view_append_column (GTK_TREE_VIEW(self),column);
        gtk_tree_view_column_set_cell_data_func(column, text_renderer, bold_if_default_cell_data,
                                                NULL, NULL);
+                       
+       /* Show the column headers,
+        * which does not seem to be the default on Maemo.
+        */                     
+       gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(self), TRUE);
 
        priv->sig1 = g_signal_connect (G_OBJECT(priv->account_mgr),"account_removed",
                                       G_CALLBACK(on_account_removed), self);