2009-11-30 [mir] 3.7.3cvs24
authorMichael Rasmussen <mir@datanom.net>
Mon, 30 Nov 2009 20:35:29 +0000 (20:35 +0000)
committerMichael Rasmussen <mir@datanom.net>
Mon, 30 Nov 2009 20:35:29 +0000 (20:35 +0000)
* src/compose.c
           Place cursor in compose window according to provided input
           If to: is present place cursor in subject field and if both
           to: and subject: is present place cursor in body. If body: is
           present insert a new line after text and place cursor there.

ChangeLog
PATCHSETS
configure.ac
src/compose.c

index 0bcf7abd0fdae27f4766f2b044c1567429c77a2f..87a8716d605609baf706279467be483156e70ea2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-11-30 [mir]       3.7.3cvs24
+
+       * src/compose.c
+           Place cursor in compose window according to provided input
+           If to: is present place cursor in subject field and if both
+           to: and subject: is present place cursor in body. If body: is
+           present insert a new line after text and place cursor there.
+
 2009-11-27 [mones]     3.7.3cvs23
 
        * src/gtk/quicksearch.c
 2009-11-27 [mones]     3.7.3cvs23
 
        * src/gtk/quicksearch.c
index ec16199a616a530b6a99c7b5fde439aa56e47d93..86cf5392527e4420a676d46473302140933c8ec8 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.179.2.248 -r 1.179.2.249 src/imap.c;  ) > 3.7.3cvs21.patchset
 ( cvs diff -u -r 1.24.2.28 -r 1.24.2.29 Makefile.am;  cvs diff -u -r 1.24.2.19 -r 1.24.2.20 src/common/Makefile.am;  cvs diff -u -r 1.36.2.179 -r 1.36.2.180 src/common/utils.c;  cvs diff -u -r 1.20.2.72 -r 1.20.2.73 src/common/utils.h;  ) > 3.7.3cvs22.patchset
 ( cvs diff -u -r 1.1.2.87 -r 1.1.2.88 src/gtk/quicksearch.c;  ) > 3.7.3cvs23.patchset
 ( cvs diff -u -r 1.179.2.248 -r 1.179.2.249 src/imap.c;  ) > 3.7.3cvs21.patchset
 ( cvs diff -u -r 1.24.2.28 -r 1.24.2.29 Makefile.am;  cvs diff -u -r 1.24.2.19 -r 1.24.2.20 src/common/Makefile.am;  cvs diff -u -r 1.36.2.179 -r 1.36.2.180 src/common/utils.c;  cvs diff -u -r 1.20.2.72 -r 1.20.2.73 src/common/utils.h;  ) > 3.7.3cvs22.patchset
 ( cvs diff -u -r 1.1.2.87 -r 1.1.2.88 src/gtk/quicksearch.c;  ) > 3.7.3cvs23.patchset
+( cvs diff -u -r 1.382.2.525 -r 1.382.2.526 src/compose.c;  ) > 3.7.3cvs24.patchset
index e9396028e945d0017e964bb03fc1328c0e0ebba1..1e88f5811bbfb48bdaae1f69a2ced29d29cade38 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=7
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=23
+EXTRA_VERSION=24
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 97056e26ab13f03ce3d2891e1a7a6a9fd71d0745..3cd2f2d40a73b124636ff489ad61b4514457e175 100644 (file)
@@ -162,6 +162,13 @@ typedef enum
        COMPOSE_QUOTE_SKIP
 } ComposeQuoteMode;
 
        COMPOSE_QUOTE_SKIP
 } ComposeQuoteMode;
 
+typedef enum {
+    TO_FIELD_PRESENT,
+    SUBJECT_FIELD_PRESENT,
+    BODY_FIELD_PRESENT,
+    NO_FIELD_PRESENT
+} MailField;
+
 #define B64_LINE_SIZE          57
 #define B64_BUFFSIZE           77
 
 #define B64_LINE_SIZE          57
 #define B64_BUFFSIZE           77
 
@@ -207,7 +214,7 @@ static void compose_set_out_encoding                (Compose        *compose);
 static void compose_set_template_menu          (Compose        *compose);
 static void compose_destroy                    (Compose        *compose);
 
 static void compose_set_template_menu          (Compose        *compose);
 static void compose_destroy                    (Compose        *compose);
 
