diff options
Diffstat (limited to 'addressbook/gui/contact-list-editor')
3 files changed, 112 insertions, 0 deletions
diff --git a/addressbook/gui/contact-list-editor/contact-list-editor.glade b/addressbook/gui/contact-list-editor/contact-list-editor.glade index 5f0b8bfaf5..3f6953cbf4 100644 --- a/addressbook/gui/contact-list-editor/contact-list-editor.glade +++ b/addressbook/gui/contact-list-editor/contact-list-editor.glade @@ -337,6 +337,7 @@ <child> <widget class="GtkButton" id="add-email-button"> <property name="visible">True</property> + <property name="tooltip" translatable="yes">Add an email to the List</property> <property name="can_default">True</property> <property name="can_focus">True</property> <property name="label">gtk-add</property> @@ -348,6 +349,7 @@ <child> <widget class="GtkButton" id="remove-button"> <property name="visible">True</property> + <property name="tooltip" translatable="yes">Remove an email address from the List</property> <property name="can_default">True</property> <property name="can_focus">True</property> <property name="label">gtk-remove</property> @@ -355,6 +357,18 @@ <property name="relief">GTK_RELIEF_NORMAL</property> </widget> </child> + + <child> + <widget class="GtkButton" id="select-button"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Insert email adresses from Adress Book</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Select</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + </widget> + </child> </widget> <packing> <property name="padding">0</property> 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 e5a0da68ec..80d5b6c660 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -34,6 +34,10 @@ #include <gal/e-table/e-table-scrolled.h> #include <libgnomevfs/gnome-vfs-ops.h> +#include <bonobo/bonobo-control.h> +#include <bonobo/bonobo-widget.h> +#include <bonobo/bonobo-exception.h> + #include "shell/evolution-shell-component-utils.h" #include "widgets/misc/e-image-chooser.h" @@ -68,6 +72,7 @@ static void fill_in_info(EContactListEditor *editor); static void add_email_cb (GtkWidget *w, EContactListEditor *editor); static void remove_entry_cb (GtkWidget *w, EContactListEditor *editor); +static void select_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); @@ -210,6 +215,7 @@ e_contact_list_editor_init (EContactListEditor *editor) editor->add_button = glade_xml_get_widget (editor->gui, "add-email-button"); editor->remove_button = glade_xml_get_widget (editor->gui, "remove-button"); + editor->select_button = glade_xml_get_widget (editor->gui, "select-button"); editor->email_entry = glade_xml_get_widget (gui, "email-entry"); editor->list_name_entry = glade_xml_get_widget (gui, "list-name-entry"); @@ -227,6 +233,8 @@ e_contact_list_editor_init (EContactListEditor *editor) "activate", G_CALLBACK(add_email_cb), editor); g_signal_connect (editor->remove_button, "clicked", G_CALLBACK(remove_entry_cb), editor); + g_signal_connect (editor->select_button, + "clicked", G_CALLBACK(select_cb), editor); g_signal_connect (editor->list_name_entry, "changed", G_CALLBACK(list_name_changed_cb), editor); g_signal_connect (editor->visible_addrs_checkbutton, @@ -638,6 +646,90 @@ e_contact_list_editor_create_table(gchar *name, return table; } +static void +add_to_model (EContactListEditor *editor, EDestination **cards) +{ + int i; + + for (i = 0; cards[i] != NULL; i++) { + e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL(editor->model), cards[i]); + } +} + +static void +select_names_ok_cb (BonoboListener *listener, const char *event_name, const CORBA_any *arg, + CORBA_Environment *ev, gpointer data) +{ + EDestination **destv; + + char *string = NULL; + + EContactListEditor *ce; + + ce = E_CONTACT_LIST_EDITOR (data); + + Bonobo_Control corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection + (ce->corba_select_names, "Members", ev); + GtkWidget *control_widget = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL); + + bonobo_widget_get_property (BONOBO_WIDGET (control_widget), "destinations", + TC_CORBA_string, &string, NULL); + + destv = e_destination_importv (string); + if (destv) { + add_to_model (ce, destv); + g_free (destv); + } + + ce->changed = TRUE; + command_state_changed (ce); +} + +static gboolean +setup_corba (EContactListEditor *editor) +{ + + CORBA_Environment ev; + + CORBA_exception_init (&ev); + + editor->corba_select_names = bonobo_activation_activate_from_id (SELECT_NAMES_OAFIID, 0, NULL, &ev); + + /* OAF seems to be broken -- it can return a CORBA_OBJECT_NIL without + raising an exception in `ev'. */ + if (ev._major != CORBA_NO_EXCEPTION || editor->corba_select_names == CORBA_OBJECT_NIL) { + CORBA_exception_free (&ev); + return FALSE; + } + + GNOME_Evolution_Addressbook_SelectNames_addSection ( + editor->corba_select_names, "Members", gettext ("Members"), &ev); + + bonobo_event_source_client_add_listener (editor->corba_select_names, + (BonoboListenerCallbackFn) select_names_ok_cb, + "GNOME/Evolution:ok:dialog", NULL, editor); + + CORBA_exception_free (&ev); + + return TRUE; +} + +static void +select_cb (GtkWidget *w, EContactListEditor *editor) +{ + CORBA_Environment ev; + + if(!setup_corba (editor)) + return; + + CORBA_exception_init (&ev); + + GNOME_Evolution_Addressbook_SelectNames_activateDialog ( + editor->corba_select_names, _("Required Participants"), &ev); + + CORBA_exception_free (&ev); +} + GtkWidget * e_contact_list_editor_create_source_option_menu (gchar *name, gchar *string1, gchar *string2, 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 26de00e6f8..5a1074321c 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.h @@ -30,6 +30,8 @@ #include <libebook/e-book-async.h> #include <libebook/e-contact.h> +#include "addressbook/util/e-destination.h" +#include "addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.h" G_BEGIN_DECLS @@ -39,6 +41,7 @@ G_BEGIN_DECLS #define E_IS_CONTACT_LIST_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CONTACT_LIST_EDITOR)) #define E_IS_CONTACT_LIST_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_CONTACT_LIST_EDITOR)) +#define SELECT_NAMES_OAFIID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION typedef struct _EContactListEditor EContactListEditor; typedef struct _EContactListEditorClass EContactListEditorClass; @@ -64,6 +67,7 @@ struct _EContactListEditor GtkWidget *list_name_entry; GtkWidget *add_button; GtkWidget *remove_button; + GtkWidget *select_button; GtkWidget *list_image_button; GtkWidget *visible_addrs_checkbutton; GtkWidget *list_image; @@ -71,6 +75,8 @@ struct _EContactListEditor GtkWidget *ok_button; GtkWidget *cancel_button; + GNOME_Evolution_Addressbook_SelectNames corba_select_names; + /* Whether we are editing a new contact or an existing one */ guint is_new_list : 1; |