diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-06-06 09:03:43 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-06-06 09:03:43 +0200 |
commit | c09eb8ccfa2e7731ca15564e2f17d186f7910dbc (patch) | |
tree | 2370c92ae457865fade5768ed8fbf576885e3bcd | |
parent | 3977a1e63e1be54c009194d9b762b6fb49fc42b9 (diff) | |
parent | cf32ce6be9b43a02d6ef36af877ba59562878ba4 (diff) | |
download | ayatana-indicator-session-c09eb8ccfa2e7731ca15564e2f17d186f7910dbc.tar.gz ayatana-indicator-session-c09eb8ccfa2e7731ca15564e2f17d186f7910dbc.tar.bz2 ayatana-indicator-session-c09eb8ccfa2e7731ca15564e2f17d186f7910dbc.zip |
Merge branch 'tari01-pr/custom-item'
Attributes GH PR #86: https://github.com/AyatanaIndicators/ayatana-indicator-session/pull/86
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | data/org.ayatana.indicator.session.gschema.xml | 16 | ||||
-rw-r--r-- | src/service.c | 29 | ||||
-rw-r--r-- | tests/org.ayatana.indicator.session.gschema.xml | 16 |
4 files changed, 59 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cffc63..8919acd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.13) -project (ayatana-indicator-session C CXX) +project (ayatana-indicator-session VERSION 22.9.1 LANGUAGES C CXX) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE) @@ -7,7 +7,6 @@ endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -set (PROJECT_VERSION "22.9.1") set (PACKAGE ${CMAKE_PROJECT_NAME}) set (GETTEXT_PACKAGE "ayatana-indicator-session") diff --git a/data/org.ayatana.indicator.session.gschema.xml b/data/org.ayatana.indicator.session.gschema.xml index dd35390..807c631 100644 --- a/data/org.ayatana.indicator.session.gschema.xml +++ b/data/org.ayatana.indicator.session.gschema.xml @@ -55,6 +55,20 @@ <summary>Show bug report item</summary> <description>Show the bug report menu item.</description> </key> + <key name="show-custom-item" type="b"> + <default>false</default> + <summary>Show custom item</summary> + <description>Show the custom menu item.</description> + </key> + <key name="custom-item-label" type="s"> + <default>""</default> + <summary>Custom item label</summary> + <description>The label of the custom menu item.</description> + </key> + <key name="custom-item-uri" type="s"> + <default>""</default> + <summary>Custom item URI</summary> + <description>The location the custom menu item should open.</description> + </key> </schema> - </schemalist> diff --git a/src/service.c b/src/service.c index 6f4e294..d05f2cb 100644 --- a/src/service.c +++ b/src/service.c @@ -381,6 +381,22 @@ create_admin_section (IndicatorSessionService * self) priv_t * p = self->priv; menu = g_menu_new (); + gboolean bShowCustom = g_settings_get_boolean (self->priv->indicator_settings, "show-custom-item"); + + if (bShowCustom) + { + gchar *sLabel = g_settings_get_string (self->priv->indicator_settings, "custom-item-label"); + gchar *sUri = g_settings_get_string (self->priv->indicator_settings, "custom-item-uri"); + + if (*sLabel != '\0' && *sUri != '\0') + { + g_menu_append (menu, sLabel, "indicator.custom"); + } + + g_free (sUri); + g_free (sLabel); + } + gboolean bShowDeviceInfo = g_settings_get_boolean (self->priv->indicator_settings, "show-device-info"); if (bShowDeviceInfo) @@ -1039,6 +1055,13 @@ on_user_activated (GSimpleAction * a G_GNUC_UNUSED, username); } +static void on_custom_activated (GSimpleAction *pAction G_GNUC_UNUSED, GVariant *pParam G_GNUC_UNUSED, gpointer pUserData) +{ + IndicatorSessionService *self = INDICATOR_SESSION_SERVICE (pUserData); + gchar *sUri = g_settings_get_string (self->priv->indicator_settings, "custom-item-uri"); + ayatana_common_utils_open_url (sUri); +} + static void init_gactions (IndicatorSessionService * self) { @@ -1059,7 +1082,8 @@ init_gactions (IndicatorSessionService * self) { "switch-to-screensaver", on_screensaver_activated }, { "switch-to-greeter", on_greeter_activated }, { "suspend", on_suspend_activated }, - { "power-off", on_power_off_activated } + { "power-off", on_power_off_activated }, + { "custom", on_custom_activated } }; p->actions = g_simple_action_group_new (); @@ -1422,6 +1446,9 @@ indicator_session_service_init (IndicatorSessionService * self) g_signal_connect_swapped (gp, "changed::show-desktop-help", G_CALLBACK (rebuild_admin_section_soon), self); g_signal_connect_swapped (gp, "changed::show-distro-help", G_CALLBACK (rebuild_admin_section_soon), self); g_signal_connect_swapped (gp, "changed::show-bug-report", G_CALLBACK (rebuild_admin_section_soon), self); + g_signal_connect_swapped (gp, "changed::show-custom-item", G_CALLBACK (rebuild_admin_section_soon), self); + g_signal_connect_swapped (gp, "changed::custom-item-label", G_CALLBACK (rebuild_admin_section_soon), self); + g_signal_connect_swapped (gp, "changed::custom-item-uri", G_CALLBACK (rebuild_admin_section_soon), self); /* watch for changes to the lock keybinding */ gp = p->keybinding_settings; diff --git a/tests/org.ayatana.indicator.session.gschema.xml b/tests/org.ayatana.indicator.session.gschema.xml index b6bacd8..2e1c01f 100644 --- a/tests/org.ayatana.indicator.session.gschema.xml +++ b/tests/org.ayatana.indicator.session.gschema.xml @@ -51,6 +51,20 @@ <summary>Show bug report item</summary> <description>Show the bug report menu item.</description> </key> + <key name="show-custom-item" type="b"> + <default>false</default> + <summary>Show custom item</summary> + <description>Show the custom menu item.</description> + </key> + <key name="custom-item-label" type="s"> + <default>""</default> + <summary>Custom item label</summary> + <description>The label of the custom menu item.</description> + </key> + <key name="custom-item-uri" type="s"> + <default>""</default> + <summary>Custom item URI</summary> + <description>The location the custom menu item should open.</description> + </key> </schema> - </schemalist> |