X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-recpt-editor.c;h=b0a4bc9a05f00897d4cdd25a20dcff1997bc4466;hb=afa0056e1dda60a53fb70d4dc2de1b3c978333bf;hp=b4caefc5c72e684aa911c678185656d1a77f1d30;hpb=bd6f842fd8084d2a0ca0afae7641d6dddf5e03f9;p=modest diff --git a/src/widgets/modest-recpt-editor.c b/src/widgets/modest-recpt-editor.c index b4caefc..b0a4bc9 100644 --- a/src/widgets/modest-recpt-editor.c +++ b/src/widgets/modest-recpt-editor.c @@ -43,6 +43,7 @@ #include #include #include +#include /* FIXNE: we should have no maemo-deps in widgets/ */ #ifndef MODEST_TOOLKIT_GTK @@ -86,13 +87,14 @@ static void modest_recpt_editor_class_init (ModestRecptEditorClass *klass); /* widget events */ static void modest_recpt_editor_on_abook_clicked (GtkButton *button, ModestRecptEditor *editor); -static gboolean modest_recpt_editor_on_button_release_event (GtkWidget *widget, - GdkEventButton *event, - ModestRecptEditor *editor); static void modest_recpt_editor_move_cursor_to_end (ModestRecptEditor *editor); static gboolean modest_recpt_editor_on_focus_in (GtkTextView *text_view, GdkEventFocus *event, ModestRecptEditor *editor); +static void modest_recpt_editor_on_mark_set (GtkTextBuffer *buffer, + GtkTextIter *iter, + GtkTextMark *mark, + ModestRecptEditor *editor); static void modest_recpt_editor_on_insert_text (GtkTextBuffer *buffer, GtkTextIter *location, gchar *text, @@ -121,7 +123,7 @@ modest_recpt_editor_new (void) { ModestRecptEditor *self = g_object_new (MODEST_TYPE_RECPT_EDITOR, "homogeneous", FALSE, - "spacing", 1, + "spacing", MODEST_MARGIN_NONE, NULL); return GTK_WIDGET (self); @@ -262,6 +264,25 @@ modest_recpt_editor_replace_with_resolved_recipient (ModestRecptEditor *recpt_ed GtkTextIter *start, GtkTextIter *end, GSList *email_list, const gchar * recipient_id) { + GSList *email_lists_list; + GSList *recipient_ids_list; + + email_lists_list = g_slist_append (NULL, email_list); + recipient_ids_list = g_slist_append (NULL, (gpointer) recipient_id); + + modest_recpt_editor_replace_with_resolved_recipients (recpt_editor, start, end, + email_lists_list, recipient_ids_list); + + g_slist_free (email_lists_list); + g_slist_free (recipient_ids_list); + +} + +void +modest_recpt_editor_replace_with_resolved_recipients (ModestRecptEditor *recpt_editor, + GtkTextIter *start, GtkTextIter *end, + GSList *email_lists_list, GSList * recipient_ids_list) +{ ModestRecptEditorPrivate *priv; GtkTextBuffer *buffer; GtkTextTag *tag; @@ -280,7 +301,10 @@ modest_recpt_editor_replace_with_resolved_recipient (ModestRecptEditor *recpt_ed gtk_text_buffer_delete (buffer, start, end); - if (email_list) { + while (email_lists_list) { + gchar *recipient_id = (gchar *) recipient_ids_list->data; + GSList *email_list = (GSList *) email_lists_list->data; + tag = gtk_text_buffer_create_tag (buffer, NULL, "underline", PANGO_UNDERLINE_SINGLE, @@ -305,6 +329,9 @@ modest_recpt_editor_replace_with_resolved_recipient (ModestRecptEditor *recpt_ed is_first_recipient = FALSE; } } + + email_lists_list = g_slist_next (email_lists_list); + recipient_ids_list = g_slist_next (recipient_ids_list); } g_signal_handlers_unblock_by_func (buffer, modest_recpt_editor_on_insert_text, recpt_editor); @@ -352,6 +379,7 @@ modest_recpt_editor_instance_init (GTypeInstance *instance, gpointer g_class) { ModestRecptEditorPrivate *priv; GtkWidget *abook_icon; + GtkWidget *abook_align; GtkTextBuffer *buffer; priv = MODEST_RECPT_EDITOR_GET_PRIVATE (instance); @@ -398,7 +426,10 @@ modest_recpt_editor_instance_init (GTypeInstance *instance, gpointer g_class) gtk_box_pack_start (GTK_BOX (instance), priv->scrolled_window, TRUE, TRUE, 0); /* gtk_box_pack_start (GTK_BOX (instance), priv->text_view, TRUE, TRUE, 0); */ #endif - gtk_box_pack_end (GTK_BOX (instance), priv->abook_button, FALSE, FALSE, 0); + abook_align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); + gtk_alignment_set_padding (GTK_ALIGNMENT (abook_align), 0, 0, MODEST_MARGIN_DEFAULT, 0); + gtk_container_add (GTK_CONTAINER (abook_align), priv->abook_button); + gtk_box_pack_end (GTK_BOX (instance), abook_align, FALSE, FALSE, 0); gtk_text_view_set_accepts_tab (GTK_TEXT_VIEW (priv->text_view), FALSE); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (priv->text_view), TRUE); @@ -415,10 +446,10 @@ modest_recpt_editor_instance_init (GTypeInstance *instance, gpointer g_class) buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->text_view)); #endif g_signal_connect (G_OBJECT (priv->abook_button), "clicked", G_CALLBACK (modest_recpt_editor_on_abook_clicked), instance); - g_signal_connect (G_OBJECT (priv->text_view), "button-release-event", G_CALLBACK (modest_recpt_editor_on_button_release_event), instance); g_signal_connect (G_OBJECT (priv->text_view), "key-press-event", G_CALLBACK (modest_recpt_editor_on_key_press_event), instance); g_signal_connect (G_OBJECT (priv->text_view), "focus-in-event", G_CALLBACK (modest_recpt_editor_on_focus_in), instance); g_signal_connect (G_OBJECT (buffer), "insert-text", G_CALLBACK (modest_recpt_editor_on_insert_text), instance); + g_signal_connect (G_OBJECT (buffer), "mark-set", G_CALLBACK (modest_recpt_editor_on_mark_set), instance); /* gtk_container_set_focus_child (GTK_CONTAINER (instance), priv->text_view); */ @@ -464,23 +495,25 @@ modest_recpt_editor_on_abook_clicked (GtkButton *button, ModestRecptEditor *edit g_signal_emit_by_name (G_OBJECT (editor), "open-addressbook"); } -static gboolean -modest_recpt_editor_on_button_release_event (GtkWidget *widget, - GdkEventButton *event, - ModestRecptEditor *recpt_editor) +static void +modest_recpt_editor_on_mark_set (GtkTextBuffer *buffer, + GtkTextIter *iter, + GtkTextMark *mark, + ModestRecptEditor *recpt_editor) { ModestRecptEditorPrivate *priv; - GtkTextIter location, start, end; - GtkTextMark *mark; - GtkTextBuffer *buffer; + GtkTextIter start, end; + GtkTextMark *selection_bound; GtkTextTag *tag; gboolean selection_changed = FALSE; priv = MODEST_RECPT_EDITOR_GET_PRIVATE (recpt_editor); buffer = modest_recpt_editor_get_buffer (recpt_editor); - mark = gtk_text_buffer_get_insert (buffer); - gtk_text_buffer_get_iter_at_mark (buffer, &location, mark); + selection_bound = gtk_text_buffer_get_selection_bound (buffer); + + if (mark != selection_bound) + return; gtk_text_buffer_get_selection_bounds (buffer, &start, &end); @@ -500,11 +533,7 @@ modest_recpt_editor_on_button_release_event (GtkWidget *widget, if (selection_changed) { gtk_text_buffer_select_range (buffer, &start, &end); - } else { - GTK_TEXT_VIEW (priv->text_view)->pending_place_cursor_button = 0; } - - return FALSE; } static gboolean