Commit Graph

108 Commits

Author SHA1 Message Date
Florian Müllner
3b1330880f cleanup: Use Function.prototype.bind()
When not using arrow notation with anonymous functions, we use Lang.bind()
to bind `this` to named callbacks. However since ES5, this functionality
is already provided by Function.prototype.bind() - in fact, Lang.bind()
itself uses it when no extra arguments are specified. Just use the built-in
function directly where possible, and use arrow notation in the few places
where we pass additional arguments.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:02 +00:00
Florian Müllner
213e38c2ef cleanup: Use arrow notation for anonymous functions
Arrow notation is great, use it consistently through-out the code base
to bind `this` to anonymous functions, replacing the more overbose
Lang.bind(this, function() {}).

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:00 +00:00
Florian Müllner
76f09b1e49 cleanup: Use method syntax
Modern javascript has a short-hand for function properties, embrace
it for better readability and to prepare for an eventual port to
ES6 classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:54:58 +00:00
Bastien Nocera
29987ae033 dateMenu: Fix possible crash with unknown locations
If there are locations unknown to the libgweather version gnome-shell is
using, don't crash.

JS ERROR: TypeError: b.location is null
WorldClocksSection<._clocksChanged/<@resource:///org/gnome/shell/ui/dateMenu.js:141:1
WorldClocksSection<._clocksChanged@resource:///org/gnome/shell/ui/dateMenu.js:139:9

https://bugzilla.gnome.org/show_bug.cgi?id=791148
2017-12-06 02:02:48 +01:00
Bastien Nocera
a29ceb31dd dateMenu: Ignore malformed world-clocks settings
Guard against a malformed setting that doesn't contain a
'location' key.

https://bugzilla.gnome.org/show_bug.cgi?id=791148
2017-12-06 02:02:48 +01:00
Florian Müllner
156032a7ec weather: Mark conditions as significant
Otherwise the passed phenomenon/qualifier are ignored and a fallback
string is used.
2017-10-04 18:12:26 +02:00
Martin Andersson
59fc26f821 calendar: Rebuild the calendar when the time zone changes
A time zone change can cause the date to change so we need to clear
SpiderMonkey's time zone cache and rebuild the calendar.

https://bugzilla.gnome.org/show_bug.cgi?id=678507
2017-10-04 16:44:07 +02:00
Florian Müllner
bddc2c0016 dateMenu: Use icon for message indicator
Using a unicode character here means it may look quite different
from the intended style (for instance with emoji fonts). Avoid
this by providing a custom icon and use that instead.

https://bugzilla.gnome.org/show_bug.cgi?id=766368
2017-09-12 17:32:51 +02:00
Florian Müllner
56f4ce37cd dateMenu: Adjust to GWeather IAPI change
It's not exactly clear what changed - gobject-introspection, gjs - but
the newly added gweather_condition_to_string_full() API no longer works
like it used to. The replacement code does look more idiomatic anyway,
so just fix the code without investigating the reason of the breakage.

https://bugzilla.gnome.org/show_bug.cgi?id=787423
2017-09-12 17:32:51 +02:00
Florian Müllner
2339351499 dateMenu: Use non-capitalized forecasts where appropriate
GWeather now provides us with API to request strings that don't
use sentence capitalization, so we can use it for summaries that
don't start a sentence to make for more natural phrases.

https://bugzilla.gnome.org/show_bug.cgi?id=779873
2017-08-21 15:43:34 +02:00
Florian Müllner
2582d16ca7 Define classes with 'var' instead of 'const'
Any symbols (including class properties) that should be visible
outside the module it's defined in need to be defined as global.
For now gjs still allows the access for 'const', but get rid of
the warnings spill now by changing it.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Florian Müllner
c1758c4d69 dateMenu: Set _delegate on non-menu-item menu child
PopupMenu needs special-treatment of certain types of menu items,
which it determines via children's _delegate property. However as
the calendar drop-down is very unmenu-ish, we use regular actors
rather than PopupMenuItems and the missing _delegate property
triggers a warning. Just add it as the bare minimum to make
PopupMenu happy.

