X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-signature-editor-dialog.c;h=acc9c6b95cb19809f46da28efcbc8314ecdb1270;hb=21b666ae007ad3d154fb0a081a43404529f57896;hp=c90e340fecf4597bb1da8f5289f42a7400c8b0dc;hpb=147ce908f5f1720d2a589e81bb1bf2163f460cb9;p=modest diff --git a/src/maemo/modest-signature-editor-dialog.c b/src/maemo/modest-signature-editor-dialog.c index c90e340..acc9c6b 100644 --- a/src/maemo/modest-signature-editor-dialog.c +++ b/src/maemo/modest-signature-editor-dialog.c @@ -1,18 +1,19 @@ /* connection-specific-smtp-window.c */ #include "modest-signature-editor-dialog.h" -#include "maemo/modest-maemo-ui-constants.h" -#include -#include +#include "widgets/modest-ui-constants.h" +#include "modest-hildon-includes.h" #include "widgets/modest-serversecurity-combo-box.h" #include "widgets/modest-secureauth-combo-box.h" #include "widgets/modest-validating-entry.h" +#include "modest-runtime.h" #include #include #include #include #include #include +#include #include #include @@ -28,6 +29,7 @@ struct _ModestSignatureEditorDialogPrivate { GtkWidget *checkbox_use; GtkWidget *label; + GtkWidget *scrolledwindow; GtkWidget *textview; }; @@ -78,6 +80,25 @@ modest_signature_editor_dialog_class_init (ModestSignatureEditorDialogClass *kla } static void +enable_widgets (ModestSignatureEditorDialog *self) +{ + ModestSignatureEditorDialogPrivate *priv = + SIGNATURE_EDITOR_DIALOG_GET_PRIVATE (self); + + const gboolean enable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->checkbox_use)); + gtk_widget_set_sensitive (priv->label, enable); + gtk_widget_set_sensitive (priv->scrolledwindow, enable); + gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->textview), enable); +} + +static void +on_toggle_button_changed (GtkToggleButton *togglebutton, gpointer user_data) +{ + ModestSignatureEditorDialog *self = MODEST_SIGNATURE_EDITOR_DIALOG (user_data); + enable_widgets (self); +} + +static void modest_signature_editor_dialog_init (ModestSignatureEditorDialog *self) { ModestSignatureEditorDialogPrivate *priv = @@ -86,19 +107,34 @@ modest_signature_editor_dialog_init (ModestSignatureEditorDialog *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); */ + gtk_container_set_border_width (GTK_CONTAINER (box), 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); + g_signal_connect (G_OBJECT (priv->checkbox_use), "toggled", + G_CALLBACK (on_toggle_button_changed), self); + + 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->scrolledwindow = gtk_scrolled_window_new (NULL, NULL); + gtk_container_set_border_width (GTK_CONTAINER (priv->scrolledwindow), MODEST_MARGIN_DEFAULT); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolledwindow), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolledwindow), GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (box), priv->scrolledwindow, FALSE, FALSE, MODEST_MARGIN_HALF); + gtk_widget_show (priv->scrolledwindow); + priv->textview = gtk_text_view_new (); - gtk_box_pack_start (GTK_BOX (box), priv->textview, FALSE, FALSE, MODEST_MARGIN_HALF); + gtk_container_add (GTK_CONTAINER (priv->scrolledwindow), priv->textview); gtk_widget_show (priv->textview); + GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->textview)); + gtk_text_buffer_set_text (buffer, "--\n", -1); /* Default, as per the UI spec. */ /* Add the buttons: */ gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_OK, GTK_RESPONSE_OK); @@ -106,6 +142,11 @@ modest_signature_editor_dialog_init (ModestSignatureEditorDialog *self) gtk_widget_show (box); + + /* When this window is shown, hibernation should not be possible, + * because there is no sensible way to save the state: */ + modest_window_mgr_prevent_hibernation_while_window_is_shown ( + modest_runtime_get_window_mgr (), GTK_WINDOW (self)); } ModestSignatureEditorDialog* @@ -134,7 +175,9 @@ modest_signature_editor_dialog_set_settings ( if (signature) gtk_text_buffer_set_text (buffer, signature, -1); else - gtk_text_buffer_set_text (buffer, "", -1); + gtk_text_buffer_set_text (buffer, "--\n", -1); /* Default, as per the UI spec. */ + + enable_widgets (window); } /*