X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-recpt-editor.c;h=5e66325d9842e0a1f99e92d7ac5a8a0fb12d25f0;hp=1cab400cd65d7635e89d05afc021e1d749d417b9;hb=aab537f6ce755830767baa7260d7879449ceeb38;hpb=bdf3144895871178bf6883bff6d29dbbbd0d7fae diff --git a/src/widgets/modest-recpt-editor.c b/src/widgets/modest-recpt-editor.c index 1cab400..5e66325 100644 --- a/src/widgets/modest-recpt-editor.c +++ b/src/widgets/modest-recpt-editor.c @@ -333,9 +333,13 @@ modest_recpt_editor_instance_init (GTypeInstance *instance, gpointer g_class) gtk_container_add (GTK_CONTAINER (priv->abook_button), abook_icon); priv->text_view = gtk_text_view_new (); + /* Auto-capitalization is the default, so let's turn it off: */ + hildon_gtk_text_view_set_input_mode (GTK_TEXT_VIEW (priv->text_view), + HILDON_GTK_INPUT_MODE_FULL); + priv->recipients = NULL; - priv->scrolled_window = modest_scroll_text_new (GTK_TEXT_VIEW (priv->text_view), 5); + priv->scrolled_window = modest_scroll_text_new (GTK_TEXT_VIEW (priv->text_view), 1024); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolled_window), GTK_SHADOW_IN); @@ -451,6 +455,7 @@ is_valid_insert (const gchar *text, gint len) gunichar c; gunichar next_c; gint i= 0; + gboolean quoted = FALSE; const gchar *current, *next_current; if (text == NULL) return TRUE; @@ -463,14 +468,20 @@ is_valid_insert (const gchar *text, gint len) next_c = g_utf8_get_char (g_utf8_next_char (current)); else next_c = 0; - if (c == g_utf8_get_char(",") || c == g_utf8_get_char (";")) { + if (!quoted && ((c == g_utf8_get_char(",") || c == g_utf8_get_char (";")))) { if ((next_c != 0) && (next_c != g_utf8_get_char ("\n"))) return FALSE; + else { + current = g_utf8_next_char (next_current); + continue; + } } if (c == 0x2022 || c == 0xfffc || c == g_utf8_get_char ("\n") || c == g_utf8_get_char ("\t")) return FALSE; + if (c == g_utf8_get_char ("\"")) + quoted = !quoted; current = g_utf8_next_char (current); i = current - text; } @@ -484,6 +495,7 @@ create_valid_text (const gchar *text, gint len) gunichar next_c; gint i= 0; GString *str; + gboolean quoted = FALSE; const gchar *current, *next_current; if (text == NULL) @@ -503,10 +515,12 @@ create_valid_text (const gchar *text, gint len) c != g_utf8_get_char ("\n") && c != g_utf8_get_char ("\t")) str = g_string_append_unichar (str, c); - if (c == g_utf8_get_char(",") || c == g_utf8_get_char (";")) { + if (!quoted && ((c == g_utf8_get_char(",") || c == g_utf8_get_char (";")))) { if ((next_c != 0) && (next_c != g_utf8_get_char ("\n"))) str = g_string_append_c (str, '\n'); } + if (c == g_utf8_get_char ("\"")) + quoted = !quoted; current = g_utf8_next_char (current); i = current - text; } @@ -523,12 +537,16 @@ modest_recpt_editor_on_insert_text (GtkTextBuffer *buffer, GtkTextIter prev; gunichar prev_char; ModestRecptEditorPrivate *priv = MODEST_RECPT_EDITOR_GET_PRIVATE (editor); + + if (len > 1024) + len = 1024; if (!is_valid_insert (text, len)) { gchar *new_text = create_valid_text (text, len); g_signal_stop_emission_by_name (G_OBJECT (buffer), "insert-text"); gtk_text_buffer_insert (buffer, location, new_text, -1); g_free (new_text); + return; } if (iter_has_recipient (location)) { @@ -836,6 +854,17 @@ modest_recpt_editor_grab_focus (ModestRecptEditor *recpt_editor) gtk_widget_grab_focus (priv->text_view); } +gboolean +modest_recpt_editor_has_focus (ModestRecptEditor *recpt_editor) +{ + ModestRecptEditorPrivate *priv; + + g_return_val_if_fail (MODEST_IS_RECPT_EDITOR (recpt_editor), FALSE); + priv = MODEST_RECPT_EDITOR_GET_PRIVATE (recpt_editor); + + return gtk_widget_is_focus (priv->text_view); +} + static void modest_recpt_editor_finalize (GObject *object) {