https://bugzilla.gnome.org/show_bug.cgi?id=781471
2017-07-13 17:23:54 +02:00
Florian Müllner
6362b3d057 dateMenu: Fix a runtime warning
GJS now warns about excess parameters, so wrap the queue_relayout()
into an anonymous function instead of using it directly as signal
handler.
2017-05-11 15:20:10 +02:00
Florian Müllner
d393ca4f09 weather: Track whether a location was set
Setting GWeatherInfo:location to null helpfully doesn't mean
"no location", but "NYC". This obviously isn't what we want
to show users, so track the location validity separately and
consider it when updating the label shown to users.

https://bugzilla.gnome.org/show_bug.cgi?id=780252
2017-03-20 19:02:08 +01:00
Allan Day
252dce1ec2 fix typos
The shell was crashing for me - these fixes from Debarshi seem to
fix it.
2017-03-01 16:24:35 +00:00
Florian Müllner
62606c68b9 dateMenu: Add Weather section
Similar to the Clocks integration we've had in the date+time drop-down for
a while, the designs have called for a similar section that integrates
GNOME weather as well. Use the WeatherClient added in the previous commit
to implement that section and add it to the popover.

https://bugzilla.gnome.org/show_bug.cgi?id=754031
2017-03-01 10:52:13 +01:00
Florian Müllner
4b166dcc79 dateMenu: Do a better job at size freezing while browsing dates
In order to avoid distracting popup size changes while browsing
other dates, we freeze the size to the last size request. However
in case of more complex size negotiations - wrapping or ellipsizing
labels, scrollable elements etc. - there's a chance of stray calls
to get_preferred_width/height() that are not used for the actual
allocation. If such a call happens to be the last size request
before the layout is frozen, the saved size will be wrong. To fix
this, save the allocated size rather than the requested one.

https://bugzilla.gnome.org/show_bug.cgi?id=754031
2017-02-27 21:23:48 +01:00
Florian Müllner
796fdca5c5 dateMenu: Enforce calendar column width
We want the width of the calendar column to be determined by the
calendar, other elements should adjust their allocation accordingly.
However neither ellipsization nor wrapping will kick in unless the
parent's width is restricted, so use a small custom layout manager
that enforces the desired behavior.

https://bugzilla.gnome.org/show_bug.cgi?id=754031
2017-02-27 21:23:47 +01:00
Florian Müllner
0353ebde5d dateMenu: Use AppSettingsMonitor for world clocks
When gnome-clocks is installed, there is currently a race between the
GSettings schema being added to the database and the world clocks
session trying to use it. The prize if we win that race is an abort
in GIO, so use the newly added AppSettingsMonitor skip the race
altogether.

https://bugzilla.gnome.org/show_bug.cgi?id=766410
2017-02-27 20:02:16 +01:00
Philip Chimento
aefd61c3db js: Avoid double declarations with let
The following code is a syntax error in ES6:

    let a = 'something';
    let a = 'other thing';

Previously GJS would silently accept this code, but in the next release the
SpiderMonkey JS engine will be more ES6-compliant.

https://bugzilla.gnome.org/show_bug.cgi?id=778425
2017-02-10 13:35:50 -08:00
Florian Müllner
ee8fd1e613 calendar: Split out message list base classes
Currently both the base classes for messages/sections and the message
list itself that instantiates the available sections are located in
the same module. As a result, it isn't possible to define sections
in a different module without introducing circular dependencies. The
Calendar module is already unwieldily large, so split it up a bit to
avoid it growing even bigger in the future.

https://bugzilla.gnome.org/show_bug.cgi?id=756491
2016-02-17 14:56:52 +01:00
Meet Parikh
08690d658f panel: Block banners when opening menus that would overlap
We currently block banners while the time+date menu is open, as it
would obscure the notification. However it is not necessarily the
only menu for which this is the case, so generalize the behavior
to all menus that would overlap banners when open.

https://bugzilla.gnome.org/show_bug.cgi?id=745910
2015-04-25 09:56:05 +02:00
Florian Müllner
bb2d7f7e7e dateMenu: Set label_actor for WorldClock button
Ideally we would allow navigating into the button in the screen
reader case, so the configured clocks are read out properly.
However we can still do better than nothing short-term by pointing
to the section header as the button's label_actor.

https://bugzilla.gnome.org/show_bug.cgi?id=745393
2015-03-04 13:57:30 +01:00
Florian Müllner
39fd7b9a05 dateMenu: Use formatTime() for world clock
https://bugzilla.gnome.org/show_bug.cgi?id=745111
2015-03-04 13:55:01 +01:00
Florian Müllner
61c5f259ec dateMenu: Hide displays section when disabled by session mode
We currently show the world clocks section unconditionally, even when
the session mode disallows launching the Clocks app to configure the
displayed clocks. This does not make sense, so hide the entire section
when the session mode disallows settings.

