Show 2 Times from Different Time Zones in Week and Day View in Thunderbird Lightning Extension - thunderbird

The Thunderbird Lightning extension shows the time on the left side of the Week and Day views as shown here...
I would like the time to show 2 different time zones (e.g. local time and Pacific Time) as shown here...
Is there a configuration parameter to do this? Is there another extension which can tweak this? If not, how do I hack the Thunderbird extension to do this?
For reference, Outlook has this functionality. Also, this answer shows how to hack the Lightning extension.

I didn't solve the problem for the general case. I simply caused the time to be displayed in the current time zone and the previous hour to be displayed. In my case, the current time zone is USA Mountain time and the previous hour ends up being USA Pacific time.
The file calendar-multiday-view.xml in the following jar file must be edited while Thunderbird is not running.
C:\Users\nreynold.ORADEV\AppData\Roaming\Thunderbird\Profiles\profile\extensions\{e2fda1a4-762b-4020-b5ad-a41df1933103}\chrome.jar
The method makeTimeBox() must be changed as indicated by comments:
function makeTimeBox(timestr, time2str, size) { // Add time2str parameter
var box = createXULElement("box");
box.setAttribute("orient", orient);
box.setAttribute("align", "left"); // Add
if (orient == "horizontal") {
box.setAttribute("width", size);
} else {
box.setAttribute("height", size);
}
var label = createXULElement("label");
label.setAttribute("class", "calendar-time-bar-label");
label.setAttribute("value", timestr);
label.setAttribute("style", "color: #4080C0; font-weight: bold;"); // Replace "align"
box.appendChild(label);
var label = createXULElement("label"); // Add
label.setAttribute("class", "calendar-time-bar-label"); // Add
label.setAttribute("value", time2str); // Add
box.appendChild(label); // Add
return box;
}
Add the following method after makeTimeBox().
function makeTime(hour) {
var h = hour % 12;
if (h == 0)
h = 12;
var s = hour >= 12 ? " pm" : " am";
var result = h + s;
return result;
}
Remove the following line which appears a few lines below makeTimeBox()
var formatter = Components.classes["#mozilla.org/intl/scriptabledateformat;1"].
getService(Components.interfaces.nsIScriptableDateFormat);
Change the following line...
var timeString;
... to be ...
var timeString, time2String;
About 25 lines lower, replace the following lines...
timeString = formatter.FormatTime("",
Components.interfaces.nsIScriptableDateFormat.timeFormatNoSeconds,
theHour, 0, 0);
box = makeTimeBox(timeString, durPix);
... to be ...
timeString = makeTime(theHour) + " MT";
ptHour = theHour - 1;
ptHour += 23;
ptHour %= 24;
ptHour += 1;
time2String = makeTime(ptHour) + " PT";
box = makeTimeBox(timeString, time2String, durPix);

