2007-04-23 Murray Cumming <murrayc@murrayc.com>
+ * src/maemo/modest-connection-specific-smtp-edit-window.c:
+ (modest_connection_specific_smtp_edit_window_init): Use spacing constants.
+
+ * src/modest-defs.h:
+ * src/modest-account-mgr-helpers.h:
+ * src/modest-account-mgr-helpers.c:
+ Added modest_account_mgr_get/set_signature(), using new gconf keys.
+
+ * src/maemo/Makefile.am:
+ * src/maemo/modest-signature-editor-dialog.c:
+ * src/maemo/modest-signature-editor-dialog.h: New dialog for editing signatures,
+ as per the UI spec.
+
+ * src/maemo/modest-account-settings-dialog.h:
+ * src/maemo/modest-account-settings-dialog.c:
+ (modest_account_settings_dialog_finalize), (on_button_signature),
+ (save_configuration): Use the new dialog when the Edit button is pressed, and
+ save the changes if necessary, as per the UI spec.
+
+2007-04-23 Murray Cumming <murrayc@murrayc.com>
+
* src/maemo/Makefile.am:
* src/maemo/modest-maemo-ui-constants.h: New header with some defines for widget spacing,
based on maemo-develoers email from Dirk.
modest-main-window.c \
modest-main-window-ui.h \
modest-platform.c \
+ modest-signature-editor-dialog.c \
+ modest-signature-editor-dialog.h \
modest-store-widget.c \
modest-store-widget.h \
modest-transport-widget.c \
#include "modest-account-mgr-helpers.h" /* For modest_account_mgr_get_account_data(). */
#include "modest-runtime.h" /* For modest_runtime_get_account_mgr(). */
#include "maemo/modest-connection-specific-smtp-window.h"
+#include "maemo/modest-signature-editor-dialog.h"
#include <maemo/modest-maemo-ui-constants.h>
#include <gconf/gconf-client.h>
#include <string.h> /* For strlen(). */
if (self->specific_window)
gtk_widget_destroy (self->specific_window);
+
+ if (self->signature_dialog)
+ gtk_widget_destroy (self->signature_dialog);
G_OBJECT_CLASS (modest_account_settings_dialog_parent_class)->finalize (object);
}
static void
on_button_signature (GtkButton *button, gpointer user_data)
{
+ ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
+ /* Create the window, if necessary: */
+ if (!(self->signature_dialog)) {
+ self->signature_dialog = GTK_WIDGET (modest_signature_editor_dialog_new ());
+
+ gboolean use_signature = FALSE;
+ gchar *signature = modest_account_mgr_get_signature(self->account_manager, self->account_name,
+ &use_signature);
+ const gchar* account_title = gtk_entry_get_text (GTK_ENTRY (self->entry_account_title));
+ modest_signature_editor_dialog_set_settings (
+ MODEST_SIGNATURE_EDITOR_DIALOG (self->signature_dialog),
+ use_signature, signature, account_title);
+ g_free (signature);
+ signature = NULL;
+ }
+
+ /* Show the window: */
+ gtk_window_set_transient_for (GTK_WINDOW (self->signature_dialog), GTK_WINDOW (self));
+ gtk_window_set_modal (GTK_WINDOW (self->signature_dialog), TRUE);
+ const gint response = gtk_dialog_run (GTK_DIALOG (self->signature_dialog));
+ gtk_widget_hide (self->signature_dialog);
+ if (response != GTK_RESPONSE_OK) {
+ /* Destroy the widget now, and its data: */
+ gtk_widget_destroy (self->signature_dialog);
+ self->signature_dialog = NULL;
+ }
+ else {
+ /* Mark modified, so we use the dialog's data later: */
+ self->modified = TRUE;
+ }
}
static GtkWidget*
MODEST_ACCOUNT_EMAIL, emailaddress, FALSE /* not server account */);
if (!test)
return FALSE;
+
+ /* Signature: */
+ if (dialog->signature_dialog) {
+ gboolean use_signature = FALSE;
+ gchar *signature = modest_signature_editor_dialog_get_settings (
+ MODEST_SIGNATURE_EDITOR_DIALOG (dialog->signature_dialog),
+ &use_signature);
+
+ modest_account_mgr_set_signature(dialog->account_manager, account_name,
+ signature, use_signature);
+ g_free (signature);
+ }
gchar *retrieve = modest_retrieve_combo_box_get_active_retrieve_conf (
MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve));
GtkWidget *button_outgoing_smtp_servers;
GtkWidget *specific_window;
+ GtkWidget *signature_dialog;
} ModestAccountSettingsDialog;
/* connection-specific-smtp-window.c */
#include "modest-connection-specific-smtp-edit-window.h"
+#include "maemo/modest-maemo-ui-constants.h"
#include <hildon-widgets/hildon-caption.h>
#include <hildon-widgets/hildon-number-editor.h>
#include "widgets/modest-serversecurity-combo-box.h"
ModestConnectionSpecificSmtpEditWindowPrivate *priv =
CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
- GtkWidget *box = GTK_DIALOG(self)->vbox; /* gtk_vbox_new (FALSE, 2); */
+ GtkWidget *box = GTK_DIALOG(self)->vbox; /* gtk_vbox_new (FALSE, MODEST_MARGIN_HALF); */
/* 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.
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_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
/* Show a default port number when the security method changes, as per the UI spec: */
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_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
/* The username widgets: */
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_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
/* Prevent the use of some characters in the username,
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_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
/* The secure connection widgets: */
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_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
/* The port number widgets: */
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_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
/* Add the buttons: */
--- /dev/null
+/* connection-specific-smtp-window.c */
+
+#include "modest-signature-editor-dialog.h"
+#include "maemo/modest-maemo-ui-constants.h"
+#include <hildon-widgets/hildon-caption.h>
+#include <hildon-widgets/hildon-number-editor.h>
+#include "widgets/modest-serversecurity-combo-box.h"
+#include "widgets/modest-secureauth-combo-box.h"
+#include "widgets/modest-validating-entry.h"
+#include <modest-account-mgr-helpers.h>
+#include <gtk/gtkcheckbutton.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtktextview.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkstock.h>
+
+#include <glib/gi18n.h>
+
+G_DEFINE_TYPE (ModestSignatureEditorDialog, modest_signature_editor_dialog, GTK_TYPE_DIALOG);
+
+#define SIGNATURE_EDITOR_DIALOG_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_SIGNATURE_EDITOR_DIALOG, ModestSignatureEditorDialogPrivate))
+
+typedef struct _ModestSignatureEditorDialogPrivate ModestSignatureEditorDialogPrivate;
+
+struct _ModestSignatureEditorDialogPrivate
+{
+ GtkWidget *checkbox_use;
+ GtkWidget *label;
+ GtkWidget *textview;
+};
+
+static void
+modest_signature_editor_dialog_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_signature_editor_dialog_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_signature_editor_dialog_dispose (GObject *object)
+{
+ if (G_OBJECT_CLASS (modest_signature_editor_dialog_parent_class)->dispose)
+ G_OBJECT_CLASS (modest_signature_editor_dialog_parent_class)->dispose (object);
+}
+
+static void
+modest_signature_editor_dialog_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (modest_signature_editor_dialog_parent_class)->finalize (object);
+}
+
+static void
+modest_signature_editor_dialog_class_init (ModestSignatureEditorDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (ModestSignatureEditorDialogPrivate));
+
+ object_class->get_property = modest_signature_editor_dialog_get_property;
+ object_class->set_property = modest_signature_editor_dialog_set_property;
+ object_class->dispose = modest_signature_editor_dialog_dispose;
+ object_class->finalize = modest_signature_editor_dialog_finalize;
+}
+
+static void
+modest_signature_editor_dialog_init (ModestSignatureEditorDialog *self)
+{
+ ModestSignatureEditorDialogPrivate *priv =
+ SIGNATURE_EDITOR_DIALOG_GET_PRIVATE (self);
+
+ gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_email_signatures_edit_title"));
+
+ GtkWidget *box = GTK_DIALOG(self)->vbox; /* gtk_vbox_new (FALSE, MODEST_MARGIN_HALF); */
+
+ priv->checkbox_use = gtk_check_button_new_with_label (
+ _("mcen_fi_email_signatures_use_signature"));
+ gtk_box_pack_start (GTK_BOX (box), priv->checkbox_use, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (priv->checkbox_use);
+
+ priv->label = gtk_label_new (""); /* Set in modest_signature_editor_dialog_set_settings(). */
+ gtk_box_pack_start (GTK_BOX (box), priv->label, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (priv->label);
+
+ priv->textview = gtk_text_view_new ();
+ gtk_box_pack_start (GTK_BOX (box), priv->textview, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (priv->textview);
+
+ /* Add the buttons: */
+ gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_OK, GTK_RESPONSE_OK);
+ gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+
+ gtk_widget_show (box);
+}
+
+ModestSignatureEditorDialog*
+modest_signature_editor_dialog_new (void)
+{
+ return g_object_new (MODEST_TYPE_SIGNATURE_EDITOR_DIALOG, NULL);
+}
+
+void
+modest_signature_editor_dialog_set_settings (
+ ModestSignatureEditorDialog *window, gboolean use_signature, const gchar* signature,
+ const gchar* account_title)
+{
+ ModestSignatureEditorDialogPrivate *priv =
+ SIGNATURE_EDITOR_DIALOG_GET_PRIVATE (window);
+
+ /* This causes a warning because of the %s in the translation, but not in the original string: */
+ gchar* label_text = g_strdup_printf (_("mcen_ia_email_signatures_edit_dlg_label"),
+ account_title);
+ gtk_label_set_text (GTK_LABEL (priv->label), label_text);
+ g_free (label_text);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbox_use), use_signature);
+
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->textview));
+ if (signature)
+ gtk_text_buffer_set_text (buffer, signature, -1);
+ else
+ gtk_text_buffer_set_text (buffer, "", -1);
+}
+
+/*
+ * The result must be freed with g_free(). */
+gchar*
+modest_signature_editor_dialog_get_settings (
+ ModestSignatureEditorDialog *window, gboolean* use_signature)
+{
+ ModestSignatureEditorDialogPrivate *priv =
+ SIGNATURE_EDITOR_DIALOG_GET_PRIVATE (window);
+
+ g_assert(use_signature);
+
+ *use_signature = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->checkbox_use));
+
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->textview));
+
+ GtkTextIter start, end;
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ return gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
+}
--- /dev/null
+/* 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_SIGNATURE_EDITOR_DIALOG
+#define __MODEST_MAEMO_SIGNATURE_EDITOR_DIALOG
+
+#include <modest-account-mgr.h>
+#include <modest-account-mgr-helpers.h> /* For ModestServerAccountData */
+#include <gtk/gtkdialog.h>
+#include <gtk/gtktreeview.h>
+
+G_BEGIN_DECLS
+
+#define MODEST_TYPE_SIGNATURE_EDITOR_DIALOG modest_signature_editor_dialog_get_type()
+
+#define MODEST_SIGNATURE_EDITOR_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ MODEST_TYPE_SIGNATURE_EDITOR_DIALOG, ModestSignatureEditorDialog))
+
+#define MODEST_SIGNATURE_EDITOR_DIALOG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ MODEST_TYPE_SIGNATURE_EDITOR_DIALOG, ModestSignatureEditorDialogClass))
+
+#define MODEST_IS_SIGNATURE_EDITOR_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ MODEST_TYPE_SIGNATURE_EDITOR_DIALOG))
+
+#define MODEST_IS_SIGNATURE_EDITOR_DIALOG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ MODEST_TYPE_SIGNATURE_EDITOR_DIALOG))
+
+#define MODEST_SIGNATURE_EDITOR_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ MODEST_TYPE_SIGNATURE_EDITOR_DIALOG, ModestSignatureEditorDialogClass))
+
+typedef struct {
+ GtkDialog parent;
+
+} ModestSignatureEditorDialog;
+
+typedef struct {
+ GtkDialogClass parent_class;
+} ModestSignatureEditorDialogClass;
+
+GType modest_signature_editor_dialog_get_type (void);
+
+ModestSignatureEditorDialog* modest_signature_editor_dialog_new (void);
+
+void modest_signature_editor_dialog_set_settings (
+ ModestSignatureEditorDialog *window, gboolean use_signature, const gchar* signature,
+ const gchar* account_title);
+
+gchar* modest_signature_editor_dialog_get_settings (
+ ModestSignatureEditorDialog *window, gboolean* use_signature);
+
+
+G_END_DECLS
+
+#endif /* __MODEST_MAEMO_CONNECTION_SPECIFIC_SMTP_WINDOW */
return modest_account_mgr_get_bool (self, name, MODEST_ACCOUNT_ENABLED, FALSE);
}
+gboolean modest_account_mgr_set_signature (ModestAccountMgr *self, const gchar* name,
+ const gchar* signature, gboolean use_signature)
+{
+ gboolean result = modest_account_mgr_set_bool (self, name, MODEST_ACCOUNT_USE_SIGNATURE,
+ use_signature, FALSE);
+ result = result && modest_account_mgr_set_string (self, name, MODEST_ACCOUNT_SIGNATURE,
+ signature, FALSE);
+ return result;
+}
+
+
+gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name,
+ gboolean* use_signature)
+{
+ if (use_signature) {
+ *use_signature =
+ modest_account_mgr_get_bool (self, name, MODEST_ACCOUNT_USE_SIGNATURE, FALSE);
+ }
+
+ return modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SIGNATURE, FALSE);
+}
+
+
+
#if 0 /* Not needed, but works. */
static gint
compare_option_strings_for_name (const gchar* a, const gchar* b)
gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
/**
+ * modest_account_mgr_set_signature
+ * @self: a ModestAccountMgr instance
+ * @name: the account name to check
+ * @signature: the signature text
+ * @use_signature: Whether the signature should be used.
+ *
+ * Sets the signature text for the account.
+ *
+ * Returns: TRUE if it worked, FALSE otherwise
+ */
+gboolean modest_account_mgr_set_signature (ModestAccountMgr *self, const gchar* name,
+ const gchar* signature, gboolean use_signature);
+
+/**
+ * modest_account_mgr_get_signature:
+ * @self: a ModestAccountMgr instance
+ * @name: the account name
+ * @use_signature: Pointer to a gboolean taht will be set to TRUE if the signature should be used.
+ *
+ * Gets the signature text for this account.
+ *
+ * Returns: The signature text, which should be freed with g_free().
+ */
+gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name,
+ gboolean* use_signature);
+
+/**
* modest_account_mgr_set_connection_specific_smtp
* @self: a ModestAccountMgr instance
* @name: the account name
#define MODEST_ACCOUNT_REMEMBER_PWD "remember_pwd" /* boolean */
#define MODEST_ACCOUNT_HOSTNAME "hostname" /* string */
#define MODEST_ACCOUNT_USERNAME "username" /* string */
+#define MODEST_ACCOUNT_USE_SIGNATURE "use_signature" /* boolean */
+#define MODEST_ACCOUNT_SIGNATURE "signature" /* string */
#define MODEST_ACCOUNT_URI "uri" /* string */
#define MODEST_ACCOUNT_PROTO "proto" /* string */