of attachment %s does not exist!!\n",
G_STRFUNC, (gchar *) g_object_get_data (object, "uri")));
return;
}
/* Show or hide the DIV which contains
* the attachment (iframe, image...). */
css = webkit_dom_element_get_style (element);
webkit_dom_css_style_declaration_set_property (
css, "display", expanded ? "block" : "none", "", NULL);
}
static void
mail_display_attachment_count_changed (EAttachmentStore *store,
GParamSpec *pspec,
GtkWidget *box)
{
WebKitDOMHTMLElement *element;
GList *children;
children = gtk_container_get_children (GTK_CONTAINER (box));
g_return_if_fail (children && children->data);
element = g_object_get_data (children->data, "parent_element");
g_list_free (children);
g_return_if_fail (WEBKIT_DOM_IS_HTML_ELEMENT (element));
if (e_attachment_store_get_num_attachments (store) == 0) {
gtk_widget_hide (box);
webkit_dom_html_element_set_hidden (element, TRUE);
} else {
gtk_widget_show (box);
webkit_dom_html_element_set_hidden (element, FALSE);
}
}
static GtkWidget *
mail_display_plugin_widget_requested (WebKitWebView *web_view,
gchar *mime_type,
gchar *uri,
GHashTable *param,
gpointer user_data)
{
EMailDisplay *display;
EMailExtensionRegistry *reg;
EMailFormatterExtension *extension;
GQueue *extensions;
GList *head, *link;
EMailPart *part = NULL;
GtkWidget *widget = NULL;
gchar *part_id, *type, *object_uri;
part_id = g_hash_table_lookup (param, "data");
if (part_id == NULL || !g_str_has_prefix (uri, "mail://"))
return NULL;
type = g_hash_table_lookup (param, "type");
if (type == NULL)
return NULL;
display = E_MAIL_DISPLAY (web_view);
widget = g_hash_table_lookup (display->priv->widgets, part_id);
if (widget != NULL) {
d (printf ("Handeled %s widget request from cache\n", part_id));
return widget;
}
/* Find the EMailPart representing the requested widget. */
part = e_mail_part_list_ref_part (display->priv->part_list, part_id);
if (part == NULL)
return NULL;
reg = e_mail_formatter_get_extension_registry (display->priv->formatter);
extensions = e_mail_extension_registry_get_for_mime_type (reg, type);
if (extensions == NULL)
goto exit;
extension = NULL;
head = g_queue_peek_head_link (extensions);
for (link = head; link != NULL; link = g_list_next (link)) {
extension = link->data;
if (extension == NULL)
continue;
if (e_mail_formatter_extension_has_widget (extension))
break;
}
if (extension == NULL)
goto exit;
/* Get the widget from formatter */
widget = e_mail_formatter_extension_get_widget (
extension, display->priv->part_list, part, param);
d (
printf ("Created widget %s (%p) for part %s\n",
G_OBJECT_TYPE_NAME (widget), widget, part_id));
/* Should not happen! WebKit will display an ugly 'Plug-in not
* available' placeholder instead of hiding the