From 0eabd23e17847dc35b67f6ef4cd84af0a25e5dcd Mon Sep 17 00:00:00 2001 From: Hans Petter Jansson Date: Thu, 23 Dec 2004 02:42:11 +0000 Subject: Unref the name selector. (e_contact_list_editor_save_contact): Fix a 2004-12-22 Hans Petter Jansson * addressbook/gui/contact-list-editor/e-contact-list-editor.c (e_contact_list_editor_dispose): Unref the name selector. (e_contact_list_editor_save_contact): Fix a warning. (add_to_model): Take a list instead of a vector of destinations. (select_names_ok_cb): Adapt to new name selector. (setup_corba): Renamed to setup_name_selector () and adapted. (select_cb): Adapt to new name selector. * addressbook/gui/contact-list-editor/e-contact-list-editor.h: Adapt to new name selector and remove CORBA/Bonobo. * addressbook/gui/widgets/eab-popup.c (eabp_target_free) (eabp_popup_target_new_select_names): #ifdef out code that depended on the old name selector. 2004-12-22 Hans Petter Jansson * calendar/gui/Makefile.am (IDLS) (SELECT_NAMES_IDL_GENERATED_H) (SELECT_NAMES_IDL_GENERATED_C) (SELECT_NAMES_IDL_GENERATED) (IDL_GENERATED): Remove the addressbook IDL. * calendar/gui/e-meeting-list-view.c (e_meeting_list_finalize) (add_section) (e_meeting_list_view_init) (process_section) (name_selector_dialog_close_cb) (get_select_name_dialog): Adapt to new ENameSelector. * calendar/gui/e-select-names-editable.c (esne_start_editing) (esne_finalize) (esne_init) (e_select_names_editable_get_type) (entry_activate) (e_select_names_editable_construct) (e_select_names_editable_get_address) (e_select_names_editable_get_name) (e_select_names_editable_set_address): Adapt to new ENameSelector. * calendar/gui/e-select-names-renderer.c (e_select_names_renderer_editing_done) (e_select_names_renderer_activated) (e_select_names_renderer_start_editing): Adapt to new ENameSelector. * calendar/gui/dialogs/alarm-dialog.c (malarm_widgets_to_alarm) (addressbook_clicked_cb) (addressbook_response_cb) (setup_select_names) (check_custom_email) (malarm_addresses_changed_cb): Adapt to new ENameSelector. * calendar/gui/dialogs/e-delegate-dialog.c (e_delegate_dialog_finalize) (e_delegate_dialog_construct) (addressbook_clicked_cb) (addressbook_response_cb) (e_delegate_dialog_get_delegate) (e_delegate_dialog_get_delegate_name): Adapt to new ENameSelector. 2004-12-22 Hans Petter Jansson * composer/e-msg-composer-hdrs.c (addressbook_dialog_response) (setup_corba) (setup_name_selector) (address_button_clicked_cb) (addressbook_entry_changed) (create_addressbook_entry) (destroy) (e_msg_composer_hdrs_new) (destinations_to_name_selector_entry) (e_msg_composer_hdrs_set_to) (e_msg_composer_hdrs_set_cc) (e_msg_composer_hdrs_set_bcc) (destination_list_to_destv) (e_msg_composer_hdrs_get_to) (e_msg_composer_hdrs_get_cc) (e_msg_composer_hdrs_get_bcc): Adapt to new ENameSelector. svn path=/trunk/; revision=28186 --- addressbook/ChangeLog | 17 ++ .../contact-list-editor/e-contact-list-editor.c | 121 +++++------ .../contact-list-editor/e-contact-list-editor.h | 15 +- addressbook/gui/widgets/eab-popup.c | 10 + addressbook/gui/widgets/eab-popup.h | 11 + calendar/ChangeLog | 43 ++++ calendar/gui/Makefile.am | 21 +- calendar/gui/dialogs/alarm-dialog.c | 109 +++++----- calendar/gui/dialogs/e-delegate-dialog.c | 131 ++++++------ calendar/gui/e-meeting-list-view.c | 155 +++++--------- calendar/gui/e-select-names-editable.c | 88 ++++---- calendar/gui/e-select-names-editable.h | 6 +- calendar/gui/e-select-names-renderer.c | 14 +- composer/ChangeLog | 19 ++ composer/e-msg-composer-hdrs.c | 223 ++++++++++++--------- composer/e-msg-composer-hdrs.h | 2 - 16 files changed, 525 insertions(+), 460 deletions(-) diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 8acc9d1e98..3b8ac134c4 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,20 @@ +2004-12-22 Hans Petter Jansson + + * gui/contact-list-editor/e-contact-list-editor.c + (e_contact_list_editor_dispose): Unref the name selector. + (e_contact_list_editor_save_contact): Fix a warning. + (add_to_model): Take a list instead of a vector of destinations. + (select_names_ok_cb): Adapt to new name selector. + (setup_corba): Renamed to setup_name_selector () and adapted. + (select_cb): Adapt to new name selector. + + * gui/contact-list-editor/e-contact-list-editor.h: Adapt to new + name selector and remove CORBA/Bonobo. + + * gui/widgets/eab-popup.c (eabp_target_free) + (eabp_popup_target_new_select_names): #ifdef out code that + depended on the old name selector. + 2004-12-17 Not Zed * util/ea-popup.c (emp_standard_menu_factory): 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 07b6598b08..ce44c109f7 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -36,10 +36,6 @@ #include #include -#include -#include -#include - #include "shell/evolution-shell-component-utils.h" #include "widgets/misc/e-image-chooser.h" @@ -47,9 +43,8 @@ #include "addressbook/gui/component/addressbook.h" #include "addressbook/gui/widgets/eab-gui-util.h" #include "addressbook/util/eab-book-util.h" -#include "Evolution-Addressbook-SelectNames.h" -#include "eab-editor.h" +#include "eab-editor.h" #include "e-contact-editor.h" #include "e-contact-list-model.h" #include "e-contact-list-editor-marshal.h" @@ -335,11 +330,17 @@ source_selected (GtkWidget *source_option_menu, ESource *source, EContactListEdi static void e_contact_list_editor_dispose (GObject *object) { - cancel_load (E_CONTACT_LIST_EDITOR (object)); + EContactListEditor *editor = E_CONTACT_LIST_EDITOR (object); + + cancel_load (editor); + + if (editor->name_selector) { + g_object_unref (editor->name_selector); + editor->name_selector = NULL; + } if (G_OBJECT_CLASS (parent_class)->dispose) (* G_OBJECT_CLASS (parent_class)->dispose) (object); - } typedef struct { @@ -440,7 +441,7 @@ e_contact_list_editor_save_contact (EABEditor *editor, gboolean should_close) { EContactListEditor *cle = E_CONTACT_LIST_EDITOR (editor); - save_contact (editor, should_close); + save_contact (cle, should_close); } static gboolean @@ -657,86 +658,90 @@ e_contact_list_editor_create_table(gchar *name, } static void -add_to_model (EContactListEditor *editor, EDestination **cards) +add_to_model (EContactListEditor *editor, GList *destinations) { - int i; + GList *l; - for (i = 0; cards[i] != NULL; i++) { - e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL(editor->model), cards[i]); + for (l = destinations; l; l = g_list_next (l)) { + EDestination *destination = l->data; + e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL(editor->model), destination); } } static void -select_names_ok_cb (BonoboListener *listener, const char *event_name, const CORBA_any *arg, - CORBA_Environment *ev, gpointer data) +select_names_ok_cb (GtkWidget *widget, gint response, gpointer data) { - EContactListEditor *ce; - EDestination **destv; - Bonobo_Control corba_control; - GtkWidget *control_widget; - char *string = NULL; + EContactListEditor *ce; + ENameSelectorDialog *name_selector_dialog; + ENameSelectorModel *name_selector_model; + EDestinationStore *destination_store; + GList *destinations; ce = E_CONTACT_LIST_EDITOR (data); - corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (ce->corba_select_names, - "Members", ev); - control_widget = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL); + name_selector_dialog = e_name_selector_peek_dialog (ce->name_selector); + gtk_widget_hide (GTK_WIDGET (name_selector_dialog)); + + name_selector_model = e_name_selector_peek_model (ce->name_selector); + e_name_selector_model_peek_section (name_selector_model, "Members", NULL, &destination_store); + destinations = e_destination_store_list_destinations (destination_store); - bonobo_widget_get_property (BONOBO_WIDGET (control_widget), "destinations", - TC_CORBA_string, &string, NULL); + add_to_model (ce, destinations); - destv = e_destination_importv (string); - if (destv) { - add_to_model (ce, destv); - g_free (destv); - } + g_list_free (destinations); ce->changed = TRUE; command_state_changed (ce); } -static gboolean -setup_corba (EContactListEditor *editor) +static void +setup_name_selector (EContactListEditor *editor) { - CORBA_Environment ev; + ENameSelectorModel *name_selector_model; + ENameSelectorDialog *name_selector_dialog; - 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); + if (editor->name_selector) + return; - bonobo_event_source_client_add_listener (editor->corba_select_names, - (BonoboListenerCallbackFn) select_names_ok_cb, - "GNOME/Evolution:ok:dialog", NULL, editor); + editor->name_selector = e_name_selector_new (); - CORBA_exception_free (&ev); + name_selector_model = e_name_selector_peek_model (editor->name_selector); + e_name_selector_model_add_section (name_selector_model, "Members", gettext ("Members"), NULL); - return TRUE; + name_selector_dialog = e_name_selector_peek_dialog (editor->name_selector); + gtk_window_set_title (GTK_WINDOW (name_selector_dialog), _("Contact List Members")); + g_signal_connect (name_selector_dialog, "response", + G_CALLBACK (select_names_ok_cb), editor); } static void select_cb (GtkWidget *w, EContactListEditor *editor) { - CORBA_Environment ev; + ENameSelectorModel *name_selector_model; + ENameSelectorDialog *name_selector_dialog; + EDestinationStore *destination_store; + GList *destinations; + GList *l; - if(!setup_corba (editor)) - return; + setup_name_selector (editor); + + /* We need to empty out the destination store, since we copy its contents every time. + * This sucks, we should really be wired directly to the EDestinationStore that + * the name selector uses in true MVC fashion. */ - CORBA_exception_init (&ev); + name_selector_model = e_name_selector_peek_model (editor->name_selector); + e_name_selector_model_peek_section (name_selector_model, "Members", NULL, &destination_store); + destinations = e_destination_store_list_destinations (destination_store); + + for (l = destinations; l; l = g_list_next (l)) { + EDestination *destination = l->data; + e_destination_store_remove_destination (destination_store, destination); + } - GNOME_Evolution_Addressbook_SelectNames_activateDialog ( - editor->corba_select_names, _("Required Participants"), &ev); + g_list_free (destinations); - CORBA_exception_free (&ev); + name_selector_dialog = e_name_selector_peek_dialog (editor->name_selector); + gtk_widget_show (GTK_WIDGET (name_selector_dialog)); } GtkWidget * 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 7cc49acbd2..af1f8e1163 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.h @@ -22,9 +22,9 @@ #include #include -#include #include #include +#include #include "addressbook/gui/contact-editor/eab-editor.h" @@ -40,8 +40,6 @@ 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; @@ -54,9 +52,6 @@ struct _EContactListEditor EContact *contact; - /* UI handler */ - BonoboUIComponent *uic; - GladeXML *gui; GtkWidget *app; @@ -74,13 +69,7 @@ struct _EContactListEditor GtkWidget *ok_button; GtkWidget *cancel_button; - /* FIXME: Unfortunately, we can't use the proper name here, as it'd - * create a circular dependency. The long-term solution would be to - * move the select-names component out of the component/ dir so it can - * be built before sources using this. - * - * GNOME_Evolution_Addressbook_SelectNames corba_select_names; */ - gpointer corba_select_names; + ENameSelector *name_selector; /* Whether we are editing a new contact or an existing one */ guint is_new_list : 1; diff --git a/addressbook/gui/widgets/eab-popup.c b/addressbook/gui/widgets/eab-popup.c index 9bda77d162..8a292b745f 100644 --- a/addressbook/gui/widgets/eab-popup.c +++ b/addressbook/gui/widgets/eab-popup.c @@ -65,11 +65,17 @@ eabp_target_free(EPopup *ep, EPopupTarget *t) g_object_unref(s->selector); break; } + +#ifdef ADAPTED_TO_E_NAME_SELECTOR + case EAB_POPUP_TARGET_SELECT_NAMES: { EABPopupTargetSelectNames *s = (EABPopupTargetSelectNames *)t; g_object_unref(s->model); break; } + +#endif + } ((EPopupClass *)eabp_parent)->target_free(ep, t); @@ -199,6 +205,8 @@ eab_popup_target_new_source(EABPopup *eabp, ESourceSelector *selector) return t; } +#ifdef ADAPTED_TO_E_NAME_SELECTOR + EABPopupTargetSelectNames * eab_popup_target_new_select_names(EABPopup *eabp, struct _ESelectNamesModel *model, int row) { @@ -214,6 +222,8 @@ eab_popup_target_new_select_names(EABPopup *eabp, struct _ESelectNamesModel *mod return t; } +#endif + /* ********************************************************************** */ /* Popup menu plugin handler */ diff --git a/addressbook/gui/widgets/eab-popup.h b/addressbook/gui/widgets/eab-popup.h index 7fec4cc742..20aab2edfe 100644 --- a/addressbook/gui/widgets/eab-popup.h +++ b/addressbook/gui/widgets/eab-popup.h @@ -31,6 +31,8 @@ extern "C" { #pragma } #endif /* __cplusplus */ +#define ADAPTED_TO_E_NAME_SELECTOR 1 + typedef struct _EABPopup EABPopup; typedef struct _EABPopupClass EABPopupClass; @@ -113,6 +115,8 @@ struct _EABPopupTargetSource { struct _ESourceSelector *selector; }; +#ifdef ADAPTED_TO_E_NAME_SELECTOR + /** * struct _EABPopupTargetSelectNames - A select names target. * @@ -130,6 +134,8 @@ struct _EABPopupTargetSelectNames { int row; }; +#endif + typedef struct _EPopupItem EABPopupItem; /* The object */ @@ -149,8 +155,13 @@ EABPopup *eab_popup_new(const char *menuid); EABPopupTargetSelect *eab_popup_target_new_select(EABPopup *eabp, struct _EBook *book, int readonly, GPtrArray *cards); EABPopupTargetSource *eab_popup_target_new_source(EABPopup *eabp, struct _ESourceSelector *selector); + +#ifdef ADAPTED_TO_E_NAME_SELECTOR + EABPopupTargetSelectNames *eab_popup_target_new_select_names(EABPopup *eabp, struct _ESelectNamesModel *model, int row); +#endif + /* ********************************************************************** */ typedef struct _EABPopupHook EABPopupHook; diff --git a/calendar/ChangeLog b/calendar/ChangeLog index cc97a2a5dc..62d6ec54d9 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,46 @@ +2004-12-22 Hans Petter Jansson + + * gui/Makefile.am (IDLS) + (SELECT_NAMES_IDL_GENERATED_H) + (SELECT_NAMES_IDL_GENERATED_C) + (SELECT_NAMES_IDL_GENERATED) + (IDL_GENERATED): Remove the addressbook IDL. + + * gui/e-meeting-list-view.c (e_meeting_list_finalize) + (add_section) + (e_meeting_list_view_init) + (process_section) + (name_selector_dialog_close_cb) + (get_select_name_dialog): Adapt to new ENameSelector. + + * gui/e-select-names-editable.c (esne_start_editing) + (esne_finalize) + (esne_init) + (e_select_names_editable_get_type) + (entry_activate) + (e_select_names_editable_construct) + (e_select_names_editable_get_address) + (e_select_names_editable_get_name) + (e_select_names_editable_set_address): Adapt to new ENameSelector. + + * gui/e-select-names-renderer.c (e_select_names_renderer_editing_done) + (e_select_names_renderer_activated) + (e_select_names_renderer_start_editing): Adapt to new ENameSelector. + + * gui/dialogs/alarm-dialog.c (malarm_widgets_to_alarm) + (addressbook_clicked_cb) + (addressbook_response_cb) + (setup_select_names) + (check_custom_email) + (malarm_addresses_changed_cb): Adapt to new ENameSelector. + + * gui/dialogs/e-delegate-dialog.c (e_delegate_dialog_finalize) + (e_delegate_dialog_construct) + (addressbook_clicked_cb) + (addressbook_response_cb) + (e_delegate_dialog_get_delegate) + (e_delegate_dialog_get_delegate_name): Adapt to new ENameSelector. + 2004-12-22 JP Rosevear * gui/e-meeting-store.c (freebusy_async): prevent compare against diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index fecdaa5cbc..555be8e0ac 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -2,8 +2,7 @@ IDLS = \ $(top_srcdir)/composer/Evolution-Composer.idl \ - $(top_srcdir)/calendar/idl/evolution-calendar.idl \ - $(top_srcdir)/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl + $(top_srcdir)/calendar/idl/evolution-calendar.idl CALENDAR_IDL_GENERATED_H = \ evolution-calendar.h @@ -33,23 +32,7 @@ $(COMPOSER_IDL_GENERATED_H): $(IDLS) $(srcdir)/../../composer/Evolution-Composer.idl $(COMPOSER_IDL_GENERATED_C): $(COMPOSER_IDL_GENERATED_H) -# SelectNames IDL files - -SELECT_NAMES_IDL_GENERATED_H = \ - Evolution-Addressbook-SelectNames.h -SELECT_NAMES_IDL_GENERATED_C = \ - Evolution-Addressbook-SelectNames-common.c \ - Evolution-Addressbook-SelectNames-skels.c \ - Evolution-Addressbook-SelectNames-stubs.c -SELECT_NAMES_IDL_GENERATED = $(SELECT_NAMES_IDL_GENERATED_C) $(SELECT_NAMES_IDL_GENERATED_H) - -$(SELECT_NAMES_IDL_GENERATED_H): $(IDLS) - $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) \ - $(top_srcdir)/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl -$(SELECT_NAMES_IDL_GENERATED_C): $(SELECT_NAMES_IDL_GENERATED_H) - - -IDL_GENERATED = $(CALENDAR_IDL_GENERATED) $(COMPOSER_IDL_GENERATED) $(SELECT_NAMES_IDL_GENERATED) +IDL_GENERATED = $(CALENDAR_IDL_GENERATED) $(COMPOSER_IDL_GENERATED) # The marshallers MARSHAL_GENERATED = e-calendar-marshal.c e-calendar-marshal.h diff --git a/calendar/gui/dialogs/alarm-dialog.c b/calendar/gui/dialogs/alarm-dialog.c index de0469617b..6cdc789eab 100644 --- a/calendar/gui/dialogs/alarm-dialog.c +++ b/calendar/gui/dialogs/alarm-dialog.c @@ -52,7 +52,7 @@ #include "e-util/e-dialog-widgets.h" #include "e-util/e-icon-factory.h" #include -#include "Evolution-Addressbook-SelectNames.h" +#include #include "../calendar-config.h" #include "comp-editor-util.h" #include "alarm-dialog.h" @@ -105,15 +105,16 @@ typedef struct { GtkWidget *malarm_addressbook; GtkWidget *malarm_message; GtkWidget *malarm_description; - GNOME_Evolution_Addressbook_SelectNames corba_select_names; /* Procedure alarm widgets */ GtkWidget *palarm_group; GtkWidget *palarm_program; GtkWidget *palarm_args; + + /* Addressbook name selector */ + ENameSelector *name_selector; } Dialog; -#define SELECT_NAMES_OAFID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION static const char *section_name = "Send To"; /* "relative" types */ @@ -344,21 +345,24 @@ malarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) EDestination **destv; GtkTextBuffer *text_buffer; GtkTextIter text_iter_start, text_iter_end; + ENameSelectorModel *name_selector_model; + EDestinationStore *destination_store; + GList *destinations; icalcomponent *icalcomp; icalproperty *icalprop; + GList *l; int i; /* Attendees */ - bonobo_widget_get_property (BONOBO_WIDGET (dialog->malarm_addresses), "destinations", - TC_CORBA_string, &str, NULL); - destv = e_destination_importv (str); - g_free (str); - - for (i = 0; destv[i] != NULL; i++) { + name_selector_model = e_name_selector_peek_model (dialog->name_selector); + e_name_selector_model_peek_section (name_selector_model, section_name, NULL, &destination_store); + destinations = e_destination_store_list_destinations (destination_store); + + for (l = destinations; l; l = g_list_next (l)) { EDestination *dest; ECalComponentAttendee *a; - dest = destv[i]; + dest = l->data; a = g_new0 (ECalComponentAttendee, 1); a->value = e_destination_get_email (dest); @@ -370,7 +374,7 @@ malarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) e_cal_component_alarm_set_attendee_list (alarm, attendee_list); e_cal_component_free_attendee_list (attendee_list); - e_destination_freev (destv); + g_list_free (destinations); if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->malarm_message))) return; @@ -616,48 +620,45 @@ static void addressbook_clicked_cb (GtkWidget *widget, gpointer data) { Dialog *dialog = data; - CORBA_Environment ev; - - CORBA_exception_init (&ev); + ENameSelectorDialog *name_selector_dialog; - GNOME_Evolution_Addressbook_SelectNames_activateDialog (dialog->corba_select_names, - section_name, &ev); - - CORBA_exception_free (&ev); + name_selector_dialog = e_name_selector_peek_dialog (dialog->name_selector); + gtk_widget_show (GTK_WIDGET (name_selector_dialog)); +} + +static void +addressbook_response_cb (GtkWidget *widget, gint response, gpointer data) +{ + Dialog *dialog = data; + ENameSelectorDialog *name_selector_dialog; + + name_selector_dialog = e_name_selector_peek_dialog (dialog->name_selector); + gtk_widget_hide (GTK_WIDGET (name_selector_dialog)); } static gboolean setup_select_names (Dialog *dialog) { - Bonobo_Control corba_control; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - dialog->corba_select_names = bonobo_activation_activate_from_id (SELECT_NAMES_OAFID, 0, NULL, &ev); - if (BONOBO_EX (&ev)) - return FALSE; - - GNOME_Evolution_Addressbook_SelectNames_addSection (dialog->corba_select_names, - section_name, section_name, &ev); - if (BONOBO_EX (&ev)) - return FALSE; + ENameSelectorModel *name_selector_model; + ENameSelectorDialog *name_selector_dialog; - corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (dialog->corba_select_names, - section_name, &ev); + dialog->name_selector = e_name_selector_new (); + name_selector_model = e_name_selector_peek_model (dialog->name_selector); - if (BONOBO_EX (&ev)) - return FALSE; - - CORBA_exception_free (&ev); + e_name_selector_model_add_section (name_selector_model, section_name, section_name, NULL); - dialog->malarm_addresses = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL); + dialog->malarm_addresses = + GTK_WIDGET (e_name_selector_peek_section_entry (dialog->name_selector, section_name)); gtk_widget_show (dialog->malarm_addresses); gtk_box_pack_end_defaults (GTK_BOX (dialog->malarm_address_group), dialog->malarm_addresses); gtk_signal_connect (GTK_OBJECT (dialog->malarm_addressbook), "clicked", GTK_SIGNAL_FUNC (addressbook_clicked_cb), dialog); + name_selector_dialog = e_name_selector_peek_dialog (dialog->name_selector); + g_signal_connect (name_selector_dialog, "response", + G_CALLBACK (addressbook_response_cb), dialog); + return TRUE; } @@ -774,31 +775,29 @@ check_custom_email (Dialog *dialog) char *str; GtkTextBuffer *text_buffer; GtkTextIter text_iter_start, text_iter_end; - EDestination **destv; + ENameSelectorModel *name_selector_model; + EDestinationStore *destination_store; + GList *destinations; gboolean sens; - bonobo_widget_get_property (BONOBO_WIDGET (dialog->malarm_addresses), "destinations", - TC_CORBA_string, &str, NULL); - destv = e_destination_importv (str); - g_free (str); - + name_selector_model = e_name_selector_peek_model (dialog->name_selector); + e_name_selector_model_peek_section (name_selector_model, section_name, NULL, &destination_store); + destinations = e_destination_store_list_destinations (destination_store); + text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->malarm_description)); gtk_text_buffer_get_start_iter (text_buffer, &text_iter_start); gtk_text_buffer_get_end_iter (text_buffer, &text_iter_end); str = gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE); - sens = (destv != NULL) && (e_dialog_toggle_get (dialog->malarm_message) ? str && *str : TRUE); + sens = (destinations != NULL) && (e_dialog_toggle_get (dialog->malarm_message) ? str && *str : TRUE); gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->toplevel), GTK_RESPONSE_OK, sens); - e_destination_freev (destv); + g_list_free (destinations); } static void -malarm_addresses_changed_cb (BonoboListener *listener, - const char *event_name, - const CORBA_any *arg, - CORBA_Environment *ev, - gpointer data) +malarm_addresses_changed_cb (GtkWidget *editable, + gpointer data) { Dialog *dialog = data; @@ -905,12 +904,8 @@ init_widgets (Dialog *dialog) g_signal_connect (G_OBJECT (text_buffer), "changed", G_CALLBACK (malarm_description_changed_cb), dialog); - cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (dialog->malarm_addresses)); - pb = bonobo_control_frame_get_control_property_bag (cf, NULL); - - bonobo_event_source_client_add_listener (pb, malarm_addresses_changed_cb, - "Bonobo/Property:change:entry_changed", - NULL, dialog); + g_signal_connect (dialog->malarm_addresses, "changed", + G_CALLBACK (malarm_addresses_changed_cb), dialog); } gboolean diff --git a/calendar/gui/dialogs/e-delegate-dialog.c b/calendar/gui/dialogs/e-delegate-dialog.c index 9fd15651dd..cd0c768c63 100644 --- a/calendar/gui/dialogs/e-delegate-dialog.c +++ b/calendar/gui/dialogs/e-delegate-dialog.c @@ -23,10 +23,6 @@ #include #endif -#include -#include -#include -#include #include #include #include @@ -36,7 +32,7 @@ #include #include #include -#include "Evolution-Addressbook-SelectNames.h" +#include #include "e-delegate-dialog.h" struct _EDelegateDialogPrivate { @@ -51,17 +47,17 @@ struct _EDelegateDialogPrivate { GtkWidget *hbox; GtkWidget *addressbook; - GNOME_Evolution_Addressbook_SelectNames corba_select_names; + ENameSelector *name_selector; GtkWidget *entry; }; -#define SELECT_NAMES_OAFID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION static const char *section_name = "Delegate To"; static void e_delegate_dialog_finalize (GObject *object); static gboolean get_widgets (EDelegateDialog *edd); static void addressbook_clicked_cb (GtkWidget *widget, gpointer data); +static void addressbook_response_cb (GtkWidget *widget, gint response, gpointer data); G_DEFINE_TYPE (EDelegateDialog, e_delegate_dialog, G_TYPE_OBJECT); @@ -102,6 +98,8 @@ e_delegate_dialog_finalize (GObject *object) edd = E_DELEGATE_DIALOG (object); priv = edd->priv; + g_object_unref (priv->name_selector); + /* Destroy the actual dialog. */ dialog = e_delegate_dialog_get_toplevel (edd); gtk_widget_destroy (dialog); @@ -121,10 +119,10 @@ EDelegateDialog * e_delegate_dialog_construct (EDelegateDialog *edd, const char *name, const char *address) { EDelegateDialogPrivate *priv; + EDestinationStore *destination_store; EDestination *dest; - EDestination *destv[2] = {NULL, NULL}; - Bonobo_Control corba_control; - CORBA_Environment ev; + ENameSelectorModel *name_selector_model; + ENameSelectorDialog *name_selector_dialog; char *str; g_return_val_if_fail (edd != NULL, NULL); @@ -145,48 +143,32 @@ e_delegate_dialog_construct (EDelegateDialog *edd, const char *name, const char g_message ("e_delegate_dialog_construct(): Could not find all widgets in the XML file!"); goto error; } - - CORBA_exception_init (&ev); - - priv->corba_select_names = bonobo_activation_activate_from_id (SELECT_NAMES_OAFID, 0, NULL, &ev); - GNOME_Evolution_Addressbook_SelectNames_addSectionWithLimit (priv->corba_select_names, - section_name, - section_name, - 1, &ev); - - if (BONOBO_EX (&ev)) { - g_message ("e_delegate_dialog_construct(): Unable to add section!"); - goto error; - } - corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (priv->corba_select_names, - section_name, &ev); - - if (BONOBO_EX (&ev)) { - g_message ("e_delegate_dialog_construct(): Unable to get addressbook entry!"); - goto error; - } - - CORBA_exception_free (&ev); + priv->name_selector = e_name_selector_new (); + name_selector_model = e_name_selector_peek_model (priv->name_selector); + e_name_selector_model_add_section (name_selector_model, section_name, section_name, NULL); - priv->entry = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL); + priv->entry = GTK_WIDGET (e_name_selector_peek_section_entry (priv->name_selector, section_name)); gtk_widget_show (priv->entry); gtk_box_pack_start (GTK_BOX (priv->hbox), priv->entry, TRUE, TRUE, 6); dest = e_destination_new (); - destv[0] = dest; + if (name != NULL && *name) e_destination_set_name (dest, name); if (address != NULL && *address) e_destination_set_email (dest, address); - str = e_destination_exportv(destv); - bonobo_widget_set_property (BONOBO_WIDGET (priv->entry), "destinations", TC_CORBA_string, str, NULL); - g_free(str); + + e_name_selector_model_peek_section (name_selector_model, section_name, NULL, &destination_store); + e_destination_store_append_destination (destination_store, dest); g_object_unref (dest); g_signal_connect((priv->addressbook), "clicked", G_CALLBACK (addressbook_clicked_cb), edd); + name_selector_dialog = e_name_selector_peek_dialog (priv->name_selector); + g_signal_connect (name_selector_dialog, "response", G_CALLBACK (addressbook_response_cb), edd); + return edd; error: @@ -218,17 +200,26 @@ addressbook_clicked_cb (GtkWidget *widget, gpointer data) { EDelegateDialog *edd = data; EDelegateDialogPrivate *priv; - CORBA_Environment ev; + ENameSelectorDialog *name_selector_dialog; priv = edd->priv; - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_SelectNames_activateDialog (priv->corba_select_names, section_name, &ev); - - CORBA_exception_free (&ev); + name_selector_dialog = e_name_selector_peek_dialog (priv->name_selector); + gtk_widget_show (GTK_WIDGET (name_selector_dialog)); } +static void +addressbook_response_cb (GtkWidget *widget, gint response, gpointer data) +{ + EDelegateDialog *edd = data; + EDelegateDialogPrivate *priv; + ENameSelectorDialog *name_selector_dialog; + + priv = edd->priv; + + name_selector_dialog = e_name_selector_peek_dialog (priv->name_selector); + gtk_widget_hide (GTK_WIDGET (name_selector_dialog)); +} /** * e_delegate_dialog_new: @@ -251,25 +242,30 @@ char * e_delegate_dialog_get_delegate (EDelegateDialog *edd) { EDelegateDialogPrivate *priv; - EDestination **destv; - char *string = NULL; + ENameSelectorModel *name_selector_model; + EDestinationStore *destination_store; + GList *destinations; + EDestination *destination; g_return_val_if_fail (edd != NULL, NULL); g_return_val_if_fail (E_IS_DELEGATE_DIALOG (edd), NULL); priv = edd->priv; - - bonobo_widget_get_property (BONOBO_WIDGET (priv->entry), "destinations", TC_CORBA_string, &string, NULL); - destv = e_destination_importv (string); - - if (destv && destv[0] != NULL) { + + name_selector_model = e_name_selector_peek_model (priv->name_selector); + e_name_selector_model_peek_section (name_selector_model, section_name, NULL, &destination_store); + destinations = e_destination_store_list_destinations (destination_store); + if (!destinations) + return NULL; + + destination = destinations->data; + + if (destination) { g_free (priv->address); - priv->address = g_strdup (e_destination_get_email (destv[0])); - g_free (destv); + priv->address = g_strdup (e_destination_get_email (destination)); } - g_free (string); - + g_list_free (destinations); return g_strdup (priv->address); } @@ -278,27 +274,30 @@ char * e_delegate_dialog_get_delegate_name (EDelegateDialog *edd) { EDelegateDialogPrivate *priv; - EDestination **destv; - char *string = NULL; + ENameSelectorModel *name_selector_model; + EDestinationStore *destination_store; + GList *destinations; + EDestination *destination; g_return_val_if_fail (edd != NULL, NULL); g_return_val_if_fail (E_IS_DELEGATE_DIALOG (edd), NULL); priv = edd->priv; - bonobo_widget_get_property (BONOBO_WIDGET (priv->entry), "destinations", TC_CORBA_string, &string, NULL); - destv = e_destination_importv (string); - - g_message ("importv: [%s]", string); - - if (destv && destv[0] != NULL) { + name_selector_model = e_name_selector_peek_model (priv->name_selector); + e_name_selector_model_peek_section (name_selector_model, section_name, NULL, &destination_store); + destinations = e_destination_store_list_destinations (destination_store); + if (!destinations) + return NULL; + + destination = destinations->data; + + if (destination) { g_free (priv->name); - priv->name = g_strdup (e_destination_get_name (destv[0])); - g_free (destv); + priv->name = g_strdup (e_destination_get_name (destination)); } - g_free (string); - + g_list_free (destinations); return g_strdup (priv->name); } diff --git a/calendar/gui/e-meeting-list-view.c b/calendar/gui/e-meeting-list-view.c index 64e04baf4c..a3965da4af 100644 --- a/calendar/gui/e-meeting-list-view.c +++ b/calendar/gui/e-meeting-list-view.c @@ -39,23 +39,23 @@ #include #include #include -#include "Evolution-Addressbook-SelectNames.h" +#include #include "calendar-config.h" #include "e-meeting-list-view.h" #include #include #include "e-select-names-renderer.h" -#define SELECT_NAMES_OAFID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION - struct _EMeetingListViewPrivate { EMeetingStore *store; - GNOME_Evolution_Addressbook_SelectNames corba_select_names; + ENameSelector *name_selector; }; #define BUF_SIZE 1024 +static void name_selector_dialog_close_cb (ENameSelectorDialog *dialog, gint response, gpointer data); + static char *sections[] = {N_("Chair Persons"), N_("Required Participants"), N_("Optional Participants"), @@ -75,12 +75,8 @@ e_meeting_list_view_finalize (GObject *obj) EMeetingListView *view = E_MEETING_LIST_VIEW (obj); EMeetingListViewPrivate *priv = view->priv; - if (priv->corba_select_names != CORBA_OBJECT_NIL) { - CORBA_Environment ev; - CORBA_exception_init (&ev); - bonobo_object_release_unref (priv->corba_select_names, &ev); - CORBA_exception_free (&ev); - } + if (priv->name_selector) + g_object_unref (priv->name_selector); g_free (priv); @@ -99,16 +95,36 @@ e_meeting_list_view_class_init (EMeetingListViewClass *klass) } +static void +add_section (ENameSelector *name_selector, const char *name) +{ + ENameSelectorModel *name_selector_model; + + name_selector_model = e_name_selector_peek_model (name_selector); + e_name_selector_model_add_section (name_selector_model, name, gettext (name), NULL); +} + static void e_meeting_list_view_init (EMeetingListView *view) { EMeetingListViewPrivate *priv; + ENameSelectorDialog *name_selector_dialog; + gint i; priv = g_new0 (EMeetingListViewPrivate, 1); view->priv = priv; - priv->corba_select_names = CORBA_OBJECT_NIL; + priv->name_selector = e_name_selector_new (); + + for (i = 0; sections [i]; i++) + add_section (priv->name_selector, sections [i]); + + name_selector_dialog = e_name_selector_peek_dialog (view->priv->name_selector); + gtk_window_set_title (GTK_WINDOW (name_selector_dialog), _("Required Participants")); + g_signal_connect (name_selector_dialog, "response", + G_CALLBACK (name_selector_dialog_close_cb), view); + } static GList * @@ -307,17 +323,18 @@ e_meeting_list_view_edit (EMeetingListView *emlv, EMeetingAttendee *attendee) } static void -process_section (EMeetingListView *view, EDestination **cards, icalparameter_role role) +process_section (EMeetingListView *view, GList *destinations, icalparameter_role role) { EMeetingListViewPrivate *priv; - int i; + GList *l; priv = view->priv; - for (i = 0; cards[i] != NULL; i++) { + for (l = destinations; l; l = g_list_next (l)) { + EDestination *destination = l->data; const char *name, *attendee = NULL; char *attr = NULL; - name = e_destination_get_name (cards[i]); + name = e_destination_get_name (destination); /* Get the field as attendee from the backend */ if (e_cal_get_ldap_attribute (e_meeting_store_get_e_cal (priv->store), @@ -328,7 +345,7 @@ process_section (EMeetingListView *view, EDestination **cards, icalparameter_rol /* FIXME: this does not work, have to use first e_destination_use_contact() */ - contact = e_destination_get_contact (cards[i]); + contact = e_destination_get_contact (destination); if (contact) { attendee = e_contact_get (contact, E_CONTACT_FREEBUSY_URL); if (!attendee) @@ -339,7 +356,7 @@ process_section (EMeetingListView *view, EDestination **cards, icalparameter_rol /* If we couldn't get the attendee prior, get the email address as the default */ if (attendee == NULL || *attendee == '\0') { - attendee = e_destination_get_email (cards[i]); + attendee = e_destination_get_email (destination); } if (attendee == NULL || *attendee == '\0') @@ -358,105 +375,35 @@ process_section (EMeetingListView *view, EDestination **cards, icalparameter_rol } static void -select_names_ok_cb (BonoboListener *listener, const char *event_name, const CORBA_any *arg, CORBA_Environment *ev, gpointer data) -{ - EMeetingListView *view = E_MEETING_LIST_VIEW (data); - int i; - - for (i = 0; sections[i] != NULL; i++) { - EDestination **destv; - char *string = NULL; - Bonobo_Control corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection - (view->priv->corba_select_names, sections[i], 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) { - process_section (view, destv, roles[i]); - g_free (destv); - } - } -} - -static void -add_section (GNOME_Evolution_Addressbook_SelectNames corba_select_names, const char *name) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_SelectNames_addSection ( - corba_select_names, name, gettext (name), &ev); - - CORBA_exception_free (&ev); -} - -static gboolean -get_select_name_dialog (EMeetingListView *view) +name_selector_dialog_close_cb (ENameSelectorDialog *dialog, gint response, gpointer data) { - EMeetingListViewPrivate *priv; - CORBA_Environment ev; + EMeetingListView *view = E_MEETING_LIST_VIEW (data); + ENameSelectorModel *name_selector_model; int i; - - priv = view->priv; - - CORBA_exception_init (&ev); - if (priv->corba_select_names != CORBA_OBJECT_NIL) { - int i; - - for (i = 0; sections[i] != NULL; i++) { - GtkWidget *control_widget; - Bonobo_Control corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection - (priv->corba_select_names, sections[i], &ev); - if (BONOBO_EX (&ev)) { - CORBA_exception_free (&ev); - return FALSE; - } - - control_widget = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL); - - bonobo_widget_set_property (BONOBO_WIDGET (control_widget), "text", TC_CORBA_string, "", NULL); - } - CORBA_exception_free (&ev); - - return TRUE; - } + name_selector_model = e_name_selector_peek_model (view->priv->name_selector); - priv->corba_select_names = bonobo_activation_activate_from_id (SELECT_NAMES_OAFID, 0, NULL, &ev); + for (i = 0; sections[i] != NULL; i++) { + EDestinationStore *destination_store; + GList *destinations; - for (i = 0; sections[i] != NULL; i++) - add_section (priv->corba_select_names, sections[i]); + e_name_selector_model_peek_section (name_selector_model, sections [i], + NULL, &destination_store); + g_assert (destination_store); - bonobo_event_source_client_add_listener (priv->corba_select_names, - (BonoboListenerCallbackFn) select_names_ok_cb, - "GNOME/Evolution:ok:dialog", NULL, view); - - if (BONOBO_EX (&ev)) { - CORBA_exception_free (&ev); - return FALSE; + destinations = e_destination_store_list_destinations (destination_store); + process_section (view, destinations, roles [i]); + g_list_free (destinations); } - CORBA_exception_free (&ev); - - return TRUE; + gtk_widget_hide (GTK_WIDGET (dialog)); } void e_meeting_list_view_invite_others_dialog (EMeetingListView *view) { - CORBA_Environment ev; - - if (!get_select_name_dialog (view)) - return; - - CORBA_exception_init (&ev); + ENameSelectorDialog *dialog; - GNOME_Evolution_Addressbook_SelectNames_activateDialog ( - view->priv->corba_select_names, _("Required Participants"), &ev); - - CORBA_exception_free (&ev); + dialog = e_name_selector_peek_dialog (view->priv->name_selector); + gtk_widget_show (GTK_WIDGET (dialog)); } - diff --git a/calendar/gui/e-select-names-editable.c b/calendar/gui/e-select-names-editable.c index c195b8a55e..249d20d328 100644 --- a/calendar/gui/e-select-names-editable.c +++ b/calendar/gui/e-select-names-editable.c @@ -23,32 +23,25 @@ #include #include #include -#include -#include #include +#include #include "e-select-names-editable.h" -#include "Evolution-Addressbook-SelectNames.h" - -#define SELECT_NAMES_OAFIID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION struct _ESelectNamesEditablePriv { - GNOME_Evolution_Addressbook_SelectNames select_names; - Bonobo_Control control; - Bonobo_PropertyBag bag; + }; -static BonoboWidgetClass *parent_class; +static ENameSelectorEntryClass *parent_class; static void esne_start_editing (GtkCellEditable *cell_editable, GdkEvent *event) { ESelectNamesEditable *esne = E_SELECT_NAMES_EDITABLE (cell_editable); - BonoboControlFrame *cf; /* Grab the focus */ - cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (cell_editable)); - bonobo_control_frame_control_activate (cf); + + /* TODO */ } static void @@ -62,14 +55,6 @@ esne_finalize (GObject *obj) { ESelectNamesEditable *esne = (ESelectNamesEditable *) obj; - if (esne->priv->select_names != CORBA_OBJECT_NIL) - bonobo_object_release_unref (esne->priv->select_names, NULL); - esne->priv->select_names = CORBA_OBJECT_NIL; - - if (esne->priv->bag != CORBA_OBJECT_NIL) - bonobo_object_release_unref (esne->priv->bag, NULL); - esne->priv->bag = CORBA_OBJECT_NIL; - g_free (esne->priv); if (G_OBJECT_CLASS (parent_class)->finalize) @@ -80,10 +65,6 @@ static void esne_init (ESelectNamesEditable *esne) { esne->priv = g_new0 (ESelectNamesEditablePriv, 1); - - esne->priv->select_names = CORBA_OBJECT_NIL; - esne->priv->control = CORBA_OBJECT_NIL; - esne->priv->bag = CORBA_OBJECT_NIL; } static void @@ -91,7 +72,7 @@ esne_class_init (GObjectClass *klass) { klass->finalize = esne_finalize; - parent_class = BONOBO_WIDGET_CLASS (g_type_class_peek_parent (klass)); + parent_class = E_NAME_SELECTOR_ENTRY_CLASS (g_type_class_peek_parent (klass)); } GType @@ -118,7 +99,7 @@ e_select_names_editable_get_type (void) NULL }; - esne_type = g_type_register_static (BONOBO_TYPE_WIDGET, "ESelectNamesEditable", &esne_info, 0); + esne_type = g_type_register_static (E_TYPE_NAME_SELECTOR_ENTRY, "ESelectNamesEditable", &esne_info, 0); g_type_add_interface_static (esne_type, GTK_TYPE_CELL_EDITABLE, &cell_editable_info); } @@ -127,7 +108,7 @@ e_select_names_editable_get_type (void) } static void -entry_activate (BonoboListener *listener, const char *event_name, const CORBA_any *arg, CORBA_Environment *ev, gpointer esne) +entry_activate (ESelectNamesEditable *esne) { gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (esne)); gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (esne)); @@ -136,6 +117,11 @@ entry_activate (BonoboListener *listener, const char *event_name, const CORBA_an ESelectNamesEditable * e_select_names_editable_construct (ESelectNamesEditable *esne) { + g_signal_connect (esne, "activate", G_CALLBACK (entry_activate), esne); + + return esne; + +#if 0 CORBA_Environment ev; CORBA_exception_init (&ev); @@ -170,6 +156,7 @@ e_select_names_editable_construct (ESelectNamesEditable *esne) NULL, esne); return esne; +#endif } ESelectNamesEditable * @@ -191,44 +178,65 @@ e_select_names_editable_new () gchar * e_select_names_editable_get_address (ESelectNamesEditable *esne) { - EDestination **dest; + EDestinationStore *destination_store; + GList *destinations; + EDestination *destination; gchar *dest_str; gchar *result = NULL; g_return_val_if_fail (E_SELECT_NAMES_EDITABLE (esne), NULL); - dest_str = bonobo_pbclient_get_string (esne->priv->bag, "destinations", NULL); - dest = e_destination_importv (dest_str); - if (dest) - result = g_strdup (e_destination_get_email (*dest)); - e_destination_freev (dest); + destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (esne)); + destinations = e_destination_store_list_destinations (destination_store); + if (!destinations) + return NULL; + destination = destinations->data; + result = g_strdup (e_destination_get_email (destination)); + g_list_free (destinations); return result; } gchar * e_select_names_editable_get_name (ESelectNamesEditable *esne) { - EDestination **dest; + EDestinationStore *destination_store; + GList *destinations; + EDestination *destination; gchar *dest_str; gchar *result = NULL; g_return_val_if_fail (E_SELECT_NAMES_EDITABLE (esne), NULL); - dest_str = bonobo_pbclient_get_string (esne->priv->bag, "destinations", NULL); - dest = e_destination_importv (dest_str); - if (dest) - result = g_strdup (e_destination_get_name (*dest)); - e_destination_freev (dest); + destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (esne)); + destinations = e_destination_store_list_destinations (destination_store); + if (!destinations) + return NULL; + destination = destinations->data; + result = g_strdup (e_destination_get_name (destination)); + g_list_free (destinations); return result; } void e_select_names_editable_set_address (ESelectNamesEditable *esne, const gchar *text) { + EDestinationStore *destination_store; + GList *destinations; + EDestination *destination; + gchar *dest_str; + gchar *result = NULL; + g_return_if_fail (E_IS_SELECT_NAMES_EDITABLE (esne)); - bonobo_pbclient_set_string (esne->priv->bag, "addresses", text, NULL); + destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (esne)); + destinations = e_destination_store_list_destinations (destination_store); + if (!destinations) + return; + + destination = destinations->data; + e_destination_set_address (destination, text); + g_list_free (destinations); } diff --git a/calendar/gui/e-select-names-editable.h b/calendar/gui/e-select-names-editable.h index 867118fe9e..f361c48cd8 100644 --- a/calendar/gui/e-select-names-editable.h +++ b/calendar/gui/e-select-names-editable.h @@ -23,7 +23,7 @@ #ifndef __E_SELECT_NAMES_EDITABLE_H__ #define __E_SELECT_NAMES_EDITABLE_H__ -#include +#include G_BEGIN_DECLS @@ -40,14 +40,14 @@ typedef struct _ESelectNamesEditablePriv ESelectNamesEditablePriv; struct _ESelectNamesEditable { - BonoboWidget parent; + ENameSelectorEntry parent; ESelectNamesEditablePriv *priv; }; struct _ESelectNamesEditableClass { - BonoboWidgetClass parent_class; + ENameSelectorEntryClass parent_class; }; GType e_select_names_editable_get_type (void); diff --git a/calendar/gui/e-select-names-renderer.c b/calendar/gui/e-select-names-renderer.c index 0ee5ea2455..5a8e3316a7 100644 --- a/calendar/gui/e-select-names-renderer.c +++ b/calendar/gui/e-select-names-renderer.c @@ -53,11 +53,9 @@ static void e_select_names_renderer_editing_done (GtkCellEditable *editable, ESelectNamesRenderer *cell) { gchar *new_address, *new_name; - BonoboControlFrame *cf; /* We don't need to listen for the de-activation any more */ - cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (editable)); - g_signal_handlers_disconnect_matched (G_OBJECT (cf), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, cell); + g_signal_handlers_disconnect_matched (editable, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, cell); new_address = e_select_names_editable_get_address (E_SELECT_NAMES_EDITABLE (editable)); new_name = e_select_names_editable_get_name (E_SELECT_NAMES_EDITABLE (editable)); @@ -70,10 +68,9 @@ e_select_names_renderer_editing_done (GtkCellEditable *editable, ESelectNamesRen } static void -e_select_names_renderer_activated (BonoboControlFrame *cf, gboolean activated, ESelectNamesRenderer *cell) +e_select_names_renderer_activated (ESelectNamesEditable *editable, ESelectNamesRenderer *cell) { - if (!activated) - e_select_names_renderer_editing_done (GTK_CELL_EDITABLE (cell->priv->editable), cell); + e_select_names_renderer_editing_done (GTK_CELL_EDITABLE (cell->priv->editable), cell); } static GtkCellEditable * @@ -83,7 +80,6 @@ e_select_names_renderer_start_editing (GtkCellRenderer *cell, GdkEvent *event, G ESelectNamesRenderer *sn_cell = E_SELECT_NAMES_RENDERER (cell); GtkCellRendererText *text_cell = GTK_CELL_RENDERER_TEXT (cell); ESelectNamesEditable *editable; - BonoboControlFrame *cf; if (!text_cell->editable) return NULL; @@ -94,11 +90,13 @@ e_select_names_renderer_start_editing (GtkCellRenderer *cell, GdkEvent *event, G g_signal_connect (editable, "editing_done", G_CALLBACK (e_select_names_renderer_editing_done), sn_cell); +#if 0 /* Listen for de-activation/loss of focus */ cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (editable)); bonobo_control_frame_set_autoactivate (cf, TRUE); +#endif - g_signal_connect (cf, "activated", G_CALLBACK (e_select_names_renderer_activated), sn_cell); + g_signal_connect (editable, "activate", G_CALLBACK (e_select_names_renderer_activated), sn_cell); sn_cell->priv->editable = g_object_ref (editable); sn_cell->priv->path = g_strdup (path); diff --git a/composer/ChangeLog b/composer/ChangeLog index 34507eac3b..a6b931380e 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,22 @@ +2004-12-22 Hans Petter Jansson + + * e-msg-composer-hdrs.c (addressbook_dialog_response) + (setup_corba) + (setup_name_selector) + (address_button_clicked_cb) + (addressbook_entry_changed) + (create_addressbook_entry) + (destroy) + (e_msg_composer_hdrs_new) + (destinations_to_name_selector_entry) + (e_msg_composer_hdrs_set_to) + (e_msg_composer_hdrs_set_cc) + (e_msg_composer_hdrs_set_bcc) + (destination_list_to_destv) + (e_msg_composer_hdrs_get_to) + (e_msg_composer_hdrs_get_cc) + (e_msg_composer_hdrs_get_bcc): Adapt to new ENameSelector. + 2004-12-17 Not Zed * e-msg-composer-attachment-bar.c (emcab_popup): diff --git a/composer/e-msg-composer-hdrs.c b/composer/e-msg-composer-hdrs.c index c79bd1f4f6..112216f090 100644 --- a/composer/e-msg-composer-hdrs.c +++ b/composer/e-msg-composer-hdrs.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "Composer.h" @@ -81,7 +82,7 @@ typedef struct { } EMsgComposerHdrPair; struct _EMsgComposerHdrsPrivate { - GNOME_Evolution_Addressbook_SelectNames corba_select_names; + ENameSelector *name_selector; /* ui component */ BonoboUIComponent *uic; @@ -112,30 +113,28 @@ enum { static int signals[LAST_SIGNAL]; -static gboolean -setup_corba (EMsgComposerHdrs *hdrs) +static void +addressbook_dialog_response (ENameSelectorDialog *name_selector_dialog, gint response, gpointer user_data) +{ + EMsgComposerHdrs *hdrs = E_MSG_COMPOSER_HDRS (user_data); + + gtk_widget_hide (GTK_WIDGET (name_selector_dialog)); +} + +static void +setup_name_selector (EMsgComposerHdrs *hdrs) { EMsgComposerHdrsPrivate *priv; - CORBA_Environment ev; + ENameSelectorDialog *name_selector_dialog; priv = hdrs->priv; - g_assert (priv->corba_select_names == CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - priv->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 || priv->corba_select_names == CORBA_OBJECT_NIL) { - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - - return TRUE; + g_assert (priv->name_selector == NULL); + + priv->name_selector = e_name_selector_new (); + name_selector_dialog = e_name_selector_peek_dialog (priv->name_selector); + g_signal_connect (name_selector_dialog, "response", + G_CALLBACK (addressbook_dialog_response), hdrs); } typedef struct { @@ -172,18 +171,14 @@ address_button_clicked_cb (GtkButton *button, gpointer data) EMsgComposerHdrsAndString *emchas; EMsgComposerHdrs *hdrs; EMsgComposerHdrsPrivate *priv; - CORBA_Environment ev; + ENameSelectorDialog *name_selector_dialog; emchas = data; hdrs = emchas->hdrs; priv = hdrs->priv; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_SelectNames_activateDialog ( - priv->corba_select_names, emchas->string, &ev); - - CORBA_exception_free (&ev); + + name_selector_dialog = e_name_selector_peek_dialog (priv->name_selector); + gtk_widget_show (GTK_WIDGET (name_selector_dialog)); } static void @@ -421,11 +416,8 @@ create_from_optionmenu (EMsgComposerHdrs *hdrs) } static void -addressbook_entry_changed (BonoboListener *listener, - const char *event_name, - const CORBA_any *arg, - CORBA_Environment *ev, - gpointer user_data) +addressbook_entry_changed (GtkWidget *entry, + gpointer user_data) { EMsgComposerHdrs *hdrs = E_MSG_COMPOSER_HDRS (user_data); @@ -436,16 +428,22 @@ static GtkWidget * create_addressbook_entry (EMsgComposerHdrs *hdrs, const char *name) { EMsgComposerHdrsPrivate *priv; - GNOME_Evolution_Addressbook_SelectNames corba_select_names; - Bonobo_Control corba_control; - GtkWidget *control_widget; - CORBA_Environment ev; - BonoboControlFrame *cf; - Bonobo_PropertyBag pb = CORBA_OBJECT_NIL; + ENameSelectorModel *name_selector_model; + ENameSelectorEntry *name_selector_entry; priv = hdrs->priv; - corba_select_names = priv->corba_select_names; - + + name_selector_model = e_name_selector_peek_model (priv->name_selector); + e_name_selector_model_add_section (name_selector_model, name, name, NULL); + + name_selector_entry = e_name_selector_peek_section_entry (priv->name_selector, name); + g_signal_connect (name_selector_entry, "changed", + G_CALLBACK (addressbook_entry_changed), hdrs); + + return GTK_WIDGET (name_selector_entry); + +#if 0 + CORBA_exception_init (&ev); GNOME_Evolution_Addressbook_SelectNames_addSection ( @@ -478,8 +476,9 @@ create_addressbook_entry (EMsgComposerHdrs *hdrs, const char *name) pb, addressbook_entry_changed, "Bonobo/Property:change:entry_changed", NULL, hdrs); - - return control_widget; + + return control_widget; +#endif } static void @@ -747,14 +746,11 @@ destroy (GtkObject *object) priv = hdrs->priv; if (priv) { - if (priv->corba_select_names != CORBA_OBJECT_NIL) { - CORBA_Environment ev; - CORBA_exception_init (&ev); - bonobo_object_release_unref (priv->corba_select_names, &ev); - CORBA_exception_free (&ev); - priv->corba_select_names = CORBA_OBJECT_NIL; + if (priv->name_selector != NULL) { + g_object_unref (priv->name_selector); + priv->name_selector = NULL; } - + if (priv->tooltips) { gtk_object_destroy (GTK_OBJECT (priv->tooltips)); g_object_unref (priv->tooltips); @@ -896,10 +892,7 @@ e_msg_composer_hdrs_new (BonoboUIComponent *uic, int visible_mask, int visible_f g_object_ref (new); gtk_object_sink (GTK_OBJECT (new)); - if (!setup_corba (new)) { - g_object_unref (new); - return NULL; - } + setup_name_selector (new); new->visible_mask = visible_mask; @@ -1129,6 +1122,32 @@ e_msg_composer_hdrs_set_reply_to (EMsgComposerHdrs *hdrs, set_pair_visibility (hdrs, &hdrs->priv->cc, TRUE); } +static void +destinations_to_name_selector_entry (ENameSelectorEntry *name_selector_entry, EDestination **destv) +{ + EDestinationStore *destination_store; + GList *destinations; + GList *l; + gint i; + + /* First clear the store */ + destination_store = e_name_selector_entry_peek_destination_store (name_selector_entry); + destinations = e_destination_store_list_destinations (destination_store); + + for (l = destinations; l; l = g_list_next (l)) { + EDestination *destination = l->data; + e_destination_store_remove_destination (destination_store, destination); + } + + g_list_free (destinations); + + if (!destv) + return; + + for (i = 0; destv [i]; i++) + e_destination_store_append_destination (destination_store, destv [i]); +} + void e_msg_composer_hdrs_set_to (EMsgComposerHdrs *hdrs, EDestination **to_destv) @@ -1136,10 +1155,8 @@ e_msg_composer_hdrs_set_to (EMsgComposerHdrs *hdrs, char *str; g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); - - str = e_destination_exportv (to_destv); - bonobo_widget_set_property (BONOBO_WIDGET (hdrs->priv->to.entry), "destinations", TC_CORBA_string, str ? str : "", NULL); - g_free (str); + + destinations_to_name_selector_entry (E_NAME_SELECTOR_ENTRY (hdrs->priv->to.entry), to_destv); } void @@ -1149,12 +1166,11 @@ e_msg_composer_hdrs_set_cc (EMsgComposerHdrs *hdrs, char *str; g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); + + destinations_to_name_selector_entry (E_NAME_SELECTOR_ENTRY (hdrs->priv->cc.entry), cc_destv); - str = e_destination_exportv (cc_destv); - bonobo_widget_set_property (BONOBO_WIDGET (hdrs->priv->cc.entry), "destinations", TC_CORBA_string, str ? str :"", NULL); - if (str && *str) + if (cc_destv && *cc_destv) set_pair_visibility (hdrs, &hdrs->priv->cc, TRUE); - g_free (str); } void @@ -1164,12 +1180,11 @@ e_msg_composer_hdrs_set_bcc (EMsgComposerHdrs *hdrs, char *str; g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); + + destinations_to_name_selector_entry (E_NAME_SELECTOR_ENTRY (hdrs->priv->bcc.entry), bcc_destv); - str = e_destination_exportv (bcc_destv); - bonobo_widget_set_property (BONOBO_WIDGET (hdrs->priv->bcc.entry), "destinations", TC_CORBA_string, str ? str : "", NULL); - if (str && *str) + if (bcc_destv && *bcc_destv) set_pair_visibility (hdrs, &hdrs->priv->bcc, TRUE); - g_free (str); } @@ -1364,21 +1379,45 @@ e_msg_composer_hdrs_get_reply_to (EMsgComposerHdrs *hdrs) return addr; } +static EDestination ** +destination_list_to_destv (GList *destinations) +{ + EDestination **destv; + GList *l; + gint n, i; + + n = g_list_length (destinations); + + destv = g_new0 (EDestination *, n + 1); + + for (i = 0, l = destinations; l; i++, l = g_list_next (l)) { + EDestination *destination = l->data; + + /* Need to ref, as users expect to own it */ + g_object_ref (destination); + destv [i] = l->data; + } + + return destv; +} + EDestination ** e_msg_composer_hdrs_get_to (EMsgComposerHdrs *hdrs) { char *str = NULL; + EDestinationStore *destination_store; + GList *destinations; EDestination **destv = NULL; g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - - bonobo_widget_get_property (BONOBO_WIDGET (hdrs->priv->to.entry), "destinations", TC_CORBA_string, &str, NULL); - - if (str != NULL) { - destv = e_destination_importv (str); - g_free (str); - } - + + destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY ( + hdrs->priv->to.entry)); + destinations = e_destination_store_list_destinations (destination_store); + + destv = destination_list_to_destv (destinations); + + g_list_free (destinations); return destv; } @@ -1386,17 +1425,19 @@ EDestination ** e_msg_composer_hdrs_get_cc (EMsgComposerHdrs *hdrs) { char *str = NULL; + EDestinationStore *destination_store; + GList *destinations; EDestination **destv = NULL; g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - - bonobo_widget_get_property (BONOBO_WIDGET (hdrs->priv->cc.entry), "destinations", TC_CORBA_string, &str, NULL); - - if (str != NULL) { - destv = e_destination_importv (str); - g_free (str); - } - + + destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY ( + hdrs->priv->cc.entry)); + destinations = e_destination_store_list_destinations (destination_store); + + destv = destination_list_to_destv (destinations); + + g_list_free (destinations); return destv; } @@ -1404,17 +1445,19 @@ EDestination ** e_msg_composer_hdrs_get_bcc (EMsgComposerHdrs *hdrs) { char *str = NULL; + EDestinationStore *destination_store; + GList *destinations; EDestination **destv = NULL; g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - - bonobo_widget_get_property (BONOBO_WIDGET (hdrs->priv->bcc.entry), "destinations", TC_CORBA_string, &str, NULL); - - if (str != NULL) { - destv = e_destination_importv (str); - g_free (str); - } - + + destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY ( + hdrs->priv->bcc.entry)); + destinations = e_destination_store_list_destinations (destination_store); + + destv = destination_list_to_destv (destinations); + + g_list_free (destinations); return destv; } diff --git a/composer/e-msg-composer-hdrs.h b/composer/e-msg-composer-hdrs.h index 8f3d40ead6..843b06526d 100644 --- a/composer/e-msg-composer-hdrs.h +++ b/composer/e-msg-composer-hdrs.h @@ -45,8 +45,6 @@ extern "C" { #define E_IS_MSG_COMPOSER_HDRS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_MSG_COMPOSER_HDRS)) -#define SELECT_NAMES_OAFIID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION - typedef struct _EMsgComposerHdrs EMsgComposerHdrs; typedef struct _EMsgComposerHdrsClass EMsgComposerHdrsClass; typedef struct _EMsgComposerHdrsPrivate EMsgComposerHdrsPrivate; -- cgit v1.2.3