2007-04-05 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Thu, 5 Apr 2007 10:48:27 +0000 (10:48 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Thu, 5 Apr 2007 10:48:27 +0000 (10:48 +0000)
* src/maemo/Makefile.am:
        * src/maemo/modest-connection-specific-smtp-edit-window.c:
        * src/maemo/modest-connection-specific-smtp-edit-window.h:
        New window for editing connection-specific smtp details.
        Not fully implemented.

        * src/maemo/modest-connection-specific-smtp-window.c:
        (modest_connection_specific_smtp_window_finalize) :
        unref the tree model.
        (on_button_edit): Show the edit window.

pmo-trunk-r1511

ChangeLog2
src/maemo/Makefile.am
src/maemo/easysetup/modest-easysetup-wizard.c
src/maemo/modest-connection-specific-smtp-edit-window.c [new file with mode: 0644]
src/maemo/modest-connection-specific-smtp-edit-window.h [new file with mode: 0644]
src/maemo/modest-connection-specific-smtp-window.c

index 564c372..476539c 100644 (file)
@@ -1,5 +1,18 @@
 2007-04-05  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/maemo/Makefile.am:
+       * src/maemo/modest-connection-specific-smtp-edit-window.c:
+       * src/maemo/modest-connection-specific-smtp-edit-window.h: 
+       New window for editing connection-specific smtp details.
+       Not fully implemented.
+
+       * src/maemo/modest-connection-specific-smtp-window.c:
+       (modest_connection_specific_smtp_window_finalize) :
+       unref the tree model.
+       (on_button_edit): Show the edit window.
+
+2007-04-05  Murray Cumming  <murrayc@murrayc.com>
+
        * src/Makefile.am: Change sequence of sub-libraries, which fixed an undefined symbol 
        error for me.
        
index 13376d7..a97fccf 100644 (file)
@@ -59,8 +59,10 @@ libmodest_ui_la_SOURCES=              \
        modest-account-assistant.c    \
        modest-account-assistant.h    \
        modest-maemo-utils.c          \
-       modest-connection-specific-smtp-window.h          \
-       modest-connection-specific-smtp-window.c
+       modest-connection-specific-smtp-window.h \
+       modest-connection-specific-smtp-window.c \
+       modest-connection-specific-smtp-edit-window.h \
+       modest-connection-specific-smtp-edit-window.c
 
 LDADD = \
        $(MODEST_GSTUFF_LIBS) \
index c168b55..bdcfc96 100644 (file)
@@ -594,6 +594,7 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
         * so we can supply them when creating the connection somehow.
         */
        GtkWidget *window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
+       gtk_window_set_transient_for (GTK_WINDOW (self), GTK_WINDOW (window));
        g_signal_connect (G_OBJECT (window), "hide",
                G_CALLBACK (on_smtp_servers_window_hide), self);
     gtk_widget_show (window);
diff --git a/src/maemo/modest-connection-specific-smtp-edit-window.c b/src/maemo/modest-connection-specific-smtp-edit-window.c
new file mode 100644 (file)
index 0000000..65266d4
--- /dev/null
@@ -0,0 +1,210 @@
+/* connection-specific-smtp-window.c */
+
+#include "modest-connection-specific-smtp-edit-window.h"
+#include <hildon-widgets/hildon-caption.h>
+#include "maemo/easysetup/modest-easysetup-country-combo-box.h"
+#include "maemo/easysetup/modest-easysetup-provider-combo-box.h"
+#include "maemo/easysetup/modest-easysetup-servertype-combo-box.h"
+#include "maemo/easysetup/modest-easysetup-serversecurity-combo-box.h"
+#include "maemo/easysetup/modest-easysetup-secureauth-combo-box.h"
+#include "maemo/easysetup/modest-validating-entry.h"
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtkstock.h>
+
+#include <glib/gi18n.h>
+
+G_DEFINE_TYPE (ModestConnectionSpecificSmtpEditWindow, modest_connection_specific_smtp_edit_window, GTK_TYPE_WINDOW);
+
+#define CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE(o) \
+       (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW, ModestConnectionSpecificSmtpEditWindowPrivate))
+
+typedef struct _ModestConnectionSpecificSmtpEditWindowPrivate ModestConnectionSpecificSmtpEditWindowPrivate;
+
+struct _ModestConnectionSpecificSmtpEditWindowPrivate
+{
+       GtkWidget *entry_outgoingserver;
+       GtkWidget *combo_outgoing_auth;
+       GtkWidget *entry_user_username;
+       GtkWidget *entry_user_password;
+       GtkWidget *combo_outgoing_security;
+       GtkWidget *entry_port;
+       
+       GtkWidget *button_ok;
+       GtkWidget *button_cancel;
+};
+
+static void
+modest_connection_specific_smtp_edit_window_get_property (GObject *object, guint property_id,
+                                                                                                                       GValue *value, GParamSpec *pspec)
+{
+       switch (property_id) {
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+       }
+}
+
+static void
+modest_connection_specific_smtp_edit_window_set_property (GObject *object, guint property_id,
+                                                                                                                       const GValue *value, GParamSpec *pspec)
+{
+       switch (property_id) {
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+       }
+}
+
+static void
+modest_connection_specific_smtp_edit_window_dispose (GObject *object)
+{
+       if (G_OBJECT_CLASS (modest_connection_specific_smtp_edit_window_parent_class)->dispose)
+               G_OBJECT_CLASS (modest_connection_specific_smtp_edit_window_parent_class)->dispose (object);
+}
+
+static void
+modest_connection_specific_smtp_edit_window_finalize (GObject *object)
+{
+       G_OBJECT_CLASS (modest_connection_specific_smtp_edit_window_parent_class)->finalize (object);
+}
+
+static void
+modest_connection_specific_smtp_edit_window_class_init (ModestConnectionSpecificSmtpEditWindowClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (klass, sizeof (ModestConnectionSpecificSmtpEditWindowPrivate));
+
+       object_class->get_property = modest_connection_specific_smtp_edit_window_get_property;
+       object_class->set_property = modest_connection_specific_smtp_edit_window_set_property;
+       object_class->dispose = modest_connection_specific_smtp_edit_window_dispose;
+       object_class->finalize = modest_connection_specific_smtp_edit_window_finalize;
+}
+
+enum MODEL_COLS {
+       MODEL_COL_NAME = 0,
+       MODEL_COL_SERVER_NAME = 1,
+       MODEL_COL_ID = 2
+};
+
+static void
+on_button_edit (GtkButton *button, gpointer user_data)
+{
+       
+}
+
+static void
+on_button_cancel (GtkButton *button, gpointer user_data)
+{
+       ModestConnectionSpecificSmtpEditWindow *self = MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (user_data);
+
+       /* Hide the window.
+        * The code that showed it will respond to the hide signal. */  
+       gtk_widget_hide (GTK_WIDGET (self));
+}
+
+static void
+modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEditWindow *self)
+{
+       ModestConnectionSpecificSmtpEditWindowPrivate *priv = CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
+       
+       GtkWidget *box = gtk_vbox_new (FALSE, 2);
+       
+       /* Create a size group to be used by all captions.
+        * Note that HildonCaption does not create a default size group if we do not specify one.
+        * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
+       GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+        
+       /* The outgoing server widgets: */
+       if (!priv->entry_outgoingserver)
+               priv->entry_outgoingserver = gtk_entry_new ();
+       GtkWidget *caption = hildon_caption_new (sizegroup, 
+               _("mcen_li_emailsetup_smtp"), priv->entry_outgoingserver, NULL, HILDON_CAPTION_OPTIONAL);
+       gtk_widget_show (priv->entry_outgoingserver);
+       gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
+       gtk_widget_show (caption);
+       
+       /* The secure authentication widgets: */
+       if (!priv->combo_outgoing_auth)
+               priv->combo_outgoing_auth = GTK_WIDGET (easysetup_secureauth_combo_box_new ());
+       caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"), 
+               priv->combo_outgoing_auth, NULL, HILDON_CAPTION_OPTIONAL);
+       gtk_widget_show (priv->combo_outgoing_auth);
+       gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
+       gtk_widget_show (caption);
+       
+       /* The username widgets: */     
+       priv->entry_user_username = GTK_WIDGET (easysetup_validating_entry_new ());
+       caption = hildon_caption_new (sizegroup, _("mail_fi_username"), 
+               priv->entry_user_username, NULL, HILDON_CAPTION_MANDATORY);
+       gtk_widget_show (priv->entry_user_username);
+       gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
+       gtk_widget_show (caption);
+       
+       /* Prevent the use of some characters in the username, 
+        * as required by our UI specification: */
+       easysetup_validating_entry_set_unallowed_characters_whitespace (
+               EASYSETUP_VALIDATING_ENTRY (priv->entry_user_username));
+       
+       /* Set max length as in the UI spec:
+        * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
+       gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_username), 64);
+       
+       /* The password widgets: */     
+       priv->entry_user_password = gtk_entry_new ();
+       gtk_entry_set_visibility (GTK_ENTRY (priv->entry_user_password), FALSE);
+       /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */
+       caption = hildon_caption_new (sizegroup, 
+               _("mail_fi_password"), priv->entry_user_password, NULL, HILDON_CAPTION_OPTIONAL);
+       gtk_widget_show (priv->entry_user_password);
+       gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
+       gtk_widget_show (caption);
+       
+       /* The secure connection widgets: */    
+       if (!priv->combo_outgoing_security)
+               priv->combo_outgoing_security = GTK_WIDGET (easysetup_serversecurity_combo_box_new ());
+       easysetup_serversecurity_combo_box_fill (
+               EASYSETUP_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), MODEST_PROTOCOL_TRANSPORT_SMTP);
+       easysetup_serversecurity_combo_box_set_active_serversecurity (
+               EASYSETUP_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), MODEST_PROTOCOL_SECURITY_NONE);
+       caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"), 
+               priv->combo_outgoing_security, NULL, HILDON_CAPTION_OPTIONAL);
+       gtk_widget_show (priv->combo_outgoing_security);
+       gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
+       gtk_widget_show (caption);
+       
+       /* The port number widgets: */
+       if (!priv->entry_port)
+               priv->entry_port = gtk_entry_new ();
+       caption = hildon_caption_new (sizegroup, 
+               _("mcen_li_emailsetup_smtp"), priv->entry_port, NULL, HILDON_CAPTION_OPTIONAL);
+       gtk_widget_show (priv->entry_port);
+       gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
+       gtk_widget_show (caption);
+       
+       /* Add the buttons: */
+       GtkWidget *hbox = gtk_hbox_new (FALSE, 2);
+       gtk_box_pack_start (GTK_BOX (box), hbox, TRUE, TRUE, 2);
+       gtk_widget_show (hbox);
+       
+       GtkWidget *button_edit = gtk_button_new_from_stock (GTK_STOCK_EDIT);
+       gtk_box_pack_start (GTK_BOX (hbox), button_edit, TRUE, FALSE, 2);
+       gtk_widget_show (button_edit);
+       g_signal_connect (G_OBJECT (button_edit), "clicked",
+               G_CALLBACK (on_button_edit), self);
+       
+       GtkWidget *button_cancel = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+       gtk_box_pack_start (GTK_BOX (hbox), button_cancel, TRUE, FALSE, 2);
+       gtk_widget_show (button_cancel);
+       g_signal_connect (G_OBJECT (button_edit), "clicked",
+               G_CALLBACK (on_button_cancel), self);
+       
+       gtk_widget_show (box);
+}
+
+ModestConnectionSpecificSmtpEditWindow*
+modest_connection_specific_smtp_edit_window_new (void)
+{
+       return g_object_new (MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW, NULL);
+}
+
diff --git a/src/maemo/modest-connection-specific-smtp-edit-window.h b/src/maemo/modest-connection-specific-smtp-edit-window.h
new file mode 100644 (file)
index 0000000..1018ed2
--- /dev/null
@@ -0,0 +1,75 @@
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the
+ *      documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *      contributors may be used to endorse or promote products derived from
+ *      this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __MODEST_MAEMO_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW
+#define __MODEST_MAEMO_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW
+
+#include <gtk/gtkwindow.h>
+#include <gtk/gtktreeview.h>
+
+G_BEGIN_DECLS
+
+#define MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW modest_connection_specific_smtp_edit_window_get_type()
+
+#define MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+       MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW, ModestConnectionSpecificSmtpEditWindow))
+
+#define MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_CLASS(klass) \
+       (G_TYPE_CHECK_CLASS_CAST ((klass), \
+       MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW, ModestConnectionSpecificSmtpEditWindowClass))
+
+#define MODEST_IS_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+       MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW))
+
+#define MODEST_IS_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_CLASS(klass) \
+       (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+       MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW))
+
+#define MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+       MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW, ModestConnectionSpecificSmtpEditWindowClass))
+
+typedef struct {
+       GtkWindow parent;
+       
+} ModestConnectionSpecificSmtpEditWindow;
+
+typedef struct {
+       GtkWindowClass parent_class;
+} ModestConnectionSpecificSmtpEditWindowClass;
+
+GType modest_connection_specific_smtp_edit_window_get_type (void);
+
+ModestConnectionSpecificSmtpEditWindow* modest_connection_specific_smtp_edit_window_new (void);
+
+G_END_DECLS
+
+#endif /* __MODEST_MAEMO_CONNECTION_SPECIFIC_SMTP_WINDOW */
index 71f597e..d53402c 100644 (file)
@@ -1,6 +1,7 @@
 /* connection-specific-smtp-window.c */
 
 #include "modest-connection-specific-smtp-window.h"
