diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-04-09 06:10:47 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-04-09 06:10:47 +0800 |
commit | 58e7df4e0376d1248ced78659d27d61adc1434b9 (patch) | |
tree | edda4073e9e79d89b8bb9a34498049259998718d /addressbook | |
parent | 6beb74f53508f0f92ad5ed0fe7e823b6a5be76f3 (diff) | |
download | gsoc2013-evolution-58e7df4e0376d1248ced78659d27d61adc1434b9.tar.gz gsoc2013-evolution-58e7df4e0376d1248ced78659d27d61adc1434b9.tar.zst gsoc2013-evolution-58e7df4e0376d1248ced78659d27d61adc1434b9.zip |
pixmap_DATA isn't defined so don't use it as a variable.
2000-04-08 Christopher James Lahey <clahey@helixcode.com>
* art/Makefile.am: pixmap_DATA isn't defined so don't use it as a variable.
* addressbook/gui/component/,
addressbook/gui/component/.cvsignore, addressbook/gui/Makefile.am,
addressbook/gui/component/addressbook-factory.c,
addressbook/gui/component/addressbook.c,
addressbook/gui/component/addressbook.gnorba,
addressbook/gui/component/addressbook.h: New directory to proivde
the component for contact management. Simply uses an e-minicard-view.
* addressbook/gui/minicard/e-minicard-view.c,
addressbook/gui/minicard/e-minicard-view.h: New subclass of
e-reflow-sorted that takes an EBook and uses it to compute the
card data to display.
* addressbook/gui/minicard/e-minicard.c,
addressbook/gui/minicard/e-minicard.h: This now backends to a
ECard instead of a ETableModel.
* addressbook/gui/minicard/e-reflow.c,
addressbook/gui/minicard/e-reflow.h: This now has a virtualized
add method.
* addressbook/gui/minicard/e-reflow-sorted.c,
addressbook/gui/minicard/e-reflow-sorted.h: New subclass of
e-reflow that allows the data to be sorted on the fly.
* addressbook/gui/minicard/test-minicard-view.c: New test to test
the new minicard view.
* addressbook/gui/minicard/test-reflow.c: Uses the new ECard
backend of the e-minicard.
* addressbook/gui/minicard/.cvsignore,
addressbook/gui/minicard/Makefile.am: Added new test. Fixed
dependencies. Added new files.
* addressbook/gui/, addressbook/gui/Makefile.am,
addressbook/gui/.cvsignore: New directory for addressbook gui
bits. Added subdirectories. Created an initial .cvsignore.
* addressbook/Makefile.am (SUBDIRS): Removed demo and added gui.
* addressbook/backend/pas/pas-backend-file.c: Added code to do
notification on bookviews when changes in the backend are made.
* addressbook/backend/pas/pas-book-view.c,
addressbook/backend/pas/pas-book-view.h: Added helper functions to
notify the view about the addition or modification of a single
card. Fixed a mistaken extra free.
* addressbook/backend/ebook/e-card-list-iterator.h: Fixed
incorrect parent class.
* addressbook/backend/ebook/test-client.c: Made this accept an
optional parameter that specifies the vcard to add.
* configure.in: Replaced widgets/e-minicard/Makefile and
addressbook/demo/Makefile with addressbook/gui/minicard/Makefile
and addressbook/gui/component/Makefile respectively.
* widgets/Makefile.am: Removed e-minicard since it's being moved
to addressbook/gui/minicard.
* widgets/e-text/e-text.c: Fixed the border width around tooltips
and made the main tooltip area yellow.
From camel/ChangeLog:
2000-04-08 Christopher James Lahey <clahey@helixcode.com>
* providers/smtp/.cvsignore: Added a .cvsignore file.
From calendar/ChangeLog:
2000-04-08 Christopher James Lahey <clahey@helixcode.com>
* gui/Makefile.am: Removed linking with libetable and libeminicard
since they weren't being used.
svn path=/trunk/; revision=2343
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/Makefile.am | 2 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-card-list-iterator.h | 4 | ||||
-rw-r--r-- | addressbook/backend/ebook/test-client.c | 38 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-file.c | 79 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book-view.c | 20 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book-view.h | 4 | ||||
-rw-r--r-- | addressbook/gui/.cvsignore | 6 | ||||
-rw-r--r-- | addressbook/gui/Makefile.am | 1 | ||||
-rw-r--r-- | addressbook/gui/component/.cvsignore | 8 | ||||
-rw-r--r-- | addressbook/gui/component/Makefile.am | 36 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-factory.c | 47 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.c | 275 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.gnorba | 11 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.h | 8 |
14 files changed, 514 insertions, 25 deletions
diff --git a/addressbook/Makefile.am b/addressbook/Makefile.am index 8e421f8e2d..b5d6387af6 100644 --- a/addressbook/Makefile.am +++ b/addressbook/Makefile.am @@ -1,2 +1,2 @@ SUBDIRS = \ - backend contact-editor printing demo + backend gui contact-editor printing diff --git a/addressbook/backend/ebook/e-card-list-iterator.h b/addressbook/backend/ebook/e-card-list-iterator.h index cdc7a312b1..67d56cfb9c 100644 --- a/addressbook/backend/ebook/e-card-list-iterator.h +++ b/addressbook/backend/ebook/e-card-list-iterator.h @@ -26,14 +26,14 @@ typedef struct _ECardListIterator ECardListIterator; typedef struct _ECardListIteratorClass ECardListIteratorClass; struct _ECardListIterator { - GtkObject object; + ECardIterator parent; ECardList *list; GList *iterator; }; struct _ECardListIteratorClass { - GtkObjectClass parent_class; + ECardIteratorClass parent_class; }; ECardIterator *e_card_list_iterator_new (ECardList *list); diff --git a/addressbook/backend/ebook/test-client.c b/addressbook/backend/ebook/test-client.c index f535d2db1a..15c5410146 100644 --- a/addressbook/backend/ebook/test-client.c +++ b/addressbook/backend/ebook/test-client.c @@ -30,8 +30,9 @@ " " -CORBA_Environment ev; -CORBA_ORB orb; +static CORBA_Environment ev; +static CORBA_ORB orb; +static char *cardstr; static void init_bonobo (int argc, char **argv) @@ -99,7 +100,7 @@ add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure) static void book_open_cb (EBook *book, EBookStatus status, gpointer closure) { - e_book_add_vcard(book, TEST_VCARD, add_card_cb, NULL); + e_book_add_vcard(book, cardstr, add_card_cb, NULL); } static guint @@ -125,6 +126,30 @@ ebook_create (void) return FALSE; } +static char * +read_file (char *name) +{ + int len; + char buff[65536]; + char line[1024]; + FILE *f; + + f = fopen (name, "r"); + if (f == NULL) + g_error ("Unable to open %s!\n", name); + + len = 0; + while (fgets (line, sizeof (line), f) != NULL) { + strcpy (buff + len, line); + len += strlen (line); + } + + fclose (f); + + return g_strdup (buff); +} + + int main (int argc, char **argv) { @@ -132,6 +157,13 @@ main (int argc, char **argv) CORBA_exception_init (&ev); init_bonobo (argc, argv); + cardstr = NULL; + if (argc == 2) + cardstr = read_file (argv [1]); + + if (cardstr == NULL) + cardstr = TEST_VCARD; + gtk_idle_add ((GtkFunction) ebook_create, NULL); bonobo_main (); diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c index 706ab1f9a2..935dab19d5 100644 --- a/addressbook/backend/pas/pas-backend-file.c +++ b/addressbook/backend/pas/pas-backend-file.c @@ -25,11 +25,13 @@ static PASBackendClass *pas_backend_file_parent_class; typedef struct _PASBackendFileCursorPrivate PASBackendFileCursorPrivate; +typedef struct _PASBackendFileBookView PASBackendFileBookView; struct _PASBackendFilePrivate { GList *clients; gboolean loaded; DB *file_db; + GList *book_views; }; struct _PASBackendFileCursorPrivate { @@ -40,6 +42,11 @@ struct _PASBackendFileCursorPrivate { guint32 num_elements; }; +struct _PASBackendFileBookView { + PASBookView *book_view; + gchar *search; +}; + static long get_length(PASCardCursor *cursor, gpointer data) { @@ -89,6 +96,20 @@ view_destroy(GtkObject *object, gpointer data) CORBA_Environment ev; Evolution_Book corba_book; PASBook *book = (PASBook *)data; + PASBackendFile *bf; + GList *list; + + bf = PAS_BACKEND_FILE(pas_book_get_backend(book)); + for (list = bf->priv->book_views; list; list = g_list_next(list)) { + PASBackendFileBookView *view = list->data; + if (view->book_view == PAS_BOOK_VIEW(object)) { + g_free (view->search); + g_free (view); + bf->priv->book_views = g_list_remove_link(bf->priv->book_views, list); + g_list_free_1(list); + break; + } + } corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book)); @@ -131,6 +152,7 @@ pas_backend_file_process_create_card (PASBackend *backend, DBT id_dbt, vcard_dbt; int db_error; char *id; + GList *list; id = pas_backend_file_create_unique_id (req->vcard); @@ -140,9 +162,11 @@ pas_backend_file_process_create_card (PASBackend *backend, db_error = db->put (db, &id_dbt, &vcard_dbt, 0); if (0 == db_error) { -#if 0 - pas_book_notify_add(book, id); -#endif + for (list = bf->priv->book_views; list; list = g_list_next(list)) { + PASBackendFileBookView *view = list->data; + /* if (card matches view->search) */ + pas_book_view_notify_add_1 (view->book_view, req->vcard); + } pas_book_respond_create ( book, @@ -175,15 +199,18 @@ pas_backend_file_process_remove_card (PASBackend *backend, DB *db = bf->priv->file_db; DBT id_dbt; int db_error; + GList *list; string_to_dbt (req->id, &id_dbt); db_error = db->del (db, &id_dbt, 0); if (0 == db_error) { -#if 0 - pas_book_notify_remove (book, req->id); -#endif + for (list = bf->priv->book_views; list; list = g_list_next(list)) { + PASBackendFileBookView *view = list->data; + /* if (card matches view->search) */ + pas_book_view_notify_remove (view->book_view, req->id); + } pas_book_respond_remove ( book, @@ -211,6 +238,7 @@ pas_backend_file_process_modify_card (PASBackend *backend, DB *db = bf->priv->file_db; DBT id_dbt, vcard_dbt; int db_error; + GList *list; string_to_dbt (req->id, &id_dbt); string_to_dbt (req->vcard, &vcard_dbt); @@ -218,9 +246,16 @@ pas_backend_file_process_modify_card (PASBackend *backend, db_error = db->put (db, &id_dbt, &vcard_dbt, 0); if (0 == db_error) { -#if 0 - pas_book_notify_change (book, req->id); -#endif + for (list = bf->priv->book_views; list; list = g_list_next(list)) { + PASBackendFileBookView *view = list->data; + /* if (card matches view->search) */ + pas_book_view_notify_change_1 (view->book_view, req->vcard); + /* else if (card changes to match view->search ) + pas_book_view_notify_add_1 (view->book_view, req->vcard); + else if (card changes to not match view->search ) + pas_book_view_notify_remove (view->book_view, req->id); + */ + } pas_book_respond_modify ( book, @@ -335,9 +370,11 @@ pas_backend_file_process_get_book_view (PASBackend *backend, DBT id_dbt, vcard_dbt; CORBA_Environment ev; int db_error = 0; - PASBookView *view; + PASBookView *book_view; Evolution_Book corba_book; GList *cards = NULL; + PASBackendFileBookView *view; + g_return_if_fail (req->listener != NULL); @@ -354,16 +391,16 @@ pas_backend_file_process_get_book_view (PASBackend *backend, CORBA_exception_free(&ev); - view = pas_book_view_new (req->listener); + book_view = pas_book_view_new (req->listener); - gtk_signal_connect(GTK_OBJECT(view), "destroy", + gtk_signal_connect(GTK_OBJECT(book_view), "destroy", GTK_SIGNAL_FUNC(view_destroy), book); pas_book_respond_get_book_view (book, (db_error == 0 ? Evolution_BookListener_Success : Evolution_BookListener_CardNotFound /* XXX */), - view); + book_view); /* ** no reason to not iterate through the file now and notify @@ -390,14 +427,19 @@ pas_backend_file_process_get_book_view (PASBackend *backend, g_warning ("pas_backend_file_process_get_book_view: error building list\n"); } else { - pas_book_view_notify_add (view, cards); + pas_book_view_notify_add (book_view, cards); } /* - ** the following should be done when the view is destroyed + ** It's fine to do this now since the data has been handed off. */ g_list_foreach (cards, (GFunc)g_free, NULL); g_list_free (cards); + + view = g_new(PASBackendFileBookView, 1); + view->book_view = book_view; + view->search = g_strdup(req->search); + bf->priv->book_views = g_list_prepend(bf->priv->book_views, view); } static void @@ -684,9 +726,10 @@ pas_backend_file_init (PASBackendFile *backend) { PASBackendFilePrivate *priv; - priv = g_new0 (PASBackendFilePrivate, 1); - priv->loaded = FALSE; - priv->clients = NULL; + priv = g_new0 (PASBackendFilePrivate, 1); + priv->loaded = FALSE; + priv->clients = NULL; + priv->book_views = NULL; backend->priv = priv; } diff --git a/addressbook/backend/pas/pas-book-view.c b/addressbook/backend/pas/pas-book-view.c index fc706bc897..f712cc8ccf 100644 --- a/addressbook/backend/pas/pas-book-view.c +++ b/addressbook/backend/pas/pas-book-view.c @@ -50,6 +50,15 @@ pas_book_view_notify_change (PASBookView *book_view, CORBA_free(card_sequence._buffer); } +void +pas_book_view_notify_change_1 (PASBookView *book_view, + const char *card) +{ + GList *list = g_list_append(NULL, (char *) card); + pas_book_view_notify_change(book_view, list); + g_list_free(list); +} + /** * pas_book_view_notify_remove: */ @@ -89,7 +98,7 @@ pas_book_view_notify_add (PASBookView *book_view, card_sequence._length = length; for ( i = 0; cards; cards = g_list_next(cards), i++ ) { - card_sequence._buffer[i] = (char *) cards->data; + card_sequence._buffer[i] = CORBA_string_dup((char *) cards->data); } CORBA_exception_init (&ev); @@ -106,6 +115,15 @@ pas_book_view_notify_add (PASBookView *book_view, CORBA_free(card_sequence._buffer); } +void +pas_book_view_notify_add_1 (PASBookView *book_view, + const char *card) +{ + GList *list = g_list_append(NULL, (char *) card); + pas_book_view_notify_add(book_view, list); + g_list_free(list); +} + static gboolean pas_book_view_construct (PASBookView *book_view, Evolution_BookViewListener listener) diff --git a/addressbook/backend/pas/pas-book-view.h b/addressbook/backend/pas/pas-book-view.h index b742b2ba1a..9644c79de1 100644 --- a/addressbook/backend/pas/pas-book-view.h +++ b/addressbook/backend/pas/pas-book-view.h @@ -33,10 +33,14 @@ PASBookView *pas_book_view_new (Evolution_BookView void pas_book_view_notify_change (PASBookView *book_view, const GList *cards); +void pas_book_view_notify_change_1 (PASBookView *book_view, + const char *card); void pas_book_view_notify_remove (PASBookView *book_view, const char *id); void pas_book_view_notify_add (PASBookView *book_view, const GList *cards); +void pas_book_view_notify_add_1 (PASBookView *book_view, + const char *card); GtkType pas_book_view_get_type (void); diff --git a/addressbook/gui/.cvsignore b/addressbook/gui/.cvsignore new file mode 100644 index 0000000000..09980ae6ba --- /dev/null +++ b/addressbook/gui/.cvsignore @@ -0,0 +1,6 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.la diff --git a/addressbook/gui/Makefile.am b/addressbook/gui/Makefile.am new file mode 100644 index 0000000000..50c258b544 --- /dev/null +++ b/addressbook/gui/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = minicard component
\ No newline at end of file diff --git a/addressbook/gui/component/.cvsignore b/addressbook/gui/component/.cvsignore new file mode 100644 index 0000000000..a0427f184f --- /dev/null +++ b/addressbook/gui/component/.cvsignore @@ -0,0 +1,8 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.la +evolution-addressbook +test-addressbook
\ No newline at end of file diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am new file mode 100644 index 0000000000..f5269071c4 --- /dev/null +++ b/addressbook/gui/component/Makefile.am @@ -0,0 +1,36 @@ +INCLUDES = \ + $(EXTRA_GNOME_CFLAGS) \ + $(GNOME_INCLUDEDIR) \ + -I$(top_srcdir)/widgets/e-text \ + -I$(top_srcdir)/e-util \ + -I$(top_srcdir) \ + -I$(top_srcdir)/addressbook/gui/minicard \ + -I$(top_srcdir)/addressbook/backend/ebook \ + $(BONOBO_HTML_GNOME_CFLAGS) \ + -DEVOLUTION_VERSION=\""$(VERSION)"\" \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ + -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \ + -DEVOLUTION_LOCALEDIR=\""$(datadir)/locale"\" \ + -DCAMEL_PROVIDERDIR=\""$(providerdir)"\" + +bin_PROGRAMS = \ + evolution-addressbook + +evolution_addressbook_SOURCES = \ + addressbook-factory.c \ + addressbook.c \ + addressbook.h + +evolution_addressbook_LDADD = \ + $(EXTRA_GNOME_LIBS) \ + $(BONOBO_HTML_GNOME_LIBS) \ + $(top_builddir)/addressbook/gui/minicard/libeminicard.a \ + $(top_builddir)/widgets/e-text/libetext.a \ + $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/addressbook/backend/ebook/libebook.la \ + $(top_builddir)/libversit/libversit.la + +evolution_addressbook_LDFLAGS = `gnome-config --libs gdk_pixbuf` + +gnorbadir = $(sysconfdir)/CORBA/servers +gnorba_DATA = addressbook.gnorba diff --git a/addressbook/gui/component/addressbook-factory.c b/addressbook/gui/component/addressbook-factory.c new file mode 100644 index 0000000000..cf59177f84 --- /dev/null +++ b/addressbook/gui/component/addressbook-factory.c @@ -0,0 +1,47 @@ +/** + * sample-control-factory.c + * + * Copyright 1999, Helix Code, Inc. + * + * Author: + * Nat Friedman (nat@nat.org) + * + */ + +#include <config.h> +#include <gnome.h> +#include <libgnorba/gnorba.h> +#include <bonobo.h> + +#include "addressbook.h" + +CORBA_Environment ev; +CORBA_ORB orb; + +static void +init_bonobo (int argc, char **argv) +{ + + gnome_CORBA_init_with_popt_table ( + "evolution-addressbook", "0.0", + &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); + + orb = gnome_CORBA_ORB (); + + if (bonobo_init (orb, NULL, NULL) == FALSE) + g_error (_("Could not initialize Bonobo")); +} + +int +main (int argc, char **argv) +{ + CORBA_exception_init (&ev); + + init_bonobo (argc, argv); + + addressbook_factory_init (); + + bonobo_main (); + + return 0; +} diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c new file mode 100644 index 0000000000..3fb9a036ca --- /dev/null +++ b/addressbook/gui/component/addressbook.c @@ -0,0 +1,275 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * folder-browser-factory.c: A Bonobo Control factory for Folder Browsers + * + * Author: + * Miguel de Icaza (miguel@helixcode.com) + * + * (C) 2000 Helix Code, Inc. + */ +/* + * bonobo-clock-control.c + * + * Copyright 1999, Helix Code, Inc. + * + * Author: + * Nat Friedman (nat@nat.org) + */ + +#include <config.h> +#include <gnome.h> +#include <libgnorba/gnorba.h> +#include <bonobo.h> + +#include "addressbook.h" + +#include "e-book.h" +#include "e-canvas.h" +#include "e-minicard-view.h" + +static void +control_deactivate (BonoboControl *control, BonoboUIHandler *uih) +{ + /* how to remove a menu item */ + bonobo_ui_handler_menu_remove (uih, "/Actions/New Contact"); + + /* remove our toolbar */ + bonobo_ui_handler_dock_remove (uih, "/Toolbar"); +} + +static void +do_nothing_cb (BonoboUIHandler *uih, void *user_data, const char *path) +{ + printf ("Yow! I am called back!\n"); +} + +static GnomeUIInfo gnome_toolbar [] = { + GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new contact"), do_nothing_cb, GNOME_STOCK_PIXMAP_NEW), + + GNOMEUIINFO_SEPARATOR, + + GNOMEUIINFO_ITEM_STOCK (N_("Find"), N_("Find a contact"), do_nothing_cb, GNOME_STOCK_PIXMAP_SEARCH), + GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print contacts"), do_nothing_cb, GNOME_STOCK_PIXMAP_PRINT), + GNOMEUIINFO_ITEM_STOCK (N_("Delete"), N_("Delete a contact"), do_nothing_cb, GNOME_STOCK_PIXMAP_TRASH), + + GNOMEUIINFO_END +}; + + + + +static void +control_activate (BonoboControl *control, BonoboUIHandler *uih) +{ + Bonobo_UIHandler remote_uih; + GtkWidget *toolbar; + BonoboControl *toolbar_control; + + remote_uih = bonobo_control_get_remote_ui_handler (control); + bonobo_ui_handler_set_container (uih, remote_uih); + + bonobo_ui_handler_menu_new_item (uih, "/Actions/New Contact", N_("_New Contact"), + NULL, -1, + BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, + 0, 0, do_nothing_cb, NULL); + + toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, + GTK_TOOLBAR_BOTH); + + gnome_app_fill_toolbar (GTK_TOOLBAR (toolbar), + gnome_toolbar, + NULL); + + gtk_widget_show_all (toolbar); + + toolbar_control = bonobo_control_new (toolbar); + bonobo_ui_handler_dock_add ( + uih, "/Toolbar", + bonobo_object_corba_objref (BONOBO_OBJECT (toolbar_control)), + GNOME_DOCK_ITEM_BEH_LOCKED | + GNOME_DOCK_ITEM_BEH_EXCLUSIVE, + GNOME_DOCK_TOP, + 1, 1, 0); +} + +static void +control_activate_cb (BonoboControl *control, + gboolean activate, + gpointer user_data) +{ + BonoboUIHandler *uih; + + uih = bonobo_control_get_ui_handler (control); + g_assert (uih); + + if (activate) + control_activate (control, uih); + else + control_deactivate (control, uih); +} + +typedef struct { + GtkWidget *canvas; + GnomeCanvasItem *view; + GnomeCanvasItem *rect; + GtkAllocation last_alloc; +} AddressbookView; + +static void +book_open_cb (EBook *book, EBookStatus status, gpointer closure) +{ + AddressbookView *view = closure; + if (status == E_BOOK_STATUS_SUCCESS) + gnome_canvas_item_set(view->view, + "book", book, + NULL); +} + +static EBook * +ebook_create (AddressbookView *view) +{ + EBook *book; + + book = e_book_new (); + + if (!book) { + printf ("%s: %s(): Couldn't create EBook, bailing.\n", + __FILE__, + __FUNCTION__); + return NULL; + } + + + if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, view)) { + printf ("error calling load_uri!\n"); + } + + + return book; +} + +static void destroy_callback(GtkWidget *widget, gpointer data) +{ + AddressbookView *view = data; + g_free(view); +} + +static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) +{ + double width; + AddressbookView *view = data; + view->last_alloc = *allocation; + gnome_canvas_item_set( view->view, + "height", (double) allocation->height, + NULL ); + gnome_canvas_item_set( view->view, + "minimum_width", (double) allocation->width, + NULL ); + gtk_object_get(GTK_OBJECT(view->view), + "width", &width, + NULL); + width = MAX(width, allocation->width); + gnome_canvas_set_scroll_region(GNOME_CANVAS( view->canvas ), 0, 0, width, allocation->height ); + gnome_canvas_item_set( view->rect, + "x2", (double) width, + "y2", (double) allocation->height, + NULL ); +} + +static void resize(GnomeCanvas *canvas, gpointer data) +{ + double width; + AddressbookView *view = data; + gtk_object_get(GTK_OBJECT(view->view), + "width", &width, + NULL); + width = MAX(width, view->last_alloc.width); + gnome_canvas_set_scroll_region(GNOME_CANVAS(view->canvas), 0, 0, width, view->last_alloc.height ); + gnome_canvas_item_set( view->rect, + "x2", (double) width, + "y2", (double) view->last_alloc.height, + NULL ); +} + +static BonoboObject * +addressbook_factory (BonoboGenericFactory *Factory, void *closure) +{ + BonoboControl *control; + EBook *book; + GtkWidget *vbox, *scrollbar; + AddressbookView *view; + view = g_new (AddressbookView, 1); + + vbox = gtk_vbox_new(FALSE, 0); + + view->canvas = e_canvas_new(); + view->rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( view->canvas ) ), + gnome_canvas_rect_get_type(), + "x1", (double) 0, + "y1", (double) 0, + "x2", (double) 100, + "y2", (double) 100, + "fill_color", "white", + NULL ); + view->view = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( view->canvas ) ), + e_minicard_view_get_type(), + "height", (double) 100, + "minimum_width", (double) 100, + NULL ); + gtk_signal_connect( GTK_OBJECT( view->canvas ), "reflow", + GTK_SIGNAL_FUNC( resize ), + view); + + gnome_canvas_set_scroll_region ( GNOME_CANVAS( view->canvas ), + 0, 0, + 100, 100 ); + + gtk_box_pack_start(GTK_BOX(vbox), view->canvas, TRUE, TRUE, 0); + + scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(view->canvas))); + + gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0); + + /* Connect the signals */ + gtk_signal_connect( GTK_OBJECT( vbox ), "destroy", + GTK_SIGNAL_FUNC( destroy_callback ), + ( gpointer ) view ); + + gtk_signal_connect( GTK_OBJECT( view->canvas ), "size_allocate", + GTK_SIGNAL_FUNC( allocate_callback ), + ( gpointer ) view ); + + gtk_widget_show_all( vbox ); +#if 0 + gdk_window_set_back_pixmap( GTK_LAYOUT(view->canvas)->bin_window, NULL, FALSE); +#endif + + + book = ebook_create(view); + + /* Create the control. */ + control = bonobo_control_new(vbox); + + gtk_signal_connect (GTK_OBJECT (control), "activate", + control_activate_cb, NULL); + + return BONOBO_OBJECT (control); +} + +void +addressbook_factory_init (void) +{ + static BonoboGenericFactory *addressbook_control_factory = NULL; + + if (addressbook_control_factory != NULL) + return; + + addressbook_control_factory = + bonobo_generic_factory_new ( + "control-factory:addressbook", + addressbook_factory, NULL); + + if (addressbook_control_factory == NULL) { + g_error ("I could not register a Addressbook factory."); + } +} diff --git a/addressbook/gui/component/addressbook.gnorba b/addressbook/gui/component/addressbook.gnorba new file mode 100644 index 0000000000..7114b1c332 --- /dev/null +++ b/addressbook/gui/component/addressbook.gnorba @@ -0,0 +1,11 @@ +[control-factory:addressbook] +type=exe +repo_id=IDL:GNOME/GenericFactory:1.0 +description=Factory for the sample Addressbook control +location_info=evolution-addressbook + +[control:addressbook] +type=factory +repo_id=IDL:BonoboControl/addressbook-control:1.0 IDL:GNOME/Control:1.0 +description=A sample Bonobo control which displays an addressbook. +location_info=control-factory:addressbook diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h new file mode 100644 index 0000000000..e9289128a6 --- /dev/null +++ b/addressbook/gui/component/addressbook.h @@ -0,0 +1,8 @@ +#ifndef __ADDRESSBOOK_H__ +#define __ADDRESSBOOK_H__ + +#include <bonobo/bonobo-control.h> + +void addressbook_factory_init (void); + +#endif /* __ADDRESSBOOK_H__ */ |