diff options
author | Chris Toshok <toshok@ximian.com> | 2004-02-20 10:20:52 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2004-02-20 10:20:52 +0800 |
commit | 31e82459bdaca03ce878a0181a55102c43a1de69 (patch) | |
tree | 5683ba500227c89ea3877b16aa6142f8a80e0011 /addressbook | |
parent | 65500ade9a6cd497eeffa32253beebb0d0508c54 (diff) | |
download | gsoc2013-evolution-31e82459bdaca03ce878a0181a55102c43a1de69.tar.gz gsoc2013-evolution-31e82459bdaca03ce878a0181a55102c43a1de69.tar.zst gsoc2013-evolution-31e82459bdaca03ce878a0181a55102c43a1de69.zip |
split out the majority of the set_prop code for PROPERTY_SOURCE_UID_IDX
2004-02-19 Chris Toshok <toshok@ximian.com>
* gui/component/addressbook.c (activate_source): split out the
majority of the set_prop code for PROPERTY_SOURCE_UID_IDX here, so
it can be used for both SOURCE_UID and FOLDER_URI.
(set_prop): add a setter for "folder_uri". we sorta fudge things
and use the uri for the uid (the uid is only used as a hash key to
look up the view associated with the uri/source, so we should be
good still.)
(get_prop): add getter for "folder_uri".
(addressbook_new_control): add the "folder_uri" property to our
property bag.
svn path=/trunk/; revision=24808
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 13 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.c | 218 |
2 files changed, 147 insertions, 84 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index b9bd0c8da8..a1e13f43d3 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,16 @@ +2004-02-19 Chris Toshok <toshok@ximian.com> + + * gui/component/addressbook.c (activate_source): split out the + majority of the set_prop code for PROPERTY_SOURCE_UID_IDX here, so + it can be used for both SOURCE_UID and FOLDER_URI. + (set_prop): add a setter for "folder_uri". we sorta fudge things + and use the uri for the uid (the uid is only used as a hash key to + look up the view associated with the uri/source, so we should be + good still.) + (get_prop): add getter for "folder_uri". + (addressbook_new_control): add the "folder_uri" property to our + property bag. + 2004-02-19 Hans Petter Jansson <hpj@ximian.com> Fixes #45308 and duplicates. diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 372767f043..293f8664fe 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -61,8 +61,10 @@ static GdkPixbuf *progress_icon = NULL; #define d(x) #define PROPERTY_SOURCE_UID "source_uid" +#define PROPERTY_FOLDER_URI "folder_uri" #define PROPERTY_SOURCE_UID_IDX 1 +#define PROPERTY_FOLDER_URI_IDX 2 typedef struct { gint refs; @@ -890,109 +892,132 @@ addressbook_load_default_book (EBookCallback cb, gpointer closure) } static void -set_prop (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) +activate_source (AddressbookView *view, + ESource *source, + const char *uid) { - AddressbookView *view = user_data; + GtkWidget *uid_view; + EBook *book; + BookOpenData *data; + + uid_view = g_hash_table_lookup (view->uid_to_view, uid); + + if (uid_view) { + /* there is a view for this uid. make + sure that the view actually + contains an EBook (if it doesn't + contain an EBook a previous load + failed. try to load it again */ + g_object_get (uid_view, + "book", &book, + NULL); + + if (book) { + g_object_unref (book); + } + else { + book = e_book_new (); - switch (arg_id) { + g_object_get (uid_view, + "source", &source, + NULL); - case PROPERTY_SOURCE_UID_IDX: { - ESource *source; - const gchar *uid; + /* source can be NULL here, if + a previous load hasn't + actually made it to + book_open_cb yet. */ + if (source) { + data = g_new (BookOpenData, 1); + data->view = g_object_ref (uid_view); + data->source = source; /* transfer the ref we get back from g_object_get */ - uid = BONOBO_ARG_GET_STRING (arg); + addressbook_load_source (book, source, book_open_cb, data); + } + } + } + else { + /* we don't have a view for this uid already + set up. */ + GtkWidget *label = gtk_label_new (uid); - source = e_source_list_peek_source_by_uid (view->source_list, uid); + uid_view = eab_view_new (); - if (source) { - GtkWidget *uid_view; - EBook *book; - BookOpenData *data; - - uid_view = g_hash_table_lookup (view->uid_to_view, uid); - - if (uid_view) { - /* there is a view for this uid. make - sure that the view actually - contains an EBook (if it doesn't - contain an EBook a previous load - failed. try to load it again */ - g_object_get (uid_view, - "book", &book, - NULL); - - if (book) { - g_object_unref (book); - } - else { - book = e_book_new (); - - g_object_get (uid_view, - "source", &source, - NULL); - - /* source can be NULL here, if - a previous load hasn't - actually made it to - book_open_cb yet. */ - if (source) { - data = g_new (BookOpenData, 1); - data->view = g_object_ref (uid_view); - data->source = source; /* transfer the ref we get back from g_object_get */ - - addressbook_load_source (book, source, book_open_cb, data); - } - } - } - else { - /* we don't have a view for this uid already - set up. */ - GtkWidget *label = gtk_label_new (uid); + gtk_widget_show (uid_view); + gtk_widget_show (label); - uid_view = eab_view_new (); + g_object_set (uid_view, "type", EAB_VIEW_TABLE, NULL); - gtk_widget_show (uid_view); - gtk_widget_show (label); + gtk_notebook_append_page (GTK_NOTEBOOK (view->notebook), + uid_view, + label); - g_object_set (uid_view, "type", EAB_VIEW_TABLE, NULL); + g_hash_table_insert (view->uid_to_view, g_strdup (uid), uid_view); - gtk_notebook_append_page (GTK_NOTEBOOK (view->notebook), - uid_view, - label); + g_signal_connect (uid_view, "status_message", + G_CALLBACK(set_status_message), view); - g_hash_table_insert (view->uid_to_view, g_strdup (uid), uid_view); + g_signal_connect (uid_view, "search_result", + G_CALLBACK(search_result), view); - g_signal_connect (uid_view, "status_message", - G_CALLBACK(set_status_message), view); + g_signal_connect (uid_view, "command_state_change", + G_CALLBACK(update_command_state), view); - g_signal_connect (uid_view, "search_result", - G_CALLBACK(search_result), view); + book = e_book_new (); - g_signal_connect (uid_view, "command_state_change", - G_CALLBACK(update_command_state), view); + data = g_new (BookOpenData, 1); + data->view = g_object_ref (uid_view); + data->source = g_object_ref (source); - book = e_book_new (); + addressbook_load_source (book, source, book_open_cb, data); + } - data = g_new (BookOpenData, 1); - data->view = g_object_ref (uid_view); - data->source = g_object_ref (source); + gtk_notebook_set_current_page (GTK_NOTEBOOK (view->notebook), + gtk_notebook_page_num (GTK_NOTEBOOK (view->notebook), + uid_view)); - addressbook_load_source (book, source, book_open_cb, data); - } + /* change menus/toolbars to reflect the new view, assuming we are already displayed */ + if (bonobo_ui_component_get_container (bonobo_control_get_ui_component (view->control)) != CORBA_OBJECT_NIL) { + eab_view_setup_menus (EAB_VIEW (uid_view), bonobo_control_get_ui_component (view->control)); + update_command_state (EAB_VIEW (uid_view), view); + } +} + +static void +set_prop (BonoboPropertyBag *bag, + const BonoboArg *arg, + guint arg_id, + CORBA_Environment *ev, + gpointer user_data) +{ + AddressbookView *view = user_data; + ESource *source; - gtk_notebook_set_current_page (GTK_NOTEBOOK (view->notebook), - gtk_notebook_page_num (GTK_NOTEBOOK (view->notebook), - uid_view)); + switch (arg_id) { - /* change menus/toolbars to reflect the new view, assuming we are already displayed */ - if (bonobo_ui_component_get_container (bonobo_control_get_ui_component (view->control)) != CORBA_OBJECT_NIL) { - eab_view_setup_menus (EAB_VIEW (uid_view), bonobo_control_get_ui_component (view->control)); - update_command_state (EAB_VIEW (uid_view), view); - } + case PROPERTY_FOLDER_URI_IDX: { + const gchar *string = BONOBO_ARG_GET_STRING (arg); + ESourceGroup *group; + + group = e_source_group_new ("", string); + source = e_source_new ("", ""); + e_source_set_group (source, group); + + /* we use the uri as the uid here. */ + activate_source (view, source, string); + + g_object_unref (group); + + break; + } + case PROPERTY_SOURCE_UID_IDX: { + const gchar *uid; + + uid = BONOBO_ARG_GET_STRING (arg); + + source = e_source_list_peek_source_by_uid (view->source_list, uid); + + if (source) { + activate_source (view, source, uid); } else { g_warning ("Could not find source by UID '%s'!", uid); @@ -1019,6 +1044,26 @@ get_prop (BonoboPropertyBag *bag, switch (arg_id) { + case PROPERTY_FOLDER_URI_IDX: + if (v) { + g_object_get (v, + "source", &source, + NULL); + } + + if (source) { + char *uri = e_source_get_uri (source); + + BONOBO_ARG_SET_STRING (arg, uri); + + g_free (uri); + g_object_unref (source); + } + else { + BONOBO_ARG_SET_STRING (arg, ""); + } + break; + case PROPERTY_SOURCE_UID_IDX: if (v) { g_object_get (v, @@ -1070,6 +1115,11 @@ addressbook_new_control (void) BONOBO_ARG_STRING, NULL, _("UID of the contacts source that the view will display"), 0); + bonobo_property_bag_add (view->properties, + PROPERTY_FOLDER_URI, PROPERTY_FOLDER_URI_IDX, + BONOBO_ARG_STRING, NULL, + _("The URI that the address book will display"), 0); + bonobo_control_set_properties (view->control, bonobo_object_corba_objref (BONOBO_OBJECT (view->properties)), NULL); |