From 31c401df882702ae0adfd7b92c8f78c166b20c1e Mon Sep 17 00:00:00 2001 From: H P Nadig Date: Mon, 7 Jun 2004 20:19:14 +0000 Subject: Added few headers needed for select names dialog. 2004-06-07 H P Nadig * gui/contact-list-editor/e-contact-list-editor.h: Added few headers needed for select names dialog. * gui/contact-list-editor/e-contact-list-editor.c (e_contact_list_editor_init): Added select button handler. (select_cb): The callback function for Select Button. (setup_corba): To setup corba for select names dialog. (select_names_ok_cb): Handle Select names dialog entries. (add_to_model): Adds cards to the model. * gui/contact-list-editor/contact-list-editor.glade: New 'Select' Button. Tooltips added for buttons in button Box. svn path=/trunk/; revision=26240 --- .../contact-list-editor/contact-list-editor.glade | 14 ++++ .../contact-list-editor/e-contact-list-editor.c | 92 ++++++++++++++++++++++ .../contact-list-editor/e-contact-list-editor.h | 6 ++ 3 files changed, 112 insertions(+) (limited to 'addressbook/gui') 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 @@ True + Add an email to the List True True gtk-add @@ -348,6 +349,7 @@ True + Remove an email address from the List True True gtk-remove @@ -355,6 +357,18 @@ GTK_RELIEF_NORMAL + + + + True + Insert email adresses from Adress Book + True + True + Select + True + GTK_RELIEF_NORMAL + + 0 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 #include +#include +#include +#include + #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 #include +#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; -- cgit v1.2.3