I am not aware of any existing add-ons that do this, but I can tell you how it is done. First of all create a typical skeleton Thunderbird extension, in the Firefox world this is called a "legacy" extension in case you are searching for docs. It should contain an install.rdf and a chrome.manifest. I'm assuming you choose view-zones as the identifier in chrome.manifest.
Next you need to create a CSS file that will allow you to override the calendar-time-bar binding. Note that with this method there can only be one extension that overrides the binding. The contents will look like this:
calendar-time-bar {
-moz-binding: url(chrome://view-zones/content/bindings.xml#calendar-time-bar) !important;
}
This will override the time bar with your binding, which you will create in the bindings.xml file. It extends the builtin time bar, but adds some code after the relayout to add those extra labels. The CSS file needs to be referenced in the chrome.manifest file with a style directive and can extend chrome://calendar/skin/calendar-views.css. Then you will have to create the xml file for chrome://view-zones/content/bindings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings id="calendar-multiday-view-bindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="calendar-time-bar"
extends="chrome://calendar/content/calendar-multiday-view.xml#calendar-time-bar">
<implementation>
<method name="relayout">
<body><![CDATA[
this.__proto__.__proto__.relayout.call(this);
let XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
let topbox = document.getAnonymousElementByAttribute(this, "anonid", "topbox");
for (let box of topbox.childNodes) {
let timelabel = box.appendChild(document.createElementNS(XUL_NS, "label"));
timelabel.setAttribute("value", "10:00 PT");
}
]]></body>
</method>
</implementation>
</binding>
</bindings>
I've left the label static for now, but you can think of some logic that would change the "10:00 PT" to the actual time based on the other label or the same algorithm used in the actual method. You can also add classes and styling to make it look different.
That said, maybe you'd be interested in adding this feature to core Lightning instead? I think it would be a nice addition. I'm pretty sure we had a bug open for this but I can't find it at the moment, so if you are interested maybe you could file a bug and I can give you more information on how to get set up. In that case it would be a matter of changing the binding to show more than one label and adding user-visible preferences to be able to chose the timezone.

Related

Eclipse Formatter

Does anyone knows how can I adjust Eclipse Formatter to align (or wrap) the strings inside brackets?
I would like t`he format keep the code aligned like this:
#Component(
immediate = true,
property = {
"com.liferay.portlet.display-category=category.sample",
"com.liferay.portlet.header-portlet-css=/css/main.css",
"com.liferay.portlet.instanceable=true",
"javax.portlet.display-name=PortletModule",
"javax.portlet.init-param.template-path=/",
"javax.portlet.init-param.view-template=/view.jsp",
"javax.portlet.name=" + PortletModulePortletKeys.PORTLETMODULE,
"javax.portlet.resource-bundle=content.Language",
"javax.portlet.security-role-ref=power-user,user"
},
service = Portlet.class
)
But when I do save (with formatting on save actions), the code auto adjusts to this:
#Component(
immediate = true,
property = { "com.liferay.portlet.display-category=category.sample",
"com.liferay.portlet.header-portlet-css=/css/main.css", "com.liferay.portlet.instanceable=true",
"javax.portlet.display-name=PortletModule", "javax.portlet.init-param.template-path=/",
"javax.portlet.init-param.view-template=/view.jsp",
"javax.portlet.name=" + PortletModulePortletKeys.PORTLETMODULE,
"javax.portlet.resource-bundle=content.Language", "javax.portlet.security-role-ref=power-user,user" },
service = Portlet.class
)
Any ideas?
You can create a new Formatter profile at:
Window > Preferences > Java > Code Style > Formatter
then edit it according to your need, I was also looking to format my Portlet, so I share you my-formatter.xml, just import it and edit the Maximum line width as you need (inside the Line Wrapping options), 91 works for me.
I hope this will help.

Gtk (mm) limit width of combobox

Because I use Comboboxes that may contain text entries of very long size,
which leads to the combobox increasing its width far beyond reasonable size,
I am trying to give a maximum width to the combobox.
If I am doing this like this:
class MyCombo : public Gtk::ComboBox {
private:
CellRendererText render;
public:
MyCombo() {
render.property_width_chars() = 10;
render.property_ellipsize() = Pango::ELLIPSIZE_END;
pack_start(render, true);
}
};
The result will be an empty cell of the desired width, which seems logical since I did not specify which column to show. But how can I do this with that attempt? Using pack_start will just bypass the renderer...
Another approach is this one:
class MyCombo : public Gtk::ComboBox {
private:
CellRendererText render;
public:
MyCombo() {
pack_start(render, true);
set_cell_data_func(render, sigc::mem_fun(*this, &MyCombo::render_iter));
}
void render_iter(const TreeModel::const_iterator& iter) {
Glib::ustring data = get_string_from_iter(iter);
int desired_width_chars = 10; //for example
render.property_text() = ellipsize_string(data, desired_width_chars);
}
};
Using that approach, it works, but the text in the popup (what opens up when u click the combobox) is also shortened which is not what I want (obviously the user should be able to read the whole string and I dont care about the popup widht.)
Can you please help me with this? I would be happy for any advice/alternative solutions.
Regards tagelicht
NOTE: set_wrap_width is a function that wraps the total number of entries in the combo box over a number of columns specified; it does not answer the question.
Using set_wrap_width(1) | Using set_wrap_width(5)
Following Noup's answer as a guide I managed to get the below code; which directly answers the question and its requirements (C++/Gtkmm).
// Get the first cell renderer of the ComboBox.
auto v_cellRenderer = (Gtk::CellRendererText*)v_comboBox.get_first_cell();
// Probably obsolete; Sets character width to 1.
v_cellRenderer->property_width_chars() = 1;
// Sets the ellipses ("...") to be at the end, where text overflows.
// See Pango::ELLIPSIZE enum for other values.
v_cellRenderer->property_ellipsize() = Pango::ELLIPSIZE_END;
// Sets the size of the box, change this to suit your needs.
// -1 sets it to automatic scaling: (width, height).
v_cellRenderer->set_fixed_size(200, -1);
Result (image):
Result of code
BE AWARE: Depending on where you perform the above code; either all the cells will be the same size, or just the box itself (intended).
From experimenting, I've found:
In the parent object constructor: All cell sizes are the same.
In a separate function: Only the first cell (the box) is affected.
I'd recommend you put the code in a function that's connected to the comboBox's changed signal, such as:
v_comboBox.signal_changed().connect(sigc::mem_fun(*this, &YourClass::comboBox_changedFunction));
This may be what you are looking for:
cell_renderer_text.set_wrap_width(10)
This is for Python, but you get the idea :-)
Unfortunately, the documentation is scarce. I found this by poking around in Anjuta/Glade.
Edit:
the docs are here. They are not overly helpful, but they do exist.
As an alternative, the following works for me without having to set wrap_width nor to subclass ComboBox (in Gtk#):
ComboBoxText cb = new ComboBoxText();
cb.Hexpand = true; //If there's available space, we use it
CellRendererText renderer = (cb.Cells[0] as CellRendererText); //Get the ComboBoxText only renderer
renderer.WidthChars = 20; //Always show at least 20 chars
renderer.Ellipsize = Pango.EllipsizeMode.End;
Note: I'm using Expand to use space if it's available. If you just want to keep the combo box on a fixed width, just remove that bit.

How can I use a zk-chart on click?

I have a great problem with ZK charts!
I have 2 type of chart: a chart with data of the current day (so this chart is generated automatically) and a chart with data of a clicked date.
The first chart works correctely, the second not!
If I have clicked on a date, I build a graph! But it's impossible to modify the label position or name of label! And I need to modify these things. This is my graph:
<charts width="1700" style="height: 400px" type="line" model="#bind(vm.chart2)" title="">
</charts>
When I clicked I call this method:
#Command
#NotifyChange("chart2")
public ChartsModel viewGraph(#BindingParam("self") Group self){
String a = self.getLabel();//this is for passed a parameter
ServiceImpl usr = new ServiceImpl();
chart2 = usr.viewGraph(a);
return chart2;
}
viewGraph is so built:
#Override
public ChartsModel viewGraph(String data) {
//chart2 = new Charts();
chart2.setModel(LineLabelsData.setCategoryModel2(data));
chart2.getXAxis().getLabels().setRotation(180);
chart2.getYAxis().getTitle().setText("TEXT");
chart2.getTooltip().setEnabled(false);
chart2.getXAxis().getLabels().setRotation(180);
LinePlotOptions linePlotOptions =
chart2.getPlotData().getPlotOptions().getLine();
linePlotOptions.setEnableMouseTracking(false);
linePlotOptions.getDataLabels().setEnabled(true);
return chart2.getModel();
}
If I print something in this method my console view it correctely! The problem is that
chart2.getYAxis().getTitle().setText("TEXT");
does not work like
chart2.getXAxis().getLabels().setRotation(180);
How can I change that values?
To change yAxis title, you can simply call chart2.getYAxis().setTitle("title");
You may want to post your questions in ZK Forum rather than stackoverflow as our community users are experienced in ZK, and can help you quicker.

3DText - Change Text Through Script - Unity

I have read lot of questions on how to change text of a 3DText from script.
Lot of them suggested the following :::
GetComponent(TextMesh).text = "blah";
But when I try to use this, I get an error Expression denotes atype', where a variable',value' or method group' was expected
I tried a lot of examples and couldn't really get it to work.
TextMesh textMesh;
textMesh = (TextMesh) descriptionObject.transform.GetComponent("Text Mesh");
textMesh.text = "Name : ABC";
The above code though Compiles without errors doesn't change the text. Can someone help me out with this? How do I change the TEXT of a 3DText Object.
Thanks...
This would be a prettier solution than one already given(C# script used in example) :
//define a Textmesh that we want to edit
public TextMesh tm;
// here in start method (run at instantiating of script) i find component of type
// TextMesh ( <TextMesh> ) of object named"nameOfTheObject" and reference it
// via tm variable;
void Start () {
tm = (TextMesh)GameObject.Find ("nameOfTheObject").GetComponent<TextMesh>();
// here we change the value of displayed text
tm.text = "new Text u want to see";
}
Or if u want to do it the shortest way possible (syntax wise):
//keep in mind this requires for the script to be attached to the object u
// are editing (the 3dText);
//same as above, the only difference is the note in the line above as this
// method is run from gameObject.GetComponent....
// gameObject is a variable which would be equivalent of this.GetComp...
// in some other programming languages
GetComponent<TextMesh>().text ="new Text u want";
This Works !!!!
textMesh = (TextMesh) descriptionObject.transform.GetComponent(typeof(TextMesh));
textMesh.text = "Name : ABC";

How can I make a cell update with the current date, using a dropdown next to the cell?

I need to make Data Validation on a range of cells. I want a dropdown list, where the only option is the current date. To get the current date, I can use =TODAY(). The problem is, that the dates don't remain static. When the sheet recalculates, so will all the dates. I need the dates to remain the same.
How can I work around this?
I found a blog where the answer might be, but I can't see how the author has made his spreadsheet.
I will have a dropdown item which says "dags dato". Next i use an eventlistener that checks if the text in a cell is changed to "dags dato".
if so, it puts the current date in the cell, like this:
function onEdit(event)
{
var ss = event.source.getActiveSheet();
var r = event.source.getActiveRange();
var currentValue = r.getValue();
if(currentValue == "dags dato")
{
var dd = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd");
r.setValue(dd);
}
}