2007-07-12 Murray Cumming <murrayc@murrayc.com>
[modest] / src / gnome / modest-gnome-global-settings-dialog.c
index 21ac609..a5cbca4 100644 (file)
 #include <gtk/gtklabel.h>
 #include <gtk/gtkcheckbutton.h>
 #include <gtk/gtkhseparator.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtkspinbutton.h>
 #include "widgets/modest-global-settings-dialog-priv.h"
 #include "widgets/modest-combo-box.h"
 #include "gnome/modest-gnome-global-settings-dialog.h"
-#include "modest-ui-constants.h"
+#include "widgets/modest-ui-constants.h"
 
 
 /* include other impl specific header files */
@@ -60,6 +62,7 @@ enum {
 
 static GtkWidget* create_updating_page  (ModestGnomeGlobalSettingsDialog *self);
 static GtkWidget* create_composing_page (ModestGnomeGlobalSettingsDialog *self);
+static ModestConnectedVia current_connection (void);
 
 typedef struct _ModestGnomeGlobalSettingsDialogPrivate ModestGnomeGlobalSettingsDialogPrivate;
 struct _ModestGnomeGlobalSettingsDialogPrivate {
@@ -107,6 +110,8 @@ modest_gnome_global_settings_dialog_class_init (ModestGnomeGlobalSettingsDialogC
        gobject_class->finalize = modest_gnome_global_settings_dialog_finalize;
 
        g_type_class_add_private (gobject_class, sizeof(ModestGnomeGlobalSettingsDialogPrivate));
+
+       MODEST_GLOBAL_SETTINGS_DIALOG_CLASS (klass)->current_connection_func = current_connection;
 }
 
 static void
@@ -196,7 +201,6 @@ create_updating_page (ModestGnomeGlobalSettingsDialog *self)
 {
        GtkWidget *vbox, *table_update, *table_limit;
        GtkWidget *label, *check, *combo, *spin;
-       ModestPairList *list;
 
        vbox = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
        table_update = gtk_table_new (3, 2, FALSE);
@@ -214,16 +218,27 @@ create_updating_page (ModestGnomeGlobalSettingsDialog *self)
 
        /* Connected via */
        label = create_label (_("mcen_fi_options_connectiontype"));
-       list = get_connected_via ();
-       combo = modest_combo_box_new (list, g_int_equal);
-       modest_pair_list_free (list);
+
+       ModestGlobalSettingsDialogPrivate *ppriv = 
+               MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+       /* Note: This ModestPairList* must exist for as long as the combo
+        * that uses it, because the ModestComboBox uses the ID opaquely, 
+        * so it can't know how to manage its memory. */
+       ppriv->connected_via_list = _modest_global_settings_dialog_get_connected_via ();
+       combo = modest_combo_box_new (ppriv->connected_via_list, g_int_equal);
+
        add_to_table (GTK_TABLE (table_update), label, combo);
 
        /* Update interval */
        label = create_label (_("mcen_fi_options_updateinterval"));
-       list = get_update_interval ();
-       combo = modest_combo_box_new (list, g_int_equal);
-       modest_pair_list_free (list);
+
+       /* Note: This ModestPairList* must exist for as long as the combo
+        * that uses it, because the ModestComboBox uses the ID opaquely, 
+        * so it can't know how to manage its memory. */
+       ppriv->update_interval_list = _modest_global_settings_dialog_get_update_interval ();
+       combo = modest_combo_box_new (ppriv->update_interval_list, g_int_equal);
+
        add_to_table (GTK_TABLE (table_update), label, combo);
 
        /* Add to vbox */
@@ -256,7 +271,6 @@ create_composing_page (ModestGnomeGlobalSettingsDialog *self)
 {
        GtkWidget *vbox, *table;
        GtkWidget *label, *check, *combo;
-       ModestPairList *list;
 
        vbox = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
        table = gtk_table_new (2, 2, FALSE);
@@ -266,9 +280,16 @@ create_composing_page (ModestGnomeGlobalSettingsDialog *self)
 
        /* Update interval */
        label = create_label (_("mcen_fi_options_messageformat"));
-       list = get_msg_formats ();
-       combo = modest_combo_box_new (list, g_int_equal);
-       modest_pair_list_free (list);
+
+       ModestGlobalSettingsDialogPrivate *ppriv = 
+               MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+       /* Note: This ModestPairList* must exist for as long as the combo
+        * that uses it, because the ModestComboBox uses the ID opaquely, 
+        * so it can't know how to manage its memory. */
+       ppriv->combo_msg_formats_list = _modest_global_settings_dialog_get_msg_formats ();
+       combo = modest_combo_box_new (ppriv->cmsg_formats_list, g_int_equal);
+
        add_to_table (GTK_TABLE (table), label, combo);
 
        label = create_label (_("mcen_va_options_include_original_inreply"));
@@ -280,3 +301,9 @@ create_composing_page (ModestGnomeGlobalSettingsDialog *self)
 
        return vbox;
 }
+
+static ModestConnectedVia 
+current_connection (void)
+{
+       return MODEST_CONNECTED_VIA_ANY;
+}