+#include "modest-connection-specific-smtp-edit-window.h"
 #include <gtk/gtktreeview.h>
 #include <gtk/gtkcellrenderertext.h>
 #include <gtk/gtkliststore.h>
@@ -55,6 +56,10 @@ modest_connection_specific_smtp_window_dispose (GObject *object)
 static void
 modest_connection_specific_smtp_window_finalize (GObject *object)
 {
+       ModestConnectionSpecificSmtpWindowPrivate *priv = CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (object);
+
+       g_object_unref (G_OBJECT (priv->model));
+       
        G_OBJECT_CLASS (modest_connection_specific_smtp_window_parent_class)->finalize (object);
 }
 
@@ -84,10 +89,26 @@ fill_with_connections (ModestConnectionSpecificSmtpWindow *self)
        * When TnyMaemoDevice provides enough of the libconic API to implement this. */
 }
 
+       
+static void
+on_edit_window_hide (GtkWindow *window, gpointer user_data)
+{
+       /* Destroy the window when it is closed: */
+       gtk_widget_destroy (GTK_WIDGET (window));
+}
+
+       
 static void
 on_button_edit (GtkButton *button, gpointer user_data)
 {
+       ModestConnectionSpecificSmtpWindow *self = MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (user_data);
        
+       /* TODO: Specify the chosen connection to edit: */
+       GtkWidget * window = GTK_WIDGET (modest_connection_specific_smtp_edit_window_new ());
+       gtk_window_set_transient_for (GTK_WINDOW (self), GTK_WINDOW (window));
+       g_signal_connect (G_OBJECT (window), "hide",
+               G_CALLBACK (on_edit_window_hide), self);
+       gtk_widget_show (window);
 }
 
 static void