Calendar: only show events when configured in Evolution
When no calendars are enabled, hide the events pane completely instead of showing it empty. https://bugzilla.gnome.org/show_bug.cgi?id=680083
This commit is contained in:
parent
ec39aa3890
commit
ee50904147
@ -170,6 +170,7 @@ const EmptyEventSource = new Lang.Class({
|
|||||||
_init: function() {
|
_init: function() {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
this.isDummy = true;
|
this.isDummy = true;
|
||||||
|
this.hasCalendars = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
@ -196,6 +197,7 @@ const CalendarServerIface = <interface name="org.gnome.Shell.CalendarServer">
|
|||||||
<arg type="b" direction="in" />
|
<arg type="b" direction="in" />
|
||||||
<arg type="a(sssbxxa{sv})" direction="out" />
|
<arg type="a(sssbxxa{sv})" direction="out" />
|
||||||
</method>
|
</method>
|
||||||
|
<property name="HasCalendars" type="b" access="read" />
|
||||||
<signal name="Changed" />
|
<signal name="Changed" />
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
@ -206,8 +208,7 @@ function CalendarServer() {
|
|||||||
g_interface_name: CalendarServerInfo.name,
|
g_interface_name: CalendarServerInfo.name,
|
||||||
g_interface_info: CalendarServerInfo,
|
g_interface_info: CalendarServerInfo,
|
||||||
g_name: 'org.gnome.Shell.CalendarServer',
|
g_name: 'org.gnome.Shell.CalendarServer',
|
||||||
g_object_path: '/org/gnome/Shell/CalendarServer',
|
g_object_path: '/org/gnome/Shell/CalendarServer' });
|
||||||
g_flags: Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _datesEqual(a, b) {
|
function _datesEqual(a, b) {
|
||||||
@ -256,7 +257,12 @@ const DBusEventSource = new Lang.Class({
|
|||||||
this._onNameVanished();
|
this._onNameVanished();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
this._dbusProxy.connect('g-properties-changed', Lang.bind(this, function() {
|
||||||
|
this.emit('notify::has-calendars');
|
||||||
|
}));
|
||||||
|
|
||||||
this._initialized = true;
|
this._initialized = true;
|
||||||
|
this.emit('notify::has-calendars');
|
||||||
this._onNameAppeared();
|
this._onNameAppeared();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
@ -265,6 +271,13 @@ const DBusEventSource = new Lang.Class({
|
|||||||
this._dbusProxy.run_dispose();
|
this._dbusProxy.run_dispose();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get hasCalendars() {
|
||||||
|
if (this._initialized)
|
||||||
|
return this._dbusProxy.HasCalendars;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
_resetCache: function() {
|
_resetCache: function() {
|
||||||
this._events = [];
|
this._events = [];
|
||||||
this._lastRequestBegin = null;
|
this._lastRequestBegin = null;
|
||||||
|
@ -161,8 +161,10 @@ const DateMenuButton = new Lang.Class({
|
|||||||
this._openClocksItem.actor.visible = app !== null;
|
this._openClocksItem.actor.visible = app !== null;
|
||||||
},
|
},
|
||||||
|
|
||||||
_setEventsVisibility: function(visible) {
|
_updateEventsVisibility: function() {
|
||||||
|
let visible = this._eventSource.hasCalendars;
|
||||||
this._openCalendarItem.actor.visible = visible;
|
this._openCalendarItem.actor.visible = visible;
|
||||||
|
this._openClocksItem.actor.visible = visible;
|
||||||
this._separator.visible = visible;
|
this._separator.visible = visible;
|
||||||
if (visible) {
|
if (visible) {
|
||||||
let alignment = 0.25;
|
let alignment = 0.25;
|
||||||
@ -184,6 +186,9 @@ const DateMenuButton = new Lang.Class({
|
|||||||
this._eventList.setEventSource(eventSource);
|
this._eventList.setEventSource(eventSource);
|
||||||
|
|
||||||
this._eventSource = eventSource;
|
this._eventSource = eventSource;
|
||||||
|
this._eventSource.connect('notify::has-calendars', Lang.bind(this, function() {
|
||||||
|
this._updateEventsVisibility();
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_sessionUpdated: function() {
|
_sessionUpdated: function() {
|
||||||
@ -195,7 +200,7 @@ const DateMenuButton = new Lang.Class({
|
|||||||
eventSource = new Calendar.EmptyEventSource();
|
eventSource = new Calendar.EmptyEventSource();
|
||||||
}
|
}
|
||||||
this._setEventSource(eventSource);
|
this._setEventSource(eventSource);
|
||||||
this._setEventsVisibility(showEvents);
|
this._updateEventsVisibility();
|
||||||
|
|
||||||
// This needs to be handled manually, as the code to
|
// This needs to be handled manually, as the code to
|
||||||
// autohide separators doesn't work across the vbox
|
// autohide separators doesn't work across the vbox
|
||||||
|
@ -490,6 +490,17 @@ calendar_sources_registry_source_removed_cb (ESourceRegistry *registry,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ensure_appointment_sources (CalendarSources *sources)
|
||||||
|
{
|
||||||
|
if (!sources->priv->appointment_sources.loaded)
|
||||||
|
{
|
||||||
|
calendar_sources_load_esource_list (sources->priv->registry,
|
||||||
|
&sources->priv->appointment_sources);
|
||||||
|
sources->priv->appointment_sources.loaded = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GList *
|
GList *
|
||||||
calendar_sources_get_appointment_clients (CalendarSources *sources)
|
calendar_sources_get_appointment_clients (CalendarSources *sources)
|
||||||
{
|
{
|
||||||
@ -497,12 +508,7 @@ calendar_sources_get_appointment_clients (CalendarSources *sources)
|
|||||||
|
|
||||||
g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), NULL);
|
g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), NULL);
|
||||||
|
|
||||||
if (!sources->priv->appointment_sources.loaded)
|
ensure_appointment_sources (sources);
|
||||||
{
|
|
||||||
calendar_sources_load_esource_list (sources->priv->registry,
|
|
||||||
&sources->priv->appointment_sources);
|
|
||||||
sources->priv->appointment_sources.loaded = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
list = g_hash_table_get_values (sources->priv->appointment_sources.clients);
|
list = g_hash_table_get_values (sources->priv->appointment_sources.clients);
|
||||||
|
|
||||||
@ -512,6 +518,17 @@ calendar_sources_get_appointment_clients (CalendarSources *sources)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ensure_task_sources (CalendarSources *sources)
|
||||||
|
{
|
||||||
|
if (!sources->priv->task_sources.loaded)
|
||||||
|
{
|
||||||
|
calendar_sources_load_esource_list (sources->priv->registry,
|
||||||
|
&sources->priv->task_sources);
|
||||||
|
sources->priv->task_sources.loaded = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GList *
|
GList *
|
||||||
calendar_sources_get_task_clients (CalendarSources *sources)
|
calendar_sources_get_task_clients (CalendarSources *sources)
|
||||||
{
|
{
|
||||||
@ -519,12 +536,7 @@ calendar_sources_get_task_clients (CalendarSources *sources)
|
|||||||
|
|
||||||
g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), NULL);
|
g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), NULL);
|
||||||
|
|
||||||
if (!sources->priv->task_sources.loaded)
|
ensure_task_sources (sources);
|
||||||
{
|
|
||||||
calendar_sources_load_esource_list (sources->priv->registry,
|
|
||||||
&sources->priv->task_sources);
|
|
||||||
sources->priv->task_sources.loaded = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
list = g_hash_table_get_values (sources->priv->task_sources.clients);
|
list = g_hash_table_get_values (sources->priv->task_sources.clients);
|
||||||
|
|
||||||
@ -533,3 +545,15 @@ calendar_sources_get_task_clients (CalendarSources *sources)
|
|||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
calendar_sources_has_sources (CalendarSources *sources)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), FALSE);
|
||||||
|
|
||||||
|
ensure_appointment_sources (sources);
|
||||||
|
ensure_task_sources (sources);
|
||||||
|
|
||||||
|
return g_hash_table_size (sources->priv->appointment_sources.clients) > 0 ||
|
||||||
|
g_hash_table_size (sources->priv->task_sources.clients) > 0;
|
||||||
|
}
|
||||||
|
@ -61,6 +61,8 @@ CalendarSources *calendar_sources_get (void);
|
|||||||
GList *calendar_sources_get_appointment_clients (CalendarSources *sources);
|
GList *calendar_sources_get_appointment_clients (CalendarSources *sources);
|
||||||
GList *calendar_sources_get_task_clients (CalendarSources *sources);
|
GList *calendar_sources_get_task_clients (CalendarSources *sources);
|
||||||
|
|
||||||
|
gboolean calendar_sources_has_sources (CalendarSources *sources);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __CALENDAR_SOURCES_H__ */
|
#endif /* __CALENDAR_SOURCES_H__ */
|
||||||
|
@ -57,6 +57,7 @@ static const gchar introspection_xml[] =
|
|||||||
" <signal name='Changed'/>"
|
" <signal name='Changed'/>"
|
||||||
" <property name='Since' type='x' access='read'/>"
|
" <property name='Since' type='x' access='read'/>"
|
||||||
" <property name='Until' type='x' access='read'/>"
|
" <property name='Until' type='x' access='read'/>"
|
||||||
|
" <property name='HasCalendars' type='b' access='read'/>"
|
||||||
" </interface>"
|
" </interface>"
|
||||||
"</node>";
|
"</node>";
|
||||||
static GDBusNodeInfo *introspection_data = NULL;
|
static GDBusNodeInfo *introspection_data = NULL;
|
||||||
@ -726,6 +727,12 @@ app_load_events (App *app)
|
|||||||
app->cache_invalid = FALSE;
|
app->cache_invalid = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
app_has_calendars (App *app)
|
||||||
|
{
|
||||||
|
return calendar_sources_has_sources (app->sources);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_appointment_sources_changed (CalendarSources *sources,
|
on_appointment_sources_changed (CalendarSources *sources,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@ -734,6 +741,26 @@ on_appointment_sources_changed (CalendarSources *sources,
|
|||||||
|
|
||||||
print_debug ("Sources changed\n");
|
print_debug ("Sources changed\n");
|
||||||
app_load_events (app);
|
app_load_events (app);
|
||||||
|
|
||||||
|
/* Notify the HasCalendars property */
|
||||||
|
{
|
||||||
|
GVariantBuilder dict_builder;
|
||||||
|
|
||||||
|
g_variant_builder_init (&dict_builder, G_VARIANT_TYPE ("a{sv}"));
|
||||||
|
g_variant_builder_add (&dict_builder, "{sv}", "HasCalendars",
|
||||||
|
g_variant_new_boolean (app_has_calendars (app)));
|
||||||
|
|
||||||
|
g_dbus_connection_emit_signal (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL),
|
||||||
|
NULL,
|
||||||
|
"/org/gnome/Shell/CalendarServer",
|
||||||
|
"org.freedesktop.DBus.Properties",
|
||||||
|
"PropertiesChanged",
|
||||||
|
g_variant_new ("(sa{sv}as)",
|
||||||
|
"org.gnome.Shell.CalendarServer",
|
||||||
|
&dict_builder,
|
||||||
|
NULL),
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static App *
|
static App *
|
||||||
@ -933,6 +960,10 @@ handle_get_property (GDBusConnection *connection,
|
|||||||
{
|
{
|
||||||
ret = g_variant_new_int64 (app->until);
|
ret = g_variant_new_int64 (app->until);
|
||||||
}
|
}
|
||||||
|
else if (g_strcmp0 (property_name, "HasCalendars") == 0)
|
||||||
|
{
|
||||||
|
ret = g_variant_new_boolean (app_has_calendars (app));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user