aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-12-19 16:52:54 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-12-19 16:52:54 +0100
commitecaacccacf853059ea4588c44bd13035faaba6af (patch)
tree1c24cf2d4695dff1584bcedee3913da6391b178e
parent2aace1535ca5dd971b2ac7b796b8eaa03c11bd96 (diff)
parent4d984d26c3bd930eac72f27aa3fb9165eaef056d (diff)
downloadayatana-indicator-datetime-ecaacccacf853059ea4588c44bd13035faaba6af.tar.gz
ayatana-indicator-datetime-ecaacccacf853059ea4588c44bd13035faaba6af.tar.bz2
ayatana-indicator-datetime-ecaacccacf853059ea4588c44bd13035faaba6af.zip
Merge branch 'luigi311-toggle_events'
Attributes GH PR #117: https://github.com/AyatanaIndicators/ayatana-indicator-datetime/pull/117
-rw-r--r--src/menu.cpp41
-rw-r--r--tests/test-menus.cpp8
2 files changed, 30 insertions, 19 deletions
diff --git a/src/menu.cpp b/src/menu.cpp
index e2c32dc..0ee9242 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -428,29 +428,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);
diff --git a/tests/test-menus.cpp b/tests/test-menus.cpp
index 1f73193..853c3c5 100644
--- a/tests/test-menus.cpp
+++ b/tests/test-menus.cpp
@@ -325,9 +325,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