2
* Copyright (C) 2002 Diego Gonzalez
4
* Written by: Diego Gonzalez <diego@pemas.net>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26
#include <glib/gstdio.h>
28
#include <gconf/gconf-client.h>
30
#include <libebook/e-book.h>
31
#include <dbus/dbus-glib-bindings.h>
33
#define GNOME_DESKTOP_USE_UNSTABLE_API
34
#include <libgnomeui/gnome-desktop-thumbnail.h>
36
#include "e-image-chooser.h"
37
#include "gnome-about-me-password.h"
38
#include "gnome-about-me-fingerprint.h"
41
#include "capplet-util.h"
43
#define MAX_HEIGHT 150
53
GtkWidget *enable_fingerprint_button;
54
GtkWidget *disable_fingerprint_button;
55
GtkWidget *image_chooser;
59
GnomeDesktopThumbnailFactory *thumbs;
61
EContactAddress *addr1;
62
EContactAddress *addr2;
63
gchar *email[EMAIL_SLOTS];
64
const gchar *email_types[EMAIL_SLOTS];
67
gboolean image_changed;
74
guint commit_timeout_id;
77
static GnomeAboutMe *me = NULL;
95
#define ADDRESS_HOME 21
96
#define ADDRESS_WORK 27
98
struct WidToCid ids[] = {
100
{ "email-work-e", 0 }, /* 00 */
101
{ "email-home-e", 1 }, /* 01 */
103
{ "phone-home-e", E_CONTACT_PHONE_HOME }, /* 02 */
104
{ "phone-mobile-e", E_CONTACT_PHONE_MOBILE }, /* 03 */
105
{ "phone-work-e", E_CONTACT_PHONE_BUSINESS }, /* 04 */
106
{ "phone-work-fax-e", E_CONTACT_PHONE_BUSINESS_FAX }, /* 05 */
108
{ "im-jabber-e", E_CONTACT_IM_JABBER_HOME_1 }, /* 06 */
109
{ "im-msn-e", E_CONTACT_IM_MSN_HOME_1 }, /* 07 */
110
{ "im-icq-e", E_CONTACT_IM_ICQ_HOME_1 }, /* 08 */
111
{ "im-yahoo-e", E_CONTACT_IM_YAHOO_HOME_1 }, /* 09 */
112
{ "im-aim-e", E_CONTACT_IM_AIM_HOME_1 }, /* 10 */
113
{ "im-groupwise-e", E_CONTACT_IM_GROUPWISE_HOME_1 }, /* 11 */
115
{ "web-homepage-e", E_CONTACT_HOMEPAGE_URL }, /* 12 */
116
{ "web-calendar-e", E_CONTACT_CALENDAR_URI }, /* 13 */
117
{ "web-weblog-e", E_CONTACT_BLOG_URL }, /* 14 */
119
{ "job-profession-e", E_CONTACT_ROLE }, /* 15 */
120
{ "job-title-e", E_CONTACT_TITLE }, /* 16 */
121
{ "job-dept-e", E_CONTACT_ORG_UNIT }, /* 17 */
122
{ "job-assistant-e", E_CONTACT_ASSISTANT }, /* 18 */
123
{ "job-company-e", E_CONTACT_ORG }, /* 19 */
124
{ "job-manager-e", E_CONTACT_MANAGER }, /* 20 */
126
{ "addr-street-1", ADDRESS_STREET }, /* 21 */
127
{ "addr-po-1", ADDRESS_POBOX }, /* 22 */
128
{ "addr-locality-1", ADDRESS_LOCALITY }, /* 23 */
129
{ "addr-code-1", ADDRESS_CODE }, /* 24 */
130
{ "addr-region-1", ADDRESS_REGION }, /* 25 */
131
{ "addr-country-1", ADDRESS_COUNTRY }, /* 26 */
133
{ "addr-street-2", ADDRESS_STREET }, /* 27 */
134
{ "addr-po-2", ADDRESS_POBOX }, /* 28 */
135
{ "addr-locality-2", ADDRESS_LOCALITY }, /* 29 */
136
{ "addr-code-2", ADDRESS_CODE }, /* 30 */
137
{ "addr-region-2", ADDRESS_REGION }, /* 31 */
138
{ "addr-country-2", ADDRESS_COUNTRY }, /* 32 */
143
#define ATTRIBUTE_HOME "HOME"
144
#define ATTRIBUTE_WORK "WORK"
145
#define ATTRIBUTE_OTHER "OTHER"
147
static void about_me_set_address_field (EContactAddress *, guint, gchar *);
150
/*** Utility functions ***/
152
about_me_error (GtkWindow *parent, gchar *str)
156
dialog = gtk_message_dialog_new (parent,
157
GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
158
GTK_BUTTONS_OK, str);
160
gtk_dialog_run (GTK_DIALOG (dialog));
161
gtk_widget_destroy (dialog);
164
/********************/
166
about_me_destroy (void)
168
e_contact_address_free (me->addr1);
169
e_contact_address_free (me->addr2);
172
g_object_unref (me->contact);
174
g_object_unref (me->book);
176
g_object_unref (me->dialog);
178
g_free (me->email[0]);
179
g_free (me->email[1]);
180
g_free (me->email[2]);
181
g_free (me->email[3]);
185
g_free (me->username);
191
about_me_update_email (GnomeAboutMe *me)
196
for (i = 0; i < EMAIL_SLOTS; ++i) {
197
if (me->email[i] != NULL) {
198
EVCardAttribute *attr;
199
const gchar *type = me->email_types[i];
201
attr = e_vcard_attribute_new (NULL, EVC_EMAIL);
203
e_vcard_attribute_add_param_with_value (attr,
204
e_vcard_attribute_param_new (EVC_TYPE),
205
type ? type : ATTRIBUTE_OTHER);
207
e_vcard_attribute_add_value (attr, me->email[i]);
208
attrs = g_list_append (attrs, attr);
212
e_contact_set_attributes (me->contact, E_CONTACT_EMAIL, attrs);
214
g_list_foreach (attrs, (GFunc) e_vcard_attribute_free, NULL);
219
about_me_commit (GnomeAboutMe *me)
223
char *strings[4], **stringptr;
228
if (me->create_self) {
229
if (me->username == NULL)
230
fileas = g_strdup ("Myself");
232
name = e_contact_name_from_string (me->username);
235
if (name->family && *name->family)
236
*(stringptr++) = name->family;
237
if (name->given && *name->given)
238
*(stringptr++) = name->given;
240
fileas = g_strjoinv (", ", strings);
243
e_contact_set (me->contact, E_CONTACT_FILE_AS, fileas);
244
e_contact_set (me->contact, E_CONTACT_NICKNAME, me->login);
245
e_contact_set (me->contact, E_CONTACT_FULL_NAME, me->username);
247
e_contact_name_free (name);
251
about_me_update_email (me);
253
if (me->create_self) {
254
e_book_add_contact (me->book, me->contact, NULL);
255
e_book_set_self (me->book, me->contact, NULL);
257
if (!e_book_commit_contact (me->book, me->contact, NULL))
258
g_warning ("Could not save contact information");
261
me->create_self = FALSE;
265
about_me_commit_from_timeout (GnomeAboutMe *me)
267
about_me_commit (me);
273
about_me_focus_out (GtkWidget *widget, GdkEventFocus *event, GnomeAboutMe *unused)
282
wid = gtk_buildable_get_name (GTK_BUILDABLE (widget));
287
for (i = 0; ids[i].wid != NULL; i++)
288
if (strcmp (ids[i].wid, wid) == 0)
291
if (GTK_IS_ENTRY (widget)) {
292
str = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
293
} else if (GTK_IS_TEXT_VIEW (widget)) {
294
GtkTextBuffer *buffer;
295
GtkTextIter iter_start;
296
GtkTextIter iter_end;
298
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
299
gtk_text_buffer_get_start_iter (buffer, &iter_start);
300
iter_end = iter_start;
301
gtk_text_iter_forward_to_end (&iter_end);
302
str = gtk_text_iter_get_text (&iter_start, &iter_end);
307
if (i == EMAIL_HOME || i == EMAIL_WORK) {
309
g_free (me->email[ids[i].cid]);
311
me->email[ids[i].cid] = NULL;
313
me->email[ids[i].cid] = g_strdup (str);
314
me->email_types[ids[i].cid] = (i == EMAIL_HOME) ? ATTRIBUTE_HOME : ATTRIBUTE_WORK;
315
/* FIXME: i'm getting an empty address field in evolution */
316
} else if (i >= ADDRESS_HOME && i < ADDRESS_WORK) {
317
about_me_set_address_field (me->addr1, ids[i].cid, str);
318
e_contact_set (me->contact, E_CONTACT_ADDRESS_HOME, me->addr1);
319
} else if (i >= ADDRESS_WORK) {
320
about_me_set_address_field (me->addr2, ids[i].cid, str);
321
e_contact_set (me->contact, E_CONTACT_ADDRESS_WORK, me->addr2);
323
e_contact_set (me->contact, ids[i].cid, str);
328
if (me->commit_timeout_id) {
329
g_source_remove (me->commit_timeout_id);
332
me->commit_timeout_id = g_timeout_add (600, (GSourceFunc) about_me_commit_from_timeout, me);
342
about_me_get_address_field (EContactAddress *addr, guint cid)
357
case ADDRESS_LOCALITY:
358
str = addr->locality;
366
case ADDRESS_COUNTRY:
378
about_me_set_address_field (EContactAddress *addr, guint cid, gchar *str)
382
g_free (addr->street);
383
addr->street = g_strdup (str);
387
addr->po = g_strdup (str);
389
case ADDRESS_LOCALITY:
390
g_free (addr->locality);
391
addr->locality = g_strdup (str);
395
addr->code = g_strdup (str);
398
g_free (addr->region);
399
addr->region = g_strdup (str);
401
case ADDRESS_COUNTRY:
402
g_free (addr->country);
403
addr->country = g_strdup (str);
409
about_me_setup_email (GnomeAboutMe *me)
412
gboolean has_home = FALSE, has_work = FALSE;
415
attrs = e_contact_get_attributes (me->contact, E_CONTACT_EMAIL);
417
for (la = attrs, i = 0; la; la = la->next, ++i) {
418
EVCardAttribute *a = la->data;
420
me->email[i] = e_vcard_attribute_get_value (a);
421
if (e_vcard_attribute_has_type (a, ATTRIBUTE_HOME)) {
422
me->email_types[i] = ATTRIBUTE_HOME;
424
ids[EMAIL_HOME].cid = i;
427
} else if (e_vcard_attribute_has_type (a, ATTRIBUTE_WORK)) {
428
me->email_types[i] = ATTRIBUTE_WORK;
430
ids[EMAIL_WORK].cid = i;
434
me->email_types[i] = ATTRIBUTE_OTHER;
437
e_vcard_attribute_free (a);
442
if (ids[EMAIL_HOME].cid == ids[EMAIL_WORK].cid) {
444
ids[EMAIL_WORK].cid = 1;
446
ids[EMAIL_HOME].cid = 0;
449
me->email_types[ids[EMAIL_WORK].cid] = ATTRIBUTE_WORK;
450
me->email_types[ids[EMAIL_HOME].cid] = ATTRIBUTE_HOME;
454
* about_me_load_string_field:
456
* wid: UI widget name
457
* cid: id of the field (EDS id)
458
* aid: position in the array WidToCid
462
about_me_load_string_field (GnomeAboutMe *me, const gchar *wid, guint cid, guint aid)
472
if (me->create_self == TRUE) {
473
g_signal_connect (widget, "focus-out-event", G_CALLBACK (about_me_focus_out), me);
477
if (aid == EMAIL_HOME || aid == EMAIL_WORK) {
478
str = e_contact_get_const (me->contact, E_CONTACT_EMAIL_1 + cid);
479
} else if (aid >= ADDRESS_HOME && aid < ADDRESS_WORK) {
480
str = about_me_get_address_field (me->addr1, cid);
481
} else if (aid >= ADDRESS_WORK) {
482
str = about_me_get_address_field (me->addr2, cid);
484
str = e_contact_get_const (me->contact, cid);
487
str = str ? str : "";
489
if (GTK_IS_ENTRY (widget)) {
490
gtk_entry_set_text (GTK_ENTRY (widget), str);
491
} else if (GTK_IS_TEXT_VIEW (widget)) {
492
GtkTextBuffer *buffer;
494
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
495
gtk_text_buffer_set_text (buffer, str, -1);
498
g_signal_connect (widget, "focus-out-event", G_CALLBACK (about_me_focus_out), me);
502
about_me_load_photo (GnomeAboutMe *me, EContact *contact)
505
EContactPhoto *photo;
510
e_image_chooser_set_from_file (E_IMAGE_CHOOSER (me->image_chooser), me->person);
512
photo = e_contact_get (contact, E_CONTACT_PHOTO);
514
if (photo && photo->type == E_CONTACT_PHOTO_TYPE_INLINED) {
515
me->have_image = TRUE;
516
e_image_chooser_set_image_data (E_IMAGE_CHOOSER (me->image_chooser),
517
(char *) photo->data.inlined.data, photo->data.inlined.length);
518
e_contact_photo_free (photo);
520
me->have_image = FALSE;
525
about_me_update_photo (GnomeAboutMe *me)
528
EContactPhoto *photo;
538
if (me->image_changed && me->have_image) {
539
GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
540
GdkPixbuf *pixbuf, *scaled;
542
gboolean do_scale = FALSE;
545
e_image_chooser_get_image_data (E_IMAGE_CHOOSER (me->image_chooser), (char **) &data, &length);
547
/* Before updating the image in EDS scale it to a reasonable size
548
so that the user doesn't get an application that does not respond
549
or that takes 100% CPU */
550
gdk_pixbuf_loader_write (loader, data, length, NULL);
551
gdk_pixbuf_loader_close (loader, NULL);
553
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
556
g_object_ref (pixbuf);
558
g_object_unref (loader);
560
height = gdk_pixbuf_get_height (pixbuf);
561
width = gdk_pixbuf_get_width (pixbuf);
563
if (height >= width && height > MAX_HEIGHT) {
564
scale = (float)MAX_HEIGHT/height;
566
} else if (width > height && width > MAX_WIDTH) {
567
scale = (float)MAX_WIDTH/width;
572
char *scaled_data = NULL;
575
scaled = gdk_pixbuf_scale_simple (pixbuf, width*scale, height*scale, GDK_INTERP_BILINEAR);
576
gdk_pixbuf_save_to_buffer (scaled, &scaled_data, &scaled_length, "png", NULL,
577
"compression", "9", NULL);
580
data = (guchar *) scaled_data;
581
length = scaled_length;
584
photo = g_new0 (EContactPhoto, 1);
585
photo->type = E_CONTACT_PHOTO_TYPE_INLINED;
586
photo->data.inlined.data = data;
587
photo->data.inlined.length = length;
588
e_contact_set (me->contact, E_CONTACT_PHOTO, photo);
590
/* Save the image for GDM */
591
/* FIXME: I would have to read the default used by the gdmgreeter program */
593
file = g_build_filename (g_get_home_dir (), ".face", NULL);
594
if (g_file_set_contents (file,
595
(gchar *) photo->data.inlined.data,
596
photo->data.inlined.length,
598
g_chmod (file, 0644);
600
g_warning ("Could not create %s: %s", file, error->message);
601
g_error_free (error);
606
e_contact_photo_free (photo);
608
} else if (me->image_changed && !me->have_image) {
609
/* Update the image in the card */
610
e_contact_set (me->contact, E_CONTACT_PHOTO, NULL);
612
file = g_build_filename (g_get_home_dir (), ".face", NULL);
619
about_me_commit (me);
623
about_me_load_info (GnomeAboutMe *me)
627
if (me->create_self == FALSE) {
628
me->addr1 = e_contact_get (me->contact, E_CONTACT_ADDRESS_HOME);
629
if (me->addr1 == NULL)
630
me->addr1 = g_new0 (EContactAddress, 1);
631
me->addr2 = e_contact_get (me->contact, E_CONTACT_ADDRESS_WORK);
632
if (me->addr2 == NULL)
633
me->addr2 = g_new0 (EContactAddress, 1);
635
me->addr1 = g_new0 (EContactAddress, 1);
636
me->addr2 = g_new0 (EContactAddress, 1);
639
for (i = 0; ids[i].wid != NULL; i++) {
640
about_me_load_string_field (me, ids[i].wid, ids[i].cid, i);
643
set_fingerprint_label (me->enable_fingerprint_button,
644
me->disable_fingerprint_button);
648
about_me_update_preview (GtkFileChooser *chooser,
653
uri = gtk_file_chooser_get_preview_uri (chooser);
657
GdkPixbuf *pixbuf = NULL;
659
GFileInfo *file_info;
662
me->thumbs = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
664
file = g_file_new_for_uri (uri);
665
file_info = g_file_query_info (file,
666
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
667
G_FILE_QUERY_INFO_NONE,
669
g_object_unref (file);
671
if (file_info != NULL) {
672
const gchar *content_type;
674
content_type = g_file_info_get_content_type (file_info);
678
mime_type = g_content_type_get_mime_type (content_type);
680
pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (me->thumbs,
685
g_object_unref (file_info);
688
image = gtk_file_chooser_get_preview_widget (chooser);
690
if (pixbuf != NULL) {
691
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
692
g_object_unref (pixbuf);
694
gtk_image_set_from_stock (GTK_IMAGE (image),
695
"gtk-dialog-question",
696
GTK_ICON_SIZE_DIALOG);
699
gtk_file_chooser_set_preview_widget_active (chooser, TRUE);
703
about_me_image_clicked_cb (GtkWidget *button, GnomeAboutMe *me)
705
GtkFileChooser *chooser_dialog;
709
const gchar *chooser_dir = DATADIR"/pixmaps/faces";
710
const gchar *pics_dir;
711
GtkFileFilter *filter;
715
chooser_dialog = GTK_FILE_CHOOSER (
716
gtk_file_chooser_dialog_new (_("Select Image"), GTK_WINDOW (WID ("about-me-dialog")),
717
GTK_FILE_CHOOSER_ACTION_OPEN,
718
_("No Image"), GTK_RESPONSE_NO,
719
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
720
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
722
gtk_window_set_modal (GTK_WINDOW (chooser_dialog), TRUE);
723
gtk_dialog_set_default_response (GTK_DIALOG (chooser_dialog), GTK_RESPONSE_ACCEPT);
725
gtk_file_chooser_add_shortcut_folder (chooser_dialog, chooser_dir, NULL);
726
pics_dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
727
if (pics_dir != NULL)
728
gtk_file_chooser_add_shortcut_folder (chooser_dialog, pics_dir, NULL);
730
if (!g_file_test (chooser_dir, G_FILE_TEST_IS_DIR))
731
chooser_dir = g_get_home_dir ();
733
gtk_file_chooser_set_current_folder (chooser_dialog, chooser_dir);
734
gtk_file_chooser_set_use_preview_label (chooser_dialog, FALSE);
736
image = gtk_image_new ();
737
gtk_file_chooser_set_preview_widget (chooser_dialog, image);
738
gtk_widget_set_size_request (image, 128, -1);
740
gtk_widget_show (image);
742
g_signal_connect (chooser_dialog, "update-preview",
743
G_CALLBACK (about_me_update_preview), me);
745
filter = gtk_file_filter_new ();
746
gtk_file_filter_set_name (filter, _("Images"));
747
gtk_file_filter_add_pixbuf_formats (filter);
748
gtk_file_chooser_add_filter (chooser_dialog, filter);
749
filter = gtk_file_filter_new ();
750
gtk_file_filter_set_name (filter, _("All Files"));
751
gtk_file_filter_add_pattern(filter, "*");
752
gtk_file_chooser_add_filter (chooser_dialog, filter);
754
response = gtk_dialog_run (GTK_DIALOG (chooser_dialog));
756
if (response == GTK_RESPONSE_ACCEPT) {
759
filename = gtk_file_chooser_get_filename (chooser_dialog);
760
me->have_image = TRUE;
761
me->image_changed = TRUE;
763
e_image_chooser_set_from_file (E_IMAGE_CHOOSER (me->image_chooser), filename);
765
about_me_update_photo (me);
766
} else if (response == GTK_RESPONSE_NO) {
767
me->have_image = FALSE;
768
me->image_changed = TRUE;
769
e_image_chooser_set_from_file (E_IMAGE_CHOOSER (me->image_chooser), me->person);
770
about_me_update_photo (me);
773
gtk_widget_destroy (GTK_WIDGET (chooser_dialog));
777
about_me_image_changed_cb (GtkWidget *widget, GnomeAboutMe *me)
779
me->have_image = TRUE;
780
me->image_changed = TRUE;
781
about_me_update_photo (me);
784
/* About Me Dialog Callbacks */
787
about_me_icon_theme_changed (GtkWindow *window,
792
icon = gtk_icon_theme_lookup_icon (me->theme, "stock_person", 80, 0);
794
g_debug ("Icon not found");
797
me->person = g_strdup (gtk_icon_info_get_filename (icon));
799
gtk_icon_info_free (icon);
802
e_image_chooser_set_from_file (E_IMAGE_CHOOSER (me->image_chooser), me->person);
806
about_me_button_clicked_cb (GtkDialog *dialog, gint response_id, GnomeAboutMe *me)
808
if (response_id == GTK_RESPONSE_HELP)
809
g_print ("Help goes here");
811
if (me->commit_timeout_id) {
812
g_source_remove (me->commit_timeout_id);
813
about_me_commit (me);
822
about_me_passwd_clicked_cb (GtkWidget *button, GnomeAboutMe *me)
827
gnome_about_me_password (GTK_WINDOW (WID ("about-me-dialog")));
831
about_me_fingerprint_button_clicked_cb (GtkWidget *button, GnomeAboutMe *me)
833
fingerprint_button_clicked (me->dialog,
834
me->enable_fingerprint_button,
835
me->disable_fingerprint_button);
839
about_me_setup_dialog (void)
842
GtkWidget *main_dialog;
845
GError *error = NULL;
849
me = g_new0 (GnomeAboutMe, 1);
851
dialog = gtk_builder_new ();
852
gtk_builder_add_from_file (dialog, GNOMECC_UI_DIR "/gnome-about-me-dialog.ui", NULL);
854
me->image_chooser = e_image_chooser_new ();
855
gtk_container_add (GTK_CONTAINER (WID ("button-image")), me->image_chooser);
857
if (dialog == NULL) {
864
/* Connect the close button signal */
865
main_dialog = WID ("about-me-dialog");
866
g_signal_connect (main_dialog, "response",
867
G_CALLBACK (about_me_button_clicked_cb), me);
869
gtk_window_set_resizable (GTK_WINDOW (main_dialog), FALSE);
870
capplet_set_icon (main_dialog, "user-info");
872
/* Setup theme details */
873
me->screen = gtk_window_get_screen (GTK_WINDOW (main_dialog));
874
me->theme = gtk_icon_theme_get_for_screen (me->screen);
876
icon = gtk_icon_theme_lookup_icon (me->theme, "stock_person", 80, 0);
878
me->person = g_strdup (gtk_icon_info_get_filename (icon));
879
gtk_icon_info_free (icon);
882
g_signal_connect_object (me->theme, "changed",
883
G_CALLBACK (about_me_icon_theme_changed),
887
/* Get the self contact */
888
if (!e_book_get_self (&me->contact, &me->book, &error)) {
889
if (error->code == E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED) {
890
about_me_error (NULL, _("There was an error while trying to get the addressbook information\n" \
891
"Evolution Data Server can't handle the protocol"));
892
g_clear_error (&error);
897
g_clear_error (&error);
899
me->create_self = TRUE;
900
me->contact = e_contact_new ();
902
if (me->book == NULL) {
903
me->book = e_book_new_system_addressbook (&error);
904
if (me->book == NULL || error != NULL) {
905
g_error ("%s", error->message);
906
g_clear_error (&error);
909
if (e_book_open (me->book, FALSE, NULL) == FALSE) {
910
about_me_error (GTK_WINDOW (main_dialog),
911
_("Unable to open address book"));
912
g_clear_error (&error);
916
about_me_setup_email (me);
919
me->login = g_strdup (g_get_user_name ());
920
me->username = g_strdup (g_get_real_name ());
923
about_me_load_photo (me, me->contact);
925
widget = WID ("fullname");
926
str = g_strdup_printf ("<b><span size=\"xx-large\">%s</span></b>", me->username);
928
gtk_label_set_markup (GTK_LABEL (widget), str);
931
widget = WID ("login");
932
gtk_label_set_text (GTK_LABEL (widget), me->login);
934
str = g_strdup_printf (_("About %s"), me->username);
935
gtk_window_set_title (GTK_WINDOW (main_dialog), str);
938
widget = WID ("password");
939
g_signal_connect (widget, "clicked",
940
G_CALLBACK (about_me_passwd_clicked_cb), me);
942
widget = WID ("button-image");
943
g_signal_connect (widget, "clicked",
944
G_CALLBACK (about_me_image_clicked_cb), me);
946
me->enable_fingerprint_button = WID ("enable_fingerprint_button");
947
me->disable_fingerprint_button = WID ("disable_fingerprint_button");
949
g_signal_connect (me->enable_fingerprint_button, "clicked",
950
G_CALLBACK (about_me_fingerprint_button_clicked_cb), me);
951
g_signal_connect (me->disable_fingerprint_button, "clicked",
952
G_CALLBACK (about_me_fingerprint_button_clicked_cb), me);
954
g_signal_connect (me->image_chooser, "changed",
955
G_CALLBACK (about_me_image_changed_cb), me);
957
/* Address tab: set up the focus chains */
958
chain = g_list_prepend (NULL, WID ("addr-country-1"));
959
chain = g_list_prepend (chain, WID ("addr-po-1"));
960
chain = g_list_prepend (chain, WID ("addr-region-1"));
961
chain = g_list_prepend (chain, WID ("addr-code-1"));
962
chain = g_list_prepend (chain, WID ("addr-locality-1"));
963
chain = g_list_prepend (chain, WID ("addr-scrolledwindow-1"));
964
widget = WID ("addr-table-1");
965
gtk_container_set_focus_chain (GTK_CONTAINER (widget), chain);
968
chain = g_list_prepend (NULL, WID ("addr-country-2"));
969
chain = g_list_prepend (chain, WID ("addr-po-2"));
970
chain = g_list_prepend (chain, WID ("addr-region-2"));
971
chain = g_list_prepend (chain, WID ("addr-code-2"));
972
chain = g_list_prepend (chain, WID ("addr-locality-2"));
973
chain = g_list_prepend (chain, WID ("addr-scrolledwindow-2"));
974
widget = WID ("addr-table-2");
975
gtk_container_set_focus_chain (GTK_CONTAINER (widget), chain);
978
about_me_load_info (me);
980
gtk_widget_show_all (main_dialog);
986
main (int argc, char **argv)
990
capplet_init (NULL, &argc, &argv);
992
if (!g_thread_supported ())
993
g_thread_init (NULL);
995
dbus_g_object_register_marshaller (fprintd_marshal_VOID__STRING_BOOLEAN,
996
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID);
998
rc = about_me_setup_dialog ();