From a2a23612b0d3bfed27e8b15508c5b9931766fc6e Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 24 Jun 2021 22:17:17 +0200 Subject: src/menu.cpp: Pipe appointment strings through ayatana_common_utils_ellipsize + add GSettings watcher for max-menu-text-length. --- src/menu.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/menu.cpp') diff --git a/src/menu.cpp b/src/menu.cpp index 416d02c..d19ad73 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -18,15 +18,17 @@ */ #include - #include #include - #include #include - #include +extern "C" +{ + #include +} + namespace ayatana { namespace indicator { namespace datetime { @@ -56,7 +58,6 @@ GMenuModel* Menu::menu_model() return G_MENU_MODEL(m_menu); } - /**** ***** ****/ @@ -78,6 +79,12 @@ protected: m_actions(actions), m_formatter(formatter) { + if (m_pSettings == NULL && profile_in != Phone && profile_in != PhoneGreeter) + { + m_pSettings = g_settings_new("org.ayatana.common"); + g_signal_connect(m_pSettings, "changed::max-menu-text-length", G_CALLBACK(on_string_length_changed), this); + } + // initialize the menu create_gmenu(); for (int i=0; i(pSelf)->update_section(Appointments); + } + void update_header() { auto action_group = m_actions->action_group(); @@ -308,6 +321,7 @@ private: auto fmt = m_formatter->relative_format(begin, end); auto unix_time = g_date_time_to_unix(begin); + ayatana_common_utils_ellipsize((char*)appt.summary.c_str()); auto menu_item = g_menu_item_new (appt.summary.c_str(), nullptr); g_menu_item_set_attribute (menu_item, "x-ayatana-time", "x", unix_time); g_menu_item_set_attribute (menu_item, "x-ayatana-time-format", "s", fmt.c_str()); @@ -437,6 +451,7 @@ private: //private: GVariant * m_serialized_alarm_icon = nullptr; GVariant * m_serialized_calendar_icon = nullptr; + GSettings *m_pSettings = NULL; }; // class MenuImpl -- cgit v1.2.3