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 --- .../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 ++ 4 files changed, 86 insertions(+), 71 deletions(-) (limited to 'addressbook/gui') 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; -- cgit v1.2.3