* missing free() added to on_account_selector_selection_changed() in modest_ui.c
authorSilvan Marco Fin <silvan@kernelconcepts.de>
Wed, 7 Jun 2006 13:13:01 +0000 (13:13 +0000)
committerSilvan Marco Fin <silvan@kernelconcepts.de>
Wed, 7 Jun 2006 13:13:01 +0000 (13:13 +0000)
* primitive sanity checks for first page of account wizzard
* more updates to modest.glade

pmo-trunk-r166

src/gtk-glade/modest-ui-wizzard.c
src/gtk-glade/modest-ui.c
src/gtk-glade/modest.glade

index f7791ba..4f136c8 100644 (file)
 #include "modest-ui-glade.h"
 #include "modest-ui-wizzard.h"
 
-gint do_wizzdialog1(GtkDialog *dialog, ModestUIPrivate *priv, void *account_data)
+void wizzard_missing_notification(GtkWindow *parent, gchar *info_message)
 {
-       gint result;
+        GtkWidget *DenyDialog;
 
-       gtk_widget_show_all(GTK_WIDGET(dialog));
+        DenyDialog=gtk_message_dialog_new(parent,
+                                          GTK_DIALOG_MODAL,
+                                          GTK_MESSAGE_INFO,
+                                          GTK_BUTTONS_OK,
+                                          "%s",
+                                          info_message);
 
-       result=gtk_dialog_run(GTK_DIALOG(dialog));
+        gtk_dialog_run(GTK_DIALOG(DenyDialog));
 
-       g_message("Ergebnis des Knopfdrucks: %d", result);
+        gtk_widget_destroy(DenyDialog);
+}
+
+gchar *gtk_combo_box_get_entry_text (GtkWidget *combobox)
+{
+        /* Remember to free the returned variable after usage! */
+
+       GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(combobox));
+       GtkTreeIter iter;
 
-       switch (result)
+       gchar *value;
+
+       if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combobox), &iter))
        {
-       default:
-               break;
+               gtk_tree_model_get(GTK_TREE_MODEL(model),
+                                  &iter,
+                                  0, &value,
+                                  -1);
        }
 
-       return TRUE;
+        return value;
+}
+
+
+gboolean advance_sanity_check(GtkWindow *parent, GladeXML *glade_xml, gint cp)
+{
+        GtkDialog *DenyDialog;
+        gchar *bla;
+
+        switch (cp)
+        {
+        case 0:
+                if (strlen(gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(glade_xml, "AWMailboxnameEntry"))))==0)
+                {
+                        /* FIXME:
+                         * all calls to wizzard_missing_notification lack the parent window.
+                         */
+                        wizzard_missing_notification(NULL, "Please enter mailbox name");
+                        return FALSE;
+                }
+                bla=gtk_combo_box_get_active_text(GTK_COMBO_BOX(glade_xml_get_widget(glade_xml, "AWMailboxtypeComboBox")));
+                if (bla==NULL)
+                {
+                        wizzard_missing_notification(NULL, "Please select mailbox type");
+                        return FALSE;
+                }
+                return TRUE;
+                break;
+
+        }
+
+        return FALSE;
 }
 
 void on_new_account1_activate (GtkMenuItem *menuitem,
@@ -46,27 +94,26 @@ void on_new_account1_activate (GtkMenuItem *menuitem,
         GtkWidget *NextButton;
         GtkWidget *CancelButton;
         GtkWidget *Notebook;
+        GtkWidget *awidget;
         gint cp;
-       gint result;
+        gint result;
+        gint finishallowed=0;
 
        priv = MODEST_UI_GET_PRIVATE(MODEST_UI(user_data));
 
        glade_xml = glade_xml_new(MODEST_GLADE, "account_wizzard", NULL);
 
+        dialog = glade_xml_get_widget(glade_xml, "account_wizzard");
+
+        gtk_widget_show_all(dialog);
+
         FinishButton=glade_xml_get_widget(glade_xml, "AWFinishButton");
         BackButton=glade_xml_get_widget(glade_xml, "AWBackButton");
         NextButton=glade_xml_get_widget(glade_xml, "AWNextButton");
         CancelButton=glade_xml_get_widget(glade_xml, "AWCancelButton");
         Notebook=glade_xml_get_widget(glade_xml, "AWNotebook");
 
-        dialog = glade_xml_get_widget(glade_xml, "account_wizzard");
-
-        g_message("Glade-file: %s", MODEST_GLADE);
-
-        gtk_widget_show_all(dialog);
-
-        if (FinishButton==NULL)
-                g_error("Is no notebook");
+        gtk_widget_set_sensitive(FinishButton, FALSE);
 
         do
         {
@@ -80,9 +127,11 @@ void on_new_account1_activate (GtkMenuItem *menuitem,
                         gtk_widget_set_sensitive(BackButton, TRUE);
                         break;
                 case 2:
+                        gtk_widget_set_sensitive(FinishButton, FALSE);
                         gtk_widget_set_sensitive(NextButton, TRUE);
                         break;
                 case 3:
+                        gtk_widget_set_sensitive(FinishButton, TRUE);
                         gtk_widget_set_sensitive(NextButton, FALSE);
                         break;
                 default:
@@ -91,10 +140,12 @@ void on_new_account1_activate (GtkMenuItem *menuitem,
                 }
 
                 result=gtk_dialog_run(GTK_DIALOG(dialog));
+
                 switch (result)
                 {
                 case 1:
-                        gtk_notebook_next_page(GTK_NOTEBOOK(Notebook));
+                        if (advance_sanity_check(NULL, glade_xml, cp)==TRUE)
+                                gtk_notebook_next_page(GTK_NOTEBOOK(Notebook));
                         break;
                 case 2:
                         gtk_notebook_prev_page(GTK_NOTEBOOK(Notebook));
@@ -103,6 +154,11 @@ void on_new_account1_activate (GtkMenuItem *menuitem,
         }
         while(result!=GTK_RESPONSE_DELETE_EVENT && result!=GTK_RESPONSE_ACCEPT && result!=GTK_RESPONSE_CANCEL);
 
+        if (result==GTK_RESPONSE_ACCEPT)
+        {
+                /* Do someting with the DATA from the widget */
+        }
+
        gtk_widget_destroy(dialog);
        g_object_unref(glade_xml);
 }
index 40be4bb..eef4e58 100644 (file)
@@ -524,6 +524,8 @@ on_account_selector_selection_changed (GtkWidget *widget,
        }
 
        g_message("Value: '%s'\n", account_name);
+
+       free(account_name);
 }
 
 
index 623b72b..6dfaa48 100644 (file)
                  </child>
 
                  <child>
-                   <widget class="GtkEntry" id="entry4">
+                   <widget class="GtkEntry" id="AWMailboxnameEntry">
                      <property name="visible">True</property>
                      <property name="editable">True</property>
                      <property name="visibility">True</property>
                  </child>
 
                  <child>
-                   <widget class="GtkComboBoxEntry" id="comboboxentry1">
+                   <widget class="GtkComboBox" id="AWMailboxtypeComboBox">
                      <property name="visible">True</property>
+          <property name="items" context="yes" translatable="yes">IMAP
+POP
+LOCAL</property>
                      <property name="add_tearoffs">False</property>
                      <property name="has_frame">True</property>
                      <property name="focus_on_click">True</property>