From 55e7f9a951704df272a3c56468be510cf0482e48 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Wed, 2 Jun 2004 06:23:27 +0000 Subject: Add in a source option menu to the dialog and make is sensitive only on 2004-06-01 Larry Ewing * gui/contact-list-editor/e-contact-list-editor.c: Add in a source option menu to the dialog and make is sensitive only on new lists. * gui/contact-list-editor/e-contact-list-editor.h: add load_book fields for async book loading. * gui/contact-list-editor/contact-list-editor.glade: add the new source selector in a table reorder some of the other widgets. svn path=/trunk/; revision=26150 --- addressbook/ChangeLog | 11 ++ .../contact-list-editor/contact-list-editor.glade | 127 +++++++++++++++------ .../contact-list-editor/e-contact-list-editor.c | 94 +++++++++++++++ .../contact-list-editor/e-contact-list-editor.h | 6 + 4 files changed, 206 insertions(+), 32 deletions(-) (limited to 'addressbook') diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 57af8d0338..4f58dc05c9 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,14 @@ +2004-06-01 Larry Ewing + + * gui/contact-list-editor/e-contact-list-editor.c: Add in a source + option menu to the dialog and make is sensitive only on new lists. + + * gui/contact-list-editor/e-contact-list-editor.h: add load_book + fields for async book loading. + + * gui/contact-list-editor/contact-list-editor.glade: add the new + source selector in a table reorder some of the other widgets. + 2004-05-28 Chris Toshok * gui/widgets/eab-contact-display.c (render_contact): render all diff --git a/addressbook/gui/contact-list-editor/contact-list-editor.glade b/addressbook/gui/contact-list-editor/contact-list-editor.glade index c7cdc30226..a1deb05bf3 100644 --- a/addressbook/gui/contact-list-editor/contact-list-editor.glade +++ b/addressbook/gui/contact-list-editor/contact-list-editor.glade @@ -36,39 +36,102 @@ 6 - + True - _List name: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - list-name-entry - - - 0 - False - False - - + 2 + 2 + False + 6 + 6 - - - True - True - True - True - True - 0 - - True - * - False + + + True + _List name: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + list-name-entry + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + _Where: + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + e_contact_list_editor_create_source_option_menu + 0 + 0 + Tue, 01 Jun 2004 18:22:38 GMT + + + 1 + 2 + 1 + 2 + fill + fill + + 0 @@ -89,7 +152,7 @@ 0 False - True + False diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 81b0a4a3d2..e2c62925b6 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -35,10 +35,13 @@ #include #include #include + #include "shell/evolution-shell-component-utils.h" #include "widgets/misc/e-image-chooser.h" +#include "widgets/misc/e-source-option-menu.h" +#include "addressbook/gui/component/addressbook.h" #include "addressbook/gui/widgets/eab-gui-util.h" #include "addressbook/util/eab-book-util.h" @@ -71,6 +74,7 @@ static void remove_entry_cb (GtkWidget *w, EContactListEditor *editor); static void list_name_changed_cb (GtkWidget *w, EContactListEditor *editor); static void list_image_changed_cb (GtkWidget *w, EContactListEditor *editor); static void visible_addrs_toggled_cb (GtkWidget *w, EContactListEditor *editor); +static void source_selected (GtkWidget *source_option_menu, ESource *source, EContactListEditor *editor); static gint app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data); static gboolean table_drag_drop_cb (ETable *table, int row, int col, GdkDragContext *context, @@ -192,6 +196,9 @@ e_contact_list_editor_init (EContactListEditor *editor) editor->in_async_call = FALSE; editor->is_new_list = FALSE; + editor->load_source_id = 0; + editor->load_book = NULL; + gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-list-editor.glade", NULL, NULL); editor->gui = gui; @@ -210,6 +217,7 @@ e_contact_list_editor_init (EContactListEditor *editor) editor->list_name_entry = glade_xml_get_widget (gui, "list-name-entry"); editor->list_image = glade_xml_get_widget (gui, "list-image"); editor->visible_addrs_checkbutton = glade_xml_get_widget (gui, "visible-addrs-checkbutton"); + editor->source_menu = glade_xml_get_widget (gui, "source-option-menu-source"); /* Construct the app */ bonobo_win = bonobo_window_new ("contact-list-editor", _("Contact List Editor")); @@ -271,6 +279,9 @@ e_contact_list_editor_init (EContactListEditor *editor) g_signal_connect (editor->list_image, "changed", G_CALLBACK(list_image_changed_cb), editor); + g_signal_connect (editor->source_menu, + "source_selected", G_CALLBACK (source_selected), editor); + command_state_changed (editor); /* Connect to the deletion of the dialog */ @@ -287,11 +298,60 @@ e_contact_list_editor_init (EContactListEditor *editor) } } +static void +new_target_cb (EBook *new_book, EBookStatus status, EContactListEditor *editor) +{ + editor->load_source_id = 0; + editor->load_book = NULL; + + if (status != E_BOOK_ERROR_OK || new_book == NULL) { + eab_load_error_dialog (NULL, e_book_get_source (new_book), status); + + e_source_option_menu_select (E_SOURCE_OPTION_MENU (editor->source_menu), + e_book_get_source (editor->book)); + + if (new_book) + g_object_unref (new_book); + return; + } + + g_object_set (editor, "book", new_book, NULL); + g_object_unref (new_book); +} + +static void +cancel_load (EContactListEditor *editor) +{ + if (editor->load_source_id) { + addressbook_load_cancel (editor->load_source_id); + editor->load_source_id = 0; + + g_object_unref (editor->load_book); + editor->load_book = NULL; + } +} + +static void +source_selected (GtkWidget *source_option_menu, ESource *source, EContactListEditor *editor) +{ + cancel_load (editor); + + if (e_source_equal (e_book_get_source (editor->book), source)) + return; + + editor->load_book = e_book_new (source, NULL); + editor->load_source_id = addressbook_load (editor->load_book, + (EBookCallback) new_target_cb, editor); +} + static void e_contact_list_editor_dispose (GObject *object) { + cancel_load (E_CONTACT_LIST_EDITOR (object)); + if (G_OBJECT_CLASS (parent_class)->dispose) (* G_OBJECT_CLASS (parent_class)->dispose) (object); + } typedef struct { @@ -710,6 +770,31 @@ e_contact_list_editor_create_table(gchar *name, return table; } +GtkWidget * +e_contact_list_editor_create_source_option_menu (gchar *name, + gchar *string1, gchar *string2, + gint int1, gint int2); + +GtkWidget * +e_contact_list_editor_create_source_option_menu (gchar *name, + gchar *string1, gchar *string2, + gint int1, gint int2) +{ + + GtkWidget *menu; + GConfClient *gconf_client; + ESourceList *source_list; + + gconf_client = gconf_client_get_default (); + source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/addressbook/sources"); + + menu = e_source_option_menu_new (source_list); + g_object_unref (source_list); + + gtk_widget_show (menu); + return menu; +} + static void add_email_cb (GtkWidget *w, EContactListEditor *editor) { @@ -1055,4 +1140,13 @@ fill_in_info(EContactListEditor *editor) e_contact_photo_free (photo); } } + + if (editor->book) { + ESource *source; + + source = e_book_get_source (editor->book); + e_source_option_menu_select (E_SOURCE_OPTION_MENU (editor->source_menu), source); + gtk_widget_set_sensitive (editor->source_menu, editor->is_new_list); + gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "source-label"), editor->is_new_list); + } } diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.h b/addressbook/gui/contact-list-editor/e-contact-list-editor.h index 3272cf39f0..601cb23fe2 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.h @@ -49,6 +49,7 @@ struct _EContactListEditor /* item specific fields */ EBook *book; + EContact *contact; /* UI handler */ @@ -66,6 +67,7 @@ struct _EContactListEditor GtkWidget *list_image_button; GtkWidget *visible_addrs_checkbutton; GtkWidget *list_image; + GtkWidget *source_menu; /* Whether we are editing a new contact or an existing one */ guint is_new_list : 1; @@ -81,6 +83,10 @@ struct _EContactListEditor /* Whether an async wombat call is in progress */ guint in_async_call : 1; + + /* ID for async load_source call */ + guint load_source_id; + EBook *load_book; }; struct _EContactListEditorClass -- cgit v1.2.3