Files
evolution/tools/evolution-addressbook-import.c
Ettore Perazzoli 1d9a3023e5 #include bonobo-activation instead of oaf. (main): Initialize using
* tools/evolution-addressbook-export.c: #include bonobo-activation
instead of oaf.
(main): Initialize using gnome_program_init().
(save_cards): Use g_main_loop_quit() instead of gtk_exit().

* tools/evolution-addressbook-import.c: Update include list for
GNOME 2.
(main): Initialize using gnome_program_init().
(unref_executable): Use g_main_loop_quit() instead of gtk_exit().
(add_cb): Likewise.

* tools/evolution-addressbook-abuse.c: Update include list for
GNOME 2.
(main): Initialize using gnome_program_init().
(use_addressbook): Use g_object_unref() instead of
gtk_object_unref().
(main): Use g_timeout_add() instead of gtk_timeout_add().
(add_cb): Use g_main_loop_quit() instead of gtk_exit().

* configure.in (AC_SUBST): Add tools/Makefile.

* Makefile.am (SUBDIRS): Add tools/ back into the list.

* tools/Makefile.am: Install everything in
$(datadir)/evolution-$(BASE_VERSION)/tools.
(INCLUDES): Add the defines that gnome_program_init() likes and
also add the _DISABLE_DEPRECATED stuff.

svn path=/trunk/; revision=19656
2003-01-27 18:54:56 +00:00

91 lines
1.7 KiB
C

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#include <config.h>
#include <bonobo-activation/bonobo-activation.h>
#include <bonobo/bonobo-main.h>
#include <backend/ebook/e-book-util.h>
#include <gnome.h>
static int exec_ref_count = 0;
static void
ref_executable (void)
{
exec_ref_count ++;
}
static void
unref_executable (void)
{
exec_ref_count --;
if (exec_ref_count == 0)
g_main_loop_quit (0);
}
static void
add_cb (EBook *book, EBookStatus status, const char *id, gpointer closure)
{
switch (status) {
case E_BOOK_STATUS_SUCCESS:
unref_executable ();
break;
default:
g_main_loop_quit (NULL);
break;
}
}
static void
use_addressbook (EBook *book, gpointer closure)
{
GList *cards, *list;
char *filename = closure;
if (book == NULL)
g_error (_("Error loading default addressbook."));
cards = e_card_load_cards_from_file (filename);
ref_executable ();
for (list = cards; list; list = list->next) {
ref_executable ();
e_book_add_card (book, list->data, add_cb, closure);
}
sync();
unref_executable ();
}
int
main (int argc, char *argv[])
{
char *filename = NULL;
struct poptOption options[] = {
{ "input-file", '\0', POPT_ARG_STRING, &filename, 0, N_("Input File"), NULL },
POPT_AUTOHELP
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
};
bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
textdomain (PACKAGE);
gnome_program_init ("evolution-addressbook-import", VERSION,
LIBGNOMEUI_MODULE, argc, argv,
GNOME_PROGRAM_STANDARD_PROPERTIES,
GNOME_PARAM_POPT_TABLE, options,
NULL);
if (filename == NULL) {
g_error (_("No filename provided."));
}
e_book_use_default_book (use_addressbook, filename);
bonobo_main ();
return 0;
}