https://bugzilla.gnome.org/show_bug.cgi?id=745494
2015-03-03 19:14:49 +01:00
Florian Müllner
be52ad999f dateMenu: Include "Today" button in keynav
https://bugzilla.gnome.org/show_bug.cgi?id=706903
2015-03-03 10:37:37 +01:00
Giovanni Campagna
f015f4574f calendar: fix title at shell startup
Make sure the message list section is set to the current date
when opening the menu, otherwise the calendar might skip
the selected-date-changed event (because the day did not change)
which would leave the message list with an uninitialized date.

https://bugzilla.gnome.org/show_bug.cgi?id=745412
2015-03-02 16:21:38 -08:00
Florian Müllner
880b240ecb dateMenu: Update message indicator on queue changes
The message indicator conveys that the message list contains unseen
messages that will not be shown as banner. So its visibility depends
on two factors: the number of unseen messages, and the number of
messages waiting in the queue to be shown as banner. As we currently
only update the visibility on changes to the former, the indicator is
not always accurate - for instance sources notify count changes before
passing on a notification to the message tray for display.
To fix, add a signal to the message tray to notify when the queue
changes and use it to update the indicator's visibility.

https://bugzilla.gnome.org/show_bug.cgi?id=744880
2015-02-21 10:32:08 +01:00
Florian Müllner
8032e672e9 dateMenu: Block notification banners while the calendar is open
The new banner position interferes with the calendar drop-down. Resolve
this by blocking banners while the calendar is shown.

https://bugzilla.gnome.org/show_bug.cgi?id=744850
2015-02-20 17:41:34 +01:00
Florian Müllner
d6eea0e380 dateMenu: Show indicator for messages that skipped banner mode
The summary may contain notifications that have not been seen by the user
and won't be shown as banner. Currently this is only the case for resident
notifications that are emitted by the focused app, but it will become more
common as we will start limiting the number of queued notifications.
Indicate to the user that more notifications are available by displaying a
small dot in the top bar button.

https://bugzilla.gnome.org/show_bug.cgi?id=744850
2015-02-20 17:40:48 +01:00
Florian Müllner
e404369c0f dateMenu: Freeze popup size while browsing
As the popup's height depends on its content, which itself varies
depending on the selected day, browsing the calendar can result
in distracting size changes. To avoid this, the design calls for
the height to be frozen to the previous one in that case.
As the popup will always open with the current day selected, we
don't have to be very sophisticated and can just lock the popup
to the height corresponding to that day.

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:39:25 +01:00
Florian Müllner
88c7039ebe dateMenu: Stop hiding the events list
The message list is not only a replacement for the calendar events
list, it will also take over the notification summary from the
message tray. As we start drawing events from other sources than
calendars, hiding it based on whether or not any calendars have
been set up is no longer appropriate, so always include it in the
calendar drop-down now.

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:39:25 +01:00
Florian Müllner
efc0ec4740 dateMenu: Add world clock section
Rather than just offering to open Clocks when installed, pick up
configured locations and display their time directly in the popup.

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:39:20 +01:00
Florian Müllner
7d1382afd3 dateMenu: Remove "Open Calendar" item
This functionality is now available through the Events section
header in the message list, so we don't need a separate menu
item for it.

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:38:48 +01:00
Florian Müllner
e850d9e29b dateMenu: Replace EventsList with MessageList
Turn the existing EventsList into a MessageListSection and add the
message list to the calendar drop-down. The new events list only
displays events for the currently selected day, but in a more
structured and friendlier way than the old one.

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:38:44 +01:00
Florian Müllner
de27e4e1b2 dateMenu: Remove link to Date & Time Settings
Menu items are on their way out of the calendar drop down, so let's
start with the easy one. This one is removed without replacement,
but then the Date & Time panel should be a one-time stop for most
users anyway, so not having a direct shortcut should not be much of
a problem. It is also the last remaining Settings item outside the
system menu ...

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:37:00 +01:00
Florian Müllner
33c5f5726e dateMenu: Make "today" button more prominent
Split the weekday from the date and increase the latter's size to
match the latest calendar mockups.

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:36:55 +01:00
Florian Müllner
26330fde7e dateMenu: Swap calendar and event columns
The new design has the events list on the left and the calendar on the
right, so swap them around and remove the vertical separator between
them in favor of some additional whitespace as in the mockups.

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:35:27 +01:00
Florian Müllner
3ba8a578e8 dateMenu: Remove obsolete comment
The events list has been always defined since commit ca2e09fe8b
about 2 1/2 years ago ...
2015-02-18 06:10:24 +01:00
Florian Müllner
facaea6850 environment: Define N_() globally
Commit 1291bcd0c8 implemented it for dateMenu, but the function
is already used in screenShield as well. Just add it globally as
we do for other standard gettext "macros".
2014-11-13 12:26:33 +00:00
Carlos Soriano
1291bcd0c8 dateMenu: Fix commit 52503c4c
dateMenu uses now N_() but the function is not defined.

