aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-09-18 00:55:16 +0800
committerChris Lahey <clahey@src.gnome.org>2000-09-18 00:55:16 +0800
commit7912355008d54df720894d1334313801f594c8f2 (patch)
treefa34064a7066b77dbdf7762c620eb5b9b689f0c6
parent4f04a07954d6d577dfd99fbb85fe60db5873d137 (diff)
downloadgsoc2013-evolution-7912355008d54df720894d1334313801f594c8f2.tar
gsoc2013-evolution-7912355008d54df720894d1334313801f594c8f2.tar.gz
gsoc2013-evolution-7912355008d54df720894d1334313801f594c8f2.tar.bz2
gsoc2013-evolution-7912355008d54df720894d1334313801f594c8f2.tar.lz
gsoc2013-evolution-7912355008d54df720894d1334313801f594c8f2.tar.xz
gsoc2013-evolution-7912355008d54df720894d1334313801f594c8f2.tar.zst
gsoc2013-evolution-7912355008d54df720894d1334313801f594c8f2.zip
Fixed the paths of some .h #includes.
2000-09-15 Christopher James Lahey <clahey@helixcode.com> * contact-editor/e-contact-editor.h, contact-editor/e-contact-save-as.h, gui/widgets/e-addressbook-model.h, gui/widgets/e-minicard-view-widget.h, gui/widgets/e-minicard-view.h, gui/widgets/e-minicard.c, gui/widgets/e-minicard.h: Fixed the paths of some .h #includes. * gui/component/addressbook.c: Removed all of the code to actually create and display the correct view of the addressbook and moved it to the new class gui/widgets/e-addressbook-view.c. * gui/widgets/Makefile.am: Added everything necessary for e-addressbook-view.c and e-addressbook-view.h. * gui/widgets/e-addressbook-view.c, gui/widgets/e-addressbook-view.h: New class to deal with actual display of addresses and switching between card view and table view. * gui/widgets/e-minicard-view-widget.c: Made this deal more gracefully with having the book set to NULL. svn path=/trunk/; revision=5475
-rw-r--r--addressbook/ChangeLog24
-rw-r--r--addressbook/contact-editor/e-contact-editor.h4
-rw-r--r--addressbook/contact-editor/e-contact-save-as.h4
-rw-r--r--addressbook/gui/component/addressbook.c598
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h4
-rw-r--r--addressbook/gui/contact-editor/e-contact-save-as.h4
-rw-r--r--addressbook/gui/widgets/Makefile.am9
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.h6
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c709
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.h88
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.c11
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.h2
-rw-r--r--addressbook/gui/widgets/e-minicard-view.h4
-rw-r--r--addressbook/gui/widgets/e-minicard.c2
-rw-r--r--addressbook/gui/widgets/e-minicard.h4
15 files changed, 914 insertions, 559 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index fe49daef7b..062ded4a3d 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,27 @@
+2000-09-15 Christopher James Lahey <clahey@helixcode.com>
+
+ * contact-editor/e-contact-editor.h,
+ contact-editor/e-contact-save-as.h,
+ gui/widgets/e-addressbook-model.h,
+ gui/widgets/e-minicard-view-widget.h,
+ gui/widgets/e-minicard-view.h, gui/widgets/e-minicard.c,
+ gui/widgets/e-minicard.h: Fixed the paths of some .h #includes.
+
+ * gui/component/addressbook.c: Removed all of the code to actually
+ create and display the correct view of the addressbook and moved
+ it to the new class gui/widgets/e-addressbook-view.c.
+
+ * gui/widgets/Makefile.am: Added everything necessary for
+ e-addressbook-view.c and e-addressbook-view.h.
+
+ * gui/widgets/e-addressbook-view.c,
+ gui/widgets/e-addressbook-view.h: New class to deal with actual
+ display of addresses and switching between card view and table
+ view.
+
+ * gui/widgets/e-minicard-view-widget.c: Made this deal more
+ gracefully with having the book set to NULL.
+
2000-09-16 Michael Meeks <michael@helixcode.com>
* gui/component/select-names/e-select-names.c: fix broken include.
diff --git a/addressbook/contact-editor/e-contact-editor.h b/addressbook/contact-editor/e-contact-editor.h
index de14b84ca3..4e47b5bd93 100644
--- a/addressbook/contact-editor/e-contact-editor.h
+++ b/addressbook/contact-editor/e-contact-editor.h
@@ -24,8 +24,8 @@
#include <gnome.h>
#include <glade/glade.h>
#include <bonobo.h>
-#include <ebook/e-card.h>
-#include <ebook/e-card-simple.h>
+#include "addressbook/backend/ebook/e-card.h"
+#include "addressbook/backend/ebook/e-card-simple.h"
#ifdef __cplusplus
extern "C" {
diff --git a/addressbook/contact-editor/e-contact-save-as.h b/addressbook/contact-editor/e-contact-save-as.h
index e6af13e8fd..d1c84dc596 100644
--- a/addressbook/contact-editor/e-contact-save-as.h
+++ b/addressbook/contact-editor/e-contact-save-as.h
@@ -23,8 +23,8 @@
#include <gnome.h>
#include <glade/glade.h>
-#include <ebook/e-card.h>
-#include <ebook/e-card-simple.h>
+#include "addressbook/backend/ebook/e-card.h"
+#include "addressbook/backend/ebook/e-card-simple.h"
#ifdef __cplusplus
extern "C" {
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 77f3d12891..bf66bbde2e 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -18,27 +18,17 @@
#include <ebook/e-book.h>
#include <e-util/e-util.h>
-#include <e-util/e-popup-menu.h>
#include <e-util/e-unicode.h>
-#include "addressbook/gui/widgets/e-minicard-view-widget.h"
#include "addressbook/gui/search/e-addressbook-search-dialog.h"
-#include <e-table.h>
-#include <e-cell-text.h>
+#include "addressbook/gui/widgets/e-addressbook-view.h"
-#include <e-scroll-frame.h>
-
-#include <addressbook/gui/widgets/e-addressbook-model.h>
#include <select-names/e-select-names.h>
#include <select-names/e-select-names-manager.h>
#include "e-contact-editor.h"
#include "e-contact-save-as.h"
#include "e-ldap-server-dialog.h"
-#include <libgnomeprint/gnome-print.h>
-#include <libgnomeprint/gnome-print-dialog.h>
-#include <libgnomeprint/gnome-print-master.h>
-#include <libgnomeprint/gnome-print-master-preview.h>
#include <addressbook/printing/e-contact-print.h>
@@ -48,28 +38,15 @@
#define PROPERTY_FOLDER_URI_IDX 1
-typedef enum {
- ADDRESSBOOK_VIEW_NONE, /* initialized to this */
- ADDRESSBOOK_VIEW_TABLE,
- ADDRESSBOOK_VIEW_MINICARD
-} AddressbookViewType;
-
typedef struct {
- AddressbookViewType view_type;
- EBook *book;
+ EAddressbookView *view;
GtkWidget *vbox;
- GtkWidget *minicard_hbox;
- GtkWidget *minicard_view;
- GtkWidget *table;
- ETableModel *model;
- ECardSimple *simple;
- GtkAllocation last_alloc;
BonoboControl *control;
BonoboPropertyBag *properties;
char *uri;
} AddressbookView;
-static void change_view_type (AddressbookView *view, AddressbookViewType view_type);
+static void change_view_type (AddressbookView *view, EAddressbookViewType view_type);
static void
control_deactivate (BonoboControl *control, BonoboUIHandler *uih)
@@ -141,16 +118,13 @@ new_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path)
EBook *book;
EContactEditor *ce;
AddressbookView *view = (AddressbookView *) user_data;
- GtkObject *object;
card = e_card_new("");
- if (view->minicard_view)
- object = GTK_OBJECT(view->minicard_view);
- else
- object = GTK_OBJECT(view->model);
+ gtk_object_get(GTK_OBJECT(view->view),
+ "book", &book,
+ NULL);
- gtk_object_get(object, "book", &book, NULL);
g_assert (E_IS_BOOK (book));
ce = e_contact_editor_new (card, TRUE);
@@ -171,11 +145,16 @@ static void
toggle_view_as_cb (BonoboUIHandler *uih, void *user_data, const char *path)
{
AddressbookView *view = user_data;
-
- if (view->view_type == ADDRESSBOOK_VIEW_TABLE)
- change_view_type (view, ADDRESSBOOK_VIEW_MINICARD);
+ EAddressbookViewType view_type;
+
+ gtk_object_get(GTK_OBJECT(view),
+ "type", &view_type,
+ NULL);
+
+ if (view_type == E_ADDRESSBOOK_VIEW_TABLE)
+ change_view_type (view, E_ADDRESSBOOK_VIEW_MINICARD);
else
- change_view_type (view, ADDRESSBOOK_VIEW_TABLE);
+ change_view_type (view, E_ADDRESSBOOK_VIEW_TABLE);
}
#ifdef HAVE_LDAP
@@ -190,7 +169,6 @@ new_server_cb (BonoboUIHandler *uih, void *user_data, const char *path)
ELDAPServer *server = g_new (ELDAPServer, 1);
EBook *book;
AddressbookView *view = (AddressbookView *) user_data;
- GtkObject *object;
/* fill in the defaults */
server->name = g_strdup("");
@@ -201,11 +179,10 @@ new_server_cb (BonoboUIHandler *uih, void *user_data, const char *path)
server->uri = g_strdup_printf ("ldap://%s:%s/%s", server->host, server->port, server->rootdn);
e_ldap_server_editor_show (server);
- if (view->minicard_view)
- object = GTK_OBJECT(view->minicard_view);
- else
- object = GTK_OBJECT(view->model);
- gtk_object_get(object, "book", &book, NULL);
+ gtk_object_get(GTK_OBJECT(view->view),
+ "book", &book,
+ NULL);
+
g_assert (E_IS_BOOK (book));
/* write out the new server info */
@@ -224,59 +201,15 @@ search_cb (BonoboUIHandler *uih, void *user_data, const char *path)
{
EBook *book;
AddressbookView *view = (AddressbookView *) user_data;
- GtkObject *object;
- if (view->minicard_view)
- object = GTK_OBJECT(view->minicard_view);
- else
- object = GTK_OBJECT(view->model);
- gtk_object_get(object, "book", &book, NULL);
+ gtk_object_get(GTK_OBJECT(view->view),
+ "book", &book,
+ NULL);
g_assert (E_IS_BOOK (book));
gtk_widget_show(e_addressbook_search_dialog_new(book));
}
-static char *
-get_query (AddressbookView *view)
-{
- GtkObject *object;
- char *query = NULL;
-
- if (view->minicard_view)
- object = GTK_OBJECT(view->minicard_view);
- else
- object = GTK_OBJECT(view->model);
-
- if (object)
- gtk_object_get (object, "query", &query, NULL);
-
- return query;
-}
-
-static void
-set_query (AddressbookView *view, char *query)
-{
- GtkObject *object;
-
- if (view->minicard_view)
- object = GTK_OBJECT(view->minicard_view);
- else
- object = GTK_OBJECT(view->model);
-
- gtk_object_set (object,
- "query", query,
- NULL);
-}
-
-static void
-set_book(AddressbookView *view)
-{
- if (view->book)
- gtk_object_set(view->minicard_view ? GTK_OBJECT(view->minicard_view) : GTK_OBJECT(view->model),
- "book", view->book,
- NULL);
-}
-
#if 0
static void
find_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path)
@@ -289,7 +222,9 @@ find_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path)
GtkWidget* dlg = gnome_dialog_new ("Search Contacts", "Find",
GNOME_STOCK_BUTTON_CANCEL, NULL);
- search_text = get_query (view);
+ gtk_object_get (view->view,
+ "query", &search_text,
+ NULL);
e_utf8_gtk_entry_set_text(GTK_ENTRY(search_entry), search_text);
g_free (search_text);
@@ -304,127 +239,26 @@ find_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path)
/* If the user clicks "okay"...*/
if (result == 0) {
search_text = e_utf8_gtk_entry_get_text(GTK_ENTRY(search_entry));
- set_query (view, search_text);
+ gtk_object_set (view->view,
+ "query", query,
+ NULL);
g_free (search_text);
}
}
#endif
static void
-card_deleted_cb (EBook* book, EBookStatus status, gpointer user_data)
-{
- g_print ("%s: %s(): a card was deleted\n", __FILE__, __FUNCTION__);
-}
-
-static void
delete_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path)
{
AddressbookView *view = (AddressbookView *) user_data;
- if (view->minicard_view)
- e_minicard_view_widget_remove_selection (E_MINICARD_VIEW_WIDGET(view->minicard_view), card_deleted_cb, NULL);
-}
-
-static void
-e_contact_print_destroy(GnomeDialog *dialog, gpointer data)
-{
- ETableScrolled *table = gtk_object_get_data(GTK_OBJECT(dialog), "table");
- EPrintable *printable = gtk_object_get_data(GTK_OBJECT(dialog), "printable");
- gtk_object_unref(GTK_OBJECT(printable));
- gtk_object_unref(GTK_OBJECT(table));
-}
-
-static void
-e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data)
-{
- GnomePrintMaster *master;
- GnomePrintContext *pc;
- EPrintable *printable = gtk_object_get_data(GTK_OBJECT(dialog), "printable");
- GtkWidget *preview;
- switch( button ) {
- case GNOME_PRINT_PRINT:
- master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) );
- pc = gnome_print_master_get_context( master );
- e_printable_reset(printable);
- while (e_printable_data_left(printable)) {
- if (gnome_print_gsave(pc) == -1)
- /* FIXME */;
- if (gnome_print_translate(pc, 72, 72) == -1)
- /* FIXME */;
- e_printable_print_page(printable,
- pc,
- 6.5 * 72,
- 5 * 72,
- TRUE);
- if (gnome_print_grestore(pc) == -1)
- /* FIXME */;
- if (gnome_print_showpage(pc) == -1)
- /* FIXME */;
- }
- gnome_print_master_close(master);
- gnome_print_master_print(master);
- gtk_object_unref(GTK_OBJECT(master));
- gnome_dialog_close(dialog);
- break;
- case GNOME_PRINT_PREVIEW:
- master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) );
- pc = gnome_print_master_get_context( master );
- e_printable_reset(printable);
- while (e_printable_data_left(printable)) {
- if (gnome_print_gsave(pc) == -1)
- /* FIXME */;
- if (gnome_print_translate(pc, 72, 72) == -1)
- /* FIXME */;
- e_printable_print_page(printable,
- pc,
- 6.5 * 72,
- 9 * 72,
- TRUE);
- if (gnome_print_grestore(pc) == -1)
- /* FIXME */;
- if (gnome_print_showpage(pc) == -1)
- /* FIXME */;
- }
- gnome_print_master_close(master);
- preview = GTK_WIDGET(gnome_print_master_preview_new(master, "Print Preview"));
- gtk_widget_show_all(preview);
- gtk_object_unref(GTK_OBJECT(master));
- break;
- case GNOME_PRINT_CANCEL:
- gnome_dialog_close(dialog);
- break;
- }
+ e_addressbook_view_delete_selection(view->view);
}
static void
print_cb (BonoboUIHandler *uih, void *user_data, const char *path)
{
AddressbookView *view = (AddressbookView *) user_data;
- if (view->minicard_view) {
- char *query = get_query(view);
- GtkWidget *print = e_contact_print_dialog_new(view->book, query);
- g_free(query);
- gtk_widget_show_all(print);
- } else {
- GtkWidget *dialog;
- EPrintable *printable;
-
- dialog = gnome_print_dialog_new("Print cards", GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES);
- gnome_print_dialog_construct_range_any(GNOME_PRINT_DIALOG(dialog), GNOME_PRINT_RANGE_ALL | GNOME_PRINT_RANGE_SELECTION,
- NULL, NULL, NULL);
-
- printable = e_table_scrolled_get_printable(E_TABLE_SCROLLED(view->table));
-
- gtk_object_ref(GTK_OBJECT(view->table));
-
- gtk_object_set_data(GTK_OBJECT(dialog), "table", view->table);
- gtk_object_set_data(GTK_OBJECT(dialog), "printable", printable);
-
- gtk_signal_connect(GTK_OBJECT(dialog),
- "clicked", GTK_SIGNAL_FUNC(e_contact_print_button), NULL);
- gtk_signal_connect(GTK_OBJECT(dialog),
- "destroy", GTK_SIGNAL_FUNC(e_contact_print_destroy), NULL);
- gtk_widget_show(dialog);
- }
+ e_addressbook_view_print(view->view);
}
static void
@@ -442,7 +276,9 @@ search_entry_activated (GtkWidget* widget, gpointer user_data)
search_query = g_strdup (
"(contains \"full_name\" \"\")");
- set_query(view, search_query);
+ gtk_object_set (GTK_OBJECT(view->view),
+ "query", search_query,
+ NULL);
g_free (search_query);
g_free (search_word);
@@ -525,7 +361,7 @@ control_activate (BonoboControl *control, BonoboUIHandler *uih,
bonobo_ui_container_freeze (container, NULL);
fname = bonobo_ui_util_get_ui_fname (
- EVOLUTION_DATADIR, "evolution-addressbook.xml");
+ "evolution-addressbook.xml");
g_warning ("Attempting ui load from '%s'", fname);
ui = bonobo_ui_util_new_ui (component, fname, "evolution-addressbook");
@@ -570,8 +406,6 @@ addressbook_view_free(AddressbookView *view)
{
if (view->properties)
bonobo_object_unref(BONOBO_OBJECT(view->properties));
- if (view->book)
- gtk_object_unref(GTK_OBJECT(view->book));
g_free(view->uri);
g_free(view);
}
@@ -579,9 +413,12 @@ addressbook_view_free(AddressbookView *view)
static void
book_open_cb (EBook *book, EBookStatus status, gpointer closure)
{
- AddressbookView *view = closure;
if (status == E_BOOK_STATUS_SUCCESS) {
- set_book (view);
+ AddressbookView *view = closure;
+
+ gtk_object_set(GTK_OBJECT(view->view),
+ "book", book,
+ NULL);
} else {
GtkWidget *warning_dialog, *label, *href;
warning_dialog = gnome_dialog_new (
@@ -654,14 +491,20 @@ set_prop (BonoboPropertyBag *bag,
AddressbookView *view = user_data;
char *uri_data;
+ EBook *book;
switch (arg_id) {
case PROPERTY_FOLDER_URI_IDX:
+ gtk_object_get(GTK_OBJECT(view->view),
+ "book", &book,
+ NULL);
if (view->uri) {
/* we've already had a uri set on this view, so unload it */
- e_book_unload_uri (view->book);
+ e_book_unload_uri (book);
g_free (view->uri);
+ } else {
+ book = e_book_new ();
}
view->uri = g_strdup(BONOBO_ARG_GET_STRING (arg));
@@ -675,7 +518,7 @@ set_prop (BonoboPropertyBag *bag,
uri_data = g_strdup (view->uri);
}
- if (! e_book_load_uri (view->book, uri_data, book_open_cb, view))
+ if (! e_book_load_uri (book, uri_data, book_open_cb, view))
printf ("error calling load_uri!\n");
g_free(uri_data);
@@ -688,347 +531,30 @@ set_prop (BonoboPropertyBag *bag,
}
}
-#define SPEC "<?xml version=\"1.0\"?> \
-<ETableSpecification click-to-add=\"1\"> \
- <columns-shown> \
- <column>0</column> \
- <column>1</column> \
- <column>5</column> \
- <column>3</column> \
- <column>4</column> \
- </columns-shown> \
- <grouping> \
- <leaf column=\"0\" ascending=\"1\"/> \
- </grouping> \
-</ETableSpecification>"
-
static void
-teardown_minicard_view (AddressbookView *view)
+change_view_type (AddressbookView *view, EAddressbookViewType view_type)
{
- if (view->minicard_view) {
- view->minicard_view = NULL;
- }
- if (view->minicard_hbox) {
- gtk_widget_destroy(view->minicard_hbox);
- view->minicard_hbox = NULL;
- }
-}
-
-typedef struct {
- AddressbookView *view;
- char letter;
-} LetterClosure;
-
-static void
-jump_to_letter(GtkWidget *button, LetterClosure *closure)
-{
- if (closure->view->minicard_view)
- e_minicard_view_widget_jump_to_letter(E_MINICARD_VIEW_WIDGET(closure->view->minicard_view), closure->letter);
-}
-
-static void
-free_closure(GtkWidget *button, LetterClosure *closure)
-{
- g_free(closure);
-}
-
-static void
-connect_button (AddressbookView *view, GladeXML *gui, char letter)
-{
- char *name;
- GtkWidget *button;
- LetterClosure *closure;
- name = g_strdup_printf("button-%c", letter);
- button = glade_xml_get_widget(gui, name);
- g_free(name);
- if (!button)
- return;
- closure = g_new(LetterClosure, 1);
- closure->view = view;
- closure->letter = letter;
- gtk_signal_connect(GTK_OBJECT(button), "clicked",
- GTK_SIGNAL_FUNC(jump_to_letter), closure);
- gtk_signal_connect(GTK_OBJECT(button), "destroy",
- GTK_SIGNAL_FUNC(free_closure), closure);
-}
-
-static GtkWidget *
-create_alphabet (AddressbookView *view)
-{
- GtkWidget *widget;
- char letter;
- GladeXML *gui = glade_xml_new (EVOLUTION_GLADEDIR "/alphabet.glade", NULL);
-
- widget = glade_xml_get_widget(gui, "scrolledwindow-top");
- if (!widget) {
- return NULL;
- }
-
- connect_button(view, gui, '1');
- for (letter = 'a'; letter <= 'z'; letter ++) {
- connect_button(view, gui, letter);
- }
-
- gtk_object_unref(GTK_OBJECT(gui));
- return widget;
-}
-
-static void
-create_minicard_view (AddressbookView *view, char *initial_query)
-{
- GtkWidget *scrollframe;
- GtkWidget *alphabet;
-
- gtk_widget_push_visual (gdk_rgb_get_visual ());
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
-
- view->minicard_hbox = gtk_hbox_new(FALSE, 0);
-
- view->minicard_view = e_minicard_view_widget_new();
-
- scrollframe = e_scroll_frame_new (NULL, NULL);
- e_scroll_frame_set_policy (E_SCROLL_FRAME (scrollframe),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_NEVER);
-
- gtk_container_add (GTK_CONTAINER (scrollframe), view->minicard_view);
-
- gtk_box_pack_start(GTK_BOX(view->minicard_hbox), scrollframe, TRUE, TRUE, 0);
-
- alphabet = create_alphabet(view);
- if (alphabet) {
- gtk_object_ref(GTK_OBJECT(alphabet));
- gtk_widget_unparent(alphabet);
- gtk_box_pack_start(GTK_BOX(view->minicard_hbox), alphabet, FALSE, FALSE, 0);
- gtk_object_unref(GTK_OBJECT(alphabet));
- }
-
- gtk_box_pack_start(GTK_BOX(view->vbox), view->minicard_hbox, TRUE, TRUE, 0);
-
- gtk_widget_show_all( GTK_WIDGET(view->minicard_hbox) );
-
-#if 0
- gdk_window_set_back_pixmap(
- GTK_LAYOUT(view->canvas)->bin_window, NULL, FALSE);
-#endif
-
- gtk_widget_pop_visual ();
- gtk_widget_pop_colormap ();
-}
-
-static void
-teardown_table_view (AddressbookView *view)
-{
- if (view->table) {
- gtk_widget_destroy (GTK_WIDGET (view->table));
- view->table = NULL;
- }
- if (view->model) {
- gtk_object_unref (GTK_OBJECT (view->model));
- view->model = NULL;
- }
- if (view->simple) {
- gtk_object_destroy (GTK_OBJECT (view->simple));
- view->simple = NULL;
- }
-}
-
-static void
-table_double_click(ETableScrolled *table, gint row, AddressbookView *view)
-{
- ECard *card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(view->model), row);
- EBook *book;
- EContactEditor *ce;
-
- gtk_object_get(GTK_OBJECT(view->model),
- "book", &book,
- NULL);
-
- g_assert (E_IS_BOOK (book));
-
- ce = e_contact_editor_new (card, FALSE);
-
- gtk_signal_connect (GTK_OBJECT (ce), "add_card",
- GTK_SIGNAL_FUNC (add_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
- GTK_SIGNAL_FUNC (commit_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
- GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
-
- gtk_object_unref(GTK_OBJECT(card));
-}
-
-typedef struct {
- EBook *book;
- ECard *card;
-} CardAndBook;
-
-static void
-card_and_book_free (CardAndBook *card_and_book)
-{
- gtk_object_unref(GTK_OBJECT(card_and_book->card));
- gtk_object_unref(GTK_OBJECT(card_and_book->book));
-}
-
-static void
-save_as (GtkWidget *widget, CardAndBook *card_and_book)
-{
- e_contact_save_as(_("Save as VCard"), card_and_book->card);
- card_and_book_free(card_and_book);
-}
-
-static void
-print (GtkWidget *widget, CardAndBook *card_and_book)
-{
- gtk_widget_show(e_contact_print_card_dialog_new(card_and_book->card));
- card_and_book_free(card_and_book);
-}
-
-static void
-delete (GtkWidget *widget, CardAndBook *card_and_book)
-{
- if (e_contact_editor_confirm_delete()) {
- /* Add the card in the contact editor to our ebook */
- e_book_remove_card (card_and_book->book,
- card_and_book->card,
- NULL,
- NULL);
- }
- card_and_book_free(card_and_book);
-}
-
-static gint
-table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, AddressbookView *view)
-{
- CardAndBook *card_and_book;
-
- EPopupMenu menu[] = {
- {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0},
- {"Print", NULL, GTK_SIGNAL_FUNC(print), 0},
- {"Delete", NULL, GTK_SIGNAL_FUNC(delete), 0},
- {NULL, NULL, NULL, 0}
- };
-
- card_and_book = g_new(CardAndBook, 1);
- card_and_book->card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(view->model), row);
- gtk_object_get(GTK_OBJECT(view->model),
- "book", &(card_and_book->book),
- NULL);
-
- gtk_object_ref(GTK_OBJECT(card_and_book->book));
-
- e_popup_menu_run (menu, (GdkEventButton *)event, 0, 0, card_and_book);
-
- return TRUE;
-}
-
-static void
-create_table_view (AddressbookView *view, char *initial_query)
-{
- ECell *cell_left_just;
- ETableHeader *e_table_header;
- int i;
-
- view->simple = e_card_simple_new(NULL);
-
- view->model = e_addressbook_model_new();
-
- /*
- Next we create a header. The ETableHeader is used in two
- different way. The first is the full_header. This is the
- list of possible columns in the view. The second use is
- completely internal. Many of the ETableHeader functions are
- for that purpose. The only functions we really need are
- e_table_header_new and e_table_header_add_col.
-
- First we create the header. */
- e_table_header = e_table_header_new ();
-
- /* Next we have to build renderers for all of the columns.
- Since all our columns are text columns, we can simply use
- the same renderer over and over again. If we had different
- types of columns, we could use a different renderer for
- each column. */
- cell_left_just = e_cell_text_new (view->model, NULL, GTK_JUSTIFY_LEFT);
-
- /* Next we create a column object for each view column and add
- them to the header. We don't create a column object for
- the importance column since it will not be shown. */
- for (i = 0; i < E_CARD_SIMPLE_FIELD_LAST - 1; i++){
- /* Create the column. */
- ETableCol *ecol = e_table_col_new (
- i, e_card_simple_get_name(view->simple, i+1),
- 1.0, 20, cell_left_just,
- g_str_compare, TRUE);
- /* Add it to the header. */
- e_table_header_add_column (e_table_header, ecol, i);
- }
-
- /* Here we create the table. We give it the three pieces of
- the table we've created, the header, the model, and the
- initial layout. It does the rest. */
- view->table = e_table_scrolled_new (e_table_header, E_TABLE_MODEL(view->model), SPEC);
-
- gtk_signal_connect(GTK_OBJECT(view->table), "double_click",
- GTK_SIGNAL_FUNC(table_double_click), view);
- gtk_signal_connect(GTK_OBJECT(view->table), "right_click",
- GTK_SIGNAL_FUNC(table_right_click), view);
-
- gtk_object_set (GTK_OBJECT(view->table),
- "click_to_add_message", _("* Click here to add a contact *"),
- "drawgrid", TRUE,
- NULL);
-
- gtk_box_pack_start(GTK_BOX(view->vbox), view->table, TRUE, TRUE, 0);
-
- gtk_widget_show( GTK_WIDGET(view->table) );
-}
-
-static void
-change_view_type (AddressbookView *view, AddressbookViewType view_type)
-{
- char *query = NULL;
BonoboUIHandler *uih = bonobo_control_get_ui_handler (view->control);
- if (view_type == view->view_type)
- return;
-
- if (view->view_type != ADDRESSBOOK_VIEW_NONE)
- query = get_query(view);
- else
- query = g_strdup("(contains \"x-evolution-any-field\" \"\")");
-
+ gtk_object_set(GTK_OBJECT(view->view),
+ "type", view_type,
+ NULL);
switch (view_type) {
- case ADDRESSBOOK_VIEW_MINICARD:
- teardown_table_view (view);
- create_minicard_view (view, query);
+ case E_ADDRESSBOOK_VIEW_TABLE:
if (uih)
bonobo_ui_handler_menu_set_label (uih, "/View/Toggle View",
- N_("As _Table"));
+ N_("As _Minicards"));
break;
- case ADDRESSBOOK_VIEW_TABLE:
- teardown_minicard_view (view);
- create_table_view (view, query);
+ case E_ADDRESSBOOK_VIEW_MINICARD:
if (uih)
bonobo_ui_handler_menu_set_label (uih, "/View/Toggle View",
- N_("As _Minicards"));
+ N_("As _Table"));
break;
default:
g_warning ("view_type must be either TABLE or MINICARD\n");
- g_free (query);
return;
}
-
- view->view_type = view_type;
-
- /* set the book */
- set_book (view);
-
- /* and reset the query */
- if (query)
- set_query (view, query);
- g_free (query);
}
@@ -1048,16 +574,16 @@ addressbook_factory_new_control (void)
/* Create the control. */
view->control = bonobo_control_new(view->vbox);
- view->model = NULL;
- view->minicard_view = NULL;
+ view->view = E_ADDRESSBOOK_VIEW(e_addressbook_view_new());
- /* create the initial view */
- change_view_type (view, ADDRESSBOOK_VIEW_MINICARD);
+ gtk_box_pack_start(GTK_BOX(view->vbox), GTK_WIDGET(view->view),
+ TRUE, TRUE, 0);
- gtk_widget_show_all( view->vbox );
+ /* create the initial view */
+ change_view_type (view, E_ADDRESSBOOK_VIEW_MINICARD);
- /* create the view's ebook */
- view->book = e_book_new ();
+ gtk_widget_show( view->vbox );
+ gtk_widget_show( GTK_WIDGET(view->view) );
view->properties = bonobo_property_bag_new (get_prop, set_prop, view);
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index de14b84ca3..4e47b5bd93 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -24,8 +24,8 @@
#include <gnome.h>
#include <glade/glade.h>
#include <bonobo.h>
-#include <ebook/e-card.h>
-#include <ebook/e-card-simple.h>
+#include "addressbook/backend/ebook/e-card.h"
+#include "addressbook/backend/ebook/e-card-simple.h"
#ifdef __cplusplus
extern "C" {
diff --git a/addressbook/gui/contact-editor/e-contact-save-as.h b/addressbook/gui/contact-editor/e-contact-save-as.h
index e6af13e8fd..d1c84dc596 100644
--- a/addressbook/gui/contact-editor/e-contact-save-as.h
+++ b/addressbook/gui/contact-editor/e-contact-save-as.h
@@ -23,8 +23,8 @@
#include <gnome.h>
#include <glade/glade.h>
-#include <ebook/e-card.h>
-#include <ebook/e-card-simple.h>
+#include "addressbook/backend/ebook/e-card.h"
+#include "addressbook/backend/ebook/e-card-simple.h"
#ifdef __cplusplus
extern "C" {
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am
index 2d2cc902d0..9680a0a2dc 100644
--- a/addressbook/gui/widgets/Makefile.am
+++ b/addressbook/gui/widgets/Makefile.am
@@ -1,10 +1,13 @@
+CPPFLAGS = \
+ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\"
+
INCLUDES = \
-DG_LOG_DOMAIN=\"e-minicard\" \
-I$(top_srcdir) \
- -I$(top_srcdir)/addressbook/backend \
- -I$(top_builddir)/addressbook/backend \
+ -I$(top_srcdir)/addressbook/backend/ebook \
-I$(top_srcdir)/addressbook/contact-editor \
-I$(top_srcdir)/widgets/e-text \
+ -I$(top_srcdir)/widgets/e-table \
-I$(top_srcdir)/widgets/e-reflow \
-I$(top_srcdir)/widgets/e-table \
-I$(top_srcdir)/widgets/misc \
@@ -16,6 +19,8 @@ noinst_LIBRARIES = \
libeminicard_a_SOURCES = \
e-addressbook-model.c \
e-addressbook-model.h \
+ e-addressbook-view.c \
+ e-addressbook-view.h \
e-minicard-control.c \
e-minicard-control.h \
e-minicard-label.c \
diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h
index 8f5f6485cf..267bd1b22a 100644
--- a/addressbook/gui/widgets/e-addressbook-model.h
+++ b/addressbook/gui/widgets/e-addressbook-model.h
@@ -3,9 +3,9 @@
#define _E_ADDRESSBOOK_MODEL_H_
#include "e-table-model.h"
-#include <ebook/e-book.h>
-#include <ebook/e-book-view.h>
-#include <ebook/e-card-simple.h>
+#include "addressbook/backend/ebook/e-book.h"
+#include "addressbook/backend/ebook/e-book-view.h"
+#include "addressbook/backend/ebook/e-card-simple.h"
#define E_ADDRESSBOOK_MODEL_TYPE (e_addressbook_model_get_type ())
#define E_ADDRESSBOOK_MODEL(o) (GTK_CHECK_CAST ((o), E_ADDRESSBOOK_MODEL_TYPE, EAddressbookModel))
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
new file mode 100644
index 0000000000..52f8375d53
--- /dev/null
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -0,0 +1,709 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-table-field-chooser.c
+ * 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 <config.h>
+#include <gnome.h>
+
+#include "e-addressbook-view.h"
+
+#include "e-table-scrolled.h"
+#include "e-table-model.h"
+#include "e-table-col.h"
+#include "e-table-header.h"
+#include "e-cell-text.h"
+#include "e-addressbook-model.h"
+
+#include <e-scroll-frame.h>
+#include "e-minicard-view-widget.h"
+
+#include "e-contact-editor.h"
+#include "e-contact-save-as.h"
+#include "addressbook/printing/e-contact-print.h"
+#include "e-card-simple.h"
+#include "e-card.h"
+#include "e-book.h"
+#include "e-util/e-popup-menu.h"
+
+#include "glade/glade-xml.h"
+
+#include <libgnomeprint/gnome-print.h>
+#include <libgnomeprint/gnome-print-dialog.h>
+#include <libgnomeprint/gnome-print-master.h>
+#include <libgnomeprint/gnome-print-master-preview.h>
+
+static void e_addressbook_view_init (EAddressbookView *card);
+static void e_addressbook_view_class_init (EAddressbookViewClass *klass);
+static void e_addressbook_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
+static void e_addressbook_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+static void e_addressbook_view_destroy (GtkObject *object);
+static void change_view_type (EAddressbookView *view, EAddressbookViewType view_type);
+
+static GtkTableClass *parent_class = NULL;
+
+/* The arguments we take */
+enum {
+ ARG_0,
+ ARG_BOOK,
+ ARG_QUERY,
+ ARG_TYPE,
+};
+
+GtkType
+e_addressbook_view_get_type (void)
+{
+ static GtkType type = 0;
+
+ if (!type) {
+ static const GtkTypeInfo info =
+ {
+ "EAddressbookView",
+ sizeof (EAddressbookView),
+ sizeof (EAddressbookViewClass),
+ (GtkClassInitFunc) e_addressbook_view_class_init,
+ (GtkObjectInitFunc) e_addressbook_view_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ type = gtk_type_unique (gtk_table_get_type (), &info);
+ }
+
+ return type;
+}
+
+static void
+e_addressbook_view_class_init (EAddressbookViewClass *klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS(klass);
+
+ parent_class = gtk_type_class (gtk_table_get_type ());
+
+ object_class->set_arg = e_addressbook_view_set_arg;
+ object_class->get_arg = e_addressbook_view_get_arg;
+ object_class->destroy = e_addressbook_view_destroy;
+
+ gtk_object_add_arg_type ("EAddressbookView::book", GTK_TYPE_OBJECT,
+ GTK_ARG_READWRITE, ARG_BOOK);
+ gtk_object_add_arg_type ("EAddressbookView::query", GTK_TYPE_STRING,
+ GTK_ARG_READWRITE, ARG_QUERY);
+ gtk_object_add_arg_type ("EAddressbookView::type", GTK_TYPE_ENUM,
+ GTK_ARG_READWRITE, ARG_TYPE);
+}
+
+static void
+e_addressbook_view_init (EAddressbookView *eav)
+{
+ eav->query = g_strdup("(contains \"x-evolution-any-field\" \"\")");
+ eav->view_type = E_ADDRESSBOOK_VIEW_NONE;
+
+ eav->book = NULL;
+ eav->query = NULL;
+
+ eav->object = NULL;
+ eav->widget = NULL;
+}
+
+static void
+e_addressbook_view_destroy (GtkObject *object)
+{
+ EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object);
+
+ if (eav->book)
+ gtk_object_unref(GTK_OBJECT(eav->book));
+ g_free(eav->query);
+
+ if (GTK_OBJECT_CLASS(parent_class)->destroy)
+ GTK_OBJECT_CLASS(parent_class)->destroy(object);
+}
+
+GtkWidget*
+e_addressbook_view_new (void)
+{
+ GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_addressbook_view_get_type ()));
+ return widget;
+}
+
+static void
+e_addressbook_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+{
+ EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object);
+
+ switch (arg_id){
+ case ARG_BOOK:
+ if (eav->book)
+ gtk_object_unref(GTK_OBJECT(eav->book));
+ if (GTK_VALUE_OBJECT(*arg)) {
+ eav->book = E_BOOK(GTK_VALUE_OBJECT(*arg));
+ gtk_object_ref(GTK_OBJECT(eav->book));
+ }
+ else
+ eav->book = NULL;
+ if (eav->object)
+ gtk_object_set(GTK_OBJECT(eav->object),
+ "book", eav->book,
+ NULL);
+ break;
+ case ARG_QUERY:
+ g_free(eav->query);
+ eav->query = g_strdup(GTK_VALUE_STRING(*arg));
+ if (!eav->query)
+ eav->query = g_strdup("(contains \"x-evolution-any-field\" \"\")");
+ if (eav->object)
+ gtk_object_set(GTK_OBJECT(eav->object),
+ "query", eav->query,
+ NULL);
+ break;
+ case ARG_TYPE:
+ change_view_type(eav, GTK_VALUE_ENUM(*arg));
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+e_addressbook_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+{
+ EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object);
+
+ switch (arg_id) {
+ case ARG_BOOK:
+ if (eav->book)
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(eav->book);
+ else
+ GTK_VALUE_OBJECT (*arg) = NULL;
+ break;
+ case ARG_QUERY:
+ GTK_VALUE_STRING (*arg) = eav->query;
+ break;
+ case ARG_TYPE:
+ GTK_VALUE_ENUM (*arg) = eav->view_type;
+ break;
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+
+
+typedef struct {
+ EAddressbookView *view;
+ char letter;
+} LetterClosure;
+
+static void
+jump_to_letter(GtkWidget *button, LetterClosure *closure)
+{
+ if (closure->view->widget && E_IS_MINICARD_VIEW_WIDGET(closure->view->widget))
+ e_minicard_view_widget_jump_to_letter(E_MINICARD_VIEW_WIDGET(closure->view->widget), closure->letter);
+}
+
+static void
+free_closure(GtkWidget *button, LetterClosure *closure)
+{
+ g_free(closure);
+}
+
+static void
+connect_button (EAddressbookView *view, GladeXML *gui, char letter)
+{
+ char *name;
+ GtkWidget *button;
+ LetterClosure *closure;
+ name = g_strdup_printf("button-%c", letter);
+ button = glade_xml_get_widget(gui, name);
+ g_free(name);
+ if (!button)
+ return;
+ closure = g_new(LetterClosure, 1);
+ closure->view = view;
+ closure->letter = letter;
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",
+ GTK_SIGNAL_FUNC(jump_to_letter), closure);
+ gtk_signal_connect(GTK_OBJECT(button), "destroy",
+ GTK_SIGNAL_FUNC(free_closure), closure);
+}
+
+static GtkWidget *
+create_alphabet (EAddressbookView *view)
+{
+ GtkWidget *widget;
+ char letter;
+ GladeXML *gui = glade_xml_new (EVOLUTION_GLADEDIR "/alphabet.glade", NULL);
+
+ widget = glade_xml_get_widget(gui, "scrolledwindow-top");
+ if (!widget) {
+ return NULL;
+ }
+
+ connect_button(view, gui, '1');
+ for (letter = 'a'; letter <= 'z'; letter ++) {
+ connect_button(view, gui, letter);
+ }
+
+ gtk_object_unref(GTK_OBJECT(gui));
+ return widget;
+}
+
+static void
+create_minicard_view (EAddressbookView *view)
+{
+ GtkWidget *scrollframe;
+ GtkWidget *alphabet;
+ GtkWidget *minicard_view;
+ GtkWidget *minicard_hbox;
+
+ gtk_widget_push_visual (gdk_rgb_get_visual ());
+ gtk_widget_push_colormap (gdk_rgb_get_cmap ());
+
+ minicard_hbox = gtk_hbox_new(FALSE, 0);
+
+ minicard_view = e_minicard_view_widget_new();
+
+ view->object = GTK_OBJECT(minicard_view);
+ view->widget = minicard_hbox;
+
+ scrollframe = e_scroll_frame_new (NULL, NULL);
+ e_scroll_frame_set_policy (E_SCROLL_FRAME (scrollframe),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+ gtk_container_add (GTK_CONTAINER (scrollframe), minicard_view);
+
+
+ gtk_box_pack_start(GTK_BOX(minicard_hbox), scrollframe, TRUE, TRUE, 0);
+
+ alphabet = create_alphabet(view);
+ if (alphabet) {
+ gtk_object_ref(GTK_OBJECT(alphabet));
+ gtk_widget_unparent(alphabet);
+ gtk_box_pack_start(GTK_BOX(minicard_hbox), alphabet, FALSE, FALSE, 0);
+ gtk_object_unref(GTK_OBJECT(alphabet));
+ }
+
+ gtk_table_attach(GTK_TABLE(view), minicard_hbox,
+ 0, 1,
+ 0, 1,
+ GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
+ 0, 0);
+
+ gtk_widget_show_all( GTK_WIDGET(minicard_hbox) );
+
+ gtk_widget_pop_visual ();
+ gtk_widget_pop_colormap ();
+}
+
+
+static void
+card_added_cb (EBook* book, EBookStatus status, const char *id,
+ gpointer user_data)
+{
+ g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__);
+}
+
+static void
+card_modified_cb (EBook* book, EBookStatus status,
+ gpointer user_data)
+{
+ g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__);
+}
+
+/* Callback for the add_card signal from the contact editor */
+static void
+add_card_cb (EContactEditor *ce, ECard *card, gpointer data)
+{
+ EBook *book;
+
+ book = E_BOOK (data);
+ e_book_add_card (book, card, card_added_cb, NULL);
+}
+
+/* Callback for the commit_card signal from the contact editor */
+static void
+commit_card_cb (EContactEditor *ce, ECard *card, gpointer data)
+{
+ EBook *book;
+
+ book = E_BOOK (data);
+ e_book_commit_card (book, card, card_modified_cb, NULL);
+}
+
+/* Callback for the delete_card signal from the contact editor */
+static void
+delete_card_cb (EContactEditor *ce, ECard *card, gpointer data)
+{
+ EBook *book;
+
+ book = E_BOOK (data);
+ e_book_remove_card (book, card, card_modified_cb, NULL);
+}
+
+/* Callback used when the contact editor is closed */
+static void
+editor_closed_cb (EContactEditor *ce, gpointer data)
+{
+ gtk_object_unref (GTK_OBJECT (ce));
+}
+
+static void
+table_double_click(ETableScrolled *table, gint row, EAddressbookView *view)
+{
+ if (E_IS_ADDRESSBOOK_MODEL(view->object)) {
+ EAddressbookModel *model = E_ADDRESSBOOK_MODEL(view->object);
+ ECard *card = e_addressbook_model_get_card(model, row);
+ EBook *book;
+ EContactEditor *ce;
+
+ gtk_object_get(GTK_OBJECT(model),
+ "book", &book,
+ NULL);
+
+ g_assert (E_IS_BOOK (book));
+
+ ce = e_contact_editor_new (card, FALSE);
+
+ gtk_signal_connect (GTK_OBJECT (ce), "add_card",
+ GTK_SIGNAL_FUNC (add_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
+ GTK_SIGNAL_FUNC (commit_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "delete_card",
+ GTK_SIGNAL_FUNC (delete_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
+ GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
+
+ gtk_object_unref(GTK_OBJECT(card));
+ }
+}
+
+typedef struct {
+ EBook *book;
+ ECard *card;
+} CardAndBook;
+
+static void
+card_and_book_free (CardAndBook *card_and_book)
+{
+ gtk_object_unref(GTK_OBJECT(card_and_book->card));
+ gtk_object_unref(GTK_OBJECT(card_and_book->book));
+}
+
+static void
+save_as (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ e_contact_save_as(_("Save as VCard"), card_and_book->card);
+ card_and_book_free(card_and_book);
+}
+
+static void
+print (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ gtk_widget_show(e_contact_print_card_dialog_new(card_and_book->card));
+ card_and_book_free(card_and_book);
+}
+
+static void
+delete (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ if (e_contact_editor_confirm_delete()) {
+ /* Add the card in the contact editor to our ebook */
+ e_book_remove_card (card_and_book->book,
+ card_and_book->card,
+ NULL,
+ NULL);
+ }
+ card_and_book_free(card_and_book);
+}
+
+static gint
+table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EAddressbookView *view)
+{
+ if (E_IS_ADDRESSBOOK_MODEL(view->object)) {
+ EAddressbookModel *model = E_ADDRESSBOOK_MODEL(view->object);
+ CardAndBook *card_and_book;
+
+ EPopupMenu menu[] = {
+ {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0},
+ {"Print", NULL, GTK_SIGNAL_FUNC(print), 0},
+ {"Delete", NULL, GTK_SIGNAL_FUNC(delete), 0},
+ {NULL, NULL, NULL, 0}
+ };
+
+ card_and_book = g_new(CardAndBook, 1);
+ card_and_book->card = e_addressbook_model_get_card(model, row);
+ gtk_object_get(GTK_OBJECT(model),
+ "book", &(card_and_book->book),
+ NULL);
+
+ gtk_object_ref(GTK_OBJECT(card_and_book->book));
+
+ e_popup_menu_run (menu, (GdkEventButton *)event, 0, 0, card_and_book);
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+#define SPEC "<?xml version=\"1.0\"?> \
+<ETableSpecification click-to-add=\"1\"> \
+ <columns-shown> \
+ <column>0</column> \
+ <column>1</column> \
+ <column>5</column> \
+ <column>3</column> \
+ <column>4</column> \
+ </columns-shown> \
+ <grouping> \
+ <leaf column=\"0\" ascending=\"1\"/> \
+ </grouping> \
+</ETableSpecification>"
+
+static void
+create_table_view (EAddressbookView *view)
+{
+ ECell *cell_left_just;
+ ETableHeader *e_table_header;
+ int i;
+ ETableModel *model;
+ ECardSimple *simple;
+ GtkWidget *table;
+
+ simple = e_card_simple_new(NULL);
+
+ model = e_addressbook_model_new();
+
+ /*
+ Next we create a header. The ETableHeader is used in two
+ different way. The first is the full_header. This is the
+ list of possible columns in the view. The second use is
+ completely internal. Many of the ETableHeader functions are
+ for that purpose. The only functions we really need are
+ e_table_header_new and e_table_header_add_col.
+
+ First we create the header. */
+ e_table_header = e_table_header_new ();
+
+ /* Next we have to build renderers for all of the columns.
+ Since all our columns are text columns, we can simply use
+ the same renderer over and over again. If we had different
+ types of columns, we could use a different renderer for
+ each column. */
+ cell_left_just = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT);
+
+ /* Next we create a column object for each view column and add
+ them to the header. We don't create a column object for
+ the importance column since it will not be shown. */
+ for (i = 0; i < E_CARD_SIMPLE_FIELD_LAST - 1; i++){
+ /* Create the column. */
+ ETableCol *ecol = e_table_col_new (
+ i, e_card_simple_get_name(simple, i+1),
+ 1.0, 20, cell_left_just,
+ g_str_compare, TRUE);
+ /* Add it to the header. */
+ e_table_header_add_column (e_table_header, ecol, i);
+ }
+
+ /* Here we create the table. We give it the three pieces of
+ the table we've created, the header, the model, and the
+ initial layout. It does the rest. */
+ table = e_table_scrolled_new (e_table_header, model, SPEC);
+
+ view->object = GTK_OBJECT(model);
+ view->widget = table;
+
+ gtk_signal_connect(GTK_OBJECT(table), "double_click",
+ GTK_SIGNAL_FUNC(table_double_click), view);
+ gtk_signal_connect(GTK_OBJECT(table), "right_click",
+ GTK_SIGNAL_FUNC(table_right_click), view);
+
+ gtk_object_set (GTK_OBJECT(table),
+ "click_to_add_message", _("* Click here to add a contact *"),
+ "drawgrid", TRUE,
+ NULL);
+
+ gtk_table_attach(GTK_TABLE(view), table,
+ 0, 1,
+ 0, 1,
+ GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
+ 0, 0);
+
+ gtk_widget_show( GTK_WIDGET(table) );
+
+ gtk_object_unref(GTK_OBJECT(simple));
+}
+
+
+static void
+change_view_type (EAddressbookView *view, EAddressbookViewType view_type)
+{
+ if (view_type == view->view_type)
+ return;
+
+ if (view->widget) {
+ gtk_widget_destroy (view->widget);
+ view->widget = NULL;
+ }
+ view->object = NULL;
+
+ switch (view_type) {
+ case E_ADDRESSBOOK_VIEW_MINICARD:
+ create_minicard_view (view);
+ break;
+ case E_ADDRESSBOOK_VIEW_TABLE:
+ create_table_view (view);
+ break;
+ default:
+ g_warning ("view_type must be either TABLE or MINICARD\n");
+ return;
+ }
+
+ view->view_type = view_type;
+
+ gtk_object_set(view->object,
+ "query", view->query,
+ "book", view->book,
+ NULL);
+}
+
+static void
+e_contact_print_destroy(GnomeDialog *dialog, gpointer data)
+{
+ ETableScrolled *table = gtk_object_get_data(GTK_OBJECT(dialog), "table");
+ EPrintable *printable = gtk_object_get_data(GTK_OBJECT(dialog), "printable");
+ gtk_object_unref(GTK_OBJECT(printable));
+ gtk_object_unref(GTK_OBJECT(table));
+}
+
+static void
+e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data)
+{
+ GnomePrintMaster *master;
+ GnomePrintContext *pc;
+ EPrintable *printable = gtk_object_get_data(GTK_OBJECT(dialog), "printable");
+ GtkWidget *preview;
+ switch( button ) {
+ case GNOME_PRINT_PRINT:
+ master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) );
+ pc = gnome_print_master_get_context( master );
+ e_printable_reset(printable);
+ while (e_printable_data_left(printable)) {
+ if (gnome_print_gsave(pc) == -1)
+ /* FIXME */;
+ if (gnome_print_translate(pc, 72, 72) == -1)
+ /* FIXME */;
+ e_printable_print_page(printable,
+ pc,
+ 6.5 * 72,
+ 5 * 72,
+ TRUE);
+ if (gnome_print_grestore(pc) == -1)
+ /* FIXME */;
+ if (gnome_print_showpage(pc) == -1)
+ /* FIXME */;
+ }
+ gnome_print_master_close(master);
+ gnome_print_master_print(master);
+ gtk_object_unref(GTK_OBJECT(master));
+ gnome_dialog_close(dialog);
+ break;
+ case GNOME_PRINT_PREVIEW:
+ master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) );
+ pc = gnome_print_master_get_context( master );
+ e_printable_reset(printable);
+ while (e_printable_data_left(printable)) {
+ if (gnome_print_gsave(pc) == -1)
+ /* FIXME */;
+ if (gnome_print_translate(pc, 72, 72) == -1)
+ /* FIXME */;
+ e_printable_print_page(printable,
+ pc,
+ 6.5 * 72,
+ 9 * 72,
+ TRUE);
+ if (gnome_print_grestore(pc) == -1)
+ /* FIXME */;
+ if (gnome_print_showpage(pc) == -1)
+ /* FIXME */;
+ }
+ gnome_print_master_close(master);
+ preview = GTK_WIDGET(gnome_print_master_preview_new(master, "Print Preview"));
+ gtk_widget_show_all(preview);
+ gtk_object_unref(GTK_OBJECT(master));
+ break;
+ case GNOME_PRINT_CANCEL:
+ gnome_dialog_close(dialog);
+ break;
+ }
+}
+
+void
+e_addressbook_view_print(EAddressbookView *view)
+{
+ if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD) {
+ char *query;
+ EBook *book;
+ GtkWidget *print;
+
+ gtk_object_get (view->object,
+ "query", &query,
+ "book", &book,
+ NULL);
+ print = e_contact_print_dialog_new(book, query);
+ g_free(query);
+ gtk_widget_show_all(print);
+ } else if (view->view_type == E_ADDRESSBOOK_VIEW_TABLE) {
+ GtkWidget *dialog;
+ EPrintable *printable;
+
+ dialog = gnome_print_dialog_new("Print cards", GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES);
+ gnome_print_dialog_construct_range_any(GNOME_PRINT_DIALOG(dialog), GNOME_PRINT_RANGE_ALL | GNOME_PRINT_RANGE_SELECTION,
+ NULL, NULL, NULL);
+
+ printable = e_table_scrolled_get_printable(E_TABLE_SCROLLED(view->widget));
+
+ gtk_object_ref(GTK_OBJECT(view->widget));
+
+ gtk_object_set_data(GTK_OBJECT(dialog), "table", view->widget);
+ gtk_object_set_data(GTK_OBJECT(dialog), "printable", printable);
+
+ gtk_signal_connect(GTK_OBJECT(dialog),
+ "clicked", GTK_SIGNAL_FUNC(e_contact_print_button), NULL);
+ gtk_signal_connect(GTK_OBJECT(dialog),
+ "destroy", GTK_SIGNAL_FUNC(e_contact_print_destroy), NULL);
+ gtk_widget_show(dialog);
+ }
+}
+
+static void
+card_deleted_cb (EBook* book, EBookStatus status, gpointer user_data)
+{
+ g_print ("%s: %s(): a card was deleted\n", __FILE__, __FUNCTION__);
+}
+
+void
+e_addressbook_view_delete_selection(EAddressbookView *view)
+{
+ if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD)
+ e_minicard_view_widget_remove_selection (E_MINICARD_VIEW_WIDGET(view->object), card_deleted_cb, NULL);
+}
diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h
new file mode 100644
index 0000000000..0509e897e6
--- /dev/null
+++ b/addressbook/gui/widgets/e-addressbook-view.h
@@ -0,0 +1,88 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-addressbook-view.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_ADDRESSBOOK_VIEW_H__
+#define __E_ADDRESSBOOK_VIEW_H__
+
+#include <gnome.h>
+#include "addressbook/backend/ebook/e-book.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+/* EAddressbookView - A card displaying information about a contact.
+ *
+ * The following arguments are available:
+ *
+ * name type read/write description
+ * --------------------------------------------------------------------------------
+ */
+
+#define E_ADDRESSBOOK_VIEW_TYPE (e_addressbook_view_get_type ())
+#define E_ADDRESSBOOK_VIEW(obj) (GTK_CHECK_CAST ((obj), E_ADDRESSBOOK_VIEW_TYPE, EAddressbookView))
+#define E_ADDRESSBOOK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_ADDRESSBOOK_VIEW_TYPE, EAddressbookViewClass))
+#define E_IS_ADDRESSBOOK_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_ADDRESSBOOK_VIEW_TYPE))
+#define E_IS_ADDRESSBOOK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_ADDRESSBOOK_VIEW_TYPE))
+
+typedef enum {
+ E_ADDRESSBOOK_VIEW_NONE, /* initialized to this */
+ E_ADDRESSBOOK_VIEW_TABLE,
+ E_ADDRESSBOOK_VIEW_MINICARD
+} EAddressbookViewType;
+
+
+typedef struct _EAddressbookView EAddressbookView;
+typedef struct _EAddressbookViewClass EAddressbookViewClass;
+
+struct _EAddressbookView
+{
+ GtkTable parent;
+
+ /* item specific fields */
+ EAddressbookViewType view_type;
+
+ EBook *book;
+ char *query;
+
+ GtkObject *object;
+ GtkWidget *widget;
+
+ GtkWidget *vbox;
+};
+
+struct _EAddressbookViewClass
+{
+ GtkTableClass parent_class;
+};
+
+GtkWidget *e_addressbook_view_new (void);
+GtkType e_addressbook_view_get_type (void);
+
+void e_addressbook_view_print (EAddressbookView *view);
+void e_addressbook_view_delete_selection (EAddressbookView *view);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __E_ADDRESSBOOK_VIEW_H__ */
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c
index cd1a999f14..3cf1add096 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.c
+++ b/addressbook/gui/widgets/e-minicard-view-widget.c
@@ -122,9 +122,12 @@ e_minicard_view_widget_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_BOOK:
if (emvw->book)
gtk_object_unref(GTK_OBJECT(emvw->book));
- emvw->book = E_BOOK(GTK_VALUE_OBJECT (*arg));
- if (emvw->book)
- gtk_object_ref(GTK_OBJECT(emvw->book));
+ if (GTK_VALUE_OBJECT (*arg)) {
+ emvw->book = E_BOOK(GTK_VALUE_OBJECT (*arg));
+ if (emvw->book)
+ gtk_object_ref(GTK_OBJECT(emvw->book));
+ } else
+ emvw->book = NULL;
if (emvw->emv)
gtk_object_set(GTK_OBJECT(emvw->emv),
"book", emvw->book,
@@ -243,7 +246,7 @@ e_minicard_view_widget_reflow(ECanvas *canvas)
"width", &width,
NULL);
width = MAX(width, GTK_WIDGET(canvas)->allocation.width);
- gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas), 0, 0, width - 1, GTK_WIDGET(canvas)->allocation.width - 1);
+ gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas), 0, 0, width - 1, GTK_WIDGET(canvas)->allocation.height - 1);
gnome_canvas_item_set( view->rect,
"x2", (double) width,
"y2", (double) GTK_WIDGET(canvas)->allocation.height,
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h
index 340fb1e03c..372c061f65 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.h
+++ b/addressbook/gui/widgets/e-minicard-view-widget.h
@@ -24,7 +24,7 @@
#include <gnome.h>
#include "e-minicard-view.h"
#include "e-util/e-canvas.h"
-#include <ebook/e-book.h>
+#include "addressbook/backend/ebook/e-book.h"
#ifdef __cplusplus
extern "C" {
diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h
index a938019787..93a59dfe2a 100644
--- a/addressbook/gui/widgets/e-minicard-view.h
+++ b/addressbook/gui/widgets/e-minicard-view.h
@@ -22,8 +22,8 @@
#define __E_MINICARD_VIEW_H__
#include <gnome.h>
-#include <widgets/e-reflow/e-reflow-sorted.h>
-#include <ebook/e-book.h>
+#include "widgets/e-reflow/e-reflow-sorted.h"
+#include "addressbook/backend/ebook/e-book.h"
#ifdef __cplusplus
extern "C" {
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index d870de7b25..e461294b5e 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -25,7 +25,7 @@
#include "e-minicard.h"
#include "e-minicard-label.h"
#include "e-text.h"
-#include <ebook/e-book.h>
+#include "addressbook/backend/ebook/e-book.h"
#include <e-util/e-canvas.h>
#include <e-util/e-util.h>
#include <e-util/e-canvas-utils.h>
diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h
index 47da8110c2..33a20b40ec 100644
--- a/addressbook/gui/widgets/e-minicard.h
+++ b/addressbook/gui/widgets/e-minicard.h
@@ -22,8 +22,8 @@
#define __E_MINICARD_H__
#include <gnome.h>
-#include <ebook/e-card.h>
-#include <ebook/e-card-simple.h>
+#include "addressbook/backend/ebook/e-card.h"
+#include "addressbook/backend/ebook/e-card-simple.h"
#ifdef __cplusplus
extern "C" {