diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-10-15 23:18:40 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-10-15 23:18:40 +0800 |
commit | 40ee8894e9bd85cac5b311472481fd8b56de9fec (patch) | |
tree | 4419ab77c47430c4808b84bb72f08423a250fbc8 /addressbook | |
parent | 835ad7ba36543b90ce1b1c87f526c5164331c55e (diff) | |
download | gsoc2013-evolution-40ee8894e9bd85cac5b311472481fd8b56de9fec.tar gsoc2013-evolution-40ee8894e9bd85cac5b311472481fd8b56de9fec.tar.gz gsoc2013-evolution-40ee8894e9bd85cac5b311472481fd8b56de9fec.tar.bz2 gsoc2013-evolution-40ee8894e9bd85cac5b311472481fd8b56de9fec.tar.lz gsoc2013-evolution-40ee8894e9bd85cac5b311472481fd8b56de9fec.tar.xz gsoc2013-evolution-40ee8894e9bd85cac5b311472481fd8b56de9fec.tar.zst gsoc2013-evolution-40ee8894e9bd85cac5b311472481fd8b56de9fec.zip |
Set the default file name here. Fixes Ximian bug #7053.
2001-10-15 Christopher James Lahey <clahey@ximian.com>
* gui/contact-editor/e-contact-save-as.c (e_contact_save_as,
e_contact_list_save_as): Set the default file name here. Fixes
Ximian bug #7053.
svn path=/trunk/; revision=13674
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 6 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-save-as.c | 59 |
2 files changed, 61 insertions, 4 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index b025846728..da799615e8 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,9 @@ +2001-10-15 Christopher James Lahey <clahey@ximian.com> + + * gui/contact-editor/e-contact-save-as.c (e_contact_save_as, + e_contact_list_save_as): Set the default file name here. Fixes + Ximian bug #7053. + 2001-10-14 Jon Trowbridge <trow@ximian.com> * gui/component/select-names/e-select-names.c diff --git a/addressbook/gui/contact-editor/e-contact-save-as.c b/addressbook/gui/contact-editor/e-contact-save-as.c index 35247edbfc..9ca7d844e8 100644 --- a/addressbook/gui/contact-editor/e-contact-save-as.c +++ b/addressbook/gui/contact-editor/e-contact-save-as.c @@ -20,6 +20,9 @@ */ #include <config.h> + +#include "e-contact-save-as.h" + #include <unistd.h> #include <fcntl.h> #include <gtk/gtkfilesel.h> @@ -28,8 +31,8 @@ #include <libgnomeui/gnome-dialog.h> #include <gal/util/e-util.h> #include <libgnome/gnome-i18n.h> -#include "e-contact-save-as.h" #include <errno.h> +#include <string.h> static int file_exists(GtkFileSelection *filesel, const char *filename); @@ -79,17 +82,49 @@ delete_it(GtkWidget *widget, SaveAsInfo *info) g_free (info); } +static char * +make_safe_filename (const char *prefix, char *name) +{ + char *safe, *p; + + if (!name) { + /* This is a filename. Translators take note. */ + name = _("card.vcf"); + } + + p = strrchr (name, '/'); + if (p) + safe = g_strdup_printf ("%s%s%s", prefix, p, ".vcf"); + else + safe = g_strdup_printf ("%s/%s%s", prefix, name, ".vcf"); + + p = strrchr (safe, '/') + 1; + if (p) + e_filename_make_safe (p); + + return safe; +} + void e_contact_save_as(char *title, ECard *card) { GtkFileSelection *filesel; + char *file; + char *name; SaveAsInfo *info = g_new(SaveAsInfo, 1); - + filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title)); + gtk_object_get (GTK_OBJECT (card), + "file_as", &name, + NULL); + file = make_safe_filename (g_get_home_dir(), name); + gtk_file_selection_set_filename (filesel, file); + g_free (file); + info->filesel = filesel; info->vcard = e_card_get_vcard(card); - + gtk_signal_connect(GTK_OBJECT(filesel->ok_button), "clicked", save_it, info); gtk_signal_connect(GTK_OBJECT(filesel->cancel_button), "clicked", @@ -104,9 +139,25 @@ e_contact_list_save_as(char *title, GList *list) { GtkFileSelection *filesel; SaveAsInfo *info = g_new(SaveAsInfo, 1); - + filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title)); + /* This is a filename. Translators take note. */ + if (list && list->data && list->next == NULL) { + char *name, *file; + gtk_object_get (GTK_OBJECT (list->data), + "file_as", &name, + NULL); + file = make_safe_filename (g_get_home_dir(), name); + gtk_file_selection_set_filename (filesel, file); + g_free (file); + } else { + char *file; + file = make_safe_filename (g_get_home_dir(), _("list")); + gtk_file_selection_set_filename (filesel, file); + g_free (file); + } + info->filesel = filesel; info->vcard = e_card_list_get_vcard (list); |