diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-05-23 19:03:09 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-05-23 19:03:09 +0800 |
commit | 54b0b2121cb06e2cd0483a7adf8c4aac86308daf (patch) | |
tree | 632f8a5e6ca40b83e52cb9e6bfcbaeb784060102 | |
parent | cb227b68b34052c2198cddfece3ee6da81a5e13e (diff) | |
download | gsoc2013-evolution-54b0b2121cb06e2cd0483a7adf8c4aac86308daf.tar.gz gsoc2013-evolution-54b0b2121cb06e2cd0483a7adf8c4aac86308daf.tar.zst gsoc2013-evolution-54b0b2121cb06e2cd0483a7adf8c4aac86308daf.zip |
Added e-contact-editor-save-as.c and e-contact-editor-save-as.h.
2000-05-23 Christopher James Lahey <clahey@helixcode.com>
* contact-editor/Makefile.am: Added e-contact-editor-save-as.c and
e-contact-editor-save-as.h.
* contact-editor/e-contact-save-as.c,
contact-editor/e-contact-save-as.h: New files that display a save
as dialog and then save the given card to that file.
* gui/minicard/e-minicard.c: Call e_contact_save_as in a right
click menu.
svn path=/trunk/; revision=3182
-rw-r--r-- | addressbook/ChangeLog | 12 | ||||
-rw-r--r-- | addressbook/contact-editor/Makefile.am | 4 | ||||
-rw-r--r-- | addressbook/contact-editor/e-contact-save-as.c | 74 | ||||
-rw-r--r-- | addressbook/contact-editor/e-contact-save-as.h | 42 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/Makefile.am | 4 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-save-as.c | 74 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-save-as.h | 42 | ||||
-rw-r--r-- | addressbook/gui/minicard/e-minicard.c | 12 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.c | 12 |
9 files changed, 274 insertions, 2 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index a3eb738631..f5a3ccca68 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,15 @@ +2000-05-23 Christopher James Lahey <clahey@helixcode.com> + + * contact-editor/Makefile.am: Added e-contact-editor-save-as.c and + e-contact-editor-save-as.h. + + * contact-editor/e-contact-save-as.c, + contact-editor/e-contact-save-as.h: New files that display a save + as dialog and then save the given card to that file. + + * gui/minicard/e-minicard.c: Call e_contact_save_as in a right + click menu. + 2000-05-19 Christopher James Lahey <clahey@helixcode.com> * contact-editor/e-contact-editor-categories.c, diff --git a/addressbook/contact-editor/Makefile.am b/addressbook/contact-editor/Makefile.am index d3beb08fed..c723ead970 100644 --- a/addressbook/contact-editor/Makefile.am +++ b/addressbook/contact-editor/Makefile.am @@ -19,7 +19,9 @@ libecontacteditor_a_SOURCES = \ e-contact-editor-fullname.c \ e-contact-editor-fullname.h \ e-contact-editor.c \ - e-contact-editor.h + e-contact-editor.h \ + e-contact-save-as.c \ + e-contact-save-as.h noinst_PROGRAMS = \ contact-editor-test diff --git a/addressbook/contact-editor/e-contact-save-as.c b/addressbook/contact-editor/e-contact-save-as.c new file mode 100644 index 0000000000..a8ce68a084 --- /dev/null +++ b/addressbook/contact-editor/e-contact-save-as.c @@ -0,0 +1,74 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* e-contact-editor.h + * Copyright (C) 2000 Helix Code, Inc. + * Author: Chris Lahey <clahey@helixcode.com> + * + * This library 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 library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <e-contact-save-as.h> +#include <e-util/e-util.h> +#include <unistd.h> +#include <fcntl.h> + +typedef struct { + GtkFileSelection *filesel; + ECard *card; +} SaveAsInfo; + +static void +save_it(GtkWidget *widget, SaveAsInfo *info) +{ + char *vcard = e_card_get_vcard(info->card); + const char *filename = gtk_file_selection_get_filename(info->filesel); + e_write_file(filename, vcard, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC); + g_free(vcard); + gtk_object_unref(GTK_OBJECT(info->card)); + gtk_widget_destroy(GTK_WIDGET(info->filesel)); +} + +static void +close_it(GtkWidget *widget, SaveAsInfo *info) +{ + gtk_object_unref(GTK_OBJECT(info->card)); + gtk_widget_destroy(GTK_WIDGET(info->filesel)); +} + +static void +delete_it(GtkWidget *widget, SaveAsInfo *info) +{ + gtk_object_unref(GTK_OBJECT(info->card)); +} + +void +e_contact_save_as(char *title, ECard *card) +{ + GtkFileSelection *filesel; + SaveAsInfo *info = g_new(SaveAsInfo, 1); + + filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title)); + + info->filesel = filesel; + info->card = e_card_duplicate(card); + + gtk_signal_connect(GTK_OBJECT(filesel->ok_button), "clicked", + save_it, info); + gtk_signal_connect(GTK_OBJECT(filesel->cancel_button), "clicked", + close_it, info); + gtk_signal_connect(GTK_OBJECT(filesel), "delete_event", + delete_it, info); + gtk_widget_show(GTK_WIDGET(filesel)); +} diff --git a/addressbook/contact-editor/e-contact-save-as.h b/addressbook/contact-editor/e-contact-save-as.h new file mode 100644 index 0000000000..e6af13e8fd --- /dev/null +++ b/addressbook/contact-editor/e-contact-save-as.h @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* e-contact-save-as.h + * Copyright (C) 2000 Helix Code, Inc. + * Author: Chris Lahey <clahey@helixcode.com> + * + * This library 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 library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#ifndef __E_CONTACT_SAVE_AS_H__ +#define __E_CONTACT_SAVE_AS_H__ + +#include <gnome.h> +#include <glade/glade.h> +#include <ebook/e-card.h> +#include <ebook/e-card-simple.h> + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +void +e_contact_save_as(gchar *title, ECard *card); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __E_CONTACT_EDITOR_H__ */ diff --git a/addressbook/gui/contact-editor/Makefile.am b/addressbook/gui/contact-editor/Makefile.am index d3beb08fed..c723ead970 100644 --- a/addressbook/gui/contact-editor/Makefile.am +++ b/addressbook/gui/contact-editor/Makefile.am @@ -19,7 +19,9 @@ libecontacteditor_a_SOURCES = \ e-contact-editor-fullname.c \ e-contact-editor-fullname.h \ e-contact-editor.c \ - e-contact-editor.h + e-contact-editor.h \ + e-contact-save-as.c \ + e-contact-save-as.h noinst_PROGRAMS = \ contact-editor-test diff --git a/addressbook/gui/contact-editor/e-contact-save-as.c b/addressbook/gui/contact-editor/e-contact-save-as.c new file mode 100644 index 0000000000..a8ce68a084 --- /dev/null +++ b/addressbook/gui/contact-editor/e-contact-save-as.c @@ -0,0 +1,74 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* e-contact-editor.h + * Copyright (C) 2000 Helix Code, Inc. + * Author: Chris Lahey <clahey@helixcode.com> + * + * This library 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 library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <e-contact-save-as.h> +#include <e-util/e-util.h> +#include <unistd.h> +#include <fcntl.h> + +typedef struct { + GtkFileSelection *filesel; + ECard *card; +} SaveAsInfo; + +static void +save_it(GtkWidget *widget, SaveAsInfo *info) +{ + char *vcard = e_card_get_vcard(info->card); + const char *filename = gtk_file_selection_get_filename(info->filesel); + e_write_file(filename, vcard, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC); + g_free(vcard); + gtk_object_unref(GTK_OBJECT(info->card)); + gtk_widget_destroy(GTK_WIDGET(info->filesel)); +} + +static void +close_it(GtkWidget *widget, SaveAsInfo *info) +{ + gtk_object_unref(GTK_OBJECT(info->card)); + gtk_widget_destroy(GTK_WIDGET(info->filesel)); +} + +static void +delete_it(GtkWidget *widget, SaveAsInfo *info) +{ + gtk_object_unref(GTK_OBJECT(info->card)); +} + +void +e_contact_save_as(char *title, ECard *card) +{ + GtkFileSelection *filesel; + SaveAsInfo *info = g_new(SaveAsInfo, 1); + + filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title)); + + info->filesel = filesel; + info->card = e_card_duplicate(card); + + gtk_signal_connect(GTK_OBJECT(filesel->ok_button), "clicked", + save_it, info); + gtk_signal_connect(GTK_OBJECT(filesel->cancel_button), "clicked", + close_it, info); + gtk_signal_connect(GTK_OBJECT(filesel), "delete_event", + delete_it, info); + gtk_widget_show(GTK_WIDGET(filesel)); +} diff --git a/addressbook/gui/contact-editor/e-contact-save-as.h b/addressbook/gui/contact-editor/e-contact-save-as.h new file mode 100644 index 0000000000..e6af13e8fd --- /dev/null +++ b/addressbook/gui/contact-editor/e-contact-save-as.h @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* e-contact-save-as.h + * Copyright (C) 2000 Helix Code, Inc. + * Author: Chris Lahey <clahey@helixcode.com> + * + * This library 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 library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#ifndef __E_CONTACT_SAVE_AS_H__ +#define __E_CONTACT_SAVE_AS_H__ + +#include <gnome.h> +#include <glade/glade.h> +#include <ebook/e-card.h> +#include <ebook/e-card-simple.h> + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +void +e_contact_save_as(gchar *title, ECard *card); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __E_CONTACT_EDITOR_H__ */ diff --git a/addressbook/gui/minicard/e-minicard.c b/addressbook/gui/minicard/e-minicard.c index 0089adb5dd..7831b3152d 100644 --- a/addressbook/gui/minicard/e-minicard.c +++ b/addressbook/gui/minicard/e-minicard.c @@ -29,7 +29,9 @@ #include <e-util/e-canvas.h> #include <e-util/e-util.h> #include <e-util/e-canvas-utils.h> +#include <e-util/e-popup-menu.h> #include "e-contact-editor.h" +#include "e-contact-save-as.h" #include "e-minicard-view.h" static void e_minicard_init (EMinicard *card); @@ -314,6 +316,13 @@ card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status); } +static void +save_as (GtkWidget *widget, EMinicard *minicard) +{ + e_card_simple_sync_card(minicard->simple); + e_contact_save_as(_("Save as VCard"), minicard->card); +} + static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) { @@ -367,6 +376,9 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) case GDK_BUTTON_PRESS: if (event->button.button == 1) { e_canvas_item_grab_focus(item); + } else if (event->button.button == 3) { + EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, {NULL, NULL, NULL, 0} }; + e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); } break; case GDK_2BUTTON_PRESS: diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index 0089adb5dd..7831b3152d 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -29,7 +29,9 @@ #include <e-util/e-canvas.h> #include <e-util/e-util.h> #include <e-util/e-canvas-utils.h> +#include <e-util/e-popup-menu.h> #include "e-contact-editor.h" +#include "e-contact-save-as.h" #include "e-minicard-view.h" static void e_minicard_init (EMinicard *card); @@ -314,6 +316,13 @@ card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status); } +static void +save_as (GtkWidget *widget, EMinicard *minicard) +{ + e_card_simple_sync_card(minicard->simple); + e_contact_save_as(_("Save as VCard"), minicard->card); +} + static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) { @@ -367,6 +376,9 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) case GDK_BUTTON_PRESS: if (event->button.button == 1) { e_canvas_item_grab_focus(item); + } else if (event->button.button == 3) { + EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, {NULL, NULL, NULL, 0} }; + e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); } break; case GDK_2BUTTON_PRESS: |