diff options
author | Nat Friedman <nat@src.gnome.org> | 2000-04-06 13:21:29 +0800 |
---|---|---|
committer | Nat Friedman <nat@src.gnome.org> | 2000-04-06 13:21:29 +0800 |
commit | 3d9889baee9c5c11cd960a43c0f51c449ce35b45 (patch) | |
tree | 7ed94e8a89455a0ba446e524e15db2defc4aef28 /e-util/ename/test-ename-western-gtk.c | |
parent | 2e4a5463075e387151afcdf61b74202a729944db (diff) | |
download | gsoc2013-evolution-3d9889baee9c5c11cd960a43c0f51c449ce35b45.tar gsoc2013-evolution-3d9889baee9c5c11cd960a43c0f51c449ce35b45.tar.gz gsoc2013-evolution-3d9889baee9c5c11cd960a43c0f51c449ce35b45.tar.bz2 gsoc2013-evolution-3d9889baee9c5c11cd960a43c0f51c449ce35b45.tar.lz gsoc2013-evolution-3d9889baee9c5c11cd960a43c0f51c449ce35b45.tar.xz gsoc2013-evolution-3d9889baee9c5c11cd960a43c0f51c449ce35b45.tar.zst gsoc2013-evolution-3d9889baee9c5c11cd960a43c0f51c449ce35b45.zip |
Committing this thing I wrote last year to parse names. It's cute.
svn path=/trunk/; revision=2301
Diffstat (limited to 'e-util/ename/test-ename-western-gtk.c')
-rw-r--r-- | e-util/ename/test-ename-western-gtk.c | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/e-util/ename/test-ename-western-gtk.c b/e-util/ename/test-ename-western-gtk.c new file mode 100644 index 0000000000..15db38ce10 --- /dev/null +++ b/e-util/ename/test-ename-western-gtk.c @@ -0,0 +1,148 @@ +#include <gnome.h> +#include <ename/e-name.h> + +ENameWestern *name; +GtkWidget *full; +GtkWidget *prefix; +GtkWidget *first; +GtkWidget *middle; +GtkWidget *nick; +GtkWidget *last; +GtkWidget *suffix; + +static void +fill_entries (void) +{ + +#define SET(a,b) (gtk_entry_set_text (GTK_ENTRY (a), (b) == NULL ? "" : (b))) + SET(prefix, name->prefix); + SET(first, name->first); + SET(middle, name->middle); + SET(nick, name->nick); + SET(last, name->last); + SET(suffix, name->suffix); +} + +static void +full_changed_cb (GtkEntry *fulle) +{ + e_name_western_free (name); + name = e_name_western_parse (gtk_entry_get_text (fulle)); + fill_entries (); +} + +static void +create_window (void) +{ + GtkWidget *app; + GtkTable *table; + + GtkWidget *prefix_label; + GtkWidget *first_label; + GtkWidget *middle_label; + GtkWidget *nick_label; + GtkWidget *last_label; + GtkWidget *suffix_label; + + app = gnome_app_new ("test", "Evolution Western Name Parser"); + + table = GTK_TABLE (gtk_table_new (3, 6, FALSE)); + + full = gtk_entry_new (); + prefix = gtk_entry_new (); + first = gtk_entry_new (); + middle = gtk_entry_new (); + nick = gtk_entry_new (); + last = gtk_entry_new (); + suffix = gtk_entry_new (); + + gtk_widget_set_usize (prefix, 100, 0); + gtk_widget_set_usize (first, 100, 0); + gtk_widget_set_usize (middle, 100, 0); + gtk_widget_set_usize (nick, 100, 0); + gtk_widget_set_usize (last, 100, 0); + gtk_widget_set_usize (suffix, 100, 0); + + gtk_table_attach (table, full, 0, 6, 0, 1, + GTK_EXPAND | GTK_FILL, 0, + 0, 0); + + gtk_table_attach (table, prefix, 0, 1, 1, 2, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, + 0, 0); + + gtk_table_attach (table, first, 1, 2, 1, 2, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, + 0, 0); + + gtk_table_attach (table, middle, 2, 3, 1, 2, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, + 0, 0); + + gtk_table_attach (table, nick, 3, 4, 1, 2, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, + 0, 0); + + gtk_table_attach (table, last, 4, 5, 1, 2, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, + 0, 0); + + gtk_table_attach (table, suffix, 5, 6, 1, 2, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, + 0, 0); + + prefix_label = gtk_label_new ("Prefix"); + first_label = gtk_label_new ("First"); + middle_label = gtk_label_new ("Middle"); + nick_label = gtk_label_new ("Nick"); + last_label = gtk_label_new ("Last"); + suffix_label = gtk_label_new ("Suffix"); + + gtk_table_attach (table, prefix_label, 0, 1, 2, 3, + GTK_SHRINK, 0, + 0, 0); + + gtk_table_attach (table, first_label, 1, 2, 2, 3, + GTK_SHRINK, 0, + 0, 0); + + gtk_table_attach (table, middle_label, 2, 3, 2, 3, + GTK_SHRINK, 0, + 0, 0); + + gtk_table_attach (table, nick_label, 3, 4, 2, 3, + GTK_SHRINK, 0, + 0, 0); + + gtk_table_attach (table, last_label, 4, 5, 2, 3, + GTK_SHRINK, 0, + 0, 0); + + gtk_table_attach (table, suffix_label, 5, 6, 2, 3, + GTK_SHRINK, 0, + 0, 0); + + gnome_app_set_contents (GNOME_APP (app), GTK_WIDGET (table)); + + gtk_widget_show_all (app); + + gtk_entry_set_text (GTK_ENTRY (full), + "The Honorable Doctor van Jacobsen, Albert Roderick \"The Clenched Fist\" Jr, MD, PhD, Esquire"); + + name = e_name_western_parse ("The Honorable Doctor van Jacobsen, Albert Roderick \"The Clenched Fist\" Jr, MD, PhD, Esquire"); + fill_entries (); + + gtk_signal_connect (GTK_OBJECT (full), "changed", full_changed_cb, NULL); +} + +int +main (int argc, char **argv) +{ + gnome_init ("Test EName", "Test EName", argc, argv); + + create_window (); + + gtk_main (); + + return 0; +} |