Fixes NB#116624, do not create new contacts if they already exist when invoking ...
[modest] / src / widgets / modest-recpt-editor.c
index a0add3a..430eff3 100644 (file)
@@ -72,6 +72,7 @@ struct _ModestRecptEditorPrivate
        GtkWidget *scrolled_window;
        gchar *recipients;
        gulong on_mark_set_handler;
+       gboolean show_abook;
 };
 
 #define MODEST_RECPT_EDITOR_GET_PRIVATE(o)     \
@@ -304,8 +305,7 @@ modest_recpt_editor_replace_with_resolved_recipients (ModestRecptEditor *recpt_e
        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,
                                                  "wrap-mode", GTK_WRAP_NONE,
@@ -313,17 +313,17 @@ modest_recpt_editor_replace_with_resolved_recipients (ModestRecptEditor *recpt_e
 
                g_object_set_data (G_OBJECT (tag), "recipient-tag-id", GINT_TO_POINTER (RECIPIENT_TAG_ID));
                g_object_set_data_full (G_OBJECT (tag), "recipient-id", g_strdup (recipient_id), (GDestroyNotify) g_free);
-               
+
                for (node = email_list; node != NULL; node = g_slist_next (node)) {
                        gchar *recipient = (gchar *) node->data;
 
                        if ((recipient) && (strlen (recipient) != 0)) {
-                               
+
                                if (!is_first_recipient)
                                        gtk_text_buffer_insert (buffer, start, "\n", -1);
 
                                gtk_text_buffer_insert_with_tags (buffer, start, recipient, -1, tag, NULL);
-                               
+
                                if (node->next != NULL)
                                        gtk_text_buffer_insert (buffer, start, ";", -1);
                                is_first_recipient = FALSE;
@@ -332,6 +332,10 @@ modest_recpt_editor_replace_with_resolved_recipients (ModestRecptEditor *recpt_e
 
                email_lists_list = g_slist_next (email_lists_list);
                recipient_ids_list = g_slist_next (recipient_ids_list);
+
+               /* Add a separator between lists of emails*/
+               if (recipient_ids_list)
+                       gtk_text_buffer_insert (buffer, start, ";", -1);
        }
        g_signal_handlers_unblock_by_func (buffer, modest_recpt_editor_on_insert_text, recpt_editor);
 
@@ -384,7 +388,10 @@ modest_recpt_editor_instance_init (GTypeInstance *instance, gpointer g_class)
 
        priv = MODEST_RECPT_EDITOR_GET_PRIVATE (instance);
 
+       priv->show_abook = TRUE;
        priv->abook_button = gtk_button_new ();
+       gtk_widget_set_no_show_all (GTK_WIDGET (priv->abook_button), TRUE);
+       gtk_widget_show (priv->abook_button);
 #ifdef MODEST_TOOLKIT_HILDON2
        gtk_widget_set_size_request (priv->abook_button, RECPT_BUTTON_WIDTH_HILDON2, -1);
 #else
@@ -994,6 +1001,34 @@ modest_recpt_editor_has_focus (ModestRecptEditor *recpt_editor)
                gtk_widget_is_focus (priv->text_view);
 }
 
+void 
+modest_recpt_editor_set_show_abook_button (ModestRecptEditor *recpt_editor, gboolean show)
+{
+       ModestRecptEditorPrivate *priv;
+       
+       g_return_if_fail (MODEST_IS_RECPT_EDITOR (recpt_editor));
+       priv = MODEST_RECPT_EDITOR_GET_PRIVATE (recpt_editor);
+
+       priv->show_abook = show;
+
+       if (show)
+               gtk_widget_show (priv->abook_button);
+       else
+               gtk_widget_hide (priv->abook_button);
+}
+
+gboolean
+modest_recpt_editor_get_show_abook_button (ModestRecptEditor *recpt_editor, gboolean show)
+{
+       ModestRecptEditorPrivate *priv;
+       
+       g_return_val_if_fail (MODEST_IS_RECPT_EDITOR (recpt_editor), FALSE);
+       priv = MODEST_RECPT_EDITOR_GET_PRIVATE (recpt_editor);
+
+       return priv->show_abook;
+       
+}
+
 static void
 modest_recpt_editor_finalize (GObject *object)
 {
@@ -1018,11 +1053,9 @@ static void
 modest_recpt_editor_class_init (ModestRecptEditorClass *klass)
 {
        GObjectClass *object_class;
-       GtkWidgetClass *widget_class;
 
        parent_class = g_type_class_peek_parent (klass);
        object_class = (GObjectClass*) klass;
-       widget_class = GTK_WIDGET_CLASS (klass);
 
        object_class->finalize = modest_recpt_editor_finalize;