diff options
author | Larry Ewing <lewing@ximian.com> | 2004-06-02 14:23:27 +0800 |
---|---|---|
committer | Larry Ewing <lewing@src.gnome.org> | 2004-06-02 14:23:27 +0800 |
commit | 55e7f9a951704df272a3c56468be510cf0482e48 (patch) | |
tree | ce39e1492731ced3022f18ba2e5846190e3ac4e5 | |
parent | b3a61aaf1f5b61add460daef51b806957568a9bd (diff) | |
download | gsoc2013-evolution-55e7f9a951704df272a3c56468be510cf0482e48.tar.gz gsoc2013-evolution-55e7f9a951704df272a3c56468be510cf0482e48.tar.zst gsoc2013-evolution-55e7f9a951704df272a3c56468be510cf0482e48.zip |
Add in a source option menu to the dialog and make is sensitive only on
2004-06-01 Larry Ewing <lewing@ximian.com>
* 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
-rw-r--r-- | addressbook/ChangeLog | 11 | ||||
-rw-r--r-- | addressbook/gui/contact-list-editor/contact-list-editor.glade | 127 | ||||
-rw-r--r-- | addressbook/gui/contact-list-editor/e-contact-list-editor.c | 94 | ||||
-rw-r--r-- | addressbook/gui/contact-list-editor/e-contact-list-editor.h | 6 |
4 files changed, 206 insertions, 32 deletions
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 <lewing@ximian.com> + + * 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 <toshok@ximian.com> * 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 @@ <property name="spacing">6</property> <child> - <widget class="GtkLabel" id="label10"> + <widget class="GtkTable" id="table1"> <property name="visible">True</property> - <property name="label" translatable="yes">_List name:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">list-name-entry</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <property name="n_rows">2</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> - <child> - <widget class="GtkEntry" id="list-name-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> + <child> + <widget class="GtkLabel" id="label10"> + <property name="visible">True</property> + <property name="label" translatable="yes">_List name:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">list-name-entry</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="list-name-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="has_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char" translatable="yes">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="source-label"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Where:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="Custom" id="source-option-menu-source"> + <property name="visible">True</property> + <property name="creation_function">e_contact_list_editor_create_source_option_menu</property> + <property name="int1">0</property> + <property name="int2">0</property> + <property name="last_modification_time">Tue, 01 Jun 2004 18:22:38 GMT</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options">fill</property> + </packing> + </child> </widget> <packing> <property name="padding">0</property> @@ -89,7 +152,7 @@ <packing> <property name="padding">0</property> <property name="expand">False</property> - <property name="fill">True</property> + <property name="fill">False</property> </packing> </child> </widget> 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 <bonobo/bonobo-window.h> #include <gal/e-table/e-table-scrolled.h> #include <libgnomevfs/gnome-vfs-ops.h> + #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 */ @@ -288,10 +299,59 @@ 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 |