From b693e89d362b4a4efbb780762cdbc97d220acdce Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 5 Apr 2007 12:12:36 +0000 Subject: [PATCH] 2007-04-05 Murray Cumming * src/maemo/modest-account-view-window.c: (modest_account_view_window_init), (modest_account_view_window_new): Use the same buttons as specified in the UI spec. Add the widgets to the vbox and action_area instead of just assigning them to the existing widgets, which never had a chance of working. Put the ModestAccountView treeview in a scrolled window. Do not repeat the initialization in both _init() and _new(). * src/widgets/modest-account-view.c: (update_account_view): Add a warning about modest_account_mgr_account_names() returning NULL, which is why this widget and window shows no accounts. * po/en_GB.po: Added translations needed for the dialog button logical IDs. pmo-trunk-r1513 --- ChangeLog2 | 17 +++++ po/en_GB.po | 12 ++-- src/maemo/modest-account-view-window.c | 107 ++++++++++++++------------------ src/modest-ui-actions.c | 5 +- src/widgets/modest-account-view.c | 5 ++ 5 files changed, 81 insertions(+), 65 deletions(-) diff --git a/ChangeLog2 b/ChangeLog2 index e384129..182b86d 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,5 +1,22 @@ 2007-04-05 Murray Cumming + * src/maemo/modest-account-view-window.c: + (modest_account_view_window_init), + (modest_account_view_window_new): + Use the same buttons as specified in the + UI spec. Add the widgets to the vbox and action_area instead of just assigning them to + the existing widgets, which never had a chance of working. + Put the ModestAccountView treeview in a scrolled window. + Do not repeat the initialization in both _init() and _new(). + + * src/widgets/modest-account-view.c: (update_account_view): + Add a warning about modest_account_mgr_account_names() returning NULL, which is why + this widget and window shows no accounts. + + * po/en_GB.po: Added translations needed for the dialog button logical IDs. + +2007-04-05 Murray Cumming + * src/maemo/easysetup/modest-easysetup-wizard.c: (set_default_custom_servernames): Avoid a dereference of a destroyed widget. (create_account): Do a sanity check, showing that modest_account_mgr_account_names() diff --git a/po/en_GB.po b/po/en_GB.po index cb76b36..a2aaabc 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -1641,6 +1641,10 @@ msgstr "" msgid "Align to the right" msgstr "" + +msgid "mcen_bd_new" +msgstr "New" + # E-mail application title #~ msgid "mcen_ap_name" #~ msgstr "E-mail" @@ -2472,12 +2476,12 @@ msgstr "" #~ msgstr "Set as default" # Dialog button -#~ msgid "mcen_bd_emailsetup_delete" -#~ msgstr "Delete" +msgid "mcen_bd_emailsetup_delete" +msgstr "Delete" # Dialog button -#~ msgid "mcen_bd_emailsetup_close" -#~ msgstr "Close" +msgid "mcen_bd_emailsetup_close" +msgstr "Close" # Text string #~ msgid "mcen_ia_emailsetup_default" diff --git a/src/maemo/modest-account-view-window.c b/src/maemo/modest-account-view-window.c index 0a5b200..9f86675 100644 --- a/src/maemo/modest-account-view-window.c +++ b/src/maemo/modest-account-view-window.c @@ -53,10 +53,10 @@ enum { typedef struct _ModestAccountViewWindowPrivate ModestAccountViewWindowPrivate; struct _ModestAccountViewWindowPrivate { - GtkWidget *add_button; + GtkWidget *new_button; GtkWidget *edit_button; - GtkWidget *remove_button; - GtkWidget *default_button; + GtkWidget *delete_button; + GtkWidget *close_button; ModestAccountView *account_view; }; #define MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ @@ -134,20 +134,18 @@ on_selection_changed (GtkTreeSelection *sel, ModestAccountViewWindow *self) gtk_tree_selection_get_selected (sel, &model, &iter); gtk_widget_set_sensitive (priv->edit_button, has_selection); - gtk_widget_set_sensitive (priv->remove_button, has_selection); + gtk_widget_set_sensitive (priv->delete_button, has_selection); account_name = modest_account_view_get_selected_account (priv->account_view); default_account_name = modest_account_mgr_get_default_account( modest_runtime_get_account_mgr()); - gtk_widget_set_sensitive (priv->default_button, - default_account_name == NULL || account_name == NULL || - strcmp (default_account_name, account_name) != 0); + g_free (account_name); g_free (default_account_name); } static void -on_remove_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) +on_delete_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) { ModestAccountViewWindowPrivate *priv; ModestAccountMgr *account_mgr; @@ -201,11 +199,12 @@ on_edit_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) } static void -on_add_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) +on_new_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) { GtkWidget *notebook, *assistant; ModestAccountViewWindowPrivate *priv; + /* TODO: */ modest_runtime_not_implemented (GTK_WINDOW(self)); return; @@ -221,20 +220,11 @@ on_add_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) static void -on_default_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) +on_close_button_clicked (GtkWidget *button, gpointer user_data) { - ModestAccountViewWindowPrivate *priv; - ModestAccountMgr *account_mgr; - gchar *account_name; - - priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self); - - account_mgr = modest_runtime_get_account_mgr(); - account_name = modest_account_view_get_selected_account (priv->account_view); - - modest_account_mgr_set_default_account (account_mgr, account_name); + ModestAccountViewWindow *self = MODEST_ACCOUNT_VIEW_WINDOW (user_data); - g_free (account_name); + gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_OK); } @@ -242,42 +232,38 @@ on_default_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) static GtkWidget* button_box_new (ModestAccountViewWindow *self) { - GtkWidget *button_box; - ModestAccountViewWindowPrivate *priv; + ModestAccountViewWindowPrivate *priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self); - priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self); - - button_box = gtk_hbutton_box_new (); + GtkWidget *button_box = gtk_hbutton_box_new (); gtk_button_box_set_spacing (GTK_BUTTON_BOX (button_box), 6); gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box), GTK_BUTTONBOX_START); - priv->add_button = gtk_button_new_from_stock(GTK_STOCK_ADD); - priv->default_button = gtk_button_new_with_label(_("Make default")); - priv->remove_button = gtk_button_new_from_stock(GTK_STOCK_REMOVE); - priv->edit_button = gtk_button_new_from_stock(GTK_STOCK_EDIT); + priv->new_button = gtk_button_new_from_stock(_("mcen_bd_new")); + priv->edit_button = gtk_button_new_with_label(_("mcen_bd_emailsetup_edit")); + priv->delete_button = gtk_button_new_from_stock(_("mcen_bd_emailsetup_delete")); + priv->close_button = gtk_button_new_from_stock(_("mcen_bd_emailsetup_close")); - g_signal_connect (G_OBJECT(priv->add_button), "clicked", - G_CALLBACK(on_add_button_clicked), + g_signal_connect (G_OBJECT(priv->new_button), "clicked", + G_CALLBACK(on_new_button_clicked), self); - g_signal_connect (G_OBJECT(priv->remove_button), "clicked", - G_CALLBACK(on_remove_button_clicked), + g_signal_connect (G_OBJECT(priv->delete_button), "clicked", + G_CALLBACK(on_delete_button_clicked), self); g_signal_connect (G_OBJECT(priv->edit_button), "clicked", G_CALLBACK(on_edit_button_clicked), self); - g_signal_connect (G_OBJECT(priv->default_button), "clicked", - G_CALLBACK(on_default_button_clicked), + g_signal_connect (G_OBJECT(priv->close_button), "clicked", + G_CALLBACK(on_close_button_clicked), self); - gtk_box_pack_start (GTK_BOX(button_box), priv->add_button, FALSE, FALSE,2); - gtk_box_pack_start (GTK_BOX(button_box), priv->default_button, FALSE, FALSE,2); - gtk_box_pack_start (GTK_BOX(button_box), priv->remove_button, FALSE, FALSE,2); + gtk_box_pack_start (GTK_BOX(button_box), priv->new_button, FALSE, FALSE,2); gtk_box_pack_start (GTK_BOX(button_box), priv->edit_button, FALSE, FALSE,2); + gtk_box_pack_start (GTK_BOX(button_box), priv->delete_button, FALSE, FALSE,2); + gtk_box_pack_start (GTK_BOX(button_box), priv->close_button, FALSE, FALSE,2); gtk_widget_set_sensitive (priv->edit_button, FALSE); - gtk_widget_set_sensitive (priv->remove_button, FALSE); - gtk_widget_set_sensitive (priv->default_button, FALSE); + gtk_widget_set_sensitive (priv->delete_button, FALSE); gtk_widget_show_all (button_box); return button_box; @@ -287,26 +273,29 @@ button_box_new (ModestAccountViewWindow *self) static GtkWidget* window_vbox_new (ModestAccountViewWindow *self) { - ModestAccountViewWindowPrivate *priv; - GtkTreeSelection *sel; - GtkWidget *main_hbox, *main_vbox; + ModestAccountViewWindowPrivate *priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self); - priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self); - - main_vbox = gtk_vbox_new (FALSE, 6); - main_hbox = gtk_hbox_new (FALSE, 6); + GtkWidget *main_vbox = gtk_vbox_new (FALSE, 6); + GtkWidget *main_hbox = gtk_hbox_new (FALSE, 6); priv->account_view = modest_account_view_new (modest_runtime_get_account_mgr()); gtk_widget_set_size_request (GTK_WIDGET(priv->account_view), 300, 400); + gtk_widget_show (GTK_WIDGET (priv->account_view)); - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->account_view)); + GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->account_view)); g_signal_connect (G_OBJECT(sel), "changed", G_CALLBACK(on_selection_changed), self); + + GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (priv->account_view)); + gtk_widget_show (GTK_WIDGET (scrolled_window)); + + gtk_box_pack_start (GTK_BOX(main_hbox), GTK_WIDGET(scrolled_window), TRUE, TRUE, 2); - gtk_box_pack_start (GTK_BOX(main_hbox), GTK_WIDGET(priv->account_view), TRUE, TRUE, 2); gtk_box_pack_start (GTK_BOX(main_vbox), main_hbox, TRUE, TRUE, 2); + gtk_widget_show (GTK_WIDGET (main_hbox)); + gtk_widget_show (GTK_WIDGET (main_vbox)); - gtk_widget_show_all (main_vbox); return main_vbox; } @@ -314,11 +303,14 @@ window_vbox_new (ModestAccountViewWindow *self) static void modest_account_view_window_init (ModestAccountViewWindow *obj) { - ModestAccountViewWindowPrivate *priv; - priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(obj); - - //GTK_DIALOG(obj)->vbox = window_vbox_new (MODEST_ACCOUNT_VIEW_WINDOW(obj)); - GTK_DIALOG(obj)->action_area = window_vbox_new (MODEST_ACCOUNT_VIEW_WINDOW(obj)); +/* + ModestAccountViewWindowPrivate *priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(obj); +*/ + gtk_box_pack_start (GTK_BOX((GTK_DIALOG (obj)->vbox)), GTK_WIDGET (window_vbox_new (obj)), + TRUE, TRUE, 2); + + gtk_box_pack_start (GTK_BOX((GTK_DIALOG (obj)->action_area)), GTK_WIDGET (button_box_new (obj)), + TRUE, TRUE, 2); } @@ -327,8 +319,5 @@ modest_account_view_window_new (void) { GObject *obj = g_object_new(MODEST_TYPE_ACCOUNT_VIEW_WINDOW, NULL); - GTK_DIALOG(obj)->vbox = window_vbox_new (MODEST_ACCOUNT_VIEW_WINDOW(obj)); - GTK_DIALOG(obj)->action_area = button_box_new (MODEST_ACCOUNT_VIEW_WINDOW(obj)); - return GTK_WIDGET(obj); } diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 5e4e07d..80be1c3 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -206,15 +206,16 @@ void modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win) { GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr()); - const gboolean accounts_exist = account_names != NULL; + gboolean accounts_exist = account_names != NULL; g_slist_free (account_names); /* This is currently only implemented for Maemo, * because it requires a providers preset file which is not publically available. */ #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"); + printf ("debug: modest_account_mgr_account_names() returned NULL."); /* 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)); diff --git a/src/widgets/modest-account-view.c b/src/widgets/modest-account-view.c index d264868..9c4f9e6 100644 --- a/src/widgets/modest-account-view.c +++ b/src/widgets/modest-account-view.c @@ -160,6 +160,11 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view) gtk_list_store_clear (model); cursor = account_names = modest_account_mgr_account_names (account_mgr); + + if(account_names == NULL) + { + printf ("debug: modest_account_mgr_account_names() returned NULL\n"); + } while (cursor) { gchar *account_name; -- 1.7.9.5