# HG changeset patch # User Guido Berhoerster # Date 1528925109 -7200 # Node ID 2fa34d6272c6f03b47833b4115efff03c90a60f8 # Parent 7172a0db97af36a3b79b914ed7022cae60726548 Add menu item to launch the preferences application diff -r 7172a0db97af -r 2fa34d6272c6 pui-application.c --- a/pui-application.c Wed Jun 13 20:06:00 2018 +0200 +++ b/pui-application.c Wed Jun 13 23:25:09 2018 +0200 @@ -21,6 +21,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include #include #include #include @@ -78,12 +79,15 @@ static void pui_application_show_about_dialog(GSimpleAction *, GVariant *, gpointer); +static void pui_application_open_preferences(GSimpleAction *, GVariant *, + gpointer); static void pui_application_quit(GSimpleAction *, GVariant *, gpointer); static void pui_application_install_updates(GSimpleAction *, GVariant *, gpointer); static const GActionEntry pui_application_actions[] = { { "about", pui_application_show_about_dialog }, + { "preferences", pui_application_open_preferences }, { "quit", pui_application_quit }, { "install-updates", pui_application_install_updates } }; @@ -130,6 +134,28 @@ } static void +pui_application_open_preferences(GSimpleAction *simple, GVariant *parameter, + gpointer user_data) +{ + GDesktopAppInfo *prefs_app_info; + GError *error = NULL; + + prefs_app_info = g_desktop_app_info_new("org.guido-berhoerster.code." + "package-update-indicator.preferences.desktop"); + if (prefs_app_info == NULL) { + g_warning("desktop file \"org.guido-berhoerster.code." + "package-update-indicator.preferences.desktop\" not found"); + return; + } + + if (!g_app_info_launch(G_APP_INFO(prefs_app_info), NULL, NULL, + &error)) { + g_warning("failed to launch preferences: %s", error->message); + g_error_free(error); + } +} + +static void pui_application_quit(GSimpleAction *simple, GVariant *parameter, gpointer user_data) { diff -r 7172a0db97af -r 2fa34d6272c6 pui-menu.ui --- a/pui-menu.ui Wed Jun 13 20:06:00 2018 +0200 +++ b/pui-menu.ui Wed Jun 13 23:25:09 2018 +0200 @@ -18,6 +18,15 @@ True False + app.preferences + _Preferences… + True + + + + + True + False app.about _About… True