diff options
author | Wu Xiaotian <[email protected]> | 2019-07-01 18:15:34 +0800 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-07-17 09:38:54 +0200 |
commit | 21266a4e713b262de0a931e668723d78f7278535 (patch) | |
tree | 67f08cd89270815a87911991d460c49cb0c62081 /capplets | |
parent | d361f977a857e769392cb210c629405ced6c99ba (diff) | |
download | mate-control-center-21266a4e713b262de0a931e668723d78f7278535.tar.bz2 mate-control-center-21266a4e713b262de0a931e668723d78f7278535.tar.xz |
launch lightdm-settings if installed
Diffstat (limited to 'capplets')
-rw-r--r-- | capplets/accessibility/at-properties/main.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/capplets/accessibility/at-properties/main.c b/capplets/accessibility/at-properties/main.c index 44e07563..83bbe8f4 100644 --- a/capplets/accessibility/at-properties/main.c +++ b/capplets/accessibility/at-properties/main.c @@ -1,6 +1,7 @@ #include <config.h> #include <gtk/gtk.h> #include <gio/gio.h> +#include <gio/gdesktopappinfo.h> #include "dm-util.h" #include <dbus/dbus-glib.h> @@ -24,6 +25,23 @@ enum { static gboolean initial_state; +static GDesktopAppInfo *get_desktop_app_info_from_dm (void) +{ + DMType dm_type; + GDesktopAppInfo *app_info = NULL; + + dm_type = dm_get_type(); + if (dm_type == DM_TYPE_MDM) { + app_info = g_desktop_app_info_new ("mdmsetup.desktop"); + } else if (dm_type == DM_TYPE_LIGHTDM) { + app_info = g_desktop_app_info_new ("lightdm-settings.desktop"); + if (app_info == NULL) { + app_info = g_desktop_app_info_new ("lightdm-gtk-greeter-settings.desktop"); + } + } + return app_info; +} + static GtkBuilder * create_builder (void) { @@ -34,8 +52,7 @@ create_builder (void) if (gtk_builder_add_from_resource (builder, "/org/mate/mcc/accessibility/at/at-enable-dialog.ui", &error)) { GObject *object; - gchar *prog = NULL; - DMType dm_type; + GDesktopAppInfo *app_info = NULL; object = gtk_builder_get_object (builder, "at_enable_image"); gtk_image_set_from_file (GTK_IMAGE (object), @@ -45,18 +62,13 @@ create_builder (void) "at_applications_image"); gtk_image_set_from_file (GTK_IMAGE (object), PIXMAPDIR "/at-support.png"); - - dm_type = dm_get_type(); - if (dm_type == DM_TYPE_MDM) { - prog = g_find_program_in_path ("mdmsetup"); - } else if (dm_type == DM_TYPE_LIGHTDM) { - prog = g_find_program_in_path ("lightdm-gtk-greeter-settings-pkexec"); - } - if (prog == NULL) { + app_info = get_desktop_app_info_from_dm (); + if (app_info == NULL) { object = gtk_builder_get_object (builder, "login_button"); gtk_widget_hide (GTK_WIDGET (object)); + } else { + g_object_unref (app_info); } - g_free (prog); } else { g_warning ("Could not load UI: %s", error->message); @@ -89,19 +101,13 @@ cb_mouse_preferences (GtkDialog *dialog, gint response_id) static void cb_login_preferences (GtkDialog *dialog, gint response_id) { - DMType dm_type; - gchar *prog = NULL; + GDesktopAppInfo *app_info = NULL; - dm_type = dm_get_type(); - if (dm_type == DM_TYPE_MDM) { - prog = g_find_program_in_path ("mdmsetup"); - } else if (dm_type == DM_TYPE_LIGHTDM) { - prog = g_find_program_in_path ("lightdm-gtk-greeter-settings-pkexec"); - } + app_info = get_desktop_app_info_from_dm (); - if (prog != NULL) { - g_spawn_command_line_async (prog, NULL); - g_free(prog); + if (app_info != NULL) { + g_app_info_launch (G_APP_INFO(app_info), NULL, NULL, NULL); + g_object_unref (app_info); } } |