\n");
/* The first section listing the sender */
/* FIXME What to do if the send and organizer do not match */
g_string_append_printf (buffer,
"
%s
\n",
view->priv->sender ? view->priv->sender : "");
g_string_append (buffer, "
\n");
/* Elementary event information */
g_string_append (buffer,
"
\n");
append_text_table_row (
buffer, TABLE_ROW_SUMMARY,
NULL, view->priv->summary);
append_text_table_row (
buffer, TABLE_ROW_LOCATION,
_("Location:"), view->priv->location);
append_text_table_row (
buffer, TABLE_ROW_START_DATE,
view->priv->start_header, view->priv->start_label);
append_text_table_row (
buffer, TABLE_ROW_END_DATE,
view->priv->end_header, view->priv->end_label);
append_text_table_row (
buffer, TABLE_ROW_STATUS,
_("Status:"), view->priv->status);
append_text_table_row (
buffer, TABLE_ROW_COMMENT,
_("Comment:"), view->priv->comment);
g_string_append (buffer, "
\n");
/* Description */
g_string_append_printf (
buffer,
"
%s
\n",
view->priv->description ? "" : "hidden=\"\"", view->priv->description);
g_string_append (buffer, "
");
}
void
itip_view_create_dom_bindings (ItipView *view,
WebKitDOMElement *element)
{
WebKitDOMElement *el;
WebKitDOMDocument *doc;
doc = webkit_dom_node_get_owner_document (WEBKIT_DOM_NODE (element));
view->priv->dom_document = doc;
el = webkit_dom_document_get_element_by_id (doc, CHECKBOX_RECUR);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (recur_toggled_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, CHECKBOX_RSVP);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (rsvp_toggled_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, CHECKBOX_INHERIT_ALARM);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (alarm_check_toggled_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, CHECKBOX_KEEP_ALARM);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (alarm_check_toggled_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, BUTTON_OPEN_CALENDAR);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (button_clicked_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, BUTTON_ACCEPT);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (button_clicked_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, BUTTON_ACCEPT_ALL);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (button_clicked_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, BUTTON_TENTATIVE);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (button_clicked_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, BUTTON_TENTATIVE_ALL);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (button_clicked_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, BUTTON_DECLINE);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (button_clicked_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, BUTTON_DECLINE_ALL);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (button_clicked_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, BUTTON_UPDATE);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (button_clicked_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, BUTTON_UPDATE_ATTENDEE_STATUS);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (button_clicked_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, BUTTON_SEND_INFORMATION);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "click",
G_CALLBACK (button_clicked_cb), FALSE, view);
}
el = webkit_dom_document_get_element_by_id (doc, SELECT_ESOURCE);
if (el) {
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (el), "change",
G_CALLBACK (source_changed_cb), FALSE, view);
}
}
static void
itip_view_init (ItipView *view)
{
view->priv = ITIP_VIEW_GET_PRIVATE (view);
}
ItipView *
itip_view_new (ItipPURI *puri)
{
ItipView *view;
view = ITIP_VIEW (g_object_new (ITIP_TYPE_VIEW, NULL));
view->priv->puri = puri;
return view;
}
ItipPURI *
itip_view_get_puri (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->puri;
}
static void
show_button (ItipView *view,
const gchar *id)
{
WebKitDOMElement *button;
button = webkit_dom_document_get_element_by_id (
view->priv->dom_document, id);
webkit_dom_html_element_set_hidden (
WEBKIT_DOM_HTML_ELEMENT (button), FALSE);
}
void
itip_view_set_mode (ItipView *view,
ItipViewMode mode)
{
WebKitDOMElement *row, *cell;
WebKitDOMElement *button;
g_return_if_fail (ITIP_IS_VIEW (view));
view->priv->mode = mode;
set_sender_text (view);
if (!view->priv->dom_document)
return;
row = webkit_dom_document_get_element_by_id (
view->priv->dom_document, TABLE_ROW_BUTTONS);
cell = webkit_dom_element_get_first_element_child (row);
do {
button = webkit_dom_element_get_first_element_child (cell);
webkit_dom_html_element_set_hidden (
WEBKIT_DOM_HTML_ELEMENT (button), TRUE);
} while ((cell = webkit_dom_element_get_next_element_sibling (cell)) != NULL);
view->priv->is_recur_set = itip_view_get_recur_check_state (view);
/* Always visible */
show_button (view, BUTTON_OPEN_CALENDAR);
switch (mode) {
case ITIP_VIEW_MODE_PUBLISH:
if (view->priv->needs_decline) {
show_button (view, BUTTON_DECLINE);
}
show_button (view, BUTTON_ACCEPT);
break;
case ITIP_VIEW_MODE_REQUEST:
show_button (view, view->priv->is_recur_set ? BUTTON_DECLINE_ALL : BUTTON_DECLINE);
show_button (view, view->priv->is_recur_set ? BUTTON_TENTATIVE_ALL : BUTTON_TENTATIVE);
show_button (view, view->priv->is_recur_set ? BUTTON_ACCEPT_ALL : BUTTON_ACCEPT);
break;
case ITIP_VIEW_MODE_ADD:
if (view->priv->type != E_CAL_CLIENT_SOURCE_TYPE_MEMOS) {
show_button (view, BUTTON_DECLINE);
show_button (view, BUTTON_TENTATIVE);
}
show_button (view, BUTTON_ACCEPT);
break;
case ITIP_VIEW_MODE_REFRESH:
show_button (view, BUTTON_SEND_INFORMATION);
break;
case ITIP_VIEW_MODE_REPLY:
show_button (view, BUTTON_UPDATE_ATTENDEE_STATUS);
break;
case ITIP_VIEW_MODE_CANCEL:
show_button (view, BUTTON_UPDATE);
break;
case ITIP_VIEW_MODE_COUNTER:
case ITIP_VIEW_MODE_DECLINECOUNTER:
show_button (view, BUTTON_DECLINE);
show_button (view, BUTTON_TENTATIVE);
show_button (view, BUTTON_ACCEPT);
break;
default:
break;
}
}
ItipViewMode
itip_view_get_mode (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), ITIP_VIEW_MODE_NONE);
return view->priv->mode;
}
void
itip_view_set_item_type (ItipView *view,
ECalClientSourceType type)
{
WebKitDOMElement *row, *cell;
const gchar *header;
g_return_if_fail (ITIP_IS_VIEW (view));
view->priv->type = type;
if (!view->priv->dom_document)
return;
row = webkit_dom_document_get_element_by_id (
view->priv->dom_document, TABLE_ROW_ESCB);
cell = webkit_dom_element_get_first_element_child (row);
switch (view->priv->type) {
case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
header = _("Calendar:");
break;
case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
header = _("Tasks:");
break;
case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
header = _("Memos:");
break;
default:
header = NULL;
break;
}
webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (cell), header ? header : "", NULL);
set_sender_text (view);
}
ECalClientSourceType
itip_view_get_item_type (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), ITIP_VIEW_MODE_NONE);
return view->priv->type;
}
void
itip_view_set_organizer (ItipView *view,
const gchar *organizer)
{
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->organizer)
g_free (view->priv->organizer);
view->priv->organizer = e_utf8_ensure_valid (organizer);
set_sender_text (view);
}
const gchar *
itip_view_get_organizer (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->organizer;
}
void
itip_view_set_organizer_sentby (ItipView *view,
const gchar *sentby)
{
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->organizer_sentby)
g_free (view->priv->organizer_sentby);
view->priv->organizer_sentby = e_utf8_ensure_valid (sentby);
set_sender_text (view);
}
const gchar *
itip_view_get_organizer_sentby (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->organizer_sentby;
}
void
itip_view_set_attendee (ItipView *view,
const gchar *attendee)
{
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->attendee)
g_free (view->priv->attendee);
view->priv->attendee = e_utf8_ensure_valid (attendee);
set_sender_text (view);
}
const gchar *
itip_view_get_attendee (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->attendee;
}
void
itip_view_set_attendee_sentby (ItipView *view,
const gchar *sentby)
{
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->attendee_sentby)
g_free (view->priv->attendee_sentby);
view->priv->attendee_sentby = e_utf8_ensure_valid (sentby);
set_sender_text (view);
}
const gchar *
itip_view_get_attendee_sentby (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->attendee_sentby;
}
void
itip_view_set_proxy (ItipView *view,
const gchar *proxy)
{
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->proxy)
g_free (view->priv->proxy);
view->priv->proxy = e_utf8_ensure_valid (proxy);
set_sender_text (view);
}
const gchar *
itip_view_get_proxy (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->proxy;
}
void
itip_view_set_delegator (ItipView *view,
const gchar *delegator)
{
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->delegator)
g_free (view->priv->delegator);
view->priv->delegator = e_utf8_ensure_valid (delegator);
set_sender_text (view);
}
const gchar *
itip_view_get_delegator (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->delegator;
}
void
itip_view_set_summary (ItipView *view,
const gchar *summary)
{
WebKitDOMElement *row, *col;
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->summary)
g_free (view->priv->summary);
view->priv->summary = summary ? g_strstrip (e_utf8_ensure_valid (summary)) : NULL;
if (!view->priv->dom_document)
return;
row = webkit_dom_document_get_element_by_id (
view->priv->dom_document, TABLE_ROW_SUMMARY);
webkit_dom_html_element_set_hidden (
WEBKIT_DOM_HTML_ELEMENT (row), (view->priv->summary == NULL));
col = webkit_dom_element_get_last_element_child (row);
webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (col),
view->priv->summary ? view->priv->summary : "",
NULL);
}
const gchar *
itip_view_get_summary (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->summary;
}
void
itip_view_set_location (ItipView *view,
const gchar *location)
{
WebKitDOMElement *row, *col;
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->location)
g_free (view->priv->location);
view->priv->location = location ? g_strstrip (e_utf8_ensure_valid (location)) : NULL;
if (!view->priv->dom_document)
return;
row = webkit_dom_document_get_element_by_id (
view->priv->dom_document, TABLE_ROW_LOCATION);
webkit_dom_html_element_set_hidden (
WEBKIT_DOM_HTML_ELEMENT (row), (view->priv->location == NULL));
col = webkit_dom_element_get_last_element_child (row);
webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (col),
view->priv->location ? view->priv->location : "",
NULL);
}
const gchar *
itip_view_get_location (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->location;
}
void
itip_view_set_status (ItipView *view,
const gchar *status)
{
WebKitDOMElement *row, *col;
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->status)
g_free (view->priv->status);
view->priv->status = status ? g_strstrip (e_utf8_ensure_valid (status)) : NULL;
if (!view->priv->dom_document)
return;
row = webkit_dom_document_get_element_by_id (
view->priv->dom_document, TABLE_ROW_STATUS);
webkit_dom_html_element_set_hidden (
WEBKIT_DOM_HTML_ELEMENT (row), (view->priv->status == NULL));
col = webkit_dom_element_get_last_element_child (row);
webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (col),
view->priv->status ? view->priv->status : "",
NULL);
}
const gchar *
itip_view_get_status (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->status;
}
void
itip_view_set_comment (ItipView *view,
const gchar *comment)
{
WebKitDOMElement *row, *col;
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->comment)
g_free (view->priv->comment);
view->priv->comment = comment ? g_strstrip (e_utf8_ensure_valid (comment)) : NULL;
if (!view->priv->dom_document)
return;
row = webkit_dom_document_get_element_by_id (
view->priv->dom_document, TABLE_ROW_COMMENT);
webkit_dom_html_element_set_hidden (
WEBKIT_DOM_HTML_ELEMENT (row), (view->priv->comment == NULL));
col = webkit_dom_element_get_last_element_child (row);
webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (col),
view->priv->comment ? view->priv->comment : "",
NULL);
}
const gchar *
itip_view_get_comment (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->comment;
}
void
itip_view_set_description (ItipView *view,
const gchar *description)
{
WebKitDOMElement *div;
g_return_if_fail (ITIP_IS_VIEW (view));
if (view->priv->description)
g_free (view->priv->description);
view->priv->description = description ? g_strstrip (e_utf8_ensure_valid (description)) : NULL;
if (!view->priv->dom_document)
return;
div = webkit_dom_document_get_element_by_id (
view->priv->dom_document, TABLE_ROW_DESCRIPTION);
webkit_dom_html_element_set_hidden (
WEBKIT_DOM_HTML_ELEMENT (div), (view->priv->description == NULL));
webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (div),
view->priv->description ? view->priv->description : "",
NULL);
}
const gchar *
itip_view_get_description (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->description;
}
void
itip_view_set_start (ItipView *view,
struct tm *start,
gboolean is_date)
{
ItipViewPrivate *priv;
g_return_if_fail (ITIP_IS_VIEW (view));
priv = view->priv;
if (priv->start_tm && !start) {
g_free (priv->start_tm);
priv->start_tm = NULL;
} else if (start) {
if (!priv->start_tm)
priv->start_tm = g_new0 (struct tm, 1);
*priv->start_tm = *start;
}
priv->start_tm_is_date = is_date && start;
update_start_end_times (view);
}
const struct tm *
itip_view_get_start (ItipView *view,
gboolean *is_date)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
if (is_date)
*is_date = view->priv->start_tm_is_date;
return view->priv->start_tm;
}
void
itip_view_set_end (ItipView *view,
struct tm *end,
gboolean is_date)
{
ItipViewPrivate *priv;
g_return_if_fail (ITIP_IS_VIEW (view));
priv = view->priv;
if (priv->end_tm && !end) {
g_free (priv->end_tm);
priv->end_tm = NULL;
} else if (end) {
if (!priv->end_tm)
priv->end_tm = g_new0 (struct tm, 1);
*priv->end_tm = *end;
}
priv->end_tm_is_date = is_date && end;
update_start_end_times (view);
}
const struct tm *
itip_view_get_end (ItipView *view,
gboolean *is_date)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
if (is_date)
*is_date = view->priv->end_tm_is_date;
return view->priv->end_tm;
}
guint
itip_view_add_upper_info_item (ItipView *view,
ItipViewInfoItemType type,
const gchar *message)
{
ItipViewPrivate *priv;
ItipViewInfoItem *item;
g_return_val_if_fail (ITIP_IS_VIEW (view), 0);
priv = view->priv;
item = g_new0 (ItipViewInfoItem, 1);
item->type = type;
item->message = e_utf8_ensure_valid (message);
item->id = priv->next_info_item_id++;
priv->upper_info_items = g_slist_append (priv->upper_info_items, item);
if (!view->priv->dom_document)
return item->id;
append_info_item_row (view, TABLE_UPPER_ITIP_INFO, item);
return item->id;
}
guint
itip_view_add_upper_info_item_printf (ItipView *view,
ItipViewInfoItemType type,
const gchar *format,
...)
{
va_list args;
gchar *message;
guint id;
g_return_val_if_fail (ITIP_IS_VIEW (view), 0);
va_start (args, format);
message = g_strdup_vprintf (format, args);
va_end (args);
id = itip_view_add_upper_info_item (view, type, message);
g_free (message);
return id;
}
void
itip_view_remove_upper_info_item (ItipView *view,
guint id)
{
ItipViewPrivate *priv;
GSList *l;
g_return_if_fail (ITIP_IS_VIEW (view));
priv = view->priv;
for (l = priv->upper_info_items; l; l = l->next) {
ItipViewInfoItem *item = l->data;
if (item->id == id) {
priv->upper_info_items = g_slist_remove (priv->upper_info_items, item);
g_free (item->message);
g_free (item);
if (!view->priv->dom_document)
remove_info_item_row (view, TABLE_UPPER_ITIP_INFO, id);
return;
}
}
}
void
itip_view_clear_upper_info_items (ItipView *view)
{
ItipViewPrivate *priv;
GSList *l;
g_return_if_fail (ITIP_IS_VIEW (view));
priv = view->priv;
for (l = priv->upper_info_items; l; l = l->next) {
ItipViewInfoItem *item = l->data;
if (view->priv->dom_document)
remove_info_item_row (view, TABLE_UPPER_ITIP_INFO, item->id);
g_free (item->message);
g_free (item);
}
g_slist_free (priv->upper_info_items);
priv->upper_info_items = NULL;
}
guint
itip_view_add_lower_info_item (ItipView *view,
ItipViewInfoItemType type,
const gchar *message)
{
ItipViewPrivate *priv;
ItipViewInfoItem *item;
g_return_val_if_fail (ITIP_IS_VIEW (view), 0);
priv = view->priv;
item = g_new0 (ItipViewInfoItem, 1);
item->type = type;
item->message = e_utf8_ensure_valid (message);
item->id = priv->next_info_item_id++;
priv->lower_info_items = g_slist_append (priv->lower_info_items, item);
if (!view->priv->dom_document)
return item->id;
append_info_item_row (view, TABLE_LOWER_ITIP_INFO, item);
return item->id;
}
guint
itip_view_add_lower_info_item_printf (ItipView *view,
ItipViewInfoItemType type,
const gchar *format,
...)
{
va_list args;
gchar *message;
guint id;
g_return_val_if_fail (ITIP_IS_VIEW (view), 0);
va_start (args, format);
message = g_strdup_vprintf (format, args);
va_end (args);
id = itip_view_add_lower_info_item (view, type, message);
g_free (message);
return id;
}
void
itip_view_remove_lower_info_item (ItipView *view,
guint id)
{
ItipViewPrivate *priv;
GSList *l;
g_return_if_fail (ITIP_IS_VIEW (view));
priv = view->priv;
for (l = priv->lower_info_items; l; l = l->next) {
ItipViewInfoItem *item = l->data;
if (item->id == id) {
priv->lower_info_items = g_slist_remove (priv->lower_info_items, item);
g_free (item->message);
g_free (item);
if (view->priv->dom_document)
remove_info_item_row (view, TABLE_LOWER_ITIP_INFO, id);
return;
}
}
}
void
itip_view_clear_lower_info_items (ItipView *view)
{
ItipViewPrivate *priv;
GSList *l;
g_return_if_fail (ITIP_IS_VIEW (view));
priv = view->priv;
for (l = priv->lower_info_items; l; l = l->next) {
ItipViewInfoItem *item = l->data;
if (view->priv->dom_document)
remove_info_item_row (view, TABLE_LOWER_ITIP_INFO, item->id);
g_free (item->message);
g_free (item);
}
g_slist_free (priv->lower_info_items);
priv->lower_info_items = NULL;
}
static void
source_list_changed_cb (ESourceList *source_list,
ItipView *view)
{
GSList *groups, *iter;
WebKitDOMElement *select;
d(printf("Assigning a new source list!\n"));
if (!view->priv->dom_document)
return;
select = webkit_dom_document_get_element_by_id (
view->priv->dom_document, SELECT_ESOURCE);
while (webkit_dom_node_has_child_nodes (WEBKIT_DOM_NODE (select))) {
webkit_dom_node_remove_child (
WEBKIT_DOM_NODE (select),
webkit_dom_node_get_last_child (WEBKIT_DOM_NODE (select)),
NULL);
}
groups = e_source_list_peek_groups (source_list);
for (iter = groups; iter; iter = iter->next) {
ESourceGroup *group = iter->data;
GSList *sources, *iter2;
WebKitDOMElement *optgroup;
sources = e_source_group_peek_sources (group);
if (sources == NULL)
continue;
optgroup = webkit_dom_document_create_element (
view->priv->dom_document, "OPTGROUP", NULL);
webkit_dom_html_opt_group_element_set_label (
WEBKIT_DOM_HTML_OPT_GROUP_ELEMENT (optgroup),
e_source_group_peek_name (group));
webkit_dom_node_append_child (
WEBKIT_DOM_NODE (select),
WEBKIT_DOM_NODE (optgroup),
NULL);
for (iter2 = sources; iter2; iter2 = iter2->next) {
WebKitDOMElement *option;
ESource *source = iter2->data;
option = webkit_dom_document_create_element (
view->priv->dom_document, "OPTION", NULL);
webkit_dom_html_option_element_set_value (
WEBKIT_DOM_HTML_OPTION_ELEMENT (option),
e_source_peek_uid (source));
webkit_dom_html_option_element_set_label (
WEBKIT_DOM_HTML_OPTION_ELEMENT (option),
e_source_peek_name (source));
webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (option),
e_source_peek_name (source), NULL);
webkit_dom_html_element_set_class_name (
WEBKIT_DOM_HTML_ELEMENT (option), "calendar");
webkit_dom_node_append_child (
WEBKIT_DOM_NODE (optgroup),
WEBKIT_DOM_NODE (option),
NULL);
}
}
source_changed_cb (select, NULL, view);
}
void
itip_view_set_source_list (ItipView *view,
ESourceList *source_list)
{
ItipViewPrivate *priv;
g_return_if_fail (ITIP_IS_VIEW (view));
priv = view->priv;
if (priv->source_list)
g_object_unref (priv->source_list);
if (!source_list) {
priv->source_list = NULL;
return;
}
priv->source_list = g_object_ref (source_list);
source_list_changed_cb (source_list, view);
g_signal_connect (source_list, "changed",
G_CALLBACK (source_list_changed_cb), view);
}
ESourceList *
itip_view_get_source_list (ItipView *view)
{
g_return_val_if_fail (ITIP_IS_VIEW (view), NULL);
return view->priv->source_list;
}
void
itip_view_set_source (ItipView *view,
ESource *source)
{
WebKitDOMElement *select;
WebKitDOMElement *row;
gulong i, len;
g_return_if_fail (ITIP_IS_VIEW (view));
d(printf("Settings default source '%s'\n", e_source_peek_name (source)));
if (!view->priv->dom_document)
return;
row = webkit_dom_document_get_element_by_id (
view->priv->dom_document, TABLE_ROW_ESCB);
webkit_dom_html_element_set_hidden (
WEBKIT_DOM_HTML_ELEMENT (row), (source == NULL));
if (source == NULL)
return;
select = webkit_dom_document_get_element_by_id (
view->priv->dom_document, SELECT_ESOURCE);
/*