aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--CMakeLists.txt2
-rw-r--r--ChangeLog22
-rw-r--r--NEWS5
-rw-r--r--data/org.ayatana.indicator.datetime.gschema.xml.in7
-rw-r--r--debian/changelog7
-rw-r--r--include/datetime/menu.h3
-rw-r--r--include/datetime/settings-live.h1
-rw-r--r--include/datetime/settings-shared.h1
-rw-r--r--include/datetime/settings.h1
-rw-r--r--src/actions.cpp5
-rw-r--r--src/menu.cpp82
-rw-r--r--src/settings-live.cpp13
-rw-r--r--tests/test-menus.cpp21
14 files changed, 138 insertions, 33 deletions
diff --git a/AUTHORS b/AUTHORS
index dc17748..a4e294e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -73,6 +73,7 @@ Ken VanDine <ken.vandine@canonical.com>
klausade <klaus@linuxavdelingen.no>
koffevar <egor.kafisov@gmail.com>
Kristjan Räts <kristjanrats@gmail.com>
+kugiigi <kugi_eusebio@protonmail.com>
Kyle Nitzsche <kyle.nitzsche@canonical.com>
Kyrylo Yanukovych <rhetoranswer@hotmail.com>
Laércio Cordeiro <efs.laee@gmail.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bcb0972..8404692 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 3.13)
-project (ayatana-indicator-datetime VERSION 23.10.0 LANGUAGES C CXX)
+project (ayatana-indicator-datetime VERSION 23.10.1 LANGUAGES C CXX)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
diff --git a/ChangeLog b/ChangeLog
index 09c0c75..9422213 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,26 @@
+2023-12-26 Mike Gabriel
+
+ * release 23.10.1 (HEAD -> main, tag: 23.10.1)
+
+2023-12-19 Mike Gabriel
+
+ * Merge branch 'luigi311-toggle_alarm' (d0ebe529)
+
+2021-03-20 kugiigi
+
+ * Add option to show/hide alarms (63a57fde)
+
+2023-12-19 Mike Gabriel
+
+ * Merge branch 'luigi311-toggle_events' (ecaaccca)
+
+2021-03-18 kugiigi
+
+ * Also apply show-events to Phone profile (4d984d26)
+
2023-10-12 Mike Gabriel
- * release 23.10.0 (HEAD -> main, tag: 23.10.0)
+ * release 23.10.0 (2aace153) (tag: 23.10.0)
* po/: Update translation files. (3e66ea9a)
2023-10-10 Mike Gabriel
diff --git a/NEWS b/NEWS
index f14eaf5..00a897a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+Overview of changes in ayatana-indicator-datetime 23.10.1
+
+ - Also apply show-events to Phone profile.
+ - Add option to show/hide alarms.
+
Overview of changes in ayatana-indicator-datetime 23.10.0
- tests/run-eds-ics-test: don't eat away test's result.
diff --git a/data/org.ayatana.indicator.datetime.gschema.xml.in b/data/org.ayatana.indicator.datetime.gschema.xml.in
index dd94598..62e86b9 100644
--- a/data/org.ayatana.indicator.datetime.gschema.xml.in
+++ b/data/org.ayatana.indicator.datetime.gschema.xml.in
@@ -87,6 +87,13 @@
Shows events from Evolution in indicator-datetime's menu.
</description>
</key>
+ <key name="show-alarms" type="b">
+ <default>true</default>
+ <summary>Show alarms in the indicator</summary>
+ <description>
+ Shows alarms in the events list in indicator-datetime's menu.
+ </description>
+ </key>
<key name="show-auto-detected-location" type="b">
<default>false</default>
<summary>Show the auto-detected location in the indicator</summary>
diff --git a/debian/changelog b/debian/changelog
index ccd593e..9930829 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ayatana-indicator-datetime (23.10.1-0) unstable; urgency=medium
+
+ * Upstream-provided Debian package for ayatana-indicator-datetime.
+ See upstream ChangeLog for recent changes.
+
+ -- Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Tue, 26 Dec 2023 12:32:08 +0100
+
ayatana-indicator-datetime (23.10.0-0) unstable; urgency=medium
* Upstream-provided Debian package for ayatana-indicator-datetime.
diff --git a/include/datetime/menu.h b/include/datetime/menu.h
index 0074ea5..5673bc1 100644
--- a/include/datetime/menu.h
+++ b/include/datetime/menu.h
@@ -53,7 +53,8 @@ public:
static std::vector<Appointment> get_display_appointments(
const std::vector<Appointment>&,
const DateTime& start,
- unsigned int max_items=5);
+ unsigned int max_items=5,
+ const bool include_alarms=true);
protected:
Menu (Profile profile_in, const std::string& name_in);
diff --git a/include/datetime/settings-live.h b/include/datetime/settings-live.h
index 85071ce..6a923f3 100644
--- a/include/datetime/settings-live.h
+++ b/include/datetime/settings-live.h
@@ -52,6 +52,7 @@ private:
void update_show_day();
void update_show_detected_locations();
void update_show_events();
+ void update_show_alarms();
void update_show_locations();
void update_show_seconds();
void update_show_week_numbers();
diff --git a/include/datetime/settings-shared.h b/include/datetime/settings-shared.h
index 7280c16..6e97328 100644
--- a/include/datetime/settings-shared.h
+++ b/include/datetime/settings-shared.h
@@ -40,6 +40,7 @@ TimeFormatMode;
#define SETTINGS_SHOW_CALENDAR_S "show-calendar"
#define SETTINGS_SHOW_WEEK_NUMBERS_S "show-week-numbers"
#define SETTINGS_SHOW_EVENTS_S "show-events"
+#define SETTINGS_SHOW_ALARMS_S "show-alarms"
#define SETTINGS_SHOW_LOCATIONS_S "show-locations"
#define SETTINGS_SHOW_DETECTED_S "show-auto-detected-location"
#define SETTINGS_LOCATIONS_S "locations"
diff --git a/include/datetime/settings.h b/include/datetime/settings.h
index af9227d..29905fd 100644
--- a/include/datetime/settings.h
+++ b/include/datetime/settings.h
@@ -49,6 +49,7 @@ public:
core::Property<bool> show_day;
core::Property<bool> show_detected_location;
core::Property<bool> show_events;
+ core::Property<bool> show_alarms;
core::Property<bool> show_locations;
core::Property<bool> show_seconds;
core::Property<bool> show_week_numbers;
diff --git a/src/actions.cpp b/src/actions.cpp
index c184aef..18b99e8 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -142,7 +142,10 @@ GVariant* create_calendar_state(const std::shared_ptr<State>& state)
{
gboolean days[32] = { 0 };
for (const auto& appt : state->calendar_month->appointments().get())
- days[appt.begin.day_of_month()] = true;
+ if (!appt.is_alarm() || state->settings->show_alarms.get())
+ {
+ days[appt.begin.day_of_month()] = true;
+ }
GVariantBuilder day_builder;
g_variant_builder_init(&day_builder, G_VARIANT_TYPE("ai"));
diff --git a/src/menu.cpp b/src/menu.cpp
index e2c32dc..b8ef1b6 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -72,13 +72,14 @@ GMenuModel* Menu::menu_model()
std::vector<Appointment>
Menu::get_display_appointments(const std::vector<Appointment>& appointments_in,
const DateTime& now,
- unsigned int max_items)
+ unsigned int max_items,
+ const bool include_alarms)
{
std::vector<Appointment> appointments;
std::copy_if(appointments_in.begin(),
appointments_in.end(),
std::back_inserter(appointments),
- [now](const Appointment& a){return a.end >= now;});
+ [now, include_alarms](const Appointment& a){return a.end >= now && (!a.is_alarm() || include_alarms);});
if (appointments.size() > max_items)
{
@@ -186,6 +187,9 @@ protected:
m_state->settings->show_events.changed().connect([this](bool){
update_section(Appointments); // showing events got toggled
});
+ m_state->settings->show_alarms.changed().connect([this](bool){
+ update_section(Appointments); // showing alarms got toggled
+ });
m_state->calendar_upcoming->date().changed().connect([this](const DateTime&){
update_upcoming(); // our m_upcoming is planner->upcoming() filtered by time
});
@@ -240,7 +244,9 @@ protected:
auto upcoming = get_display_appointments(
m_state->calendar_upcoming->appointments().get(),
- begin
+ begin,
+ 5,
+ m_state->settings->show_alarms.get()
);
if (m_upcoming != upcoming)
@@ -268,10 +274,6 @@ protected:
return m_serialized_alarm_icon;
}
- std::vector<Appointment> m_upcoming;
-
-private:
-
GVariant* get_serialized_calendar_icon()
{
if (G_UNLIKELY(m_serialized_calendar_icon == nullptr))
@@ -284,6 +286,10 @@ private:
return m_serialized_calendar_icon;
}
+ std::vector<Appointment> m_upcoming;
+
+private:
+
void create_gmenu()
{
g_assert(m_submenu == nullptr);
@@ -428,29 +434,32 @@ private:
{
auto menu = g_menu_new();
- if ((profile==Desktop) && m_state->settings->show_events.get())
+ if (m_state->settings->show_events.get())
{
- add_appointments (menu, profile);
-
- if (m_actions->desktop_has_calendar_app())
+ if (profile==Desktop)
{
- // add the 'Add Event…' menuitem
- auto menu_item = g_menu_item_new(_("Add Event…"), nullptr);
- const gchar* action_name = "indicator.desktop.open-calendar-app";
- auto v = g_variant_new_int64(0);
- g_menu_item_set_action_and_target_value(menu_item, action_name, v);
- g_menu_append_item(menu, menu_item);
- g_object_unref(menu_item);
+ add_appointments (menu, profile);
+
+ if (m_actions->desktop_has_calendar_app())
+ {
+ // add the 'Add Event…' menuitem
+ auto menu_item = g_menu_item_new(_("Add Event…"), nullptr);
+ const gchar* action_name = "indicator.desktop.open-calendar-app";
+ auto v = g_variant_new_int64(0);
+ g_menu_item_set_action_and_target_value(menu_item, action_name, v);
+ g_menu_append_item(menu, menu_item);
+ g_object_unref(menu_item);
+ }
}
- }
- else if (profile==Phone)
- {
- auto menu_item = g_menu_item_new (_("Clock"), "indicator.phone.open-alarm-app");
- g_menu_item_set_attribute_value (menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon());
- g_menu_append_item (menu, menu_item);
- g_object_unref (menu_item);
+ else if (profile==Phone)
+ {
+ auto menu_item = g_menu_item_new (_("Clock"), "indicator.phone.open-alarm-app");
+ g_menu_item_set_attribute_value (menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon());
+ g_menu_append_item (menu, menu_item);
+ g_object_unref (menu_item);
- add_appointments (menu, profile);
+ add_appointments (menu, profile);
+ }
}
return G_MENU_MODEL(menu);
@@ -598,6 +607,7 @@ protected:
{
// are there alarms?
bool has_alarms = false;
+ bool has_non_alarm_events = false;
for(const auto& appointment : m_upcoming)
{
has_alarms = appointment.is_alarm();
@@ -606,19 +616,33 @@ protected:
{
break;
}
+ else
+ {
+ has_non_alarm_events = true;
+ }
}
+
GVariantBuilder b;
g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string (_("Time and Date")));
g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
- if (has_alarms)
+ if (has_alarms || has_non_alarm_events)
+
{
auto label = m_formatter->header.get();
- auto a11y = g_strdup_printf(_("%s (has alarms)"), label.c_str());
+ auto a11y = g_strdup_printf(_("%s (has events)"), label.c_str());
g_variant_builder_add(&b, "{sv}", "label", g_variant_new_string(label.c_str()));
g_variant_builder_add(&b, "{sv}", "accessible-desc", g_variant_new_take_string(a11y));
- g_variant_builder_add(&b, "{sv}", "icon", get_serialized_alarm_icon());
+
+ if (has_alarms && m_state->settings->show_alarms.get())
+ {
+ g_variant_builder_add(&b, "{sv}", "icon", get_serialized_alarm_icon());
+ }
+ else
+ {
+ g_variant_builder_add(&b, "{sv}", "icon", get_serialized_calendar_icon());
+ }
}
else
{
diff --git a/src/settings-live.cpp b/src/settings-live.cpp
index cf18739..9cbc23c 100644
--- a/src/settings-live.cpp
+++ b/src/settings-live.cpp
@@ -47,6 +47,7 @@ LiveSettings::LiveSettings():
update_show_day();
update_show_detected_locations();
update_show_events();
+ update_show_alarms();
update_show_locations();
update_show_seconds();
update_show_week_numbers();
@@ -117,6 +118,10 @@ LiveSettings::LiveSettings():
g_settings_set_boolean(m_settings, SETTINGS_SHOW_EVENTS_S, value);
});
+ show_alarms.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings, SETTINGS_SHOW_ALARMS_S, value);
+ });
+
show_locations.changed().connect([this](bool value){
g_settings_set_boolean(m_settings, SETTINGS_SHOW_LOCATIONS_S, value);
});
@@ -239,6 +244,12 @@ void LiveSettings::update_show_events()
show_events.set(val);
}
+void LiveSettings::update_show_alarms()
+{
+ const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_ALARMS_S);
+ show_alarms.set(val);
+}
+
void LiveSettings::update_show_locations()
{
const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_LOCATIONS_S);
@@ -415,6 +426,8 @@ void LiveSettings::update_key_ccid(const std::string& key)
update_show_week_numbers();
else if (key == SETTINGS_SHOW_EVENTS_S)
update_show_events();
+ else if (key == SETTINGS_SHOW_ALARMS_S)
+ update_show_alarms();
else if (key == SETTINGS_SHOW_LOCATIONS_S)
update_show_locations();
else if (key == SETTINGS_SHOW_DETECTED_S)
diff --git a/tests/test-menus.cpp b/tests/test-menus.cpp
index 1f73193..e71c997 100644
--- a/tests/test-menus.cpp
+++ b/tests/test-menus.cpp
@@ -272,6 +272,19 @@ private:
for (int i=0, n=appointments.size(); i<n; i++)
InspectAppointmentMenuItem(section, first_appt_index+i, appointments[i]);
+ // there shouldn't be any alarms when "show alarms" is false
+ bool has_alarms = false;
+
+ m_state->settings->show_alarms.set(false);
+
+ for (int i=0, n=appointments.size(); i<n; i++)
+ if((has_alarms = appointments[i].is_alarm()))
+ break;
+
+ EXPECT_FALSE(has_alarms);
+
+ m_state->settings->show_alarms.set(true);
+
//g_clear_object(&section);
//g_clear_object(&submenu);
}
@@ -325,9 +338,17 @@ private:
void InspectPhoneAppointments(GMenuModel* menu_model, bool can_open_planner)
{
auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
+
+ // there shouldn't be any menuitems when "show events" is false
+ m_state->settings->show_events.set(false);
+ wait_msec();
+ section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(0, g_menu_model_get_n_items(section));
+ g_clear_object(&section);
// clear all the appointments
std::vector<Appointment> appointments;
+ m_state->settings->show_events.set(true);
m_state->calendar_upcoming->appointments().set(appointments);
wait_msec(); // wait a moment for the menu to update