[evolution-patches] Contact list editor - select from addressbook add on...
- From: HP Nadig <hpnadig pacific net in>
- To: evolution-patches ximian com
- Subject: [evolution-patches] Contact list editor - select from addressbook add on...
- Date: Thu, 27 May 2004 00:22:12 +0530
hi,
I've tried my bit to include select names dialog in contact list
editor. Please do take a look at the code and let me know if it is ok.
I'll despatch the patch again with change log if the code is ok. :)
thanks,
- hp
? gui/contact-list-editor/contact-list-editor.gladep
Index: gui/contact-list-editor/contact-list-editor.glade
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-list-editor/contact-list-editor.glade,v
retrieving revision 1.11
diff -u -r1.11 contact-list-editor.glade
--- gui/contact-list-editor/contact-list-editor.glade 19 Apr 2004 15:19:05 -0000 1.11
+++ gui/contact-list-editor/contact-list-editor.glade 26 May 2004 18:40:27 -0000
@@ -239,6 +239,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>
@@ -250,10 +251,23 @@
<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>
<property name="use_stock">True</property>
+ <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>
Index: gui/contact-list-editor/e-contact-list-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-list-editor/e-contact-list-editor.c,v
retrieving revision 1.53
diff -u -r1.53 e-contact-list-editor.c
--- gui/contact-list-editor/e-contact-list-editor.c 19 Apr 2004 15:19:05 -0000 1.53
+++ gui/contact-list-editor/e-contact-list-editor.c 26 May 2004 18:40:32 -0000
@@ -33,6 +33,9 @@
#include <bonobo/bonobo-ui-container.h>
#include <bonobo/bonobo-ui-util.h>
#include <bonobo/bonobo-window.h>
+#include <bonobo/bonobo-control.h>
+#include <bonobo/bonobo-widget.h>
+#include <bonobo/bonobo-exception.h>
#include <gal/e-table/e-table-scrolled.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include "shell/evolution-shell-component-utils.h"
@@ -68,6 +71,7 @@
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);
@@ -205,6 +209,7 @@
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");
@@ -253,6 +258,8 @@
"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,
@@ -708,6 +715,89 @@
g_object_set_data(G_OBJECT(table), "model", model);
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);
+ }
+}
+
+static gboolean
+setup_corba (EContactListEditor *editor)
+{
+
+ CORBA_Environment ev;
+
+ g_assert (editor->corba_select_names == CORBA_OBJECT_NIL);
+
+ 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);
}
static void
Index: gui/contact-list-editor/e-contact-list-editor.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-list-editor/e-contact-list-editor.h,v
retrieving revision 1.14
diff -u -r1.14 e-contact-list-editor.h
--- gui/contact-list-editor/e-contact-list-editor.h 24 Mar 2004 20:18:46 -0000 1.14
+++ gui/contact-list-editor/e-contact-list-editor.h 26 May 2004 18:40:32 -0000
@@ -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 @@
#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;
@@ -63,10 +66,12 @@
GtkWidget *list_name_entry;
GtkWidget *add_button;
GtkWidget *remove_button;
+ GtkWidget *select_button;
GtkWidget *list_image_button;
GtkWidget *visible_addrs_checkbutton;
GtkWidget *list_image;
+ GNOME_Evolution_Addressbook_SelectNames corba_select_names;
/* Whether we are editing a new contact or an existing one */
guint is_new_list : 1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]