1 /* connection-specific-smtp-window.c */
3 #include "modest-signature-editor-dialog.h"
4 #include "maemo/modest-maemo-ui-constants.h"
5 #include <hildon-widgets/hildon-caption.h>
6 #include <hildon-widgets/hildon-number-editor.h>
7 #include "widgets/modest-serversecurity-combo-box.h"
8 #include "widgets/modest-secureauth-combo-box.h"
9 #include "widgets/modest-validating-entry.h"
10 #include <modest-account-mgr-helpers.h>
11 #include <gtk/gtkcheckbutton.h>
12 #include <gtk/gtkhbox.h>
13 #include <gtk/gtkvbox.h>
14 #include <gtk/gtktextview.h>
15 #include <gtk/gtklabel.h>
16 #include <gtk/gtkstock.h>
18 #include <glib/gi18n.h>
20 G_DEFINE_TYPE (ModestSignatureEditorDialog, modest_signature_editor_dialog, GTK_TYPE_DIALOG);
22 #define SIGNATURE_EDITOR_DIALOG_GET_PRIVATE(o) \
23 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_SIGNATURE_EDITOR_DIALOG, ModestSignatureEditorDialogPrivate))
25 typedef struct _ModestSignatureEditorDialogPrivate ModestSignatureEditorDialogPrivate;
27 struct _ModestSignatureEditorDialogPrivate
29 GtkWidget *checkbox_use;
35 modest_signature_editor_dialog_get_property (GObject *object, guint property_id,
36 GValue *value, GParamSpec *pspec)
38 switch (property_id) {
40 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
45 modest_signature_editor_dialog_set_property (GObject *object, guint property_id,
46 const GValue *value, GParamSpec *pspec)
48 switch (property_id) {
50 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
55 modest_signature_editor_dialog_dispose (GObject *object)
57 if (G_OBJECT_CLASS (modest_signature_editor_dialog_parent_class)->dispose)
58 G_OBJECT_CLASS (modest_signature_editor_dialog_parent_class)->dispose (object);
62 modest_signature_editor_dialog_finalize (GObject *object)
64 G_OBJECT_CLASS (modest_signature_editor_dialog_parent_class)->finalize (object);
68 modest_signature_editor_dialog_class_init (ModestSignatureEditorDialogClass *klass)
70 GObjectClass *object_class = G_OBJECT_CLASS (klass);
72 g_type_class_add_private (klass, sizeof (ModestSignatureEditorDialogPrivate));
74 object_class->get_property = modest_signature_editor_dialog_get_property;
75 object_class->set_property = modest_signature_editor_dialog_set_property;
76 object_class->dispose = modest_signature_editor_dialog_dispose;
77 object_class->finalize = modest_signature_editor_dialog_finalize;
81 modest_signature_editor_dialog_init (ModestSignatureEditorDialog *self)
83 ModestSignatureEditorDialogPrivate *priv =
84 SIGNATURE_EDITOR_DIALOG_GET_PRIVATE (self);
86 gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_email_signatures_edit_title"));
88 GtkWidget *box = GTK_DIALOG(self)->vbox; /* gtk_vbox_new (FALSE, MODEST_MARGIN_HALF); */
90 priv->checkbox_use = gtk_check_button_new_with_label (
91 _("mcen_fi_email_signatures_use_signature"));
92 gtk_box_pack_start (GTK_BOX (box), priv->checkbox_use, FALSE, FALSE, MODEST_MARGIN_HALF);
93 gtk_widget_show (priv->checkbox_use);
95 priv->label = gtk_label_new (""); /* Set in modest_signature_editor_dialog_set_settings(). */
96 gtk_box_pack_start (GTK_BOX (box), priv->label, FALSE, FALSE, MODEST_MARGIN_HALF);
97 gtk_widget_show (priv->label);
99 priv->textview = gtk_text_view_new ();
100 gtk_box_pack_start (GTK_BOX (box), priv->textview, FALSE, FALSE, MODEST_MARGIN_HALF);
101 gtk_widget_show (priv->textview);
103 /* Add the buttons: */
104 gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_OK, GTK_RESPONSE_OK);
105 gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
108 gtk_widget_show (box);
111 ModestSignatureEditorDialog*
112 modest_signature_editor_dialog_new (void)
114 return g_object_new (MODEST_TYPE_SIGNATURE_EDITOR_DIALOG, NULL);
118 modest_signature_editor_dialog_set_settings (
119 ModestSignatureEditorDialog *window, gboolean use_signature, const gchar* signature,
120 const gchar* account_title)
122 ModestSignatureEditorDialogPrivate *priv =
123 SIGNATURE_EDITOR_DIALOG_GET_PRIVATE (window);
125 /* This causes a warning because of the %s in the translation, but not in the original string: */
126 gchar* label_text = g_strdup_printf (_("mcen_ia_email_signatures_edit_dlg_label"),
128 gtk_label_set_text (GTK_LABEL (priv->label), label_text);
131 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbox_use), use_signature);
133 GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->textview));
135 gtk_text_buffer_set_text (buffer, signature, -1);
137 gtk_text_buffer_set_text (buffer, "", -1);
141 * The result must be freed with g_free(). */
143 modest_signature_editor_dialog_get_settings (
144 ModestSignatureEditorDialog *window, gboolean* use_signature)
146 ModestSignatureEditorDialogPrivate *priv =
147 SIGNATURE_EDITOR_DIALOG_GET_PRIVATE (window);
149 g_assert(use_signature);
151 *use_signature = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->checkbox_use));
153 GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->textview));
155 GtkTextIter start, end;
156 gtk_text_buffer_get_bounds (buffer, &start, &end);
157 return gtk_text_buffer_get_text (buffer, &start, &end, TRUE);