diff options
Diffstat (limited to 'calendar/gui/e-select-names-editable.c')
-rw-r--r-- | calendar/gui/e-select-names-editable.c | 150 |
1 files changed, 72 insertions, 78 deletions
diff --git a/calendar/gui/e-select-names-editable.c b/calendar/gui/e-select-names-editable.c index 60289a5b74..10781150d1 100644 --- a/calendar/gui/e-select-names-editable.c +++ b/calendar/gui/e-select-names-editable.c @@ -29,25 +29,14 @@ #include "e-select-names-editable.h" struct _ESelectNamesEditablePriv { - + gint dummy; }; static ENameSelectorEntryClass *parent_class; static void -esne_start_editing (GtkCellEditable *cell_editable, GdkEvent *event) -{ - ESelectNamesEditable *esne = E_SELECT_NAMES_EDITABLE (cell_editable); - - /* Grab the focus */ - - /* TODO */ -} - -static void esne_cell_editable_init (GtkCellEditableIface *iface) { - iface->start_editing = esne_start_editing; } static void @@ -107,81 +96,73 @@ e_select_names_editable_get_type (void) return esne_type; } -static void -entry_activate (ESelectNamesEditable *esne) -{ - gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (esne)); - gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (esne)); -} - ESelectNamesEditable * -e_select_names_editable_construct (ESelectNamesEditable *esne) +e_select_names_editable_new () { - g_signal_connect (esne, "activate", G_CALLBACK (entry_activate), esne); + ESelectNamesEditable *esne = g_object_new (E_TYPE_SELECT_NAMES_EDITABLE, NULL); return esne; +} -#if 0 - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - esne->priv->select_names = bonobo_activation_activate_from_id (SELECT_NAMES_OAFIID, 0, NULL, &ev); - if (BONOBO_EX (&ev)) { - CORBA_exception_free (&ev); - return NULL; - } +gchar * +e_select_names_editable_get_email (ESelectNamesEditable *esne) +{ + EDestinationStore *destination_store; + GList *destinations; + EDestination *destination; + gchar *result = NULL; - GNOME_Evolution_Addressbook_SelectNames_addSection (esne->priv->select_names, "A", "A", &ev); - if (BONOBO_EX (&ev)) { - CORBA_exception_free (&ev); - return NULL; - } + g_return_val_if_fail (E_SELECT_NAMES_EDITABLE (esne), NULL); - esne->priv->control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection ( - esne->priv->select_names, "A", &ev); - if (BONOBO_EX (&ev)) { - CORBA_exception_free (&ev); + 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; - } - - bonobo_widget_construct_control_from_objref (BONOBO_WIDGET (esne), esne->priv->control, CORBA_OBJECT_NIL, &ev); - - CORBA_exception_free (&ev); - - esne->priv->bag = bonobo_control_frame_get_control_property_bag ( - bonobo_widget_get_control_frame (BONOBO_WIDGET (esne)), NULL); - bonobo_event_source_client_add_listener (esne->priv->bag, entry_activate, - "GNOME/Evolution/Addressbook/SelectNames:activate:entry", - NULL, esne); - return esne; -#endif + destination = destinations->data; + result = g_strdup (e_destination_get_email (destination)); + g_list_free (destinations); + return result; } -ESelectNamesEditable * -e_select_names_editable_new () +GList * +e_select_names_editable_get_emails (ESelectNamesEditable *esne) { - ESelectNamesEditable *esne = g_object_new (E_TYPE_SELECT_NAMES_EDITABLE, NULL); + EDestinationStore *destination_store; + GList *destinations; + EDestination *destination; + GList *result = NULL; - if (!esne) - return NULL; + g_return_val_if_fail (E_SELECT_NAMES_EDITABLE (esne), NULL); - if (!e_select_names_editable_construct (esne)) { - g_object_unref (esne); + 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; + if (e_destination_is_evolution_list (destination)) { + const GList *list_dests, *l; + + list_dests = e_destination_list_get_dests (destination); + for (l = list_dests; l != NULL; l = g_list_next (l)) { + result = g_list_append (result, g_strdup (e_destination_get_email (l->data))); + } + } else { + result = g_list_append (result, g_strdup (e_destination_get_email (destination))); } - return esne; + g_list_free (destinations); + + return result; } gchar * -e_select_names_editable_get_address (ESelectNamesEditable *esne) +e_select_names_editable_get_name (ESelectNamesEditable *esne) { EDestinationStore *destination_store; GList *destinations; EDestination *destination; - gchar *dest_str; gchar *result = NULL; g_return_val_if_fail (E_SELECT_NAMES_EDITABLE (esne), NULL); @@ -192,19 +173,18 @@ e_select_names_editable_get_address (ESelectNamesEditable *esne) return NULL; destination = destinations->data; - result = g_strdup (e_destination_get_email (destination)); + result = g_strdup (e_destination_get_name (destination)); g_list_free (destinations); return result; } -gchar * -e_select_names_editable_get_name (ESelectNamesEditable *esne) +GList * +e_select_names_editable_get_names (ESelectNamesEditable *esne) { EDestinationStore *destination_store; GList *destinations; EDestination *destination; - gchar *dest_str; - gchar *result = NULL; + GList *result = NULL; g_return_val_if_fail (E_SELECT_NAMES_EDITABLE (esne), NULL); @@ -213,30 +193,44 @@ e_select_names_editable_get_name (ESelectNamesEditable *esne) if (!destinations) return NULL; - destination = destinations->data; - result = g_strdup (e_destination_get_name (destination)); + destination = destinations->data; + if (e_destination_is_evolution_list (destination)) { + const GList *list_dests, *l; + + list_dests = e_destination_list_get_dests (destination); + for (l = list_dests; l != NULL; l = g_list_next (l)) { + result = g_list_append (result, g_strdup (e_destination_get_name (l->data))); + } + } else { + result = g_list_append (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) +e_select_names_editable_set_address (ESelectNamesEditable *esne, const gchar *name, const gchar *email) { EDestinationStore *destination_store; GList *destinations; EDestination *destination; - gchar *dest_str; - gchar *result = NULL; g_return_if_fail (E_IS_SELECT_NAMES_EDITABLE (esne)); 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 = e_destination_new (); + else + destination = g_object_ref (destinations->data); - destination = destinations->data; - e_destination_set_address (destination, text); - g_list_free (destinations); + e_destination_set_name (destination, name); + e_destination_set_email (destination, email); + + if (!destinations) + e_destination_store_append_destination (destination_store, destination); + g_object_unref (destination); } - |