[gnome-software/wip/ubuntu-3-24: 5/16] Construct the "Software Sources" menu item dynamically
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/ubuntu-3-24: 5/16] Construct the "Software Sources" menu item dynamically
- Date: Tue, 18 Jul 2017 00:49:44 +0000 (UTC)
commit 904d8b052a74c7e4f45d88e4f4af3ab9e26c0cbb
Author: Iain Lane <iain orangesquash org uk>
Date: Mon Jan 23 16:22:09 2017 +0000
Construct the "Software Sources" menu item dynamically
If we have software-properties-gtk, we'll launch that. In that case,
call the menu item "Software & Updates", since that more accurately
reflects what it does.
src/gs-application.c | 21 +++++++++++++++++++++
src/gs-menus.ui | 8 +-------
2 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index df1a047..686494c 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -765,9 +765,30 @@ gs_application_settings_changed_cb (GApplication *self,
static void
gs_application_startup (GApplication *application)
{
+ g_autofree gchar *software_properties = NULL;
+ const gchar *label = NULL;
+ g_autoptr(GMenu) menu = NULL;
+ g_autoptr(GMenu) new = NULL;
+
GSettings *settings;
G_APPLICATION_CLASS (gs_application_parent_class)->startup (application);
+ /* This follows the behaviour in src/gs-shell.c; when we have s-p-gtk,
+ * we will launch it. It provides a UI to manage update behaviour too.
+ */
+ software_properties = g_find_program_in_path ("software-properties-gtk");
+
+ if (!software_properties)
+ label = _("Software Sources");
+ else
+ label = _("Software & Updates");
+
+ menu = gtk_application_get_menu_by_id (GTK_APPLICATION (application),
+ "app-menu");
+ new = g_menu_new ();
+ g_menu_append (new, label, "app.sources");
+ g_menu_prepend_section (menu, NULL, G_MENU_MODEL (new));
+
g_action_map_add_action_entries (G_ACTION_MAP (application),
actions, G_N_ELEMENTS (actions),
application);
diff --git a/src/gs-menus.ui b/src/gs-menus.ui
index af7f63b..59e0b1e 100644
--- a/src/gs-menus.ui
+++ b/src/gs-menus.ui
@@ -2,13 +2,7 @@
<interface>
<!-- interface-requires gtk+ 3.0 -->
<menu id="app-menu">
- <section>
- <item>
- <attribute name="label" translatable="yes">_Software Sources</attribute>
- <attribute name="action">app.sources</attribute>
- <attribute name="hidden-when">action-disabled</attribute>
- </item>
- </section>
+ <!-- "Software Sources" entry inserted here in code, see src/gs-application.c -->
<section>
<item>
<attribute name="label" translatable="yes">_About</attribute>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]