-static void compose_entries_set                        (Compose        *compose,
+static MailField compose_entries_set           (Compose        *compose,
                                                 const gchar    *mailto,
                                                 ComposeEntryType to_type);
 static gint compose_parse_header               (Compose        *compose,
                                                 const gchar    *mailto,
                                                 ComposeEntryType to_type);
 static gint compose_parse_header               (Compose        *compose,
@@ -936,6 +943,9 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        gchar *mailto_from = NULL;
        PrefsAccount *mailto_account = NULL;
        MsgInfo* dummyinfo = NULL;
        gchar *mailto_from = NULL;
        PrefsAccount *mailto_account = NULL;
        MsgInfo* dummyinfo = NULL;
+       MailField mfield = NO_FIELD_PRESENT;
+       gchar* buf;
+       GtkTextMark *mark;
 
        /* check if mailto defines a from */
        if (mailto && *mailto != '\0') {
 
        /* check if mailto defines a from */
        if (mailto && *mailto != '\0') {
@@ -1017,7 +1027,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
 
        if (account->protocol != A_NNTP) {
                if (mailto && *mailto != '\0') {
 
        if (account->protocol != A_NNTP) {
                if (mailto && *mailto != '\0') {
-                       compose_entries_set(compose, mailto, COMPOSE_TO);
+                       mfield = compose_entries_set(compose, mailto, COMPOSE_TO);
 
                } else if (item && item->prefs) {
                        if (item->prefs->enable_default_bcc) {
 
                } else if (item && item->prefs) {
                        if (item->prefs->enable_default_bcc) {
@@ -1044,9 +1054,9 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        } else {
                if (mailto && *mailto != '\0') {
                        if (!strchr(mailto, '@'))
        } else {
                if (mailto && *mailto != '\0') {
                        if (!strchr(mailto, '@'))
-                               compose_entries_set(compose, mailto, COMPOSE_NEWSGROUPS);
+                               mfield = compose_entries_set(compose, mailto, COMPOSE_NEWSGROUPS);
                        else
                        else
-                               compose_entries_set(compose, mailto, COMPOSE_TO);
+                               mfield = compose_entries_set(compose, mailto, COMPOSE_TO);
                } else if (item && FOLDER_CLASS(item->folder) == news_get_class()) {
                        compose_entry_append(compose, item->path, COMPOSE_NEWSGROUPS, PREF_FOLDER);
                }
                } else if (item && FOLDER_CLASS(item->folder) == news_get_class()) {
                        compose_entry_append(compose, item->path, COMPOSE_NEWSGROUPS, PREF_FOLDER);
                }
@@ -1158,8 +1168,35 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                compose_set_save_to(compose, folderidentifier);
                g_free(folderidentifier);
        }
                compose_set_save_to(compose, folderidentifier);
                g_free(folderidentifier);
        }
-       
-       gtk_widget_grab_focus(compose->header_last->entry);
+
+       /* Place cursor according to provided input (mfield) */
+       switch (mfield) { 
+               case NO_FIELD_PRESENT:
+                       gtk_widget_grab_focus(compose->header_last->entry);
+                       break;
+               case TO_FIELD_PRESENT:
+                       buf = g_strdup("");
+                       gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);     
+                       gtk_widget_grab_focus(compose->subject_entry);
+                       break;
+               case SUBJECT_FIELD_PRESENT:
+                       textview = GTK_TEXT_VIEW(compose->text);
+                       textbuf = gtk_text_view_get_buffer(textview);
+                       mark = gtk_text_buffer_get_insert(textbuf);
+                       gtk_text_buffer_get_iter_at_mark(textbuf, &iter, mark);
+                       gtk_text_buffer_insert(textbuf, &iter, "", -1);
+                   /* 
+                    * SUBJECT_FIELD_PRESENT and BODY_FIELD_PRESENT
+                    * only defers where it comes to the variable body
+                    * is not null. If no body is present compose->text
+                    * will be null in which case you cannot place the
+                    * cursor inside the component so. An empty component
+                    * is therefore created before placing the cursor
+                    */
+               case BODY_FIELD_PRESENT:
+                       gtk_widget_grab_focus(compose->text);
+                       break;
+       }
 
        undo_unblock(compose->undostruct);
 
 
        undo_unblock(compose->undostruct);
 
@@ -2532,7 +2569,7 @@ void compose_toolbar_cb(gint action, gpointer data)
        }
 }
 
        }
 }
 
-static void compose_entries_set(Compose *compose, const gchar *mailto, ComposeEntryType to_type)
+static MailField compose_entries_set(Compose *compose, const gchar *mailto, ComposeEntryType to_type)
 {
        gchar *to = NULL;
        gchar *cc = NULL;
 {
        gchar *to = NULL;
        gchar *cc = NULL;
@@ -2542,12 +2579,15 @@ static void compose_entries_set(Compose *compose, const gchar *mailto, ComposeEn
        gchar *temp = NULL;
        gsize  len = 0;
        gchar **attach = NULL;
        gchar *temp = NULL;
        gsize  len = 0;
        gchar **attach = NULL;
+       MailField mfield = NO_FIELD_PRESENT;
 
        /* get mailto parts but skip from */
        scan_mailto_url(mailto, NULL, &to, &cc, &bcc, &subject, &body, &attach);
 
 
        /* get mailto parts but skip from */
        scan_mailto_url(mailto, NULL, &to, &cc, &bcc, &subject, &body, &attach);
 
-       if (to)
+       if (to) {
                compose_entry_append(compose, to, to_type, PREF_MAILTO);
                compose_entry_append(compose, to, to_type, PREF_MAILTO);
+               mfield = TO_FIELD_PRESENT;
+       }
        if (cc)
                compose_entry_append(compose, cc, COMPOSE_CC, PREF_MAILTO);
        if (bcc)
        if (cc)
                compose_entry_append(compose, cc, COMPOSE_CC, PREF_MAILTO);
        if (bcc)
@@ -2560,6 +2600,7 @@ static void compose_entries_set(Compose *compose, const gchar *mailto, ComposeEn
                } else {
                        gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), subject);
                }
                } else {
                        gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), subject);
                }
+               mfield = SUBJECT_FIELD_PRESENT;
        }
        if (body) {
                GtkTextView *text = GTK_TEXT_VIEW(compose->text);
        }
        if (body) {
                GtkTextView *text = GTK_TEXT_VIEW(compose->text);
@@ -2585,6 +2626,7 @@ static void compose_entries_set(Compose *compose, const gchar *mailto, ComposeEn
                compose->autowrap = prev_autowrap;
                if (compose->autowrap)
                        compose_wrap_all(compose);
                compose->autowrap = prev_autowrap;
                if (compose->autowrap)
                        compose_wrap_all(compose);
+               mfield = BODY_FIELD_PRESENT;
        }
 
        if (attach) {
        }
 
        if (attach) {
@@ -2620,6 +2662,8 @@ static void compose_entries_set(Compose *compose, const gchar *mailto, ComposeEn
        g_free(subject);
        g_free(body);
        g_strfreev(attach);
        g_free(subject);
        g_free(body);
        g_strfreev(attach);
+       
+       return mfield;
 }
 
 static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
 }
 
 static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)