diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-05-07 01:13:40 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-05-07 01:13:40 +0800 |
commit | 6ccb0487b00f9d7a4154af10ad8e4ed85e7be382 (patch) | |
tree | e09584e37ac6f52e8d52bef0711e08f769c36ac1 /addressbook | |
parent | 7453ffb6a86769bd22ce01da43fbbe919bef861d (diff) | |
download | gsoc2013-evolution-6ccb0487b00f9d7a4154af10ad8e4ed85e7be382.tar gsoc2013-evolution-6ccb0487b00f9d7a4154af10ad8e4ed85e7be382.tar.gz gsoc2013-evolution-6ccb0487b00f9d7a4154af10ad8e4ed85e7be382.tar.bz2 gsoc2013-evolution-6ccb0487b00f9d7a4154af10ad8e4ed85e7be382.tar.lz gsoc2013-evolution-6ccb0487b00f9d7a4154af10ad8e4ed85e7be382.tar.xz gsoc2013-evolution-6ccb0487b00f9d7a4154af10ad8e4ed85e7be382.tar.zst gsoc2013-evolution-6ccb0487b00f9d7a4154af10ad8e4ed85e7be382.zip |
Made the component take a uri through its property bag.
2000-05-06 Christopher James Lahey <clahey@helixcode.com>
* gui/component/addressbook.c: Made the component take a uri
through its property bag.
svn path=/trunk/; revision=2829
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 5 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.c | 106 |
2 files changed, 108 insertions, 3 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 5430229ea1..80e4a534f1 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,8 @@ +2000-05-06 Christopher James Lahey <clahey@helixcode.com> + + * gui/component/addressbook.c: Made this take a uri through its + property bag. + 2000-05-05 Christopher James Lahey <clahey@helixcode.com> * backend/ebook/Makefile.am: Added e-card-simple.c and diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index b225c5ce93..72bd8967ba 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -18,6 +18,7 @@ #include <ebook/e-book.h> #include <e-util/e-canvas.h> +#include <e-util/e-util.h> #include "e-minicard-view.h" #include "e-contact-editor.h" #include "e-ldap-server-dialog.h" @@ -28,6 +29,10 @@ #define CONTROL_FACTORY_ID "control-factory:addressbook" #endif +#define PROPERTY_FOLDER_URI "folder_uri" + +#define PROPERTY_FOLDER_URI_IDX 1 + static void control_deactivate (BonoboControl *control, BonoboUIHandler *uih) { @@ -313,9 +318,20 @@ typedef struct { GnomeCanvasItem *view; GnomeCanvasItem *rect; GtkAllocation last_alloc; + BonoboPropertyBag *properties; + char *uri; } AddressbookView; static void +addressbook_view_free(AddressbookView *view) +{ + if (view->properties) + bonobo_object_unref(BONOBO_OBJECT(view->properties)); + g_free(view->uri); + g_free(view); +} + +static void book_open_cb (EBook *book, EBookStatus status, gpointer closure) { AddressbookView *view = closure; @@ -353,7 +369,7 @@ ebook_create (AddressbookView *view) static void destroy_callback(GtkWidget *widget, gpointer data) { AddressbookView *view = data; - g_free(view); + addressbook_view_free(view); } static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) @@ -393,6 +409,79 @@ static void resize(GnomeCanvas *canvas, gpointer data) NULL ); } +static void +get_prop (BonoboPropertyBag *bag, + BonoboArg *arg, + guint arg_id, + gpointer user_data) +{ + AddressbookView *view = user_data; + + switch (arg_id) { + + case PROPERTY_FOLDER_URI_IDX: + if (view && view->uri) + BONOBO_ARG_SET_STRING (arg, view->uri); + else + BONOBO_ARG_SET_STRING (arg, ""); + break; + + default: + g_warning ("Unhandled arg %d\n", arg_id); + } +} + +static void +set_prop (BonoboPropertyBag *bag, + const BonoboArg *arg, + guint arg_id, + gpointer user_data) +{ + AddressbookView *view = user_data; + + EBook *book; + char *uri_file; + char *uri_data; + char *uri; + + switch (arg_id) { + + case PROPERTY_FOLDER_URI_IDX: + view->uri = g_strdup(BONOBO_ARG_GET_STRING (arg)); + + book = e_book_new (); + + if (!book) { + printf ("%s: %s(): Couldn't create EBook, bailing.\n", + __FILE__, + __FUNCTION__); + return; + } + + uri_file = g_concat_dir_and_file(view->uri + 7, "uri"); + + uri_data = e_read_file(uri_file); + if (uri_data) + uri = uri_data; + else + uri = view->uri; + + if (! e_book_load_uri (book, uri, book_open_cb, view)) + { + printf ("error calling load_uri!\n"); + } + + g_free(uri_data); + g_free(uri_file); + + break; + + default: + g_warning ("Unhandled arg %d\n", arg_id); + break; + } +} + static BonoboObject * addressbook_factory (BonoboGenericFactory *Factory, void *closure) { @@ -460,12 +549,23 @@ addressbook_factory (BonoboGenericFactory *Factory, void *closure) /* Create the control. */ control = bonobo_control_new(vbox); - + + view->properties = bonobo_property_bag_new (get_prop, set_prop, view); + + bonobo_property_bag_add ( + view->properties, PROPERTY_FOLDER_URI, PROPERTY_FOLDER_URI_IDX, + BONOBO_ARG_STRING, NULL, _("The URI that the Folder Browser will display"), 0); + + bonobo_control_set_property_bag (control, + view->properties); + + view->uri = NULL; + gtk_signal_connect (GTK_OBJECT (control), "activate", control_activate_cb, view->view); gtk_widget_pop_visual (); - gtk_widget_pop_colormap (); + gtk_widget_pop_colormap (); return BONOBO_OBJECT (control); } |