From 16fe21a84ea333db67e9f0509d619f8d3fee1443 Mon Sep 17 00:00:00 2001 From: Wu Xiaotian Date: Thu, 9 May 2019 12:19:23 +0800 Subject: Add Show hidden checkbox and gsettings flag. --- capplet/gsm-properties-dialog.c | 45 +++++++++++++++++++++++++++++++++++++++++ capplet/gsp-app-manager.c | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) (limited to 'capplet') diff --git a/capplet/gsm-properties-dialog.c b/capplet/gsm-properties-dialog.c index 20ceac8..3f7a816 100644 --- a/capplet/gsm-properties-dialog.c +++ b/capplet/gsm-properties-dialog.c @@ -43,11 +43,13 @@ #define CAPPLET_EDIT_WIDGET_NAME "session_properties_edit_button" #define CAPPLET_SAVE_WIDGET_NAME "session_properties_save_button" #define CAPPLET_REMEMBER_WIDGET_NAME "session_properties_remember_toggle" +#define CAPPLET_SHOW_HIDDEN_WIDGET_NAME "session_properties_show_hidden_toggle" #define STARTUP_APP_ICON "system-run" #define SPC_CONFIG_SCHEMA "org.mate.session" #define SPC_AUTOSAVE_KEY "auto-save-session" +#define SPC_SHOW_HIDDEN_KEY "show-hidden-apps" struct _GsmPropertiesDialog { @@ -457,6 +459,37 @@ on_row_activated (GtkTreeView *tree_view, on_edit_app_clicked (NULL, dialog); } +static void +update_tree_view (GsmPropertiesDialog *dialog) +{ + GSList *apps; + GSList *l; + gboolean show_hidden; + GspApp *app; + + show_hidden = g_settings_get_boolean (dialog->settings, SPC_SHOW_HIDDEN_KEY); + + apps = gsp_app_manager_get_apps (dialog->manager); + for (l = apps; l != NULL; l = l->next) { + app = GSP_APP (l->data); + if (gsp_app_get_nodisplay(app)) { + if (show_hidden) { + _app_added (dialog, app, dialog->manager); + }else{ + _app_removed (dialog, app, dialog->manager); + } + } + } + g_slist_free (apps); +} + +static void +on_show_hidden_clicked (GtkWidget *widget, + GsmPropertiesDialog *dialog) +{ + update_tree_view (dialog); +} + static void on_save_session_clicked (GtkWidget *widget, GsmPropertiesDialog *dialog) @@ -633,6 +666,17 @@ setup_dialog (GsmPropertiesDialog *dialog) g_settings_bind (dialog->settings, SPC_AUTOSAVE_KEY, button, "active", G_SETTINGS_BIND_DEFAULT); + button = GTK_WIDGET (gtk_builder_get_object (dialog->xml, + CAPPLET_SHOW_HIDDEN_WIDGET_NAME)); + + g_settings_bind (dialog->settings, SPC_SHOW_HIDDEN_KEY, + button, "active", G_SETTINGS_BIND_DEFAULT); + + g_signal_connect (button, + "clicked", + G_CALLBACK (on_show_hidden_clicked), + dialog); + button = GTK_WIDGET (gtk_builder_get_object (dialog->xml, CAPPLET_SAVE_WIDGET_NAME)); g_signal_connect (button, @@ -648,6 +692,7 @@ setup_dialog (GsmPropertiesDialog *dialog) G_CALLBACK (_app_removed), dialog); populate_model (dialog); + update_tree_view (dialog); } static GObject * diff --git a/capplet/gsp-app-manager.c b/capplet/gsp-app-manager.c index 4072036..7e245db 100644 --- a/capplet/gsp-app-manager.c +++ b/capplet/gsp-app-manager.c @@ -479,7 +479,7 @@ _gsp_app_manager_fill_from_dir (GspAppManager *manager, desktop_file_path = g_build_filename (xdgdir->dir, name, NULL); app = gsp_app_new (desktop_file_path, xdgdir->index); - if (app != NULL && !gsp_app_get_nodisplay(app)) { + if (app != NULL) { gsp_app_manager_add (manager, app); g_object_unref (app); } -- cgit v1.2.1