Skip to content

Commit

Permalink
In compact header and side toolbars show only icons in buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jmozmoz committed Aug 16, 2019
1 parent fb2d0d1 commit be23bfd
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
]>

<?xml-stylesheet href="chrome://CompactHeader/skin/CompactHeader.css" type="text/css"?>
<?xml-stylesheet href="chrome://CompactHeader/skin/headerButtons69.css" type="text/css"?>
<?xml-stylesheet href="chrome://CompactHeader-os/skin/osdef.css" type="text/css"?>


Expand Down
61 changes: 61 additions & 0 deletions chrome/CompactHeader/skin/global/headerButtons69.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joachim Herb <[email protected]>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */

/* ===== messageHeader.css ==============================================
== Styles for the header toolbars of a mail message.
======================================================================= */

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");

/*
toolbar[mode="icons"] .toolbarbutton-menubutton-button,
toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"]) {
padding-inline-start: 6px !important;
padding-inline-end: 6px !important;
}
*/

#CompactHeader_collapsed2LHeaderViewFirstLine #header-view-toolbar .toolbarbutton-text,
#CompactHeader_collapsed2LHeaderViewFirstLine #header-view-toolbar .toolbarbutton-multiline-text,
#CompactHeader_leftSidebar #header-view-toolbar .toolbarbutton-text,
#CompactHeader_leftSidebar #header-view-toolbar .toolbarbutton-multiline-text,
#CompactHeader_rightSidebar #header-view-toolbar .toolbarbutton-text,
#CompactHeader_rightSidebar #header-view-toolbar .toolbarbutton-multiline-text {
display: none;
-moz-binding: none;
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "CompactHeader",
"description": "Add ability to reduce header size to one or two lines. Linkify subjects in RSS feeds.",
"version": "3.0.0beta2",
"version": "3.0.0beta3",
"author": "Joachim Herb",
"homepage_url": "http://compactheader.mozdev.org/",
"legacy": {
Expand Down
101 changes: 66 additions & 35 deletions test/compactheader/test-compactheader-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,33 @@ function teardownModule() {
Services.prefs.clearUserPref("toolkit.customization.unsafe_drag_events");
}


/**
* Test at first that default button are sets with only icons
*/
function test_1_header_toolbar_check_default() {
let curMessage = select_message_in_folder(folder1, 0, mc);
let hdrToolbar = mc.eid("header-view-toolbar").node;
let hdrBarDefaultSet = hdrToolbar.getAttribute("defaultset");
expand_and_assert_header(mc);
set_and_assert_toolbox_position(mc, 'top');

// only icons are shown
subsubtest_button_style("hdrTrashButton", "-moz-box", "none", mc);

// Display message in new window and check that the default
// buttons are shown there.
let msgc = open_selected_message_in_new_window();
assert_selected_and_displayed(msgc, curMessage);
expand_and_assert_header(msgc);
hdrToolbar = msgc.eid("header-view-toolbar").node;
// only icons are shown
subsubtest_button_style("hdrTrashButton", "-moz-box", "none", msgc);

close_window(msgc);
}


/**
* Test header pane toolbar position
*/
Expand Down Expand Up @@ -687,7 +714,7 @@ function test_customize_header_toolbar_change_button_style(){
restore_and_check_default_buttons(mc);

// The default mode is icon visible only.
subtest_buttons_style("-moz-box", "none");
subtest_buttons_style("-moz-box", "none", mc);

// Change the button style to text and icon mode
let ctc = open_header_pane_toolbar_customization(mc);
Expand All @@ -696,7 +723,7 @@ function test_customize_header_toolbar_change_button_style(){
ctc.click(new elib.Elem(iconMode));
close_header_pane_toolbar_customization(ctc);

subtest_buttons_style("-moz-box", "-moz-box");
subtest_buttons_style("-moz-box", "-moz-box", mc);

// Change the button style to icon mode only
ctc = open_header_pane_toolbar_customization(mc);
Expand All @@ -705,7 +732,7 @@ function test_customize_header_toolbar_change_button_style(){
ctc.click(new elib.Elem(iconMode));
close_header_pane_toolbar_customization(ctc);

subtest_buttons_style("-moz-box", "none");
subtest_buttons_style("-moz-box", "none", mc);

// Change the button style to text (only) mode
ctc = open_header_pane_toolbar_customization(mc);
Expand All @@ -714,11 +741,11 @@ function test_customize_header_toolbar_change_button_style(){
ctc.click(new elib.Elem(textMode));
close_header_pane_toolbar_customization(ctc);

subtest_buttons_style("none", "-moz-box");
subtest_buttons_style("none", "-moz-box", mc);

// The default mode is icon visible only.
restore_and_check_default_buttons(mc);
subtest_buttons_style("-moz-box", "none");
subtest_buttons_style("-moz-box", "none", mc);
Services.prefs.clearUserPref("toolkit.customization.unsafe_drag_events");
}

Expand Down Expand Up @@ -878,41 +905,45 @@ function test_set_toolbar_position() {
* Check all buttons in the toolbar for the correct style
* of text and icon.
*/
function subtest_buttons_style(aIconVisibility, aLabelVisibility)
{
let toolbar = mc.eid("header-view-toolbar").node;
function subtest_buttons_style(aIconVisibility, aLabelVisibility, aController) {
let toolbar = aController.eid("header-view-toolbar").node;
let currentSet = filterInvisibleButtons(mc, toolbar.currentSet).split(",");

for (let i=0; i<currentSet.length; i++) {
// XXX For the moment only consider normal toolbar buttons.
// XXX Handling of toolbaritem buttons has to be added later,
// XXX especially the smart reply button!
if ((mc.eid(currentSet[i]).node.tagName == "toolbarbutton") &&
(currentSet[i] != "otherActionsButton") // otherActionsButton does not have an icon anymore :-(
) {
let icon = mc.aid(currentSet[i], {class: "toolbarbutton-icon"}).node;
let label = mc.aid(currentSet[i], {class: "toolbarbutton-text"}).node;

if (!icon) {
let exp1 = mc.e(currentSet[i]);
let node = mc.window.document.getAnonymousElementByAttribute(exp1, "anonid", "button");
if (node) {
icon = mc.window.document.getAnonymousElementByAttribute(node, "class", "toolbarbutton-icon");
}
let button = currentSet[i];
subsubtest_button_style(button, aIconVisibility, aLabelVisibility, aController);
}
}

function subsubtest_button_style(button, aIconVisibility, aLabelVisibility, aController) {
// XXX For the moment only consider normal toolbar buttons.
// XXX Handling of toolbaritem buttons has to be added later,
// XXX especially the smart reply button!
if ((aController.eid(button).node.tagName == "toolbarbutton") &&
(button != "otherActionsButton") // otherActionsButton does not have an icon anymore :-(
) {
let icon = aController.aid(button, {class: "toolbarbutton-icon"}).node;
let label = aController.aid(button, {class: "toolbarbutton-text"}).node;

if (!icon) {
let exp1 = aController.e(button);
let node = aController.window.document.getAnonymousElementByAttribute(exp1, "anonid", "button");
if (node) {
icon = aController.window.document.getAnonymousElementByAttribute(node, "class", "toolbarbutton-icon");
}
if (!label) {
let exp1 = mc.e(currentSet[i]);
let node = mc.window.document.getAnonymousElementByAttribute(exp1, "anonid", "button");
if (node) {
label = mc.window.document.getAnonymousElementByAttribute(node, "class", "toolbarbutton-text");
}
}
if (!label) {
let exp1 = aController.e(button);
let node = aController.window.document.getAnonymousElementByAttribute(exp1, "anonid", "button");
if (node) {
label = aController.window.document.getAnonymousElementByAttribute(node, "class", "toolbarbutton-text");
}
assert_not_equals(null, label, "No label of button " + currentSet[i] + " found!");
assert_not_equals(null, icon, "No icon of button " + currentSet[i] + " found!");
assert_equals(mc.window.getComputedStyle(icon).getPropertyValue("display"),
aIconVisibility, "wrong visiibility for icon of button " + currentSet[i]);
assert_equals(mc.window.getComputedStyle(label).getPropertyValue("display"),
aLabelVisibility, "wrong visiibility for label of button " + i);
}
assert_not_equals(null, label, "No label of button " + button + " found!");
assert_not_equals(null, icon, "No icon of button " + button + " found!");
assert_equals(aController.window.getComputedStyle(icon).getPropertyValue("display"),
aIconVisibility, "wrong visiibility for icon of button " + button);
assert_equals(aController.window.getComputedStyle(label).getPropertyValue("display"),
aLabelVisibility, "wrong visiibility for label of button " + i);
}
}

0 comments on commit be23bfd

Please sign in to comment.