To solve it, define N_().
2014-11-10 16:45:10 +01:00
Bastien Nocera
52503c4c38 js: Fix util_translate_time_string() usage
util_translate_time_string() was called to use LC_TIME to translate
strings, but those strings were not marked as to be translated.

https://bugzilla.gnome.org/show_bug.cgi?id=739822
2014-11-08 21:55:16 +01:00
Eskild Hustvedt
35fcd16992 dateMenu: Allow extensions to add custom calendar sources
Splits instantiation of the event source into a separate method,
allowing extensions to subclass the DateMenuButton and provide its
own calendar source.

https://bugzilla.gnome.org/show_bug.cgi?id=672500
2014-11-07 14:49:38 +01:00
Darcy
111a9e13f2 dateMenu: Fix typo in _isToday()
getDay() is the day of week, what we want there is getDate().

https://bugzilla.gnome.org/show_bug.cgi?id=738725
2014-11-03 15:03:54 +01:00
Florian Müllner
eb3fc7815e Use LC_TIME locale for strftime format string translations
We commonly mark strftime format strings for translation to account
for date/time representations without an existing strftime shortcut
("Yesterday %H%p"). As those translations are looked up according to
the locale defined by LC_MESSAGES, while the conversion characters
themselves are resolved according to LC_TIME, the result can be
rather odd when mixing locales ("Den 27. January"). The correct
solution would be to install translations for format strings in
the LC_TIME catalogue and look them up with dcgettext(), but we
don't have the infrastructure to do that easily. Work around this
by adding a helper method that looks up a string in LC_MESSAGES
using the locale defined by LC_TIME and use that to translate
format strings, which has the same result.

https://bugzilla.gnome.org/show_bug.cgi?id=738640
2014-10-16 23:41:51 +02:00
Jasper St. Pierre
42066a7c46 dateMenu: Don't generate JS garbage every clock tick
Instead of waking up the JS every second to set the clock and update a
date label the user will rarely see, simply use property binding to
bypass JS string handling, and update the date in the menu when the menu
is opened.
2014-10-01 15:42:49 -06:00
Florian Müllner
3e20843d9c dateMenu: Try to use the default calendar application
Commit 14ceb10555 changed the "Open Calendar" item to open the
"recommended" calendar application rather than the default one to
avoid problems with MIME subclassing (namely falling back to the
default text editor when no calendar app is installed).
With this change however, the application launched does no longer
necessarily match the one configured in Settings, which is unexpected.
To avoid both problems, use the default calendar application again,
but only if it is in the list of recommended applications.

https://bugzilla.gnome.org/show_bug.cgi?id=722333
2014-08-19 18:13:40 +02:00
Jasper St. Pierre
4f28840a59 dateMenu: Fix style 2014-06-16 15:10:36 -04:00
Carlos Soriano
19afabe2a1 dateMenu: Don't make dateMenuButton reactive on current day
Having the ability to go to the current date if the user is already
on the current date can be confusing. So don't make the button reactive
until the selected date changes.

https://bugzilla.gnome.org/show_bug.cgi?id=726724
2014-04-29 01:02:27 +02:00
Vit Stanislav
c07421c195 Calendar: make current date label clickable
Once you start navigating between months, you can't return to the
current day.  However, the current day is always displayed above the
calendar grid.  Fix this by making the current date clickable; when
clicked, the calendar grid jumps back to that day.

https://bugzilla.gnome.org/show_bug.cgi?id=641366
2014-03-05 16:40:56 +01:00