aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-msg-composer-address-entry.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>1999-11-06 07:06:09 +0800
committerEttore Perazzoli <ettore@src.gnome.org>1999-11-06 07:06:09 +0800
commitb681ec2b9a98684ef821f9b6fbdb9a231a58d4b5 (patch)
tree6dc964528b9db296aa1dfedde9a2b2122fd0db8e /widgets/e-msg-composer-address-entry.c
parentc8fce201dc8b14505f2e0387689947922e08f956 (diff)
downloadgsoc2013-evolution-b681ec2b9a98684ef821f9b6fbdb9a231a58d4b5.tar
gsoc2013-evolution-b681ec2b9a98684ef821f9b6fbdb9a231a58d4b5.tar.gz
gsoc2013-evolution-b681ec2b9a98684ef821f9b6fbdb9a231a58d4b5.tar.bz2
gsoc2013-evolution-b681ec2b9a98684ef821f9b6fbdb9a231a58d4b5.tar.lz
gsoc2013-evolution-b681ec2b9a98684ef821f9b6fbdb9a231a58d4b5.tar.xz
gsoc2013-evolution-b681ec2b9a98684ef821f9b6fbdb9a231a58d4b5.tar.zst
gsoc2013-evolution-b681ec2b9a98684ef821f9b6fbdb9a231a58d4b5.zip
Here is my initial Evolution work: message composition widget and some
installation fixes for Camel. svn path=/trunk/; revision=1369
Diffstat (limited to 'widgets/e-msg-composer-address-entry.c')
-rw-r--r--widgets/e-msg-composer-address-entry.c142
1 files changed, 142 insertions, 0 deletions
diff --git a/widgets/e-msg-composer-address-entry.c b/widgets/e-msg-composer-address-entry.c
new file mode 100644
index 0000000000..071730eef2
--- /dev/null
+++ b/widgets/e-msg-composer-address-entry.c
@@ -0,0 +1,142 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-msg-composer-address-entry.c
+ *
+ * Copyright (C) 1999 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+/* This is a custom GtkEntry for entering address lists. For now, it does not
+ have any fancy features, but in the future we might want to make it
+ cooler. */
+
+#include <gnome.h>
+
+#include "e-msg-composer-address-entry.h"
+
+
+static GtkEntryClass *parent_class = NULL;
+
+
+/* Initialization. */
+
+static void
+class_init (EMsgComposerAddressEntryClass *klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = (GtkObjectClass*) klass;
+
+ parent_class = gtk_type_class (gtk_entry_get_type ());
+}
+
+static void
+init (EMsgComposerAddressEntry *msg_composer_address_entry)
+{
+}
+
+GtkType
+e_msg_composer_address_entry_get_type (void)
+{
+ static GtkType type = 0;
+
+ if (type == 0) {
+ static const GtkTypeInfo info = {
+ "EMsgComposerAddressEntry",
+ sizeof (EMsgComposerAddressEntry),
+ sizeof (EMsgComposerAddressEntryClass),
+ (GtkClassInitFunc) class_init,
+ (GtkObjectInitFunc) init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ type = gtk_type_unique (gtk_entry_get_type (), &info);
+ }
+
+ return type;
+}
+
+
+GtkWidget *
+e_msg_composer_address_entry_new (void)
+{
+ GtkWidget *new;
+
+ new = gtk_type_new (e_msg_composer_address_entry_get_type ());
+
+ return new;
+}
+
+
+/**
+ * e_msg_composer_address_entry_get_addresses:
+ * @entry: An address entry widget
+ *
+ * Retrieve the list of addresses stored in @entry.
+ *
+ * Return value: A GList of pointers to strings representing the addresses.
+ * Notice that the strings must be freed by the caller when not needed anymore.
+ **/
+GList *
+e_msg_composer_address_entry_get_addresses (EMsgComposerAddressEntry *entry)
+{
+ GList *list;
+ const gchar *s;
+ const gchar *p, *oldp;
+ gboolean in_quotes;
+
+ s = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ in_quotes = FALSE;
+ list = NULL;
+
+ p = s;
+ oldp = s;
+
+ while (1) {
+ if (*p == '"') {
+ in_quotes = ! in_quotes;
+ p++;
+ } else if ((! in_quotes && *p == ',') || *p == 0) {
+ if (p != oldp) {
+ gchar *new_addr;
+
+ new_addr = g_strndup (oldp, p - oldp);
+ new_addr = g_strstrip (new_addr);
+ if (*new_addr != '\0')
+ list = g_list_prepend (list, new_addr);
+ else
+ g_free (new_addr);
+ }
+
+ while (*p == ',' || *p == ' ' || *p == '\t')
+ p++;
+
+ if (*p == 0)
+ break;
+
+ oldp = p;
+ } else {
+ p++;
+ }
+ }
+
+ return g_list_reverse (list);
+}