Commit c4d17ae9 authored by Johannes Zellner's avatar Johannes Zellner Committed by Milan Crha

M!5 - Replace custom expand/collapse icons with gtk stock icons

Closes GNOME/evolution!5
parent f16968eb
......@@ -3,9 +3,7 @@ set(images
draft-paper.png
draft-stamp.jpg
midnight-stars.jpg
minus.png
paper.png
plus.png
rect.png
ribbon.jpg
texture.png
......
......@@ -87,6 +87,25 @@ a.evo-awrap {
/**** HEADERS ****/
button.header-collapse {
width: 18px;
height: 18px;
margin: 0;
padding: 0;
cursor: pointer;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
button.header-collapse img {
width: 16px;
height: 16px;
padding: 0;
margin: 0;
}
table.header {
border-spacing: 0px;
border-top-width: 0px;
......
......@@ -607,13 +607,10 @@ render_contact_list_row (EABContactFormatter *formatter,
EDestination *destination,
GString *buffer)
{
gchar *evolution_imagesdir;
gboolean list_collapsed = FALSE;
const gchar *textrep;
gchar *name = NULL, *email_addr = NULL;
evolution_imagesdir = g_filename_to_uri (EVOLUTION_IMAGESDIR, NULL, NULL);
textrep = e_destination_get_textrep (destination, TRUE);
if (!eab_parse_qp_email (textrep, &name, &email_addr))
email_addr = g_strdup (textrep);
......@@ -623,11 +620,10 @@ render_contact_list_row (EABContactFormatter *formatter,
g_string_append_printf (
buffer,
"<td width=" IMAGE_COL_WIDTH " valign=\"top\" align=\"left\">"
"<img src=\"evo-file://%s/minus.png\" width=\"16px\" height=\"16px\" "
"id=\"%s\" "
"class=\"navigable _evo_collapse_button\">"
"<button type=\"button\" id=\"%s\" class=\"header-collapse _evo_collapse_button\" style=\"display: inline-block;\">"
"<img src=\"gtk-stock://pan-down-symbolic\" />"
"</button>"
"</td><td width=\"100%%\" align=\"left\">%s",
evolution_imagesdir,
e_destination_get_contact_uid (destination),
name ? name : email_addr);
......@@ -669,7 +665,6 @@ render_contact_list_row (EABContactFormatter *formatter,
g_string_append (buffer, "</tr>");
g_free (evolution_imagesdir);
g_free (name);
g_free (email_addr);
}
......
......@@ -542,12 +542,13 @@ emfe_headers_format (EMailFormatterExtension *extension,
if (is_collapsable)
g_string_append_printf (
buffer,
"<td valign=\"top\" width=\"16\" style=\"padding-left: 0px\">"
"<img src=\"evo-file://%s/%s\" class=\"navigable\" "
" id=\"__evo-collapse-headers-img\" />"
"<td valign=\"top\" width=\"18\" style=\"padding-left: 0px\">"
"<button type=\"button\" class=\"header-collapse\" id=\"__evo-collapse-headers-img\">"
"<img src=\"gtk-stock://%s\" />"
"</button>"
"</td>",
EVOLUTION_IMAGESDIR,
is_collapsed ? "plus.png" : "minus.png");
is_collapsed ? "pan-end-symbolic" : "pan-down-symbolic"
);
g_string_append (buffer, "<td>");
......
......@@ -211,9 +211,9 @@ e_mail_formatter_format_address (EMailFormatter *formatter,
"<span id=\"__evo-moreaddr\" "
"style=\"display: none;\">");
str = g_strdup_printf (
"<img src=\"evo-file://%s/plus.png\" "
"id=\"__evo-moreaddr-img\" class=\"navigable\">",
EVOLUTION_IMAGESDIR);
"<button type=\"button\" id=\"__evo-moreaddr-button\" class=\"header-collapse\" style=\"display: inline-block;\">"
"<img src=\"gtk-stock://pan-end-symbolic\" />"
"</button>");
}
}
}
......
......@@ -579,9 +579,8 @@ collapse_contacts_list (WebKitDOMEventTarget *event_target,
gpointer user_data)
{
WebKitDOMDocument *document;
WebKitDOMElement *list;
WebKitDOMElement *list, *child;
gchar *id, *list_id;
gchar *imagesdir, *src;
gboolean hidden;
document = user_data;
......@@ -598,21 +597,21 @@ collapse_contacts_list (WebKitDOMEventTarget *event_target,
if (list == NULL)
return;
imagesdir = g_filename_to_uri (EVOLUTION_IMAGESDIR, NULL, NULL);
hidden = webkit_dom_html_element_get_hidden (WEBKIT_DOM_HTML_ELEMENT (list));
if (hidden)
src = g_strdup_printf ("evo-file://%s/minus.png", imagesdir);
else
src = g_strdup_printf ("evo-file://%s/plus.png", imagesdir);
webkit_dom_html_element_set_hidden (
WEBKIT_DOM_HTML_ELEMENT (list), !hidden);
webkit_dom_html_image_element_set_src (
WEBKIT_DOM_HTML_IMAGE_ELEMENT (event_target), src);
g_free (src);
g_free (imagesdir);
for (child = webkit_dom_element_get_first_element_child (WEBKIT_DOM_ELEMENT (event_target));
child;
child = webkit_dom_element_get_next_element_sibling (child)) {
if (WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (child)) {
webkit_dom_html_image_element_set_src (
WEBKIT_DOM_HTML_IMAGE_ELEMENT (child),
hidden ? "gtk-stock://pan-down-symbolic" : "gtk-stock://pan-end-symbolic");
break;
}
}
}
static void
......@@ -620,8 +619,8 @@ toggle_headers_visibility (WebKitDOMElement *button,
WebKitDOMEvent *event,
WebKitDOMDocument *document)
{
WebKitDOMElement *short_headers = NULL, *full_headers = NULL;
WebKitDOMCSSStyleDeclaration *css_short = NULL, *css_full = NULL;
WebKitDOMElement *short_headers, *full_headers, *button_image;
WebKitDOMCSSStyleDeclaration *css_short, *css_full;
GSettings *settings;
gboolean expanded;
const gchar *path;
......@@ -652,13 +651,15 @@ toggle_headers_visibility (WebKitDOMElement *button,
css_short, "display",
expanded ? "table" : "none", "", NULL);
button_image = webkit_dom_element_get_first_element_child (button);
if (expanded)
path = "evo-file://" EVOLUTION_IMAGESDIR "/plus.png";
path = "gtk-stock://pan-end-symbolic";
else
path = "evo-file://" EVOLUTION_IMAGESDIR "/minus.png";
path = "gtk-stock://pan-down-symbolic";
webkit_dom_html_image_element_set_src (
WEBKIT_DOM_HTML_IMAGE_ELEMENT (button), path);
WEBKIT_DOM_HTML_IMAGE_ELEMENT (button_image), path);
settings = e_util_ref_settings ("org.gnome.evolution.mail");
g_settings_set_boolean (settings, "headers-collapsed", expanded);
......@@ -669,24 +670,34 @@ toggle_headers_visibility (WebKitDOMElement *button,
g_clear_object (&css_short);
g_clear_object (&full_headers);
g_clear_object (&css_full);
g_clear_object (&button_image);
}
static void
toggle_address_visibility (WebKitDOMElement *button,
toggle_address_visibility (WebKitDOMElement *element,
WebKitDOMEvent *event,
gpointer user_data)
{
WebKitDOMElement *full_addr = NULL, *ellipsis = NULL;
WebKitDOMElement *parent = NULL, *bold = NULL;
WebKitDOMCSSStyleDeclaration *css_full = NULL, *css_ellipsis = NULL;
const gchar *path;
WebKitDOMElement *full_addr, *ellipsis, *parent, *img, *tmp;
WebKitDOMCSSStyleDeclaration *css_full, *css_ellipsis;
gchar *property_value;
gboolean expanded;
/* <b> element */
bold = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (button));
/* <td> element */
parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (bold));
/* get img and parent depending on which element the click came from (button/ellipsis) */
if (WEBKIT_DOM_IS_HTML_BUTTON_ELEMENT (element)) {
tmp = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (element));
parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (tmp));
img = webkit_dom_element_get_first_element_child (element);
} else {
WebKitDOMElement *button;
parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (element));
tmp = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (parent));
button = webkit_dom_element_query_selector (tmp, "#__evo-moreaddr-button", NULL);
img = webkit_dom_element_get_first_element_child (button);
g_clear_object (&button);
}
full_addr = webkit_dom_element_query_selector (parent, "#__evo-moreaddr", NULL);
......@@ -711,21 +722,8 @@ toggle_address_visibility (WebKitDOMElement *button,
webkit_dom_css_style_declaration_set_property (
css_ellipsis, "display", (expanded ? "inline" : "none"), "", NULL);
if (expanded)
path = "evo-file://" EVOLUTION_IMAGESDIR "/plus.png";
else
path = "evo-file://" EVOLUTION_IMAGESDIR "/minus.png";
if (!WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (button)) {
WebKitDOMElement *element;
element = webkit_dom_element_query_selector (parent, "#__evo-moreaddr-img", NULL);
if (!element)
goto clean;
webkit_dom_html_image_element_set_src (WEBKIT_DOM_HTML_IMAGE_ELEMENT (element), path);
} else
webkit_dom_html_image_element_set_src (WEBKIT_DOM_HTML_IMAGE_ELEMENT (button), path);
webkit_dom_html_image_element_set_src (WEBKIT_DOM_HTML_IMAGE_ELEMENT (img),
expanded ? "gtk-stock://pan-end-symbolic" : "gtk-stock://pan-down-symbolic");
clean:
g_clear_object (&css_full);
......@@ -733,6 +731,8 @@ toggle_address_visibility (WebKitDOMElement *button,
g_clear_object (&full_addr);
g_clear_object (&ellipsis);
g_clear_object (&parent);
g_clear_object (&img);
g_clear_object (&tmp);
}
static void
......@@ -1068,7 +1068,14 @@ e_dom_utils_e_mail_display_bind_dom (WebKitDOMDocument *document,
e_dom_utils_bind_dom (
document,
"*[id^=__evo-moreaddr-]",
"#__evo-moreaddr-ellipsis",
"click",
toggle_address_visibility,
NULL);
e_dom_utils_bind_dom (
document,
"#__evo-moreaddr-button",
"click",
toggle_address_visibility,
NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment