From de76c7febaa56817c9cd39fd8746da38738914ee Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Tue, 15 Jun 2021 09:14:06 +0900 Subject: [PATCH 01/37] Fetch gio-extensions.{{c,h}@87fec42e --- thunar/thunar-gio-extensions.c | 162 +++++++++++++++++++++++++++++++++ thunar/thunar-gio-extensions.h | 5 + 2 files changed, 167 insertions(+) diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c index 394a1032e..9880969fb 100644 --- a/thunar/thunar-gio-extensions.c +++ b/thunar/thunar-gio-extensions.c @@ -40,6 +40,8 @@ +#define XFCE_ATTRIBUTE_EXECUTABLE_DIGEST "metadata::xfce-exe-hash" /* string */ + /* See : https://freedesktop.org/wiki/Specifications/icon-naming-spec/ */ static struct { @@ -871,3 +873,163 @@ thunar_g_vfs_metadata_is_supported (void) return metadata_is_supported; } + + + +/** + * TEST AREA + * + * + **/ + + +/** + * + **/ +gboolean +xfce_g_file_metadata_is_supported (GFile *file) +{ + GFileAttributeInfoList *info_list; + gboolean is_supported; + + g_return_val_if_fail (G_IS_FILE (file), FALSE); + + /* g_return_val_if_fail (G_IS_FILE (file), FALSE); */ + + info_list = g_file_query_writable_namespaces (file, NULL, NULL); + if (info_list == NULL) + return FALSE; + + is_supported = (g_file_attribute_info_list_lookup (info_list, "metadata") != NULL); + g_file_attribute_info_list_unref (info_list); + + return is_supported; +} + +/** + * + **/ +gchar * +xfce_g_file_digest (GFile *file) +{ + GFileInfo *file_info; + GFileInputStream *stream; + guchar *contents_buffer; + gchar *checksum; + gsize file_size, file_size_read; + gboolean read_successful; + + g_return_val_if_fail (G_IS_FILE (file), NULL); + + /* query size */ + file_info = g_file_query_info (file, + G_FILE_ATTRIBUTE_STANDARD_SIZE, + G_FILE_QUERY_INFO_NONE, + NULL, + NULL); + file_size = g_file_info_get_size (file_info); + g_object_unref (file_info); + + if (file_size == 0) + return g_compute_checksum_for_data (G_CHECKSUM_SHA256, NULL, 0); + + /* allocate buffer */ + contents_buffer = g_malloc (file_size); + + /* read the actual file */ + stream = g_file_read (file, NULL, NULL); + /* TODO : ERR */ + read_successful = g_input_stream_read_all (G_INPUT_STREAM (stream), + contents_buffer, + file_size, + &file_size_read, + NULL, + NULL); + if (read_successful) + checksum = g_compute_checksum_for_data (G_CHECKSUM_SHA256, + contents_buffer, + file_size_read); + else + checksum = NULL; + + /* free buffer */ + g_free (contents_buffer); + + return checksum; +} + +/** + * + * + **/ +void +xfce_g_file_set_saftey_flag (GFile *file, + gboolean is_executable) +{ + const gchar *digest_string; + + g_return_if_fail (G_IS_FILE (file)); + + /* check if GVFs metadata is supported */ + if (!xfce_g_file_metadata_is_supported (file)) + return; + + if (is_executable) + { + digest_string = xfce_g_file_digest (file); + if (digest_string == NULL) + return; + } + else + digest_string = NULL; + + g_file_set_attribute (file, + XFCE_ATTRIBUTE_EXECUTABLE_DIGEST, + is_executable ? G_FILE_ATTRIBUTE_TYPE_STRING + : G_FILE_ATTRIBUTE_TYPE_INVALID, + digest_string, + G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE | G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED, + NULL, + NULL); + g_free (digest_string); +} + +/** + * + **/ +gboolean +xfce_g_file_is_safety_flag_on (GFile *file) +{ + GFileInfo *file_info; + gboolean is_executable; + const gchar *attribute_string; + const gchar *digest_string; + + g_return_if_fail (G_IS_FILE (file)); + + if (!xfce_g_file_metadata_is_supported(file)) + return TRUE; + + file_info = g_file_query_info (file, + XFCE_ATTRIBUTE_EXECUTABLE_DIGEST, + G_FILE_QUERY_INFO_NONE, + NULL, + NULL); + + attribute_string = g_file_info_get_attribute_string (file_info, + XFCE_ATTRIBUTE_EXECUTABLE_DIGEST); + if (attribute_string != NULL) + { + digest_string = xfce_g_file_digest (file); + is_executable = (g_strcmp0 (attribute_string, digest_string) == 0); + g_info ("Attribute hash: %s", attribute_string); + g_info ("File hash : %s", digest_string); + g_free (digest_string); + } + else + is_executable = FALSE; + + g_object_unref (file_info); + + return is_executable; +} diff --git a/thunar/thunar-gio-extensions.h b/thunar/thunar-gio-extensions.h index 5b183971d..761f2994d 100644 --- a/thunar/thunar-gio-extensions.h +++ b/thunar/thunar-gio-extensions.h @@ -93,6 +93,11 @@ gboolean thunar_g_app_info_should_show (GAppInfo *info) gboolean thunar_g_vfs_metadata_is_supported (void); +gboolean xfce_g_file_metadata_is_supported (GFile *file); +gchar *xfce_g_file_digest (GFile *file); +void xfce_g_file_set_safety_flag (GFile *file, + gboolean is_executable); +gboolean xfce_g_file_is_safety_flag_on (GFile *file); G_END_DECLS -- GitLab From ee0a294a6d88df997bcd7b45945a214f50601ac4 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Tue, 15 Jun 2021 11:10:54 +0900 Subject: [PATCH 02/37] Implement safety flag interface Safety flag can be managed with file properties, and will propmt user on execution if not enabled. --- thunar/thunar-dialogs.c | 3 ++ thunar/thunar-file.c | 15 +++++-- thunar/thunar-gio-extensions.c | 9 ++-- thunar/thunar-permissions-chooser.c | 69 ++++++++++++++++++++++++++++- 4 files changed, 87 insertions(+), 9 deletions(-) diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index 9a8aa5179..1cee7c848 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -1082,6 +1082,9 @@ thunar_dialogs_show_insecure_program (gpointer parent, g_error_free (err); } + if (thunar_g_vfs_metadata_is_supported ()) + xfce_g_file_set_safety_flag (thunar_file_get_file (file), TRUE); + /* just launch */ response = GTK_RESPONSE_OK; } diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 25662ea95..2c004bc92 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1578,6 +1578,8 @@ thunar_file_execute (ThunarFile *file, const gchar *startup_id, GError **error) { + gboolean metadata_supported; + gboolean safety_flag = TRUE; gboolean snotify = FALSE; gboolean terminal; gboolean result = FALSE; @@ -1607,8 +1609,12 @@ thunar_file_execute (ThunarFile *file, uri_list = g_slist_prepend (uri_list, g_file_get_uri (li->data)); uri_list = g_slist_reverse (uri_list); + if (thunar_g_vfs_metadata_is_supported ()) + safety_flag = xfce_g_file_is_safety_flag_on (file->gfile); + if (thunar_file_is_desktop_file (file, &is_secure)) { + is_secure = is_secure && safety_flag; /* parse file first, even if it is insecure */ key_file = thunar_g_file_query_key_file (file->gfile, NULL, &err); if (key_file == NULL) @@ -1695,11 +1701,14 @@ thunar_file_execute (ThunarFile *file, /* fake the Exec line */ escaped_location = g_shell_quote (location); exec = g_strconcat (escaped_location, " %F", NULL); - command = xfce_expand_desktop_entry_field_codes (exec, uri_list, NULL, NULL, NULL, FALSE); - result = g_shell_parse_argv (command, NULL, &argv, error); + if (safety_flag || thunar_dialogs_show_insecure_program (parent, _("Untrusted executable"), file, exec)) + { + command = xfce_expand_desktop_entry_field_codes (exec, uri_list, NULL, NULL, NULL, FALSE); + result = g_shell_parse_argv (command, NULL, &argv, error); + g_free (command); + } g_free (escaped_location); g_free (exec); - g_free (command); } if (G_LIKELY (result && argv != NULL)) diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c index 9880969fb..77cb1a2cf 100644 --- a/thunar/thunar-gio-extensions.c +++ b/thunar/thunar-gio-extensions.c @@ -963,15 +963,14 @@ xfce_g_file_digest (GFile *file) * **/ void -xfce_g_file_set_saftey_flag (GFile *file, +xfce_g_file_set_safety_flag (GFile *file, gboolean is_executable) { - const gchar *digest_string; + gchar *digest_string; g_return_if_fail (G_IS_FILE (file)); - /* check if GVFs metadata is supported */ - if (!xfce_g_file_metadata_is_supported (file)) + if (!xfce_g_file_metadata_is_supported(file)) return; if (is_executable) @@ -1003,7 +1002,7 @@ xfce_g_file_is_safety_flag_on (GFile *file) GFileInfo *file_info; gboolean is_executable; const gchar *attribute_string; - const gchar *digest_string; + gchar *digest_string; g_return_if_fail (G_IS_FILE (file)); diff --git a/thunar/thunar-permissions-chooser.c b/thunar/thunar-permissions-chooser.c index 747e7d977..f76cd03df 100644 --- a/thunar/thunar-permissions-chooser.c +++ b/thunar/thunar-permissions-chooser.c @@ -45,6 +45,8 @@ #include #include #include +/*TEST*/ +#include @@ -97,6 +99,8 @@ static void thunar_permissions_chooser_group_changed (ThunarP GtkWidget *combo); static void thunar_permissions_chooser_program_toggled (ThunarPermissionsChooser *chooser, GtkWidget *button); +static void thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, + GtkWidget *button); static void thunar_permissions_chooser_fixperm_clicked (ThunarPermissionsChooser *chooser, GtkWidget *button); static ThunarJobResponse thunar_permissions_chooser_job_ask (ThunarPermissionsChooser *chooser, @@ -141,6 +145,7 @@ struct _ThunarPermissionsChooser GtkWidget *group_combo; GtkWidget *access_combos[3]; GtkWidget *program_button; + GtkWidget *launcher_button; GtkWidget *fixperm_label; GtkWidget *fixperm_button; @@ -371,6 +376,29 @@ thunar_permissions_chooser_init (ThunarPermissionsChooser *chooser) row += 1; + /* TEST AREA BEGIN */ + + label = gtk_label_new (_("Launcher:")); + gtk_label_set_xalign (GTK_LABEL (label), 1.0f); + gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ()); + gtk_grid_attach (GTK_GRID (chooser->grid), label, 0, row, 1, 1); + gtk_widget_show (label); + + chooser->launcher_button = gtk_check_button_new_with_mnemonic (_("Allow this file to be _launched from Thunar")); + g_object_bind_property (G_OBJECT (chooser->launcher_button), "visible", + G_OBJECT (label), "visible", + G_BINDING_SYNC_CREATE); + g_object_bind_property (G_OBJECT (chooser), "mutable", + G_OBJECT (chooser->launcher_button), "sensitive", + G_BINDING_SYNC_CREATE); + gtk_grid_attach (GTK_GRID (chooser->grid), chooser->launcher_button, 1, row, 1, 1); + g_signal_connect_swapped (G_OBJECT (chooser->launcher_button), "toggled", G_CALLBACK (thunar_permissions_chooser_launcher_toggled), chooser); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), chooser->launcher_button); + gtk_widget_show (chooser->launcher_button); + + row += 1; + /* TEST AREA END */ + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); g_object_bind_property (G_OBJECT (chooser), "mutable", G_OBJECT (hbox), "sensitive", @@ -893,6 +921,8 @@ thunar_permissions_chooser_file_changed (ThunarPermissionsChooser *chooser) gint file_modes[3]; GtkListStore *access_store; + gboolean is_file_regular, is_metadata_supported; + _thunar_return_if_fail (THUNAR_IS_PERMISSIONS_CHOOSER (chooser)); /* compare multiple files */ @@ -1048,12 +1078,22 @@ thunar_permissions_chooser_file_changed (ThunarPermissionsChooser *chooser) g_object_unref (G_OBJECT (access_store)); } + is_file_regular = thunar_file_is_regular (file); /* update the program setting based on the mode (only visible for regular files) */ g_signal_handlers_block_by_func (G_OBJECT (chooser->program_button), thunar_permissions_chooser_program_toggled, chooser); - g_object_set (G_OBJECT (chooser->program_button), "visible", thunar_file_is_regular (file), NULL); + g_object_set (G_OBJECT (chooser->program_button), "visible", is_file_regular, NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), (mode & 0111) != 0); g_signal_handlers_unblock_by_func (G_OBJECT (chooser->program_button), thunar_permissions_chooser_program_toggled, chooser); + /* TEST AREA BEGIN */ + is_metadata_supported = xfce_g_file_metadata_is_supported (thunar_file_get_file (file)); + /* update the launcher setting based on safety flag (only visible for regular files) */ + g_signal_handlers_block_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); + g_object_set (G_OBJECT (chooser->launcher_button), "visible", is_file_regular && is_metadata_supported, NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->launcher_button), xfce_g_file_is_safety_flag_on (thunar_file_get_file (file))); + g_signal_handlers_unblock_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); + /* TEST AREA END */ + /* update the "inconsistent folder permissions" warning and the "fix permissions" button based on the mode */ if (thunar_permissions_chooser_has_fixable_directory (chooser)) { @@ -1133,6 +1173,33 @@ thunar_permissions_chooser_program_toggled (ThunarPermissionsChooser *chooser, +static void +thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, + GtkWidget *button) +{ + gboolean safety_flag; + GFile *gfile; + + /* TODO: Multiple flags*/ + _thunar_return_if_fail (THUNAR_IS_PERMISSIONS_CHOOSER (chooser)); + _thunar_return_if_fail (chooser->launcher_button == button); + _thunar_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); + + /* verify that we have a valid file */ + if (G_UNLIKELY (chooser->files == NULL)) + return; + + safety_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + + gfile = thunar_file_get_file (THUNAR_FILE (chooser->files->data)); + g_info ("%s", thunar_g_file_get_location (gfile)); + xfce_g_file_set_safety_flag (gfile, safety_flag); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), safety_flag); +} + + + static void thunar_permissions_chooser_fixperm_clicked (ThunarPermissionsChooser *chooser, GtkWidget *button) -- GitLab From 0855cd357300a159492e17dbad22d80e39f12a39 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Wed, 16 Jun 2021 11:53:19 +0900 Subject: [PATCH 03/37] xfce_* functions moved to libxfce4util --- thunar/thunar-file.c | 1 - thunar/thunar-gio-extensions.c | 161 --------------------------------- thunar/thunar-gio-extensions.h | 6 -- 3 files changed, 168 deletions(-) diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 2c004bc92..cde885c07 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1578,7 +1578,6 @@ thunar_file_execute (ThunarFile *file, const gchar *startup_id, GError **error) { - gboolean metadata_supported; gboolean safety_flag = TRUE; gboolean snotify = FALSE; gboolean terminal; diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c index 77cb1a2cf..394a1032e 100644 --- a/thunar/thunar-gio-extensions.c +++ b/thunar/thunar-gio-extensions.c @@ -40,8 +40,6 @@ -#define XFCE_ATTRIBUTE_EXECUTABLE_DIGEST "metadata::xfce-exe-hash" /* string */ - /* See : https://freedesktop.org/wiki/Specifications/icon-naming-spec/ */ static struct { @@ -873,162 +871,3 @@ thunar_g_vfs_metadata_is_supported (void) return metadata_is_supported; } - - - -/** - * TEST AREA - * - * - **/ - - -/** - * - **/ -gboolean -xfce_g_file_metadata_is_supported (GFile *file) -{ - GFileAttributeInfoList *info_list; - gboolean is_supported; - - g_return_val_if_fail (G_IS_FILE (file), FALSE); - - /* g_return_val_if_fail (G_IS_FILE (file), FALSE); */ - - info_list = g_file_query_writable_namespaces (file, NULL, NULL); - if (info_list == NULL) - return FALSE; - - is_supported = (g_file_attribute_info_list_lookup (info_list, "metadata") != NULL); - g_file_attribute_info_list_unref (info_list); - - return is_supported; -} - -/** - * - **/ -gchar * -xfce_g_file_digest (GFile *file) -{ - GFileInfo *file_info; - GFileInputStream *stream; - guchar *contents_buffer; - gchar *checksum; - gsize file_size, file_size_read; - gboolean read_successful; - - g_return_val_if_fail (G_IS_FILE (file), NULL); - - /* query size */ - file_info = g_file_query_info (file, - G_FILE_ATTRIBUTE_STANDARD_SIZE, - G_FILE_QUERY_INFO_NONE, - NULL, - NULL); - file_size = g_file_info_get_size (file_info); - g_object_unref (file_info); - - if (file_size == 0) - return g_compute_checksum_for_data (G_CHECKSUM_SHA256, NULL, 0); - - /* allocate buffer */ - contents_buffer = g_malloc (file_size); - - /* read the actual file */ - stream = g_file_read (file, NULL, NULL); - /* TODO : ERR */ - read_successful = g_input_stream_read_all (G_INPUT_STREAM (stream), - contents_buffer, - file_size, - &file_size_read, - NULL, - NULL); - if (read_successful) - checksum = g_compute_checksum_for_data (G_CHECKSUM_SHA256, - contents_buffer, - file_size_read); - else - checksum = NULL; - - /* free buffer */ - g_free (contents_buffer); - - return checksum; -} - -/** - * - * - **/ -void -xfce_g_file_set_safety_flag (GFile *file, - gboolean is_executable) -{ - gchar *digest_string; - - g_return_if_fail (G_IS_FILE (file)); - - if (!xfce_g_file_metadata_is_supported(file)) - return; - - if (is_executable) - { - digest_string = xfce_g_file_digest (file); - if (digest_string == NULL) - return; - } - else - digest_string = NULL; - - g_file_set_attribute (file, - XFCE_ATTRIBUTE_EXECUTABLE_DIGEST, - is_executable ? G_FILE_ATTRIBUTE_TYPE_STRING - : G_FILE_ATTRIBUTE_TYPE_INVALID, - digest_string, - G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE | G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED, - NULL, - NULL); - g_free (digest_string); -} - -/** - * - **/ -gboolean -xfce_g_file_is_safety_flag_on (GFile *file) -{ - GFileInfo *file_info; - gboolean is_executable; - const gchar *attribute_string; - gchar *digest_string; - - g_return_if_fail (G_IS_FILE (file)); - - if (!xfce_g_file_metadata_is_supported(file)) - return TRUE; - - file_info = g_file_query_info (file, - XFCE_ATTRIBUTE_EXECUTABLE_DIGEST, - G_FILE_QUERY_INFO_NONE, - NULL, - NULL); - - attribute_string = g_file_info_get_attribute_string (file_info, - XFCE_ATTRIBUTE_EXECUTABLE_DIGEST); - if (attribute_string != NULL) - { - digest_string = xfce_g_file_digest (file); - is_executable = (g_strcmp0 (attribute_string, digest_string) == 0); - g_info ("Attribute hash: %s", attribute_string); - g_info ("File hash : %s", digest_string); - g_free (digest_string); - } - else - is_executable = FALSE; - - g_object_unref (file_info); - - return is_executable; -} diff --git a/thunar/thunar-gio-extensions.h b/thunar/thunar-gio-extensions.h index 761f2994d..a9491596c 100644 --- a/thunar/thunar-gio-extensions.h +++ b/thunar/thunar-gio-extensions.h @@ -93,12 +93,6 @@ gboolean thunar_g_app_info_should_show (GAppInfo *info) gboolean thunar_g_vfs_metadata_is_supported (void); -gboolean xfce_g_file_metadata_is_supported (GFile *file); -gchar *xfce_g_file_digest (GFile *file); -void xfce_g_file_set_safety_flag (GFile *file, - gboolean is_executable); -gboolean xfce_g_file_is_safety_flag_on (GFile *file); - G_END_DECLS #endif /* !__THUNAR_GIO_EXTENSIONS_H__ */ -- GitLab From 0fbef1b594e14ae09c73e4917617acb7c8324744 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Fri, 18 Jun 2021 21:56:55 +0900 Subject: [PATCH 04/37] Reflect xfce-gio-extensions changes --- thunar/thunar-dialogs.c | 3 ++- thunar/thunar-file.c | 2 +- thunar/thunar-permissions-chooser.c | 11 +++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index 1cee7c848..20b2e0653 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -1083,7 +1083,8 @@ thunar_dialogs_show_insecure_program (gpointer parent, } if (thunar_g_vfs_metadata_is_supported ()) - xfce_g_file_set_safety_flag (thunar_file_get_file (file), TRUE); + if (!xfce_g_file_set_trusted (thunar_file_get_file (file), TRUE, NULL, NULL)) + g_warning ("Safety flag set failed"); /* just launch */ response = GTK_RESPONSE_OK; diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index cde885c07..661508f6b 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1609,7 +1609,7 @@ thunar_file_execute (ThunarFile *file, uri_list = g_slist_reverse (uri_list); if (thunar_g_vfs_metadata_is_supported ()) - safety_flag = xfce_g_file_is_safety_flag_on (file->gfile); + safety_flag = xfce_g_file_is_trusted (file->gfile, NULL, NULL); if (thunar_file_is_desktop_file (file, &is_secure)) { diff --git a/thunar/thunar-permissions-chooser.c b/thunar/thunar-permissions-chooser.c index f76cd03df..d7030a085 100644 --- a/thunar/thunar-permissions-chooser.c +++ b/thunar/thunar-permissions-chooser.c @@ -1086,11 +1086,12 @@ thunar_permissions_chooser_file_changed (ThunarPermissionsChooser *chooser) g_signal_handlers_unblock_by_func (G_OBJECT (chooser->program_button), thunar_permissions_chooser_program_toggled, chooser); /* TEST AREA BEGIN */ - is_metadata_supported = xfce_g_file_metadata_is_supported (thunar_file_get_file (file)); + is_metadata_supported = thunar_g_vfs_metadata_is_supported (); /* update the launcher setting based on safety flag (only visible for regular files) */ g_signal_handlers_block_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); g_object_set (G_OBJECT (chooser->launcher_button), "visible", is_file_regular && is_metadata_supported, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->launcher_button), xfce_g_file_is_safety_flag_on (thunar_file_get_file (file))); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->launcher_button), + xfce_g_file_is_trusted (thunar_file_get_file (file), NULL, NULL)); g_signal_handlers_unblock_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); /* TEST AREA END */ @@ -1177,6 +1178,7 @@ static void thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, GtkWidget *button) { + gboolean execution_flag; gboolean safety_flag; GFile *gfile; @@ -1193,9 +1195,10 @@ thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, gfile = thunar_file_get_file (THUNAR_FILE (chooser->files->data)); g_info ("%s", thunar_g_file_get_location (gfile)); - xfce_g_file_set_safety_flag (gfile, safety_flag); + xfce_g_file_set_trusted (gfile, safety_flag, NULL, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), safety_flag); + execution_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chooser->program_button)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), safety_flag || execution_flag); } -- GitLab From 1b5515d6fbcd602e563ee8d086b0a014209bc015 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Mon, 21 Jun 2021 09:02:59 +0900 Subject: [PATCH 05/37] thunar-apr-desktop-page: GtkGrid row based code --- plugins/thunar-apr/thunar-apr-desktop-page.c | 48 ++++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 8afa74704..3fa520620 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -38,6 +38,7 @@ #include +#include #include /* use g_access() on win32 */ @@ -134,6 +135,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) GtkWidget *grid; GtkWidget *label; GtkWidget *spacer; + guint row = 0; gtk_container_set_border_width (GTK_CONTAINER (desktop_page), 12); @@ -153,7 +155,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) label = gtk_label_new (_("Description:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->description_entry = gtk_entry_new (); @@ -162,11 +164,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_signal_connect (G_OBJECT (desktop_page->description_entry), "activate", G_CALLBACK (thunar_apr_desktop_page_activated), desktop_page); g_signal_connect (G_OBJECT (desktop_page->description_entry), "focus-out-event", G_CALLBACK (thunar_apr_desktop_page_focus_out_event), desktop_page); gtk_widget_set_hexpand (desktop_page->description_entry, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->description_entry, 1, 0, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->description_entry, 1, row, 1, 1); gtk_widget_show (desktop_page->description_entry); g_object_bind_property (G_OBJECT (desktop_page->description_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (desktop_page->description_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); @@ -177,7 +181,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) label = gtk_label_new (_("Command:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->command_entry = gtk_entry_new (); @@ -185,11 +189,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_signal_connect (G_OBJECT (desktop_page->command_entry), "activate", G_CALLBACK (thunar_apr_desktop_page_activated), desktop_page); g_signal_connect (G_OBJECT (desktop_page->command_entry), "focus-out-event", G_CALLBACK (thunar_apr_desktop_page_focus_out_event), desktop_page); gtk_widget_set_hexpand (desktop_page->command_entry, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->command_entry, 1, 1, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->command_entry, 1, row, 1, 1); gtk_widget_show (desktop_page->command_entry); g_object_bind_property (G_OBJECT (desktop_page->command_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (desktop_page->command_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); @@ -200,7 +206,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) label = gtk_label_new (_("Working Directory:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->path_entry = gtk_entry_new (); @@ -208,11 +214,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_signal_connect (G_OBJECT (desktop_page->path_entry), "activate", G_CALLBACK (thunar_apr_desktop_page_activated), desktop_page); g_signal_connect (G_OBJECT (desktop_page->path_entry), "focus-out-event", G_CALLBACK (thunar_apr_desktop_page_focus_out_event), desktop_page); gtk_widget_set_hexpand (desktop_page->path_entry, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->path_entry, 1, 2, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->path_entry, 1, row, 1, 1); gtk_widget_show (desktop_page->path_entry); g_object_bind_property (G_OBJECT (desktop_page->path_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (desktop_page->path_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); @@ -223,7 +231,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) label = gtk_label_new (_("URL:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->url_entry = gtk_entry_new (); @@ -231,11 +239,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_signal_connect (G_OBJECT (desktop_page->url_entry), "activate", G_CALLBACK (thunar_apr_desktop_page_activated), desktop_page); g_signal_connect (G_OBJECT (desktop_page->url_entry), "focus-out-event", G_CALLBACK (thunar_apr_desktop_page_focus_out_event), desktop_page); gtk_widget_set_hexpand (desktop_page->url_entry, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->url_entry, 1, 3, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->url_entry, 1, row, 1, 1); gtk_widget_show (desktop_page->url_entry); g_object_bind_property (G_OBJECT (desktop_page->url_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (desktop_page->url_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); @@ -246,7 +256,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) label = gtk_label_new (_("Comment:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 4, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->comment_entry = gtk_entry_new (); @@ -256,11 +266,17 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_signal_connect (G_OBJECT (desktop_page->comment_entry), "activate", G_CALLBACK (thunar_apr_desktop_page_activated), desktop_page); g_signal_connect (G_OBJECT (desktop_page->comment_entry), "focus-out-event", G_CALLBACK (thunar_apr_desktop_page_focus_out_event), desktop_page); gtk_widget_set_hexpand (desktop_page->comment_entry, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->comment_entry, 1, 4, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->comment_entry, 1, row, 1, 1); gtk_widget_show (desktop_page->comment_entry); g_object_bind_property (G_OBJECT (desktop_page->comment_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + + /* Nothing here on purpose */ + + row++; + /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (desktop_page->comment_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); @@ -270,13 +286,15 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) /* add spacing between the entries and the options */ spacer = g_object_new (GTK_TYPE_BOX, "orientation", GTK_ORIENTATION_VERTICAL, "height-request", 12, NULL); - gtk_grid_attach (GTK_GRID (grid), spacer, 0, 6, 2, 1); + gtk_grid_attach (GTK_GRID (grid), spacer, 0, row, 2, 1); gtk_widget_show (spacer); + row++; + label = gtk_label_new (_("Options:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 7, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->snotify_button = gtk_check_button_new_with_mnemonic (_("Use _startup notification")); @@ -285,14 +303,16 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) "startup notification.")); g_signal_connect (G_OBJECT (desktop_page->snotify_button), "toggled", G_CALLBACK (thunar_apr_desktop_page_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->snotify_button, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->snotify_button, 1, 7, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->snotify_button, 1, row, 1, 1); gtk_widget_show (desktop_page->snotify_button); + row++; + desktop_page->terminal_button = gtk_check_button_new_with_mnemonic (_("Run in _terminal")); gtk_widget_set_tooltip_text (desktop_page->terminal_button, _("Select this option to run the command in a terminal window.")); g_signal_connect (G_OBJECT (desktop_page->terminal_button), "toggled", G_CALLBACK (thunar_apr_desktop_page_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->terminal_button, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->terminal_button, 1, 8, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->terminal_button, 1, row, 1, 1); gtk_widget_show (desktop_page->terminal_button); /* set Atk label relation for the buttons */ -- GitLab From 9467349d8ad2cb871ffb4be6a404bde5250ef543 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Mon, 21 Jun 2021 11:25:21 +0900 Subject: [PATCH 06/37] Dummy buttons for executable/trusted flag --- plugins/thunar-apr/thunar-apr-desktop-page.c | 180 ++++++++++++------- 1 file changed, 114 insertions(+), 66 deletions(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 3fa520620..1f551ee31 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -38,7 +38,7 @@ #include -#include +#include #include /* use g_access() on win32 */ @@ -49,22 +49,27 @@ #endif - -static void thunar_apr_desktop_page_finalize (GObject *object); -static void thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, - ThunarxFileInfo *file); -static void thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, - GtkWidget *widget); -static void thunar_apr_desktop_page_save_widget (ThunarAprDesktopPage *desktop_page, - GtkWidget *widget, - GKeyFile *key_file); -static void thunar_apr_desktop_page_activated (GtkWidget *entry, - ThunarAprDesktopPage *desktop_page); -static gboolean thunar_apr_desktop_page_focus_out_event (GtkWidget *entry, - GdkEventFocus *event, - ThunarAprDesktopPage *desktop_page); -static void thunar_apr_desktop_page_toggled (GtkWidget *button, - ThunarAprDesktopPage *desktop_page); +static void +thunar_gtk_label_set_a11y_relation (GtkLabel *label, + GtkWidget *widget); + +static void thunar_apr_desktop_page_finalize (GObject *object); +static void thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, + ThunarxFileInfo *file); +static void thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, + GtkWidget *widget); +static void thunar_apr_desktop_page_save_widget (ThunarAprDesktopPage *desktop_page, + GtkWidget *widget, + GKeyFile *key_file); +static void thunar_apr_desktop_page_activated (GtkWidget *entry, + ThunarAprDesktopPage *desktop_page); +static gboolean thunar_apr_desktop_page_focus_out_event (GtkWidget *entry, + GdkEventFocus *event, + ThunarAprDesktopPage *desktop_page); +static void thunar_apr_desktop_page_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page); +static void thunar_apr_desktop_page_security_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page); @@ -84,6 +89,8 @@ struct _ThunarAprDesktopPage GtkWidget *comment_entry; GtkWidget *snotify_button; GtkWidget *terminal_button; + GtkWidget *program_button; + GtkWidget *trusted_button; /* the values of the entries remember when * the file was saved last time to avoid a @@ -108,6 +115,27 @@ THUNARX_DEFINE_TYPE (ThunarAprDesktopPage, +/* duplicated code, need to move into libxfce4ui */ +static void +thunar_gtk_label_set_a11y_relation (GtkLabel *label, + GtkWidget *widget) +{ + AtkRelationSet *relations; + AtkRelation *relation; + AtkObject *object; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (GTK_IS_LABEL (label)); + + object = gtk_widget_get_accessible (widget); + relations = atk_object_ref_relation_set (gtk_widget_get_accessible (GTK_WIDGET (label))); + relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); + atk_relation_set_add (relations, relation); + g_object_unref (G_OBJECT (relation)); +} + + + static void thunar_apr_desktop_page_class_init (ThunarAprDesktopPageClass *klass) { @@ -127,15 +155,13 @@ thunar_apr_desktop_page_class_init (ThunarAprDesktopPageClass *klass) static void thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) { - AtkRelationSet *relations; PangoAttribute *attribute; PangoAttrList *attr_list; - AtkRelation *relation; - AtkObject *object; GtkWidget *grid; GtkWidget *label; GtkWidget *spacer; guint row = 0; + GFile *g_file; gtk_container_set_border_width (GTK_CONTAINER (desktop_page), 12); @@ -168,16 +194,10 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->description_entry); g_object_bind_property (G_OBJECT (desktop_page->description_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); row++; - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (desktop_page->description_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - label = gtk_label_new (_("Command:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); @@ -193,16 +213,10 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->command_entry); g_object_bind_property (G_OBJECT (desktop_page->command_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); row++; - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (desktop_page->command_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - label = gtk_label_new (_("Working Directory:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); @@ -218,16 +232,10 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->path_entry); g_object_bind_property (G_OBJECT (desktop_page->path_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); row++; - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (desktop_page->path_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - label = gtk_label_new (_("URL:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); @@ -243,16 +251,10 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->url_entry); g_object_bind_property (G_OBJECT (desktop_page->url_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); row++; - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (desktop_page->url_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - label = gtk_label_new (_("Comment:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); @@ -270,6 +272,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->comment_entry); g_object_bind_property (G_OBJECT (desktop_page->comment_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); row++; @@ -277,13 +280,6 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) row++; - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (desktop_page->comment_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - /* add spacing between the entries and the options */ spacer = g_object_new (GTK_TYPE_BOX, "orientation", GTK_ORIENTATION_VERTICAL, "height-request", 12, NULL); gtk_grid_attach (GTK_GRID (grid), spacer, 0, row, 2, 1); @@ -306,6 +302,9 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_grid_attach (GTK_GRID (grid), desktop_page->snotify_button, 1, row, 1, 1); gtk_widget_show (desktop_page->snotify_button); + g_object_bind_property (G_OBJECT (desktop_page->snotify_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); + row++; desktop_page->terminal_button = gtk_check_button_new_with_mnemonic (_("Run in _terminal")); @@ -315,18 +314,52 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_grid_attach (GTK_GRID (grid), desktop_page->terminal_button, 1, row, 1, 1); gtk_widget_show (desktop_page->terminal_button); - /* set Atk label relation for the buttons */ - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - object = gtk_widget_get_accessible (desktop_page->snotify_button); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - object = gtk_widget_get_accessible (desktop_page->terminal_button); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); + /* don't bind visibility with label */ + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); - g_object_bind_property (G_OBJECT (desktop_page->snotify_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + + label = gtk_label_new (_("Security:")); + gtk_label_set_xalign (GTK_LABEL (label), 1.0f); + gtk_label_set_attributes (GTK_LABEL (label), attr_list); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); + gtk_widget_show (label); + + /* same function as in thunar-permission-chooser.c */ + desktop_page->program_button = gtk_check_button_new_with_mnemonic (_("Allow this file to _run as a .desktop file")); + gtk_widget_set_tooltip_text (desktop_page->program_button, _("If not selected, .desktop file will be considered as a normal text file.")); + g_signal_connect (G_OBJECT (desktop_page->program_button), "toggled", + G_CALLBACK (thunar_apr_desktop_page_security_toggled), desktop_page); + gtk_widget_set_hexpand (desktop_page->program_button, TRUE); + gtk_grid_attach (GTK_GRID (grid), desktop_page->program_button, 1, row, 1, 1); + gtk_widget_show (desktop_page->program_button); + + g_object_bind_property (G_OBJECT (desktop_page->program_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->program_button); + + row++; + + g_file = g_file_new_for_uri ("file:///"); + if (xfce_g_file_metadata_is_supported (g_file)) + { + /* same function as in thunar-permission-chooser.c */ + desktop_page->trusted_button = gtk_check_button_new_with_mnemonic (_("Set this file as trusted")); + gtk_widget_set_tooltip_text (desktop_page->trusted_button, _("Select this option to trust this .desktop file.")); + g_signal_connect (G_OBJECT (desktop_page->trusted_button), "toggled", + G_CALLBACK (thunar_apr_desktop_page_security_toggled), desktop_page); + gtk_widget_set_hexpand (desktop_page->trusted_button, TRUE); + gtk_grid_attach (GTK_GRID (grid), desktop_page->trusted_button, 1, row, 1, 1); + gtk_widget_show (desktop_page->trusted_button); + + g_object_bind_property (G_OBJECT (desktop_page->trusted_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->trusted_button); + + row++; + } + else + desktop_page->trusted_button = NULL; + + g_object_unref (g_file); /* release shared bold Pango attributes */ pango_attr_list_unref (attr_list); @@ -818,3 +851,18 @@ thunar_apr_desktop_page_toggled (GtkWidget *button, thunar_apr_desktop_page_save (desktop_page, button); } +static void +thunar_apr_desktop_page_security_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page) +{ + GFile *g_file; + + g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); + g_return_if_fail (button == desktop_page->program_button || button == desktop_page->trusted_button); + g_return_if_fail (THUNAR_APR_IS_DESKTOP_PAGE (desktop_page)); + g_return_if_fail (THUNARX_IS_FILE_INFO (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file)); + + g_file = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); + + g_object_unref (g_file); +} -- GitLab From 7e4b4acf69afbff056476263fa65026373821474 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Wed, 23 Jun 2021 09:18:56 +0900 Subject: [PATCH 07/37] Naming convention --- docs/reference/thunarx/thunarx.actions | 0 plugins/thunar-apr/thunar-apr-desktop-page.c | 18 +++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 docs/reference/thunarx/thunarx.actions diff --git a/docs/reference/thunarx/thunarx.actions b/docs/reference/thunarx/thunarx.actions new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 1f551ee31..0946e9b13 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -161,7 +161,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) GtkWidget *label; GtkWidget *spacer; guint row = 0; - GFile *g_file; + GFile *gfile; gtk_container_set_border_width (GTK_CONTAINER (desktop_page), 12); @@ -339,8 +339,8 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) row++; - g_file = g_file_new_for_uri ("file:///"); - if (xfce_g_file_metadata_is_supported (g_file)) + gfile = g_file_new_for_uri ("file:///"); + if (xfce_g_file_metadata_is_supported (gfile)) { /* same function as in thunar-permission-chooser.c */ desktop_page->trusted_button = gtk_check_button_new_with_mnemonic (_("Set this file as trusted")); @@ -359,7 +359,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) else desktop_page->trusted_button = NULL; - g_object_unref (g_file); + g_object_unref (gfile); /* release shared bold Pango attributes */ pango_attr_list_unref (attr_list); @@ -851,18 +851,22 @@ thunar_apr_desktop_page_toggled (GtkWidget *button, thunar_apr_desktop_page_save (desktop_page, button); } + + static void thunar_apr_desktop_page_security_toggled (GtkWidget *button, ThunarAprDesktopPage *desktop_page) { - GFile *g_file; + GFile *gfile; + gboolean execution_flag; + gboolean safety_flag; g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); g_return_if_fail (button == desktop_page->program_button || button == desktop_page->trusted_button); g_return_if_fail (THUNAR_APR_IS_DESKTOP_PAGE (desktop_page)); g_return_if_fail (THUNARX_IS_FILE_INFO (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file)); - g_file = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); + gfile = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); - g_object_unref (g_file); + g_object_unref (gfile); } -- GitLab From 66719751b7d25809f3e501914eb8f40896887fd7 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Thu, 24 Jun 2021 14:39:24 +0900 Subject: [PATCH 08/37] thunar-apr: safety flag support --- plugins/thunar-apr/Makefile.am | 4 + plugins/thunar-apr/thunar-apr-desktop-page.c | 262 ++++++++++++++++--- 2 files changed, 228 insertions(+), 38 deletions(-) diff --git a/plugins/thunar-apr/Makefile.am b/plugins/thunar-apr/Makefile.am index e78e38634..f5277d214 100644 --- a/plugins/thunar-apr/Makefile.am +++ b/plugins/thunar-apr/Makefile.am @@ -27,6 +27,8 @@ thunar_apr_la_SOURCES = \ thunar_apr_la_CFLAGS = \ $(EXIF_CFLAGS) \ $(EXO_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCE4UI_CFLAGS) \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(PLATFORM_CFLAGS) @@ -43,6 +45,8 @@ thunar_apr_la_LIBADD = \ $(top_builddir)/thunarx/libthunarx-$(THUNARX_VERSION_API).la \ $(EXIF_LIBS) \ $(EXO_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCE4UI_LIBS) \ $(GLIB_LIBS) \ $(GTK_LIBS) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 0946e9b13..bed3cbe33 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -38,6 +38,7 @@ #include +#include #include #include @@ -49,9 +50,6 @@ #endif -static void -thunar_gtk_label_set_a11y_relation (GtkLabel *label, - GtkWidget *widget); static void thunar_apr_desktop_page_finalize (GObject *object); static void thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, @@ -68,8 +66,17 @@ static gboolean thunar_apr_desktop_page_focus_out_event (GtkWidget ThunarAprDesktopPage *desktop_page); static void thunar_apr_desktop_page_toggled (GtkWidget *button, ThunarAprDesktopPage *desktop_page); -static void thunar_apr_desktop_page_security_toggled (GtkWidget *button, +static void thunar_apr_desktop_page_program_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page); +#ifdef __XFCE_GIO_EXTENSIONS_H__ +static void thunar_apr_desktop_page_trusted_toggled (GtkWidget *button, ThunarAprDesktopPage *desktop_page); +#endif /* __XFCE_GIO_EXTENSIONS_H__ */ +static gboolean is_executable (GFile *gfile, + GError **error); +static gboolean set_executable (GFile *gfile, + gboolean executable, + GError **error); @@ -115,23 +122,82 @@ THUNARX_DEFINE_TYPE (ThunarAprDesktopPage, -/* duplicated code, need to move into libxfce4ui */ -static void -thunar_gtk_label_set_a11y_relation (GtkLabel *label, - GtkWidget *widget) +static gboolean +is_executable (GFile *gfile, + GError **error) { - AtkRelationSet *relations; - AtkRelation *relation; - AtkObject *object; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (GTK_IS_LABEL (label)); - - object = gtk_widget_get_accessible (widget); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (GTK_WIDGET (label))); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); + GError *error_local = NULL; + GFileInfo *info; + gboolean executable; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + g_return_val_if_fail (G_IS_FILE (gfile), FALSE); + + info = g_file_query_info (gfile, + G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE, + G_FILE_QUERY_INFO_NONE, + NULL, + &error_local); + if (error_local != NULL) + { + g_propagate_error (error, error_local); + return FALSE; + } + + executable = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE); + g_object_unref (info); + + return executable; +} + + + +/* copied from exo-die-utils.c */ +static gboolean +set_executable (GFile *gfile, + gboolean executable, + GError **error) +{ + GError *error_local = NULL; + guint32 mode = 0111, mask = 0111; + guint32 old_mode, new_mode; + GFileInfo *info; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + g_return_val_if_fail (G_IS_FILE (gfile), FALSE); + + + info = g_file_query_info (gfile, + G_FILE_ATTRIBUTE_UNIX_MODE, + G_FILE_QUERY_INFO_NONE, + NULL, + &error_local); + + if (error_local != NULL) + { + g_propagate_error (error, error_local); + return FALSE; + } + + old_mode = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE); + new_mode = executable ? ((old_mode & ~mask) | mode) : (old_mode & ~mask); + + if (old_mode != new_mode) { + g_file_set_attribute_uint32 (gfile, + G_FILE_ATTRIBUTE_UNIX_MODE, new_mode, + G_FILE_QUERY_INFO_NONE, + NULL, + &error_local); + } + g_object_unref (info); + + if (error_local != NULL) + { + g_propagate_error (error, error_local); + return FALSE; + } + + return TRUE; } @@ -194,7 +260,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->description_entry); g_object_bind_property (G_OBJECT (desktop_page->description_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); row++; @@ -213,7 +279,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->command_entry); g_object_bind_property (G_OBJECT (desktop_page->command_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); row++; @@ -232,7 +298,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->path_entry); g_object_bind_property (G_OBJECT (desktop_page->path_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); row++; @@ -251,7 +317,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->url_entry); g_object_bind_property (G_OBJECT (desktop_page->url_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); row++; @@ -272,7 +338,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->comment_entry); g_object_bind_property (G_OBJECT (desktop_page->comment_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); row++; @@ -303,7 +369,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->snotify_button); g_object_bind_property (G_OBJECT (desktop_page->snotify_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); row++; @@ -315,7 +381,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->terminal_button); /* don't bind visibility with label */ - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); row++; @@ -329,16 +395,17 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) desktop_page->program_button = gtk_check_button_new_with_mnemonic (_("Allow this file to _run as a .desktop file")); gtk_widget_set_tooltip_text (desktop_page->program_button, _("If not selected, .desktop file will be considered as a normal text file.")); g_signal_connect (G_OBJECT (desktop_page->program_button), "toggled", - G_CALLBACK (thunar_apr_desktop_page_security_toggled), desktop_page); + G_CALLBACK (thunar_apr_desktop_page_program_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->program_button, TRUE); gtk_grid_attach (GTK_GRID (grid), desktop_page->program_button, 1, row, 1, 1); gtk_widget_show (desktop_page->program_button); g_object_bind_property (G_OBJECT (desktop_page->program_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->program_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->program_button); row++; + #ifdef __XFCE_GIO_EXTENSIONS_H__ gfile = g_file_new_for_uri ("file:///"); if (xfce_g_file_metadata_is_supported (gfile)) { @@ -346,18 +413,22 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) desktop_page->trusted_button = gtk_check_button_new_with_mnemonic (_("Set this file as trusted")); gtk_widget_set_tooltip_text (desktop_page->trusted_button, _("Select this option to trust this .desktop file.")); g_signal_connect (G_OBJECT (desktop_page->trusted_button), "toggled", - G_CALLBACK (thunar_apr_desktop_page_security_toggled), desktop_page); + G_CALLBACK (thunar_apr_desktop_page_trusted_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->trusted_button, TRUE); gtk_grid_attach (GTK_GRID (grid), desktop_page->trusted_button, 1, row, 1, 1); gtk_widget_show (desktop_page->trusted_button); g_object_bind_property (G_OBJECT (desktop_page->trusted_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->trusted_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->trusted_button); row++; } else - desktop_page->trusted_button = NULL; + #endif /* __XFCE_GIO_EXTENSIONS_H__ */ + { + g_info ("metadata not supported"); + desktop_page->trusted_button = NULL; + } g_object_unref (gfile); @@ -390,8 +461,11 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, { ThunarAprDesktopPage *desktop_page = THUNAR_APR_DESKTOP_PAGE (abstract_page); GKeyFile *key_file; + GFile *gfile; gboolean writable; gboolean enabled; + gboolean executable; + gboolean trusted; GError *error = NULL; gchar *filename; gchar *value; @@ -545,6 +619,41 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, gtk_widget_hide (desktop_page->terminal_button); } + /* update flags */ + gfile = thunarx_file_info_get_location (abstract_page->file);; + + g_signal_handlers_block_by_func (G_OBJECT (desktop_page->program_button), thunar_apr_desktop_page_program_toggled, desktop_page); + executable = is_executable (gfile, &error); + if (error != NULL) + { + g_warning ("Failed to initialize program_button : %s", error->message); + g_clear_error (&error); + } + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->program_button), executable); + + #ifdef __XFCE_GIO_EXTENSIONS_H__ + if (desktop_page->trusted_button != NULL) + { + g_signal_handlers_block_by_func (G_OBJECT (desktop_page->trusted_button), thunar_apr_desktop_page_trusted_toggled, desktop_page); + trusted = xfce_g_file_is_trusted (gfile, NULL, &error); + if (error != NULL) + { + g_warning ("Failed to initialize trusted_button : %s", error->message); + g_clear_error (&error); + } + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button), trusted); + g_signal_handlers_unblock_by_func (G_OBJECT (desktop_page->trusted_button), thunar_apr_desktop_page_trusted_toggled, desktop_page); + } + #endif /* __XFCE_GIO_EXTENSIONS_H__ */ + g_signal_handlers_unblock_by_func (G_OBJECT (desktop_page->program_button), thunar_apr_desktop_page_program_toggled, desktop_page); + + g_object_unref (gfile); + + /* show security */ + gtk_widget_show (desktop_page->program_button); + if (desktop_page->trusted_button != NULL) + gtk_widget_show (desktop_page->trusted_button); + /* check if the file is writable... */ writable = (g_access (filename, W_OK) == 0); @@ -573,6 +682,9 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, gtk_widget_hide (desktop_page->comment_entry); gtk_widget_hide (desktop_page->snotify_button); gtk_widget_hide (desktop_page->terminal_button); + gtk_widget_hide (desktop_page->program_button); + if (desktop_page->trusted_button != NULL) + gtk_widget_hide (desktop_page->trusted_button); } /* cleanup */ @@ -853,20 +965,94 @@ thunar_apr_desktop_page_toggled (GtkWidget *button, +/** + * Allowed state: + * + * +-----+-----+ + * |EXE |SAFE | + * +=====+=====+ + * |TRUE |TRUE | Allowed to launch + * +-----+-----+ + * |TRUE |FALSE| Ask before launch + * +-----+-----+ + * |FALSE|FALSE| Not recognized as .desktop + * +-----+-----+ + **/ static void -thunar_apr_desktop_page_security_toggled (GtkWidget *button, - ThunarAprDesktopPage *desktop_page) +thunar_apr_desktop_page_program_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page) { - GFile *gfile; - gboolean execution_flag; - gboolean safety_flag; + GError *error = NULL; + GFile *gfile; + gboolean executable; + gboolean trusted; + g_return_if_fail (button == desktop_page->program_button); g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); - g_return_if_fail (button == desktop_page->program_button || button == desktop_page->trusted_button); g_return_if_fail (THUNAR_APR_IS_DESKTOP_PAGE (desktop_page)); g_return_if_fail (THUNARX_IS_FILE_INFO (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file)); gfile = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); + executable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->program_button)); + + if (desktop_page->trusted_button != NULL) + trusted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)); + else + trusted = FALSE; + + set_executable (gfile, executable, &error); + + if (error != NULL) + { + g_warning ("Error while setting execution flag : %s", error->message); + g_free (error); + g_object_unref (gfile); + return; + } + + if (!executable && trusted) + if (desktop_page->trusted_button != NULL) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button), FALSE); + g_object_unref (gfile); } + +#ifdef __XFCE_GIO_EXTENSIONS_H__ +static void +thunar_apr_desktop_page_trusted_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page) +{ + GError *error = NULL; + GFile *gfile; + gboolean executable; + gboolean trusted; + + g_return_if_fail (button == desktop_page->trusted_button); + g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); + g_return_if_fail (THUNAR_APR_IS_DESKTOP_PAGE (desktop_page)); + g_return_if_fail (THUNARX_IS_FILE_INFO (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file)); + + gfile = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); + + executable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->program_button)); + + if (desktop_page->trusted_button != NULL) + trusted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)); + else + trusted = FALSE; + + xfce_g_file_set_trusted (gfile, trusted, NULL, &error); + + if (error != NULL) + { + g_warning ("Error while setting safety flag : %s", error->message); + g_free (error); + g_object_unref (gfile); + return; + } + + if (!executable && trusted) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->program_button), TRUE); +} +#endif /* __XFCE_GIO_EXTENSIONS_H__ */ -- GitLab From 59161a16dbd513375d6b59973972fc9a78aa066d Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Thu, 24 Jun 2021 14:42:52 +0900 Subject: [PATCH 09/37] thunar-permission-chooser.c: Remove safety flag support --- thunar/thunar-permissions-chooser.c | 72 +---------------------------- 1 file changed, 1 insertion(+), 71 deletions(-) diff --git a/thunar/thunar-permissions-chooser.c b/thunar/thunar-permissions-chooser.c index d7030a085..747e7d977 100644 --- a/thunar/thunar-permissions-chooser.c +++ b/thunar/thunar-permissions-chooser.c @@ -45,8 +45,6 @@ #include #include #include -/*TEST*/ -#include @@ -99,8 +97,6 @@ static void thunar_permissions_chooser_group_changed (ThunarP GtkWidget *combo); static void thunar_permissions_chooser_program_toggled (ThunarPermissionsChooser *chooser, GtkWidget *button); -static void thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, - GtkWidget *button); static void thunar_permissions_chooser_fixperm_clicked (ThunarPermissionsChooser *chooser, GtkWidget *button); static ThunarJobResponse thunar_permissions_chooser_job_ask (ThunarPermissionsChooser *chooser, @@ -145,7 +141,6 @@ struct _ThunarPermissionsChooser GtkWidget *group_combo; GtkWidget *access_combos[3]; GtkWidget *program_button; - GtkWidget *launcher_button; GtkWidget *fixperm_label; GtkWidget *fixperm_button; @@ -376,29 +371,6 @@ thunar_permissions_chooser_init (ThunarPermissionsChooser *chooser) row += 1; - /* TEST AREA BEGIN */ - - label = gtk_label_new (_("Launcher:")); - gtk_label_set_xalign (GTK_LABEL (label), 1.0f); - gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ()); - gtk_grid_attach (GTK_GRID (chooser->grid), label, 0, row, 1, 1); - gtk_widget_show (label); - - chooser->launcher_button = gtk_check_button_new_with_mnemonic (_("Allow this file to be _launched from Thunar")); - g_object_bind_property (G_OBJECT (chooser->launcher_button), "visible", - G_OBJECT (label), "visible", - G_BINDING_SYNC_CREATE); - g_object_bind_property (G_OBJECT (chooser), "mutable", - G_OBJECT (chooser->launcher_button), "sensitive", - G_BINDING_SYNC_CREATE); - gtk_grid_attach (GTK_GRID (chooser->grid), chooser->launcher_button, 1, row, 1, 1); - g_signal_connect_swapped (G_OBJECT (chooser->launcher_button), "toggled", G_CALLBACK (thunar_permissions_chooser_launcher_toggled), chooser); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), chooser->launcher_button); - gtk_widget_show (chooser->launcher_button); - - row += 1; - /* TEST AREA END */ - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); g_object_bind_property (G_OBJECT (chooser), "mutable", G_OBJECT (hbox), "sensitive", @@ -921,8 +893,6 @@ thunar_permissions_chooser_file_changed (ThunarPermissionsChooser *chooser) gint file_modes[3]; GtkListStore *access_store; - gboolean is_file_regular, is_metadata_supported; - _thunar_return_if_fail (THUNAR_IS_PERMISSIONS_CHOOSER (chooser)); /* compare multiple files */ @@ -1078,23 +1048,12 @@ thunar_permissions_chooser_file_changed (ThunarPermissionsChooser *chooser) g_object_unref (G_OBJECT (access_store)); } - is_file_regular = thunar_file_is_regular (file); /* update the program setting based on the mode (only visible for regular files) */ g_signal_handlers_block_by_func (G_OBJECT (chooser->program_button), thunar_permissions_chooser_program_toggled, chooser); - g_object_set (G_OBJECT (chooser->program_button), "visible", is_file_regular, NULL); + g_object_set (G_OBJECT (chooser->program_button), "visible", thunar_file_is_regular (file), NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), (mode & 0111) != 0); g_signal_handlers_unblock_by_func (G_OBJECT (chooser->program_button), thunar_permissions_chooser_program_toggled, chooser); - /* TEST AREA BEGIN */ - is_metadata_supported = thunar_g_vfs_metadata_is_supported (); - /* update the launcher setting based on safety flag (only visible for regular files) */ - g_signal_handlers_block_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); - g_object_set (G_OBJECT (chooser->launcher_button), "visible", is_file_regular && is_metadata_supported, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->launcher_button), - xfce_g_file_is_trusted (thunar_file_get_file (file), NULL, NULL)); - g_signal_handlers_unblock_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); - /* TEST AREA END */ - /* update the "inconsistent folder permissions" warning and the "fix permissions" button based on the mode */ if (thunar_permissions_chooser_has_fixable_directory (chooser)) { @@ -1174,35 +1133,6 @@ thunar_permissions_chooser_program_toggled (ThunarPermissionsChooser *chooser, -static void -thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, - GtkWidget *button) -{ - gboolean execution_flag; - gboolean safety_flag; - GFile *gfile; - - /* TODO: Multiple flags*/ - _thunar_return_if_fail (THUNAR_IS_PERMISSIONS_CHOOSER (chooser)); - _thunar_return_if_fail (chooser->launcher_button == button); - _thunar_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); - - /* verify that we have a valid file */ - if (G_UNLIKELY (chooser->files == NULL)) - return; - - safety_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - - gfile = thunar_file_get_file (THUNAR_FILE (chooser->files->data)); - g_info ("%s", thunar_g_file_get_location (gfile)); - xfce_g_file_set_trusted (gfile, safety_flag, NULL, NULL); - - execution_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chooser->program_button)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), safety_flag || execution_flag); -} - - - static void thunar_permissions_chooser_fixperm_clicked (ThunarPermissionsChooser *chooser, GtkWidget *button) -- GitLab From c65ed6d7fc33ac09d3fc232b041db60a0042834f Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Thu, 24 Jun 2021 15:13:24 +0900 Subject: [PATCH 10/37] Use safety flag only for .desktop --- thunar/thunar-dialogs.c | 11 ++++++++--- thunar/thunar-file.c | 19 ++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index 20b2e0653..e9475dcfc 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -1079,12 +1079,17 @@ thunar_dialogs_show_insecure_program (gpointer parent, if (err != NULL) { thunar_dialogs_show_error (parent, err, ("Unable to mark launcher executable")); - g_error_free (err); + g_clear_error (&err); } + #ifdef __XFCE_GIO_EXTENSIONS_H__ if (thunar_g_vfs_metadata_is_supported ()) - if (!xfce_g_file_set_trusted (thunar_file_get_file (file), TRUE, NULL, NULL)) - g_warning ("Safety flag set failed"); + if (!xfce_g_file_set_trusted (thunar_file_get_file (file), TRUE, NULL, &err)) + { + g_warning ("Safety flag set failed: %s", err->message); + g_clear_error (&err); + } + #endif /* __XFCE_GIO_EXTENSIONS_H__ */ /* just launch */ response = GTK_RESPONSE_OK; diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 661508f6b..c02d3eccf 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1578,7 +1578,6 @@ thunar_file_execute (ThunarFile *file, const gchar *startup_id, GError **error) { - gboolean safety_flag = TRUE; gboolean snotify = FALSE; gboolean terminal; gboolean result = FALSE; @@ -1608,12 +1607,13 @@ thunar_file_execute (ThunarFile *file, uri_list = g_slist_prepend (uri_list, g_file_get_uri (li->data)); uri_list = g_slist_reverse (uri_list); - if (thunar_g_vfs_metadata_is_supported ()) - safety_flag = xfce_g_file_is_trusted (file->gfile, NULL, NULL); - if (thunar_file_is_desktop_file (file, &is_secure)) { - is_secure = is_secure && safety_flag; + #ifdef __XFCE_GIO_EXTENSIONS_H__ + if (thunar_g_vfs_metadata_is_supported ()) + is_secure = is_secure && xfce_g_file_is_trusted (file->gfile, NULL, NULL); + #endif /* __XFCE_GIO_EXTENSIONS_H__ */ + /* parse file first, even if it is insecure */ key_file = thunar_g_file_query_key_file (file->gfile, NULL, &err); if (key_file == NULL) @@ -1700,12 +1700,9 @@ thunar_file_execute (ThunarFile *file, /* fake the Exec line */ escaped_location = g_shell_quote (location); exec = g_strconcat (escaped_location, " %F", NULL); - if (safety_flag || thunar_dialogs_show_insecure_program (parent, _("Untrusted executable"), file, exec)) - { - command = xfce_expand_desktop_entry_field_codes (exec, uri_list, NULL, NULL, NULL, FALSE); - result = g_shell_parse_argv (command, NULL, &argv, error); - g_free (command); - } + command = xfce_expand_desktop_entry_field_codes (exec, uri_list, NULL, NULL, NULL, FALSE); + result = g_shell_parse_argv (command, NULL, &argv, error); + g_free (command); g_free (escaped_location); g_free (exec); } -- GitLab From 6406659f30503c55cce889fd2e9143f89094b4f1 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Thu, 24 Jun 2021 15:27:38 +0900 Subject: [PATCH 11/37] Initialize gfile as NULL --- plugins/thunar-apr/thunar-apr-desktop-page.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index bed3cbe33..ab557d53d 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -227,7 +227,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) GtkWidget *label; GtkWidget *spacer; guint row = 0; - GFile *gfile; + GFile *gfile = NULL; gtk_container_set_border_width (GTK_CONTAINER (desktop_page), 12); -- GitLab From dc60d7c650f7f6887e34cb6ab0a8a9e505c8060d Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Tue, 15 Jun 2021 09:14:06 +0900 Subject: [PATCH 12/37] Fetch gio-extensions.{{c,h}@87fec42e --- thunar/thunar-gio-extensions.c | 162 +++++++++++++++++++++++++++++++++ thunar/thunar-gio-extensions.h | 5 + 2 files changed, 167 insertions(+) diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c index 394a1032e..9880969fb 100644 --- a/thunar/thunar-gio-extensions.c +++ b/thunar/thunar-gio-extensions.c @@ -40,6 +40,8 @@ +#define XFCE_ATTRIBUTE_EXECUTABLE_DIGEST "metadata::xfce-exe-hash" /* string */ + /* See : https://freedesktop.org/wiki/Specifications/icon-naming-spec/ */ static struct { @@ -871,3 +873,163 @@ thunar_g_vfs_metadata_is_supported (void) return metadata_is_supported; } + + + +/** + * TEST AREA + * + * + **/ + + +/** + * + **/ +gboolean +xfce_g_file_metadata_is_supported (GFile *file) +{ + GFileAttributeInfoList *info_list; + gboolean is_supported; + + g_return_val_if_fail (G_IS_FILE (file), FALSE); + + /* g_return_val_if_fail (G_IS_FILE (file), FALSE); */ + + info_list = g_file_query_writable_namespaces (file, NULL, NULL); + if (info_list == NULL) + return FALSE; + + is_supported = (g_file_attribute_info_list_lookup (info_list, "metadata") != NULL); + g_file_attribute_info_list_unref (info_list); + + return is_supported; +} + +/** + * + **/ +gchar * +xfce_g_file_digest (GFile *file) +{ + GFileInfo *file_info; + GFileInputStream *stream; + guchar *contents_buffer; + gchar *checksum; + gsize file_size, file_size_read; + gboolean read_successful; + + g_return_val_if_fail (G_IS_FILE (file), NULL); + + /* query size */ + file_info = g_file_query_info (file, + G_FILE_ATTRIBUTE_STANDARD_SIZE, + G_FILE_QUERY_INFO_NONE, + NULL, + NULL); + file_size = g_file_info_get_size (file_info); + g_object_unref (file_info); + + if (file_size == 0) + return g_compute_checksum_for_data (G_CHECKSUM_SHA256, NULL, 0); + + /* allocate buffer */ + contents_buffer = g_malloc (file_size); + + /* read the actual file */ + stream = g_file_read (file, NULL, NULL); + /* TODO : ERR */ + read_successful = g_input_stream_read_all (G_INPUT_STREAM (stream), + contents_buffer, + file_size, + &file_size_read, + NULL, + NULL); + if (read_successful) + checksum = g_compute_checksum_for_data (G_CHECKSUM_SHA256, + contents_buffer, + file_size_read); + else + checksum = NULL; + + /* free buffer */ + g_free (contents_buffer); + + return checksum; +} + +/** + * + * + **/ +void +xfce_g_file_set_saftey_flag (GFile *file, + gboolean is_executable) +{ + const gchar *digest_string; + + g_return_if_fail (G_IS_FILE (file)); + + /* check if GVFs metadata is supported */ + if (!xfce_g_file_metadata_is_supported (file)) + return; + + if (is_executable) + { + digest_string = xfce_g_file_digest (file); + if (digest_string == NULL) + return; + } + else + digest_string = NULL; + + g_file_set_attribute (file, + XFCE_ATTRIBUTE_EXECUTABLE_DIGEST, + is_executable ? G_FILE_ATTRIBUTE_TYPE_STRING + : G_FILE_ATTRIBUTE_TYPE_INVALID, + digest_string, + G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE | G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED, + NULL, + NULL); + g_free (digest_string); +} + +/** + * + **/ +gboolean +xfce_g_file_is_safety_flag_on (GFile *file) +{ + GFileInfo *file_info; + gboolean is_executable; + const gchar *attribute_string; + const gchar *digest_string; + + g_return_if_fail (G_IS_FILE (file)); + + if (!xfce_g_file_metadata_is_supported(file)) + return TRUE; + + file_info = g_file_query_info (file, + XFCE_ATTRIBUTE_EXECUTABLE_DIGEST, + G_FILE_QUERY_INFO_NONE, + NULL, + NULL); + + attribute_string = g_file_info_get_attribute_string (file_info, + XFCE_ATTRIBUTE_EXECUTABLE_DIGEST); + if (attribute_string != NULL) + { + digest_string = xfce_g_file_digest (file); + is_executable = (g_strcmp0 (attribute_string, digest_string) == 0); + g_info ("Attribute hash: %s", attribute_string); + g_info ("File hash : %s", digest_string); + g_free (digest_string); + } + else + is_executable = FALSE; + + g_object_unref (file_info); + + return is_executable; +} diff --git a/thunar/thunar-gio-extensions.h b/thunar/thunar-gio-extensions.h index 5b183971d..761f2994d 100644 --- a/thunar/thunar-gio-extensions.h +++ b/thunar/thunar-gio-extensions.h @@ -93,6 +93,11 @@ gboolean thunar_g_app_info_should_show (GAppInfo *info) gboolean thunar_g_vfs_metadata_is_supported (void); +gboolean xfce_g_file_metadata_is_supported (GFile *file); +gchar *xfce_g_file_digest (GFile *file); +void xfce_g_file_set_safety_flag (GFile *file, + gboolean is_executable); +gboolean xfce_g_file_is_safety_flag_on (GFile *file); G_END_DECLS -- GitLab From 8f2d88f061dad40ee61310b749a676de74a286c4 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Tue, 15 Jun 2021 11:10:54 +0900 Subject: [PATCH 13/37] Implement safety flag interface Safety flag can be managed with file properties, and will propmt user on execution if not enabled. --- thunar/thunar-dialogs.c | 3 ++ thunar/thunar-file.c | 15 +++++-- thunar/thunar-gio-extensions.c | 9 ++-- thunar/thunar-permissions-chooser.c | 69 ++++++++++++++++++++++++++++- 4 files changed, 87 insertions(+), 9 deletions(-) diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index 9a8aa5179..1cee7c848 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -1082,6 +1082,9 @@ thunar_dialogs_show_insecure_program (gpointer parent, g_error_free (err); } + if (thunar_g_vfs_metadata_is_supported ()) + xfce_g_file_set_safety_flag (thunar_file_get_file (file), TRUE); + /* just launch */ response = GTK_RESPONSE_OK; } diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 25662ea95..2c004bc92 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1578,6 +1578,8 @@ thunar_file_execute (ThunarFile *file, const gchar *startup_id, GError **error) { + gboolean metadata_supported; + gboolean safety_flag = TRUE; gboolean snotify = FALSE; gboolean terminal; gboolean result = FALSE; @@ -1607,8 +1609,12 @@ thunar_file_execute (ThunarFile *file, uri_list = g_slist_prepend (uri_list, g_file_get_uri (li->data)); uri_list = g_slist_reverse (uri_list); + if (thunar_g_vfs_metadata_is_supported ()) + safety_flag = xfce_g_file_is_safety_flag_on (file->gfile); + if (thunar_file_is_desktop_file (file, &is_secure)) { + is_secure = is_secure && safety_flag; /* parse file first, even if it is insecure */ key_file = thunar_g_file_query_key_file (file->gfile, NULL, &err); if (key_file == NULL) @@ -1695,11 +1701,14 @@ thunar_file_execute (ThunarFile *file, /* fake the Exec line */ escaped_location = g_shell_quote (location); exec = g_strconcat (escaped_location, " %F", NULL); - command = xfce_expand_desktop_entry_field_codes (exec, uri_list, NULL, NULL, NULL, FALSE); - result = g_shell_parse_argv (command, NULL, &argv, error); + if (safety_flag || thunar_dialogs_show_insecure_program (parent, _("Untrusted executable"), file, exec)) + { + command = xfce_expand_desktop_entry_field_codes (exec, uri_list, NULL, NULL, NULL, FALSE); + result = g_shell_parse_argv (command, NULL, &argv, error); + g_free (command); + } g_free (escaped_location); g_free (exec); - g_free (command); } if (G_LIKELY (result && argv != NULL)) diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c index 9880969fb..77cb1a2cf 100644 --- a/thunar/thunar-gio-extensions.c +++ b/thunar/thunar-gio-extensions.c @@ -963,15 +963,14 @@ xfce_g_file_digest (GFile *file) * **/ void -xfce_g_file_set_saftey_flag (GFile *file, +xfce_g_file_set_safety_flag (GFile *file, gboolean is_executable) { - const gchar *digest_string; + gchar *digest_string; g_return_if_fail (G_IS_FILE (file)); - /* check if GVFs metadata is supported */ - if (!xfce_g_file_metadata_is_supported (file)) + if (!xfce_g_file_metadata_is_supported(file)) return; if (is_executable) @@ -1003,7 +1002,7 @@ xfce_g_file_is_safety_flag_on (GFile *file) GFileInfo *file_info; gboolean is_executable; const gchar *attribute_string; - const gchar *digest_string; + gchar *digest_string; g_return_if_fail (G_IS_FILE (file)); diff --git a/thunar/thunar-permissions-chooser.c b/thunar/thunar-permissions-chooser.c index 747e7d977..f76cd03df 100644 --- a/thunar/thunar-permissions-chooser.c +++ b/thunar/thunar-permissions-chooser.c @@ -45,6 +45,8 @@ #include #include #include +/*TEST*/ +#include @@ -97,6 +99,8 @@ static void thunar_permissions_chooser_group_changed (ThunarP GtkWidget *combo); static void thunar_permissions_chooser_program_toggled (ThunarPermissionsChooser *chooser, GtkWidget *button); +static void thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, + GtkWidget *button); static void thunar_permissions_chooser_fixperm_clicked (ThunarPermissionsChooser *chooser, GtkWidget *button); static ThunarJobResponse thunar_permissions_chooser_job_ask (ThunarPermissionsChooser *chooser, @@ -141,6 +145,7 @@ struct _ThunarPermissionsChooser GtkWidget *group_combo; GtkWidget *access_combos[3]; GtkWidget *program_button; + GtkWidget *launcher_button; GtkWidget *fixperm_label; GtkWidget *fixperm_button; @@ -371,6 +376,29 @@ thunar_permissions_chooser_init (ThunarPermissionsChooser *chooser) row += 1; + /* TEST AREA BEGIN */ + + label = gtk_label_new (_("Launcher:")); + gtk_label_set_xalign (GTK_LABEL (label), 1.0f); + gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ()); + gtk_grid_attach (GTK_GRID (chooser->grid), label, 0, row, 1, 1); + gtk_widget_show (label); + + chooser->launcher_button = gtk_check_button_new_with_mnemonic (_("Allow this file to be _launched from Thunar")); + g_object_bind_property (G_OBJECT (chooser->launcher_button), "visible", + G_OBJECT (label), "visible", + G_BINDING_SYNC_CREATE); + g_object_bind_property (G_OBJECT (chooser), "mutable", + G_OBJECT (chooser->launcher_button), "sensitive", + G_BINDING_SYNC_CREATE); + gtk_grid_attach (GTK_GRID (chooser->grid), chooser->launcher_button, 1, row, 1, 1); + g_signal_connect_swapped (G_OBJECT (chooser->launcher_button), "toggled", G_CALLBACK (thunar_permissions_chooser_launcher_toggled), chooser); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), chooser->launcher_button); + gtk_widget_show (chooser->launcher_button); + + row += 1; + /* TEST AREA END */ + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); g_object_bind_property (G_OBJECT (chooser), "mutable", G_OBJECT (hbox), "sensitive", @@ -893,6 +921,8 @@ thunar_permissions_chooser_file_changed (ThunarPermissionsChooser *chooser) gint file_modes[3]; GtkListStore *access_store; + gboolean is_file_regular, is_metadata_supported; + _thunar_return_if_fail (THUNAR_IS_PERMISSIONS_CHOOSER (chooser)); /* compare multiple files */ @@ -1048,12 +1078,22 @@ thunar_permissions_chooser_file_changed (ThunarPermissionsChooser *chooser) g_object_unref (G_OBJECT (access_store)); } + is_file_regular = thunar_file_is_regular (file); /* update the program setting based on the mode (only visible for regular files) */ g_signal_handlers_block_by_func (G_OBJECT (chooser->program_button), thunar_permissions_chooser_program_toggled, chooser); - g_object_set (G_OBJECT (chooser->program_button), "visible", thunar_file_is_regular (file), NULL); + g_object_set (G_OBJECT (chooser->program_button), "visible", is_file_regular, NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), (mode & 0111) != 0); g_signal_handlers_unblock_by_func (G_OBJECT (chooser->program_button), thunar_permissions_chooser_program_toggled, chooser); + /* TEST AREA BEGIN */ + is_metadata_supported = xfce_g_file_metadata_is_supported (thunar_file_get_file (file)); + /* update the launcher setting based on safety flag (only visible for regular files) */ + g_signal_handlers_block_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); + g_object_set (G_OBJECT (chooser->launcher_button), "visible", is_file_regular && is_metadata_supported, NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->launcher_button), xfce_g_file_is_safety_flag_on (thunar_file_get_file (file))); + g_signal_handlers_unblock_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); + /* TEST AREA END */ + /* update the "inconsistent folder permissions" warning and the "fix permissions" button based on the mode */ if (thunar_permissions_chooser_has_fixable_directory (chooser)) { @@ -1133,6 +1173,33 @@ thunar_permissions_chooser_program_toggled (ThunarPermissionsChooser *chooser, +static void +thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, + GtkWidget *button) +{ + gboolean safety_flag; + GFile *gfile; + + /* TODO: Multiple flags*/ + _thunar_return_if_fail (THUNAR_IS_PERMISSIONS_CHOOSER (chooser)); + _thunar_return_if_fail (chooser->launcher_button == button); + _thunar_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); + + /* verify that we have a valid file */ + if (G_UNLIKELY (chooser->files == NULL)) + return; + + safety_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + + gfile = thunar_file_get_file (THUNAR_FILE (chooser->files->data)); + g_info ("%s", thunar_g_file_get_location (gfile)); + xfce_g_file_set_safety_flag (gfile, safety_flag); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), safety_flag); +} + + + static void thunar_permissions_chooser_fixperm_clicked (ThunarPermissionsChooser *chooser, GtkWidget *button) -- GitLab From 33f2d2b4892ddab37f4b73beb6239f84e18b6670 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Wed, 16 Jun 2021 11:53:19 +0900 Subject: [PATCH 14/37] xfce_* functions moved to libxfce4util --- thunar/thunar-file.c | 1 - thunar/thunar-gio-extensions.c | 161 --------------------------------- thunar/thunar-gio-extensions.h | 6 -- 3 files changed, 168 deletions(-) diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 2c004bc92..cde885c07 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1578,7 +1578,6 @@ thunar_file_execute (ThunarFile *file, const gchar *startup_id, GError **error) { - gboolean metadata_supported; gboolean safety_flag = TRUE; gboolean snotify = FALSE; gboolean terminal; diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c index 77cb1a2cf..394a1032e 100644 --- a/thunar/thunar-gio-extensions.c +++ b/thunar/thunar-gio-extensions.c @@ -40,8 +40,6 @@ -#define XFCE_ATTRIBUTE_EXECUTABLE_DIGEST "metadata::xfce-exe-hash" /* string */ - /* See : https://freedesktop.org/wiki/Specifications/icon-naming-spec/ */ static struct { @@ -873,162 +871,3 @@ thunar_g_vfs_metadata_is_supported (void) return metadata_is_supported; } - - - -/** - * TEST AREA - * - * - **/ - - -/** - * - **/ -gboolean -xfce_g_file_metadata_is_supported (GFile *file) -{ - GFileAttributeInfoList *info_list; - gboolean is_supported; - - g_return_val_if_fail (G_IS_FILE (file), FALSE); - - /* g_return_val_if_fail (G_IS_FILE (file), FALSE); */ - - info_list = g_file_query_writable_namespaces (file, NULL, NULL); - if (info_list == NULL) - return FALSE; - - is_supported = (g_file_attribute_info_list_lookup (info_list, "metadata") != NULL); - g_file_attribute_info_list_unref (info_list); - - return is_supported; -} - -/** - * - **/ -gchar * -xfce_g_file_digest (GFile *file) -{ - GFileInfo *file_info; - GFileInputStream *stream; - guchar *contents_buffer; - gchar *checksum; - gsize file_size, file_size_read; - gboolean read_successful; - - g_return_val_if_fail (G_IS_FILE (file), NULL); - - /* query size */ - file_info = g_file_query_info (file, - G_FILE_ATTRIBUTE_STANDARD_SIZE, - G_FILE_QUERY_INFO_NONE, - NULL, - NULL); - file_size = g_file_info_get_size (file_info); - g_object_unref (file_info); - - if (file_size == 0) - return g_compute_checksum_for_data (G_CHECKSUM_SHA256, NULL, 0); - - /* allocate buffer */ - contents_buffer = g_malloc (file_size); - - /* read the actual file */ - stream = g_file_read (file, NULL, NULL); - /* TODO : ERR */ - read_successful = g_input_stream_read_all (G_INPUT_STREAM (stream), - contents_buffer, - file_size, - &file_size_read, - NULL, - NULL); - if (read_successful) - checksum = g_compute_checksum_for_data (G_CHECKSUM_SHA256, - contents_buffer, - file_size_read); - else - checksum = NULL; - - /* free buffer */ - g_free (contents_buffer); - - return checksum; -} - -/** - * - * - **/ -void -xfce_g_file_set_safety_flag (GFile *file, - gboolean is_executable) -{ - gchar *digest_string; - - g_return_if_fail (G_IS_FILE (file)); - - if (!xfce_g_file_metadata_is_supported(file)) - return; - - if (is_executable) - { - digest_string = xfce_g_file_digest (file); - if (digest_string == NULL) - return; - } - else - digest_string = NULL; - - g_file_set_attribute (file, - XFCE_ATTRIBUTE_EXECUTABLE_DIGEST, - is_executable ? G_FILE_ATTRIBUTE_TYPE_STRING - : G_FILE_ATTRIBUTE_TYPE_INVALID, - digest_string, - G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE | G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED, - NULL, - NULL); - g_free (digest_string); -} - -/** - * - **/ -gboolean -xfce_g_file_is_safety_flag_on (GFile *file) -{ - GFileInfo *file_info; - gboolean is_executable; - const gchar *attribute_string; - gchar *digest_string; - - g_return_if_fail (G_IS_FILE (file)); - - if (!xfce_g_file_metadata_is_supported(file)) - return TRUE; - - file_info = g_file_query_info (file, - XFCE_ATTRIBUTE_EXECUTABLE_DIGEST, - G_FILE_QUERY_INFO_NONE, - NULL, - NULL); - - attribute_string = g_file_info_get_attribute_string (file_info, - XFCE_ATTRIBUTE_EXECUTABLE_DIGEST); - if (attribute_string != NULL) - { - digest_string = xfce_g_file_digest (file); - is_executable = (g_strcmp0 (attribute_string, digest_string) == 0); - g_info ("Attribute hash: %s", attribute_string); - g_info ("File hash : %s", digest_string); - g_free (digest_string); - } - else - is_executable = FALSE; - - g_object_unref (file_info); - - return is_executable; -} diff --git a/thunar/thunar-gio-extensions.h b/thunar/thunar-gio-extensions.h index 761f2994d..a9491596c 100644 --- a/thunar/thunar-gio-extensions.h +++ b/thunar/thunar-gio-extensions.h @@ -93,12 +93,6 @@ gboolean thunar_g_app_info_should_show (GAppInfo *info) gboolean thunar_g_vfs_metadata_is_supported (void); -gboolean xfce_g_file_metadata_is_supported (GFile *file); -gchar *xfce_g_file_digest (GFile *file); -void xfce_g_file_set_safety_flag (GFile *file, - gboolean is_executable); -gboolean xfce_g_file_is_safety_flag_on (GFile *file); - G_END_DECLS #endif /* !__THUNAR_GIO_EXTENSIONS_H__ */ -- GitLab From cd09839121ef0a8c6aed552bb3bfe0c84f47de80 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Fri, 18 Jun 2021 21:56:55 +0900 Subject: [PATCH 15/37] Reflect xfce-gio-extensions changes --- thunar/thunar-dialogs.c | 3 ++- thunar/thunar-file.c | 2 +- thunar/thunar-permissions-chooser.c | 11 +++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index 1cee7c848..20b2e0653 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -1083,7 +1083,8 @@ thunar_dialogs_show_insecure_program (gpointer parent, } if (thunar_g_vfs_metadata_is_supported ()) - xfce_g_file_set_safety_flag (thunar_file_get_file (file), TRUE); + if (!xfce_g_file_set_trusted (thunar_file_get_file (file), TRUE, NULL, NULL)) + g_warning ("Safety flag set failed"); /* just launch */ response = GTK_RESPONSE_OK; diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index cde885c07..661508f6b 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1609,7 +1609,7 @@ thunar_file_execute (ThunarFile *file, uri_list = g_slist_reverse (uri_list); if (thunar_g_vfs_metadata_is_supported ()) - safety_flag = xfce_g_file_is_safety_flag_on (file->gfile); + safety_flag = xfce_g_file_is_trusted (file->gfile, NULL, NULL); if (thunar_file_is_desktop_file (file, &is_secure)) { diff --git a/thunar/thunar-permissions-chooser.c b/thunar/thunar-permissions-chooser.c index f76cd03df..d7030a085 100644 --- a/thunar/thunar-permissions-chooser.c +++ b/thunar/thunar-permissions-chooser.c @@ -1086,11 +1086,12 @@ thunar_permissions_chooser_file_changed (ThunarPermissionsChooser *chooser) g_signal_handlers_unblock_by_func (G_OBJECT (chooser->program_button), thunar_permissions_chooser_program_toggled, chooser); /* TEST AREA BEGIN */ - is_metadata_supported = xfce_g_file_metadata_is_supported (thunar_file_get_file (file)); + is_metadata_supported = thunar_g_vfs_metadata_is_supported (); /* update the launcher setting based on safety flag (only visible for regular files) */ g_signal_handlers_block_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); g_object_set (G_OBJECT (chooser->launcher_button), "visible", is_file_regular && is_metadata_supported, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->launcher_button), xfce_g_file_is_safety_flag_on (thunar_file_get_file (file))); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->launcher_button), + xfce_g_file_is_trusted (thunar_file_get_file (file), NULL, NULL)); g_signal_handlers_unblock_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); /* TEST AREA END */ @@ -1177,6 +1178,7 @@ static void thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, GtkWidget *button) { + gboolean execution_flag; gboolean safety_flag; GFile *gfile; @@ -1193,9 +1195,10 @@ thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, gfile = thunar_file_get_file (THUNAR_FILE (chooser->files->data)); g_info ("%s", thunar_g_file_get_location (gfile)); - xfce_g_file_set_safety_flag (gfile, safety_flag); + xfce_g_file_set_trusted (gfile, safety_flag, NULL, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), safety_flag); + execution_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chooser->program_button)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), safety_flag || execution_flag); } -- GitLab From c24cd90678107b096ffc6598091464852a4a3f28 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Mon, 21 Jun 2021 09:02:59 +0900 Subject: [PATCH 16/37] thunar-apr-desktop-page: GtkGrid row based code --- plugins/thunar-apr/thunar-apr-desktop-page.c | 48 ++++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 8afa74704..3fa520620 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -38,6 +38,7 @@ #include +#include #include /* use g_access() on win32 */ @@ -134,6 +135,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) GtkWidget *grid; GtkWidget *label; GtkWidget *spacer; + guint row = 0; gtk_container_set_border_width (GTK_CONTAINER (desktop_page), 12); @@ -153,7 +155,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) label = gtk_label_new (_("Description:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->description_entry = gtk_entry_new (); @@ -162,11 +164,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_signal_connect (G_OBJECT (desktop_page->description_entry), "activate", G_CALLBACK (thunar_apr_desktop_page_activated), desktop_page); g_signal_connect (G_OBJECT (desktop_page->description_entry), "focus-out-event", G_CALLBACK (thunar_apr_desktop_page_focus_out_event), desktop_page); gtk_widget_set_hexpand (desktop_page->description_entry, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->description_entry, 1, 0, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->description_entry, 1, row, 1, 1); gtk_widget_show (desktop_page->description_entry); g_object_bind_property (G_OBJECT (desktop_page->description_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (desktop_page->description_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); @@ -177,7 +181,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) label = gtk_label_new (_("Command:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->command_entry = gtk_entry_new (); @@ -185,11 +189,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_signal_connect (G_OBJECT (desktop_page->command_entry), "activate", G_CALLBACK (thunar_apr_desktop_page_activated), desktop_page); g_signal_connect (G_OBJECT (desktop_page->command_entry), "focus-out-event", G_CALLBACK (thunar_apr_desktop_page_focus_out_event), desktop_page); gtk_widget_set_hexpand (desktop_page->command_entry, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->command_entry, 1, 1, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->command_entry, 1, row, 1, 1); gtk_widget_show (desktop_page->command_entry); g_object_bind_property (G_OBJECT (desktop_page->command_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (desktop_page->command_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); @@ -200,7 +206,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) label = gtk_label_new (_("Working Directory:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->path_entry = gtk_entry_new (); @@ -208,11 +214,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_signal_connect (G_OBJECT (desktop_page->path_entry), "activate", G_CALLBACK (thunar_apr_desktop_page_activated), desktop_page); g_signal_connect (G_OBJECT (desktop_page->path_entry), "focus-out-event", G_CALLBACK (thunar_apr_desktop_page_focus_out_event), desktop_page); gtk_widget_set_hexpand (desktop_page->path_entry, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->path_entry, 1, 2, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->path_entry, 1, row, 1, 1); gtk_widget_show (desktop_page->path_entry); g_object_bind_property (G_OBJECT (desktop_page->path_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (desktop_page->path_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); @@ -223,7 +231,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) label = gtk_label_new (_("URL:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->url_entry = gtk_entry_new (); @@ -231,11 +239,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_signal_connect (G_OBJECT (desktop_page->url_entry), "activate", G_CALLBACK (thunar_apr_desktop_page_activated), desktop_page); g_signal_connect (G_OBJECT (desktop_page->url_entry), "focus-out-event", G_CALLBACK (thunar_apr_desktop_page_focus_out_event), desktop_page); gtk_widget_set_hexpand (desktop_page->url_entry, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->url_entry, 1, 3, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->url_entry, 1, row, 1, 1); gtk_widget_show (desktop_page->url_entry); g_object_bind_property (G_OBJECT (desktop_page->url_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (desktop_page->url_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); @@ -246,7 +256,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) label = gtk_label_new (_("Comment:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 4, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->comment_entry = gtk_entry_new (); @@ -256,11 +266,17 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_signal_connect (G_OBJECT (desktop_page->comment_entry), "activate", G_CALLBACK (thunar_apr_desktop_page_activated), desktop_page); g_signal_connect (G_OBJECT (desktop_page->comment_entry), "focus-out-event", G_CALLBACK (thunar_apr_desktop_page_focus_out_event), desktop_page); gtk_widget_set_hexpand (desktop_page->comment_entry, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->comment_entry, 1, 4, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->comment_entry, 1, row, 1, 1); gtk_widget_show (desktop_page->comment_entry); g_object_bind_property (G_OBJECT (desktop_page->comment_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + + /* Nothing here on purpose */ + + row++; + /* set Atk label relation for the entry */ object = gtk_widget_get_accessible (desktop_page->comment_entry); relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); @@ -270,13 +286,15 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) /* add spacing between the entries and the options */ spacer = g_object_new (GTK_TYPE_BOX, "orientation", GTK_ORIENTATION_VERTICAL, "height-request", 12, NULL); - gtk_grid_attach (GTK_GRID (grid), spacer, 0, 6, 2, 1); + gtk_grid_attach (GTK_GRID (grid), spacer, 0, row, 2, 1); gtk_widget_show (spacer); + row++; + label = gtk_label_new (_("Options:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); - gtk_grid_attach (GTK_GRID (grid), label, 0, 7, 1, 1); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); desktop_page->snotify_button = gtk_check_button_new_with_mnemonic (_("Use _startup notification")); @@ -285,14 +303,16 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) "startup notification.")); g_signal_connect (G_OBJECT (desktop_page->snotify_button), "toggled", G_CALLBACK (thunar_apr_desktop_page_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->snotify_button, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->snotify_button, 1, 7, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->snotify_button, 1, row, 1, 1); gtk_widget_show (desktop_page->snotify_button); + row++; + desktop_page->terminal_button = gtk_check_button_new_with_mnemonic (_("Run in _terminal")); gtk_widget_set_tooltip_text (desktop_page->terminal_button, _("Select this option to run the command in a terminal window.")); g_signal_connect (G_OBJECT (desktop_page->terminal_button), "toggled", G_CALLBACK (thunar_apr_desktop_page_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->terminal_button, TRUE); - gtk_grid_attach (GTK_GRID (grid), desktop_page->terminal_button, 1, 8, 1, 1); + gtk_grid_attach (GTK_GRID (grid), desktop_page->terminal_button, 1, row, 1, 1); gtk_widget_show (desktop_page->terminal_button); /* set Atk label relation for the buttons */ -- GitLab From ba25ee762de641c9806c0835aedfa262c42bead0 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Mon, 21 Jun 2021 11:25:21 +0900 Subject: [PATCH 17/37] Dummy buttons for executable/trusted flag --- plugins/thunar-apr/thunar-apr-desktop-page.c | 180 ++++++++++++------- 1 file changed, 114 insertions(+), 66 deletions(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 3fa520620..1f551ee31 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -38,7 +38,7 @@ #include -#include +#include #include /* use g_access() on win32 */ @@ -49,22 +49,27 @@ #endif - -static void thunar_apr_desktop_page_finalize (GObject *object); -static void thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, - ThunarxFileInfo *file); -static void thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, - GtkWidget *widget); -static void thunar_apr_desktop_page_save_widget (ThunarAprDesktopPage *desktop_page, - GtkWidget *widget, - GKeyFile *key_file); -static void thunar_apr_desktop_page_activated (GtkWidget *entry, - ThunarAprDesktopPage *desktop_page); -static gboolean thunar_apr_desktop_page_focus_out_event (GtkWidget *entry, - GdkEventFocus *event, - ThunarAprDesktopPage *desktop_page); -static void thunar_apr_desktop_page_toggled (GtkWidget *button, - ThunarAprDesktopPage *desktop_page); +static void +thunar_gtk_label_set_a11y_relation (GtkLabel *label, + GtkWidget *widget); + +static void thunar_apr_desktop_page_finalize (GObject *object); +static void thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, + ThunarxFileInfo *file); +static void thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, + GtkWidget *widget); +static void thunar_apr_desktop_page_save_widget (ThunarAprDesktopPage *desktop_page, + GtkWidget *widget, + GKeyFile *key_file); +static void thunar_apr_desktop_page_activated (GtkWidget *entry, + ThunarAprDesktopPage *desktop_page); +static gboolean thunar_apr_desktop_page_focus_out_event (GtkWidget *entry, + GdkEventFocus *event, + ThunarAprDesktopPage *desktop_page); +static void thunar_apr_desktop_page_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page); +static void thunar_apr_desktop_page_security_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page); @@ -84,6 +89,8 @@ struct _ThunarAprDesktopPage GtkWidget *comment_entry; GtkWidget *snotify_button; GtkWidget *terminal_button; + GtkWidget *program_button; + GtkWidget *trusted_button; /* the values of the entries remember when * the file was saved last time to avoid a @@ -108,6 +115,27 @@ THUNARX_DEFINE_TYPE (ThunarAprDesktopPage, +/* duplicated code, need to move into libxfce4ui */ +static void +thunar_gtk_label_set_a11y_relation (GtkLabel *label, + GtkWidget *widget) +{ + AtkRelationSet *relations; + AtkRelation *relation; + AtkObject *object; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (GTK_IS_LABEL (label)); + + object = gtk_widget_get_accessible (widget); + relations = atk_object_ref_relation_set (gtk_widget_get_accessible (GTK_WIDGET (label))); + relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); + atk_relation_set_add (relations, relation); + g_object_unref (G_OBJECT (relation)); +} + + + static void thunar_apr_desktop_page_class_init (ThunarAprDesktopPageClass *klass) { @@ -127,15 +155,13 @@ thunar_apr_desktop_page_class_init (ThunarAprDesktopPageClass *klass) static void thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) { - AtkRelationSet *relations; PangoAttribute *attribute; PangoAttrList *attr_list; - AtkRelation *relation; - AtkObject *object; GtkWidget *grid; GtkWidget *label; GtkWidget *spacer; guint row = 0; + GFile *g_file; gtk_container_set_border_width (GTK_CONTAINER (desktop_page), 12); @@ -168,16 +194,10 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->description_entry); g_object_bind_property (G_OBJECT (desktop_page->description_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); row++; - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (desktop_page->description_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - label = gtk_label_new (_("Command:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); @@ -193,16 +213,10 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->command_entry); g_object_bind_property (G_OBJECT (desktop_page->command_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); row++; - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (desktop_page->command_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - label = gtk_label_new (_("Working Directory:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); @@ -218,16 +232,10 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->path_entry); g_object_bind_property (G_OBJECT (desktop_page->path_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); row++; - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (desktop_page->path_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - label = gtk_label_new (_("URL:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); @@ -243,16 +251,10 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->url_entry); g_object_bind_property (G_OBJECT (desktop_page->url_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); row++; - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (desktop_page->url_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - label = gtk_label_new (_("Comment:")); gtk_label_set_xalign (GTK_LABEL (label), 1.0f); gtk_label_set_attributes (GTK_LABEL (label), attr_list); @@ -270,6 +272,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->comment_entry); g_object_bind_property (G_OBJECT (desktop_page->comment_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); row++; @@ -277,13 +280,6 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) row++; - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (desktop_page->comment_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - /* add spacing between the entries and the options */ spacer = g_object_new (GTK_TYPE_BOX, "orientation", GTK_ORIENTATION_VERTICAL, "height-request", 12, NULL); gtk_grid_attach (GTK_GRID (grid), spacer, 0, row, 2, 1); @@ -306,6 +302,9 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_grid_attach (GTK_GRID (grid), desktop_page->snotify_button, 1, row, 1, 1); gtk_widget_show (desktop_page->snotify_button); + g_object_bind_property (G_OBJECT (desktop_page->snotify_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); + row++; desktop_page->terminal_button = gtk_check_button_new_with_mnemonic (_("Run in _terminal")); @@ -315,18 +314,52 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_grid_attach (GTK_GRID (grid), desktop_page->terminal_button, 1, row, 1, 1); gtk_widget_show (desktop_page->terminal_button); - /* set Atk label relation for the buttons */ - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - object = gtk_widget_get_accessible (desktop_page->snotify_button); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - object = gtk_widget_get_accessible (desktop_page->terminal_button); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); + /* don't bind visibility with label */ + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); - g_object_bind_property (G_OBJECT (desktop_page->snotify_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + row++; + + label = gtk_label_new (_("Security:")); + gtk_label_set_xalign (GTK_LABEL (label), 1.0f); + gtk_label_set_attributes (GTK_LABEL (label), attr_list); + gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); + gtk_widget_show (label); + + /* same function as in thunar-permission-chooser.c */ + desktop_page->program_button = gtk_check_button_new_with_mnemonic (_("Allow this file to _run as a .desktop file")); + gtk_widget_set_tooltip_text (desktop_page->program_button, _("If not selected, .desktop file will be considered as a normal text file.")); + g_signal_connect (G_OBJECT (desktop_page->program_button), "toggled", + G_CALLBACK (thunar_apr_desktop_page_security_toggled), desktop_page); + gtk_widget_set_hexpand (desktop_page->program_button, TRUE); + gtk_grid_attach (GTK_GRID (grid), desktop_page->program_button, 1, row, 1, 1); + gtk_widget_show (desktop_page->program_button); + + g_object_bind_property (G_OBJECT (desktop_page->program_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->program_button); + + row++; + + g_file = g_file_new_for_uri ("file:///"); + if (xfce_g_file_metadata_is_supported (g_file)) + { + /* same function as in thunar-permission-chooser.c */ + desktop_page->trusted_button = gtk_check_button_new_with_mnemonic (_("Set this file as trusted")); + gtk_widget_set_tooltip_text (desktop_page->trusted_button, _("Select this option to trust this .desktop file.")); + g_signal_connect (G_OBJECT (desktop_page->trusted_button), "toggled", + G_CALLBACK (thunar_apr_desktop_page_security_toggled), desktop_page); + gtk_widget_set_hexpand (desktop_page->trusted_button, TRUE); + gtk_grid_attach (GTK_GRID (grid), desktop_page->trusted_button, 1, row, 1, 1); + gtk_widget_show (desktop_page->trusted_button); + + g_object_bind_property (G_OBJECT (desktop_page->trusted_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->trusted_button); + + row++; + } + else + desktop_page->trusted_button = NULL; + + g_object_unref (g_file); /* release shared bold Pango attributes */ pango_attr_list_unref (attr_list); @@ -818,3 +851,18 @@ thunar_apr_desktop_page_toggled (GtkWidget *button, thunar_apr_desktop_page_save (desktop_page, button); } +static void +thunar_apr_desktop_page_security_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page) +{ + GFile *g_file; + + g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); + g_return_if_fail (button == desktop_page->program_button || button == desktop_page->trusted_button); + g_return_if_fail (THUNAR_APR_IS_DESKTOP_PAGE (desktop_page)); + g_return_if_fail (THUNARX_IS_FILE_INFO (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file)); + + g_file = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); + + g_object_unref (g_file); +} -- GitLab From 10317f2fbd15c0dec97329eb3b86aaec9fb5a050 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Wed, 23 Jun 2021 09:18:56 +0900 Subject: [PATCH 18/37] Naming convention --- docs/reference/thunarx/thunarx.actions | 0 plugins/thunar-apr/thunar-apr-desktop-page.c | 18 +++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 docs/reference/thunarx/thunarx.actions diff --git a/docs/reference/thunarx/thunarx.actions b/docs/reference/thunarx/thunarx.actions new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 1f551ee31..0946e9b13 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -161,7 +161,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) GtkWidget *label; GtkWidget *spacer; guint row = 0; - GFile *g_file; + GFile *gfile; gtk_container_set_border_width (GTK_CONTAINER (desktop_page), 12); @@ -339,8 +339,8 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) row++; - g_file = g_file_new_for_uri ("file:///"); - if (xfce_g_file_metadata_is_supported (g_file)) + gfile = g_file_new_for_uri ("file:///"); + if (xfce_g_file_metadata_is_supported (gfile)) { /* same function as in thunar-permission-chooser.c */ desktop_page->trusted_button = gtk_check_button_new_with_mnemonic (_("Set this file as trusted")); @@ -359,7 +359,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) else desktop_page->trusted_button = NULL; - g_object_unref (g_file); + g_object_unref (gfile); /* release shared bold Pango attributes */ pango_attr_list_unref (attr_list); @@ -851,18 +851,22 @@ thunar_apr_desktop_page_toggled (GtkWidget *button, thunar_apr_desktop_page_save (desktop_page, button); } + + static void thunar_apr_desktop_page_security_toggled (GtkWidget *button, ThunarAprDesktopPage *desktop_page) { - GFile *g_file; + GFile *gfile; + gboolean execution_flag; + gboolean safety_flag; g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); g_return_if_fail (button == desktop_page->program_button || button == desktop_page->trusted_button); g_return_if_fail (THUNAR_APR_IS_DESKTOP_PAGE (desktop_page)); g_return_if_fail (THUNARX_IS_FILE_INFO (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file)); - g_file = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); + gfile = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); - g_object_unref (g_file); + g_object_unref (gfile); } -- GitLab From 8a13bfec280cc2d2ecf4a8b6a5f3448706f3918a Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Thu, 24 Jun 2021 14:39:24 +0900 Subject: [PATCH 19/37] thunar-apr: safety flag support --- plugins/thunar-apr/Makefile.am | 4 + plugins/thunar-apr/thunar-apr-desktop-page.c | 262 ++++++++++++++++--- 2 files changed, 228 insertions(+), 38 deletions(-) diff --git a/plugins/thunar-apr/Makefile.am b/plugins/thunar-apr/Makefile.am index e78e38634..f5277d214 100644 --- a/plugins/thunar-apr/Makefile.am +++ b/plugins/thunar-apr/Makefile.am @@ -27,6 +27,8 @@ thunar_apr_la_SOURCES = \ thunar_apr_la_CFLAGS = \ $(EXIF_CFLAGS) \ $(EXO_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCE4UI_CFLAGS) \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(PLATFORM_CFLAGS) @@ -43,6 +45,8 @@ thunar_apr_la_LIBADD = \ $(top_builddir)/thunarx/libthunarx-$(THUNARX_VERSION_API).la \ $(EXIF_LIBS) \ $(EXO_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCE4UI_LIBS) \ $(GLIB_LIBS) \ $(GTK_LIBS) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 0946e9b13..bed3cbe33 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -38,6 +38,7 @@ #include +#include #include #include @@ -49,9 +50,6 @@ #endif -static void -thunar_gtk_label_set_a11y_relation (GtkLabel *label, - GtkWidget *widget); static void thunar_apr_desktop_page_finalize (GObject *object); static void thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, @@ -68,8 +66,17 @@ static gboolean thunar_apr_desktop_page_focus_out_event (GtkWidget ThunarAprDesktopPage *desktop_page); static void thunar_apr_desktop_page_toggled (GtkWidget *button, ThunarAprDesktopPage *desktop_page); -static void thunar_apr_desktop_page_security_toggled (GtkWidget *button, +static void thunar_apr_desktop_page_program_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page); +#ifdef __XFCE_GIO_EXTENSIONS_H__ +static void thunar_apr_desktop_page_trusted_toggled (GtkWidget *button, ThunarAprDesktopPage *desktop_page); +#endif /* __XFCE_GIO_EXTENSIONS_H__ */ +static gboolean is_executable (GFile *gfile, + GError **error); +static gboolean set_executable (GFile *gfile, + gboolean executable, + GError **error); @@ -115,23 +122,82 @@ THUNARX_DEFINE_TYPE (ThunarAprDesktopPage, -/* duplicated code, need to move into libxfce4ui */ -static void -thunar_gtk_label_set_a11y_relation (GtkLabel *label, - GtkWidget *widget) +static gboolean +is_executable (GFile *gfile, + GError **error) { - AtkRelationSet *relations; - AtkRelation *relation; - AtkObject *object; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (GTK_IS_LABEL (label)); - - object = gtk_widget_get_accessible (widget); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (GTK_WIDGET (label))); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); + GError *error_local = NULL; + GFileInfo *info; + gboolean executable; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + g_return_val_if_fail (G_IS_FILE (gfile), FALSE); + + info = g_file_query_info (gfile, + G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE, + G_FILE_QUERY_INFO_NONE, + NULL, + &error_local); + if (error_local != NULL) + { + g_propagate_error (error, error_local); + return FALSE; + } + + executable = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE); + g_object_unref (info); + + return executable; +} + + + +/* copied from exo-die-utils.c */ +static gboolean +set_executable (GFile *gfile, + gboolean executable, + GError **error) +{ + GError *error_local = NULL; + guint32 mode = 0111, mask = 0111; + guint32 old_mode, new_mode; + GFileInfo *info; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + g_return_val_if_fail (G_IS_FILE (gfile), FALSE); + + + info = g_file_query_info (gfile, + G_FILE_ATTRIBUTE_UNIX_MODE, + G_FILE_QUERY_INFO_NONE, + NULL, + &error_local); + + if (error_local != NULL) + { + g_propagate_error (error, error_local); + return FALSE; + } + + old_mode = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE); + new_mode = executable ? ((old_mode & ~mask) | mode) : (old_mode & ~mask); + + if (old_mode != new_mode) { + g_file_set_attribute_uint32 (gfile, + G_FILE_ATTRIBUTE_UNIX_MODE, new_mode, + G_FILE_QUERY_INFO_NONE, + NULL, + &error_local); + } + g_object_unref (info); + + if (error_local != NULL) + { + g_propagate_error (error, error_local); + return FALSE; + } + + return TRUE; } @@ -194,7 +260,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->description_entry); g_object_bind_property (G_OBJECT (desktop_page->description_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); row++; @@ -213,7 +279,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->command_entry); g_object_bind_property (G_OBJECT (desktop_page->command_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); row++; @@ -232,7 +298,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->path_entry); g_object_bind_property (G_OBJECT (desktop_page->path_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); row++; @@ -251,7 +317,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->url_entry); g_object_bind_property (G_OBJECT (desktop_page->url_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); row++; @@ -272,7 +338,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->comment_entry); g_object_bind_property (G_OBJECT (desktop_page->comment_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); row++; @@ -303,7 +369,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->snotify_button); g_object_bind_property (G_OBJECT (desktop_page->snotify_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); row++; @@ -315,7 +381,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->terminal_button); /* don't bind visibility with label */ - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); row++; @@ -329,16 +395,17 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) desktop_page->program_button = gtk_check_button_new_with_mnemonic (_("Allow this file to _run as a .desktop file")); gtk_widget_set_tooltip_text (desktop_page->program_button, _("If not selected, .desktop file will be considered as a normal text file.")); g_signal_connect (G_OBJECT (desktop_page->program_button), "toggled", - G_CALLBACK (thunar_apr_desktop_page_security_toggled), desktop_page); + G_CALLBACK (thunar_apr_desktop_page_program_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->program_button, TRUE); gtk_grid_attach (GTK_GRID (grid), desktop_page->program_button, 1, row, 1, 1); gtk_widget_show (desktop_page->program_button); g_object_bind_property (G_OBJECT (desktop_page->program_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->program_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->program_button); row++; + #ifdef __XFCE_GIO_EXTENSIONS_H__ gfile = g_file_new_for_uri ("file:///"); if (xfce_g_file_metadata_is_supported (gfile)) { @@ -346,18 +413,22 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) desktop_page->trusted_button = gtk_check_button_new_with_mnemonic (_("Set this file as trusted")); gtk_widget_set_tooltip_text (desktop_page->trusted_button, _("Select this option to trust this .desktop file.")); g_signal_connect (G_OBJECT (desktop_page->trusted_button), "toggled", - G_CALLBACK (thunar_apr_desktop_page_security_toggled), desktop_page); + G_CALLBACK (thunar_apr_desktop_page_trusted_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->trusted_button, TRUE); gtk_grid_attach (GTK_GRID (grid), desktop_page->trusted_button, 1, row, 1, 1); gtk_widget_show (desktop_page->trusted_button); g_object_bind_property (G_OBJECT (desktop_page->trusted_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->trusted_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->trusted_button); row++; } else - desktop_page->trusted_button = NULL; + #endif /* __XFCE_GIO_EXTENSIONS_H__ */ + { + g_info ("metadata not supported"); + desktop_page->trusted_button = NULL; + } g_object_unref (gfile); @@ -390,8 +461,11 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, { ThunarAprDesktopPage *desktop_page = THUNAR_APR_DESKTOP_PAGE (abstract_page); GKeyFile *key_file; + GFile *gfile; gboolean writable; gboolean enabled; + gboolean executable; + gboolean trusted; GError *error = NULL; gchar *filename; gchar *value; @@ -545,6 +619,41 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, gtk_widget_hide (desktop_page->terminal_button); } + /* update flags */ + gfile = thunarx_file_info_get_location (abstract_page->file);; + + g_signal_handlers_block_by_func (G_OBJECT (desktop_page->program_button), thunar_apr_desktop_page_program_toggled, desktop_page); + executable = is_executable (gfile, &error); + if (error != NULL) + { + g_warning ("Failed to initialize program_button : %s", error->message); + g_clear_error (&error); + } + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->program_button), executable); + + #ifdef __XFCE_GIO_EXTENSIONS_H__ + if (desktop_page->trusted_button != NULL) + { + g_signal_handlers_block_by_func (G_OBJECT (desktop_page->trusted_button), thunar_apr_desktop_page_trusted_toggled, desktop_page); + trusted = xfce_g_file_is_trusted (gfile, NULL, &error); + if (error != NULL) + { + g_warning ("Failed to initialize trusted_button : %s", error->message); + g_clear_error (&error); + } + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button), trusted); + g_signal_handlers_unblock_by_func (G_OBJECT (desktop_page->trusted_button), thunar_apr_desktop_page_trusted_toggled, desktop_page); + } + #endif /* __XFCE_GIO_EXTENSIONS_H__ */ + g_signal_handlers_unblock_by_func (G_OBJECT (desktop_page->program_button), thunar_apr_desktop_page_program_toggled, desktop_page); + + g_object_unref (gfile); + + /* show security */ + gtk_widget_show (desktop_page->program_button); + if (desktop_page->trusted_button != NULL) + gtk_widget_show (desktop_page->trusted_button); + /* check if the file is writable... */ writable = (g_access (filename, W_OK) == 0); @@ -573,6 +682,9 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, gtk_widget_hide (desktop_page->comment_entry); gtk_widget_hide (desktop_page->snotify_button); gtk_widget_hide (desktop_page->terminal_button); + gtk_widget_hide (desktop_page->program_button); + if (desktop_page->trusted_button != NULL) + gtk_widget_hide (desktop_page->trusted_button); } /* cleanup */ @@ -853,20 +965,94 @@ thunar_apr_desktop_page_toggled (GtkWidget *button, +/** + * Allowed state: + * + * +-----+-----+ + * |EXE |SAFE | + * +=====+=====+ + * |TRUE |TRUE | Allowed to launch + * +-----+-----+ + * |TRUE |FALSE| Ask before launch + * +-----+-----+ + * |FALSE|FALSE| Not recognized as .desktop + * +-----+-----+ + **/ static void -thunar_apr_desktop_page_security_toggled (GtkWidget *button, - ThunarAprDesktopPage *desktop_page) +thunar_apr_desktop_page_program_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page) { - GFile *gfile; - gboolean execution_flag; - gboolean safety_flag; + GError *error = NULL; + GFile *gfile; + gboolean executable; + gboolean trusted; + g_return_if_fail (button == desktop_page->program_button); g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); - g_return_if_fail (button == desktop_page->program_button || button == desktop_page->trusted_button); g_return_if_fail (THUNAR_APR_IS_DESKTOP_PAGE (desktop_page)); g_return_if_fail (THUNARX_IS_FILE_INFO (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file)); gfile = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); + executable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->program_button)); + + if (desktop_page->trusted_button != NULL) + trusted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)); + else + trusted = FALSE; + + set_executable (gfile, executable, &error); + + if (error != NULL) + { + g_warning ("Error while setting execution flag : %s", error->message); + g_free (error); + g_object_unref (gfile); + return; + } + + if (!executable && trusted) + if (desktop_page->trusted_button != NULL) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button), FALSE); + g_object_unref (gfile); } + +#ifdef __XFCE_GIO_EXTENSIONS_H__ +static void +thunar_apr_desktop_page_trusted_toggled (GtkWidget *button, + ThunarAprDesktopPage *desktop_page) +{ + GError *error = NULL; + GFile *gfile; + gboolean executable; + gboolean trusted; + + g_return_if_fail (button == desktop_page->trusted_button); + g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); + g_return_if_fail (THUNAR_APR_IS_DESKTOP_PAGE (desktop_page)); + g_return_if_fail (THUNARX_IS_FILE_INFO (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file)); + + gfile = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); + + executable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->program_button)); + + if (desktop_page->trusted_button != NULL) + trusted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)); + else + trusted = FALSE; + + xfce_g_file_set_trusted (gfile, trusted, NULL, &error); + + if (error != NULL) + { + g_warning ("Error while setting safety flag : %s", error->message); + g_free (error); + g_object_unref (gfile); + return; + } + + if (!executable && trusted) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->program_button), TRUE); +} +#endif /* __XFCE_GIO_EXTENSIONS_H__ */ -- GitLab From 807ad3529565e017d1137153288da53ff8aaab99 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Thu, 24 Jun 2021 14:42:52 +0900 Subject: [PATCH 20/37] thunar-permission-chooser.c: Remove safety flag support --- thunar/thunar-permissions-chooser.c | 72 +---------------------------- 1 file changed, 1 insertion(+), 71 deletions(-) diff --git a/thunar/thunar-permissions-chooser.c b/thunar/thunar-permissions-chooser.c index d7030a085..747e7d977 100644 --- a/thunar/thunar-permissions-chooser.c +++ b/thunar/thunar-permissions-chooser.c @@ -45,8 +45,6 @@ #include #include #include -/*TEST*/ -#include @@ -99,8 +97,6 @@ static void thunar_permissions_chooser_group_changed (ThunarP GtkWidget *combo); static void thunar_permissions_chooser_program_toggled (ThunarPermissionsChooser *chooser, GtkWidget *button); -static void thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, - GtkWidget *button); static void thunar_permissions_chooser_fixperm_clicked (ThunarPermissionsChooser *chooser, GtkWidget *button); static ThunarJobResponse thunar_permissions_chooser_job_ask (ThunarPermissionsChooser *chooser, @@ -145,7 +141,6 @@ struct _ThunarPermissionsChooser GtkWidget *group_combo; GtkWidget *access_combos[3]; GtkWidget *program_button; - GtkWidget *launcher_button; GtkWidget *fixperm_label; GtkWidget *fixperm_button; @@ -376,29 +371,6 @@ thunar_permissions_chooser_init (ThunarPermissionsChooser *chooser) row += 1; - /* TEST AREA BEGIN */ - - label = gtk_label_new (_("Launcher:")); - gtk_label_set_xalign (GTK_LABEL (label), 1.0f); - gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ()); - gtk_grid_attach (GTK_GRID (chooser->grid), label, 0, row, 1, 1); - gtk_widget_show (label); - - chooser->launcher_button = gtk_check_button_new_with_mnemonic (_("Allow this file to be _launched from Thunar")); - g_object_bind_property (G_OBJECT (chooser->launcher_button), "visible", - G_OBJECT (label), "visible", - G_BINDING_SYNC_CREATE); - g_object_bind_property (G_OBJECT (chooser), "mutable", - G_OBJECT (chooser->launcher_button), "sensitive", - G_BINDING_SYNC_CREATE); - gtk_grid_attach (GTK_GRID (chooser->grid), chooser->launcher_button, 1, row, 1, 1); - g_signal_connect_swapped (G_OBJECT (chooser->launcher_button), "toggled", G_CALLBACK (thunar_permissions_chooser_launcher_toggled), chooser); - thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), chooser->launcher_button); - gtk_widget_show (chooser->launcher_button); - - row += 1; - /* TEST AREA END */ - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); g_object_bind_property (G_OBJECT (chooser), "mutable", G_OBJECT (hbox), "sensitive", @@ -921,8 +893,6 @@ thunar_permissions_chooser_file_changed (ThunarPermissionsChooser *chooser) gint file_modes[3]; GtkListStore *access_store; - gboolean is_file_regular, is_metadata_supported; - _thunar_return_if_fail (THUNAR_IS_PERMISSIONS_CHOOSER (chooser)); /* compare multiple files */ @@ -1078,23 +1048,12 @@ thunar_permissions_chooser_file_changed (ThunarPermissionsChooser *chooser) g_object_unref (G_OBJECT (access_store)); } - is_file_regular = thunar_file_is_regular (file); /* update the program setting based on the mode (only visible for regular files) */ g_signal_handlers_block_by_func (G_OBJECT (chooser->program_button), thunar_permissions_chooser_program_toggled, chooser); - g_object_set (G_OBJECT (chooser->program_button), "visible", is_file_regular, NULL); + g_object_set (G_OBJECT (chooser->program_button), "visible", thunar_file_is_regular (file), NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), (mode & 0111) != 0); g_signal_handlers_unblock_by_func (G_OBJECT (chooser->program_button), thunar_permissions_chooser_program_toggled, chooser); - /* TEST AREA BEGIN */ - is_metadata_supported = thunar_g_vfs_metadata_is_supported (); - /* update the launcher setting based on safety flag (only visible for regular files) */ - g_signal_handlers_block_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); - g_object_set (G_OBJECT (chooser->launcher_button), "visible", is_file_regular && is_metadata_supported, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->launcher_button), - xfce_g_file_is_trusted (thunar_file_get_file (file), NULL, NULL)); - g_signal_handlers_unblock_by_func (G_OBJECT (chooser->launcher_button), thunar_permissions_chooser_launcher_toggled, chooser); - /* TEST AREA END */ - /* update the "inconsistent folder permissions" warning and the "fix permissions" button based on the mode */ if (thunar_permissions_chooser_has_fixable_directory (chooser)) { @@ -1174,35 +1133,6 @@ thunar_permissions_chooser_program_toggled (ThunarPermissionsChooser *chooser, -static void -thunar_permissions_chooser_launcher_toggled (ThunarPermissionsChooser *chooser, - GtkWidget *button) -{ - gboolean execution_flag; - gboolean safety_flag; - GFile *gfile; - - /* TODO: Multiple flags*/ - _thunar_return_if_fail (THUNAR_IS_PERMISSIONS_CHOOSER (chooser)); - _thunar_return_if_fail (chooser->launcher_button == button); - _thunar_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); - - /* verify that we have a valid file */ - if (G_UNLIKELY (chooser->files == NULL)) - return; - - safety_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - - gfile = thunar_file_get_file (THUNAR_FILE (chooser->files->data)); - g_info ("%s", thunar_g_file_get_location (gfile)); - xfce_g_file_set_trusted (gfile, safety_flag, NULL, NULL); - - execution_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chooser->program_button)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->program_button), safety_flag || execution_flag); -} - - - static void thunar_permissions_chooser_fixperm_clicked (ThunarPermissionsChooser *chooser, GtkWidget *button) -- GitLab From 163904d914deffce02c654e49affc7fd05e69adc Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Thu, 24 Jun 2021 15:13:24 +0900 Subject: [PATCH 21/37] Use safety flag only for .desktop --- thunar/thunar-dialogs.c | 11 ++++++++--- thunar/thunar-file.c | 19 ++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index 20b2e0653..e9475dcfc 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -1079,12 +1079,17 @@ thunar_dialogs_show_insecure_program (gpointer parent, if (err != NULL) { thunar_dialogs_show_error (parent, err, ("Unable to mark launcher executable")); - g_error_free (err); + g_clear_error (&err); } + #ifdef __XFCE_GIO_EXTENSIONS_H__ if (thunar_g_vfs_metadata_is_supported ()) - if (!xfce_g_file_set_trusted (thunar_file_get_file (file), TRUE, NULL, NULL)) - g_warning ("Safety flag set failed"); + if (!xfce_g_file_set_trusted (thunar_file_get_file (file), TRUE, NULL, &err)) + { + g_warning ("Safety flag set failed: %s", err->message); + g_clear_error (&err); + } + #endif /* __XFCE_GIO_EXTENSIONS_H__ */ /* just launch */ response = GTK_RESPONSE_OK; diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 661508f6b..c02d3eccf 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1578,7 +1578,6 @@ thunar_file_execute (ThunarFile *file, const gchar *startup_id, GError **error) { - gboolean safety_flag = TRUE; gboolean snotify = FALSE; gboolean terminal; gboolean result = FALSE; @@ -1608,12 +1607,13 @@ thunar_file_execute (ThunarFile *file, uri_list = g_slist_prepend (uri_list, g_file_get_uri (li->data)); uri_list = g_slist_reverse (uri_list); - if (thunar_g_vfs_metadata_is_supported ()) - safety_flag = xfce_g_file_is_trusted (file->gfile, NULL, NULL); - if (thunar_file_is_desktop_file (file, &is_secure)) { - is_secure = is_secure && safety_flag; + #ifdef __XFCE_GIO_EXTENSIONS_H__ + if (thunar_g_vfs_metadata_is_supported ()) + is_secure = is_secure && xfce_g_file_is_trusted (file->gfile, NULL, NULL); + #endif /* __XFCE_GIO_EXTENSIONS_H__ */ + /* parse file first, even if it is insecure */ key_file = thunar_g_file_query_key_file (file->gfile, NULL, &err); if (key_file == NULL) @@ -1700,12 +1700,9 @@ thunar_file_execute (ThunarFile *file, /* fake the Exec line */ escaped_location = g_shell_quote (location); exec = g_strconcat (escaped_location, " %F", NULL); - if (safety_flag || thunar_dialogs_show_insecure_program (parent, _("Untrusted executable"), file, exec)) - { - command = xfce_expand_desktop_entry_field_codes (exec, uri_list, NULL, NULL, NULL, FALSE); - result = g_shell_parse_argv (command, NULL, &argv, error); - g_free (command); - } + command = xfce_expand_desktop_entry_field_codes (exec, uri_list, NULL, NULL, NULL, FALSE); + result = g_shell_parse_argv (command, NULL, &argv, error); + g_free (command); g_free (escaped_location); g_free (exec); } -- GitLab From baed8c3ce8d41fbb9aa08b191614291d6379910b Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Thu, 24 Jun 2021 15:27:38 +0900 Subject: [PATCH 22/37] Initialize gfile as NULL --- plugins/thunar-apr/thunar-apr-desktop-page.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index bed3cbe33..ab557d53d 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -227,7 +227,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) GtkWidget *label; GtkWidget *spacer; guint row = 0; - GFile *gfile; + GFile *gfile = NULL; gtk_container_set_border_width (GTK_CONTAINER (desktop_page), 12); -- GitLab From e6ce6c56538ecbd9c2195231d6d06c5c2a1a013b Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Fri, 25 Jun 2021 07:10:21 +0900 Subject: [PATCH 23/37] Temporary patch to match with current version of libxfce4ui --- plugins/thunar-apr/thunar-apr-desktop-page.c | 43 +++++++++++++++----- thunar/thunar-file.c | 2 +- thunar/thunar-gio-extensions.h | 1 + 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index ab557d53d..4a4aae3c2 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -50,7 +50,8 @@ #endif - +static void _xfce_gtk_label_set_a11y_relation (GtkLabel *label, + GtkWidget *widget); static void thunar_apr_desktop_page_finalize (GObject *object); static void thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, ThunarxFileInfo *file); @@ -122,6 +123,27 @@ THUNARX_DEFINE_TYPE (ThunarAprDesktopPage, +/* identical with non-underlined function */ +static void +_xfce_gtk_label_set_a11y_relation (GtkLabel *label, + GtkWidget *widget) +{ + AtkRelationSet *relations; + AtkRelation *relation; + AtkObject *object; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (GTK_IS_LABEL (label)); + + object = gtk_widget_get_accessible (widget); + relations = atk_object_ref_relation_set (gtk_widget_get_accessible (GTK_WIDGET (label))); + relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); + atk_relation_set_add (relations, relation); + g_object_unref (G_OBJECT (relation)); +} + + + static gboolean is_executable (GFile *gfile, GError **error) @@ -260,7 +282,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->description_entry); g_object_bind_property (G_OBJECT (desktop_page->description_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); + _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); row++; @@ -279,7 +301,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->command_entry); g_object_bind_property (G_OBJECT (desktop_page->command_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); + _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); row++; @@ -298,7 +320,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->path_entry); g_object_bind_property (G_OBJECT (desktop_page->path_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); + _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); row++; @@ -317,7 +339,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->url_entry); g_object_bind_property (G_OBJECT (desktop_page->url_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); + _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); row++; @@ -338,7 +360,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->comment_entry); g_object_bind_property (G_OBJECT (desktop_page->comment_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); + _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); row++; @@ -369,7 +391,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->snotify_button); g_object_bind_property (G_OBJECT (desktop_page->snotify_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); + _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); row++; @@ -381,7 +403,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->terminal_button); /* don't bind visibility with label */ - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); + _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); row++; @@ -401,7 +423,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->program_button); g_object_bind_property (G_OBJECT (desktop_page->program_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->program_button); + _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->program_button); row++; @@ -419,7 +441,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->trusted_button); g_object_bind_property (G_OBJECT (desktop_page->trusted_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->trusted_button); + _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->trusted_button); row++; } @@ -631,6 +653,7 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->program_button), executable); + trusted = TRUE; #ifdef __XFCE_GIO_EXTENSIONS_H__ if (desktop_page->trusted_button != NULL) { diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index c02d3eccf..864aa8d80 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1702,9 +1702,9 @@ thunar_file_execute (ThunarFile *file, exec = g_strconcat (escaped_location, " %F", NULL); command = xfce_expand_desktop_entry_field_codes (exec, uri_list, NULL, NULL, NULL, FALSE); result = g_shell_parse_argv (command, NULL, &argv, error); - g_free (command); g_free (escaped_location); g_free (exec); + g_free (command); } if (G_LIKELY (result && argv != NULL)) diff --git a/thunar/thunar-gio-extensions.h b/thunar/thunar-gio-extensions.h index a9491596c..5b183971d 100644 --- a/thunar/thunar-gio-extensions.h +++ b/thunar/thunar-gio-extensions.h @@ -93,6 +93,7 @@ gboolean thunar_g_app_info_should_show (GAppInfo *info) gboolean thunar_g_vfs_metadata_is_supported (void); + G_END_DECLS #endif /* !__THUNAR_GIO_EXTENSIONS_H__ */ -- GitLab From d0eeea00134d82c25de3db59e0963a7aabd9c243 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Fri, 25 Jun 2021 09:35:20 +0900 Subject: [PATCH 24/37] Add more explaination on tooltip --- plugins/thunar-apr/thunar-apr-desktop-page.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 4a4aae3c2..f506ae78f 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -433,7 +433,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) { /* same function as in thunar-permission-chooser.c */ desktop_page->trusted_button = gtk_check_button_new_with_mnemonic (_("Set this file as trusted")); - gtk_widget_set_tooltip_text (desktop_page->trusted_button, _("Select this option to trust this .desktop file.")); + gtk_widget_set_tooltip_text (desktop_page->trusted_button, _("Select this option to trust this .desktop file. This \"safety flag\" can assure that .desktop file is approved by a user and not by a program.")); g_signal_connect (G_OBJECT (desktop_page->trusted_button), "toggled", G_CALLBACK (thunar_apr_desktop_page_trusted_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->trusted_button, TRUE); -- GitLab From 4de436466a16a6e73b83808dd9b683327bccb1a9 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Fri, 25 Jun 2021 10:01:53 +0900 Subject: [PATCH 25/37] Prevent crash when built without safety flag support --- plugins/thunar-apr/thunar-apr-desktop-page.c | 29 +++++++++----------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index f506ae78f..268ba3551 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -249,7 +249,8 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) GtkWidget *label; GtkWidget *spacer; guint row = 0; - GFile *gfile = NULL; + GFile *gfile G_GNUC_UNUSED; + gboolean metadata_supported G_GNUC_UNUSED; gtk_container_set_border_width (GTK_CONTAINER (desktop_page), 12); @@ -429,7 +430,9 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) #ifdef __XFCE_GIO_EXTENSIONS_H__ gfile = g_file_new_for_uri ("file:///"); - if (xfce_g_file_metadata_is_supported (gfile)) + metadata_supported = xfce_g_file_metadata_is_supported (gfile); + g_object_unref (gfile); + if (metadata_supported) { /* same function as in thunar-permission-chooser.c */ desktop_page->trusted_button = gtk_check_button_new_with_mnemonic (_("Set this file as trusted")); @@ -452,8 +455,6 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) desktop_page->trusted_button = NULL; } - g_object_unref (gfile); - /* release shared bold Pango attributes */ pango_attr_list_unref (attr_list); } @@ -487,7 +488,7 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, gboolean writable; gboolean enabled; gboolean executable; - gboolean trusted; + gboolean trusted G_GNUC_UNUSED; GError *error = NULL; gchar *filename; gchar *value; @@ -642,7 +643,7 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, } /* update flags */ - gfile = thunarx_file_info_get_location (abstract_page->file);; + gfile = thunarx_file_info_get_location (abstract_page->file); g_signal_handlers_block_by_func (G_OBJECT (desktop_page->program_button), thunar_apr_desktop_page_program_toggled, desktop_page); executable = is_executable (gfile, &error); @@ -653,7 +654,6 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->program_button), executable); - trusted = TRUE; #ifdef __XFCE_GIO_EXTENSIONS_H__ if (desktop_page->trusted_button != NULL) { @@ -667,6 +667,7 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button), trusted); g_signal_handlers_unblock_by_func (G_OBJECT (desktop_page->trusted_button), thunar_apr_desktop_page_trusted_toggled, desktop_page); } + #else #endif /* __XFCE_GIO_EXTENSIONS_H__ */ g_signal_handlers_unblock_by_func (G_OBJECT (desktop_page->program_button), thunar_apr_desktop_page_program_toggled, desktop_page); @@ -1026,19 +1027,18 @@ thunar_apr_desktop_page_program_toggled (GtkWidget *button, set_executable (gfile, executable, &error); + g_object_unref (gfile); + if (error != NULL) { g_warning ("Error while setting execution flag : %s", error->message); g_free (error); - g_object_unref (gfile); return; } if (!executable && trusted) if (desktop_page->trusted_button != NULL) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button), FALSE); - - g_object_unref (gfile); } #ifdef __XFCE_GIO_EXTENSIONS_H__ @@ -1059,19 +1059,16 @@ thunar_apr_desktop_page_trusted_toggled (GtkWidget *button, gfile = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); executable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->program_button)); - - if (desktop_page->trusted_button != NULL) - trusted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)); - else - trusted = FALSE; + trusted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)); xfce_g_file_set_trusted (gfile, trusted, NULL, &error); + g_object_unref (gfile); + if (error != NULL) { g_warning ("Error while setting safety flag : %s", error->message); g_free (error); - g_object_unref (gfile); return; } -- GitLab From 255e636ccde8734bd35eae09682f36b318af52fb Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Fri, 25 Jun 2021 10:12:43 +0900 Subject: [PATCH 26/37] Show dialog when setting safety flag fails --- thunar/thunar-dialogs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index e9475dcfc..2232d403e 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -1086,7 +1086,7 @@ thunar_dialogs_show_insecure_program (gpointer parent, if (thunar_g_vfs_metadata_is_supported ()) if (!xfce_g_file_set_trusted (thunar_file_get_file (file), TRUE, NULL, &err)) { - g_warning ("Safety flag set failed: %s", err->message); + thunar_dialogs_show_error (parent, err, ("Unable to mark launcher as trusted")); g_clear_error (&err); } #endif /* __XFCE_GIO_EXTENSIONS_H__ */ -- GitLab From 1c19184dad31161e81becdd33b64035e705da694 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Fri, 25 Jun 2021 10:22:25 +0900 Subject: [PATCH 27/37] Optional support for xfce_gtk_label_set_a11y_relation() --- docs/reference/thunarx/thunarx.actions | 0 plugins/thunar-apr/thunar-apr-desktop-page.c | 10 +++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) delete mode 100644 docs/reference/thunarx/thunarx.actions diff --git a/docs/reference/thunarx/thunarx.actions b/docs/reference/thunarx/thunarx.actions deleted file mode 100644 index e69de29bb..000000000 diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 268ba3551..af234e6f5 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -123,7 +123,14 @@ THUNARX_DEFINE_TYPE (ThunarAprDesktopPage, -/* identical with non-underlined function */ +#if LIBXFCE4UI_CHECK_VERSION(4,16,1) +static inline void +_xfce_gtk_label_set_a11y_relation (GtkLabel *label, + GtkWidget *widget) +{ + xfce_gtk_label_set_a11y_relation (label, widget); +} +#else static void _xfce_gtk_label_set_a11y_relation (GtkLabel *label, GtkWidget *widget) @@ -141,6 +148,7 @@ _xfce_gtk_label_set_a11y_relation (GtkLabel *label, atk_relation_set_add (relations, relation); g_object_unref (G_OBJECT (relation)); } +#endif /* __XFCE_GIO_EXTENSIONS_H__ */ -- GitLab From c1a09d4ad6025c11deaa590acdbd9174b3c15a85 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Fri, 25 Jun 2021 11:23:58 +0900 Subject: [PATCH 28/37] Recalculate checksum on edit --- docs/reference/thunarx/thunarx.actions | 0 plugins/thunar-apr/thunar-apr-desktop-page.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 docs/reference/thunarx/thunarx.actions diff --git a/docs/reference/thunarx/thunarx.actions b/docs/reference/thunarx/thunarx.actions new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index af234e6f5..ba9c900c2 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -739,6 +739,10 @@ thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, gchar *uri; gsize data_length; FILE *fp; +#ifdef __XFCE_GIO_EXTENSIONS_H__ + GFile *gfile; + gboolean trusted; +#endif /* __XFCE_GIO_EXTENSIONS_H__ */ /* verify that we still have a valid file */ if (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file == NULL) @@ -776,6 +780,12 @@ thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, data = g_key_file_to_data (key_file, &data_length, &error); if (G_LIKELY (data_length > 0)) { + #ifdef __XFCE_GIO_EXTENSIONS_H__ + trusted = FALSE; + if (desktop_page->trusted_button != NULL) + trusted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)); + #endif /* __XFCE_GIO_EXTENSIONS_H__ */ + /* try to save the key file content to disk */ fp = fopen (filename, "w"); if (G_LIKELY (fp != NULL)) @@ -788,6 +798,16 @@ thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, { error = g_error_new_literal (G_FILE_ERROR, g_file_error_from_errno (errno), g_strerror (errno)); } + + #ifdef __XFCE_GIO_EXTENSIONS_H__ + /* Update safety flag checksum */ + if (trusted && error == NULL) + { + gfile = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); + xfce_g_file_set_trusted (gfile, trusted, NULL, &error); + g_object_unref (gfile); + } + #endif /* __XFCE_GIO_EXTENSIONS_H__ */ } /* cleanup */ -- GitLab From 04da71e0bf071e2d6d38d3f2f013c657ecde0cfd Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Mon, 28 Jun 2021 06:56:19 +0900 Subject: [PATCH 29/37] Remove guards --- plugins/thunar-apr/thunar-apr-desktop-page.c | 71 ++++---------------- 1 file changed, 13 insertions(+), 58 deletions(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index ba9c900c2..17f84458c 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -50,8 +50,7 @@ #endif -static void _xfce_gtk_label_set_a11y_relation (GtkLabel *label, - GtkWidget *widget); + static void thunar_apr_desktop_page_finalize (GObject *object); static void thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, ThunarxFileInfo *file); @@ -69,10 +68,8 @@ static void thunar_apr_desktop_page_toggled (GtkWidget ThunarAprDesktopPage *desktop_page); static void thunar_apr_desktop_page_program_toggled (GtkWidget *button, ThunarAprDesktopPage *desktop_page); -#ifdef __XFCE_GIO_EXTENSIONS_H__ static void thunar_apr_desktop_page_trusted_toggled (GtkWidget *button, ThunarAprDesktopPage *desktop_page); -#endif /* __XFCE_GIO_EXTENSIONS_H__ */ static gboolean is_executable (GFile *gfile, GError **error); static gboolean set_executable (GFile *gfile, @@ -123,35 +120,6 @@ THUNARX_DEFINE_TYPE (ThunarAprDesktopPage, -#if LIBXFCE4UI_CHECK_VERSION(4,16,1) -static inline void -_xfce_gtk_label_set_a11y_relation (GtkLabel *label, - GtkWidget *widget) -{ - xfce_gtk_label_set_a11y_relation (label, widget); -} -#else -static void -_xfce_gtk_label_set_a11y_relation (GtkLabel *label, - GtkWidget *widget) -{ - AtkRelationSet *relations; - AtkRelation *relation; - AtkObject *object; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (GTK_IS_LABEL (label)); - - object = gtk_widget_get_accessible (widget); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (GTK_WIDGET (label))); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); -} -#endif /* __XFCE_GIO_EXTENSIONS_H__ */ - - - static gboolean is_executable (GFile *gfile, GError **error) @@ -257,8 +225,8 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) GtkWidget *label; GtkWidget *spacer; guint row = 0; - GFile *gfile G_GNUC_UNUSED; - gboolean metadata_supported G_GNUC_UNUSED; + GFile *gfile; + gboolean metadata_supported; gtk_container_set_border_width (GTK_CONTAINER (desktop_page), 12); @@ -291,7 +259,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->description_entry); g_object_bind_property (G_OBJECT (desktop_page->description_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); row++; @@ -310,7 +278,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->command_entry); g_object_bind_property (G_OBJECT (desktop_page->command_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); row++; @@ -329,7 +297,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->path_entry); g_object_bind_property (G_OBJECT (desktop_page->path_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); row++; @@ -348,7 +316,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->url_entry); g_object_bind_property (G_OBJECT (desktop_page->url_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); row++; @@ -369,7 +337,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->comment_entry); g_object_bind_property (G_OBJECT (desktop_page->comment_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); row++; @@ -400,7 +368,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->snotify_button); g_object_bind_property (G_OBJECT (desktop_page->snotify_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); row++; @@ -412,7 +380,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->terminal_button); /* don't bind visibility with label */ - _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); row++; @@ -432,11 +400,10 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->program_button); g_object_bind_property (G_OBJECT (desktop_page->program_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->program_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->program_button); row++; - #ifdef __XFCE_GIO_EXTENSIONS_H__ gfile = g_file_new_for_uri ("file:///"); metadata_supported = xfce_g_file_metadata_is_supported (gfile); g_object_unref (gfile); @@ -452,12 +419,11 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->trusted_button); g_object_bind_property (G_OBJECT (desktop_page->trusted_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - _xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->trusted_button); + xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->trusted_button); row++; } else - #endif /* __XFCE_GIO_EXTENSIONS_H__ */ { g_info ("metadata not supported"); desktop_page->trusted_button = NULL; @@ -496,7 +462,7 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, gboolean writable; gboolean enabled; gboolean executable; - gboolean trusted G_GNUC_UNUSED; + gboolean trusted; GError *error = NULL; gchar *filename; gchar *value; @@ -662,7 +628,6 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->program_button), executable); - #ifdef __XFCE_GIO_EXTENSIONS_H__ if (desktop_page->trusted_button != NULL) { g_signal_handlers_block_by_func (G_OBJECT (desktop_page->trusted_button), thunar_apr_desktop_page_trusted_toggled, desktop_page); @@ -675,8 +640,6 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button), trusted); g_signal_handlers_unblock_by_func (G_OBJECT (desktop_page->trusted_button), thunar_apr_desktop_page_trusted_toggled, desktop_page); } - #else - #endif /* __XFCE_GIO_EXTENSIONS_H__ */ g_signal_handlers_unblock_by_func (G_OBJECT (desktop_page->program_button), thunar_apr_desktop_page_program_toggled, desktop_page); g_object_unref (gfile); @@ -739,10 +702,8 @@ thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, gchar *uri; gsize data_length; FILE *fp; -#ifdef __XFCE_GIO_EXTENSIONS_H__ GFile *gfile; gboolean trusted; -#endif /* __XFCE_GIO_EXTENSIONS_H__ */ /* verify that we still have a valid file */ if (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file == NULL) @@ -780,11 +741,9 @@ thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, data = g_key_file_to_data (key_file, &data_length, &error); if (G_LIKELY (data_length > 0)) { - #ifdef __XFCE_GIO_EXTENSIONS_H__ trusted = FALSE; if (desktop_page->trusted_button != NULL) trusted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)); - #endif /* __XFCE_GIO_EXTENSIONS_H__ */ /* try to save the key file content to disk */ fp = fopen (filename, "w"); @@ -799,7 +758,6 @@ thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, error = g_error_new_literal (G_FILE_ERROR, g_file_error_from_errno (errno), g_strerror (errno)); } - #ifdef __XFCE_GIO_EXTENSIONS_H__ /* Update safety flag checksum */ if (trusted && error == NULL) { @@ -807,7 +765,6 @@ thunar_apr_desktop_page_save (ThunarAprDesktopPage *desktop_page, xfce_g_file_set_trusted (gfile, trusted, NULL, &error); g_object_unref (gfile); } - #endif /* __XFCE_GIO_EXTENSIONS_H__ */ } /* cleanup */ @@ -1069,7 +1026,6 @@ thunar_apr_desktop_page_program_toggled (GtkWidget *button, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button), FALSE); } -#ifdef __XFCE_GIO_EXTENSIONS_H__ static void thunar_apr_desktop_page_trusted_toggled (GtkWidget *button, ThunarAprDesktopPage *desktop_page) @@ -1103,4 +1059,3 @@ thunar_apr_desktop_page_trusted_toggled (GtkWidget *button, if (!executable && trusted) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->program_button), TRUE); } -#endif /* __XFCE_GIO_EXTENSIONS_H__ */ -- GitLab From 3feacdf174ad38fd69609953ace16462f5223dce Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Mon, 28 Jun 2021 07:29:31 +0900 Subject: [PATCH 30/37] Remove outdated comment --- plugins/thunar-apr/thunar-apr-desktop-page.c | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 17f84458c..bda9a55f6 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -390,7 +390,6 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); - /* same function as in thunar-permission-chooser.c */ desktop_page->program_button = gtk_check_button_new_with_mnemonic (_("Allow this file to _run as a .desktop file")); gtk_widget_set_tooltip_text (desktop_page->program_button, _("If not selected, .desktop file will be considered as a normal text file.")); g_signal_connect (G_OBJECT (desktop_page->program_button), "toggled", -- GitLab From 2c369953bc68da238b31f5e23232cb44c4aa44c4 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Mon, 28 Jun 2021 07:31:09 +0900 Subject: [PATCH 31/37] Update hover text --- plugins/thunar-apr/thunar-apr-desktop-page.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index bda9a55f6..cb6b0f0f2 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -391,7 +391,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (label); desktop_page->program_button = gtk_check_button_new_with_mnemonic (_("Allow this file to _run as a .desktop file")); - gtk_widget_set_tooltip_text (desktop_page->program_button, _("If not selected, .desktop file will be considered as a normal text file.")); + gtk_widget_set_tooltip_text (desktop_page->program_button, _("Select this option to trust this .desktop file. This will generate a checksum of the file and store it via gvfs. The additional check will protect from malicious launchers which e.g. pretend to be a picture, having the executable flag pre-set")); g_signal_connect (G_OBJECT (desktop_page->program_button), "toggled", G_CALLBACK (thunar_apr_desktop_page_program_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->program_button, TRUE); -- GitLab From f083f7d481da96b0c476c6c33a4293d1f21338c6 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Mon, 28 Jun 2021 07:35:38 +0900 Subject: [PATCH 32/37] Remove unncessary block --- plugins/thunar-apr/thunar-apr-desktop-page.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index cb6b0f0f2..2773a47d3 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -618,7 +618,6 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, /* update flags */ gfile = thunarx_file_info_get_location (abstract_page->file); - g_signal_handlers_block_by_func (G_OBJECT (desktop_page->program_button), thunar_apr_desktop_page_program_toggled, desktop_page); executable = is_executable (gfile, &error); if (error != NULL) { @@ -629,7 +628,6 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, if (desktop_page->trusted_button != NULL) { - g_signal_handlers_block_by_func (G_OBJECT (desktop_page->trusted_button), thunar_apr_desktop_page_trusted_toggled, desktop_page); trusted = xfce_g_file_is_trusted (gfile, NULL, &error); if (error != NULL) { @@ -637,9 +635,7 @@ thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page, g_clear_error (&error); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button), trusted); - g_signal_handlers_unblock_by_func (G_OBJECT (desktop_page->trusted_button), thunar_apr_desktop_page_trusted_toggled, desktop_page); } - g_signal_handlers_unblock_by_func (G_OBJECT (desktop_page->program_button), thunar_apr_desktop_page_program_toggled, desktop_page); g_object_unref (gfile); -- GitLab From f79f97241a227a27bcd205a0e6f7b1394039f147 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Mon, 28 Jun 2021 08:30:48 +0900 Subject: [PATCH 33/37] Readability --- docs/reference/thunarx/thunarx.actions | 0 plugins/thunar-apr/thunar-apr-desktop-page.c | 12 ++++-------- 2 files changed, 4 insertions(+), 8 deletions(-) delete mode 100644 docs/reference/thunarx/thunarx.actions diff --git a/docs/reference/thunarx/thunarx.actions b/docs/reference/thunarx/thunarx.actions deleted file mode 100644 index e69de29bb..000000000 diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 2773a47d3..040462acf 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -999,12 +999,6 @@ thunar_apr_desktop_page_program_toggled (GtkWidget *button, gfile = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); executable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->program_button)); - - if (desktop_page->trusted_button != NULL) - trusted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)); - else - trusted = FALSE; - set_executable (gfile, executable, &error); g_object_unref (gfile); @@ -1016,6 +1010,8 @@ thunar_apr_desktop_page_program_toggled (GtkWidget *button, return; } + trusted = (desktop_page->trusted_button != NULL) ? gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)) : FALSE; + /* if the executable flag is unset, that will as well unset the trusted flag */ if (!executable && trusted) if (desktop_page->trusted_button != NULL) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button), FALSE); @@ -1037,9 +1033,7 @@ thunar_apr_desktop_page_trusted_toggled (GtkWidget *button, gfile = thunarx_file_info_get_location (THUNAR_APR_ABSTRACT_PAGE (desktop_page)->file); - executable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->program_button)); trusted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->trusted_button)); - xfce_g_file_set_trusted (gfile, trusted, NULL, &error); g_object_unref (gfile); @@ -1051,6 +1045,8 @@ thunar_apr_desktop_page_trusted_toggled (GtkWidget *button, return; } + executable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (desktop_page->program_button)); + /* setting the trusted flag automatically sets the execute flag */ if (!executable && trusted) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (desktop_page->program_button), TRUE); } -- GitLab From 3e9145a910b1896b0c40e8fd884047977b1204fa Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Mon, 28 Jun 2021 09:15:06 +0900 Subject: [PATCH 34/37] Revert a11y_relation related changes --- docs/reference/thunarx/thunarx.actions | 0 plugins/thunar-apr/thunar-apr-desktop-page.c | 59 +++++++++++++++++--- 2 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 docs/reference/thunarx/thunarx.actions diff --git a/docs/reference/thunarx/thunarx.actions b/docs/reference/thunarx/thunarx.actions new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 040462acf..8872a0eaf 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -219,8 +219,11 @@ thunar_apr_desktop_page_class_init (ThunarAprDesktopPageClass *klass) static void thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) { + AtkRelationSet *relations; PangoAttribute *attribute; PangoAttrList *attr_list; + AtkRelation *relation; + AtkObject *object; GtkWidget *grid; GtkWidget *label; GtkWidget *spacer; @@ -259,7 +262,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->description_entry); g_object_bind_property (G_OBJECT (desktop_page->description_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->description_entry); + + /* set Atk label relation for the entry */ + object = gtk_widget_get_accessible (desktop_page->description_entry); + relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); + relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); + atk_relation_set_add (relations, relation); + g_object_unref (G_OBJECT (relation)); row++; @@ -278,7 +287,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->command_entry); g_object_bind_property (G_OBJECT (desktop_page->command_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->command_entry); + + /* set Atk label relation for the entry */ + object = gtk_widget_get_accessible (desktop_page->command_entry); + relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); + relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); + atk_relation_set_add (relations, relation); + g_object_unref (G_OBJECT (relation)); row++; @@ -297,7 +312,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->path_entry); g_object_bind_property (G_OBJECT (desktop_page->path_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->path_entry); + + /* set Atk label relation for the entry */ + object = gtk_widget_get_accessible (desktop_page->path_entry); + relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); + relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); + atk_relation_set_add (relations, relation); + g_object_unref (G_OBJECT (relation)); row++; @@ -316,7 +337,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->url_entry); g_object_bind_property (G_OBJECT (desktop_page->url_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->url_entry); + + /* set Atk label relation for the entry */ + object = gtk_widget_get_accessible (desktop_page->url_entry); + relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); + relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); + atk_relation_set_add (relations, relation); + g_object_unref (G_OBJECT (relation)); row++; @@ -337,7 +364,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->comment_entry); g_object_bind_property (G_OBJECT (desktop_page->comment_entry), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->comment_entry); + + /* set Atk label relation for the entry */ + object = gtk_widget_get_accessible (desktop_page->comment_entry); + relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); + relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); + atk_relation_set_add (relations, relation); + g_object_unref (G_OBJECT (relation)); row++; @@ -368,7 +401,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->snotify_button); g_object_bind_property (G_OBJECT (desktop_page->snotify_button), "visible", G_OBJECT (label), "visible", G_BINDING_SYNC_CREATE); - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->snotify_button); + + /* set Atk label relation for the buttons */ + relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); + object = gtk_widget_get_accessible (desktop_page->snotify_button); + relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); + atk_relation_set_add (relations, relation); + g_object_unref (G_OBJECT (relation)); row++; @@ -380,7 +419,13 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_widget_show (desktop_page->terminal_button); /* don't bind visibility with label */ - xfce_gtk_label_set_a11y_relation (GTK_LABEL (label), desktop_page->terminal_button); + + /* set Atk label relation for the buttons */ + relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); + object = gtk_widget_get_accessible (desktop_page->terminal_button); + relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); + atk_relation_set_add (relations, relation); + g_object_unref (G_OBJECT (relation)); row++; -- GitLab From 707a22b55db65ea5d91a2507ed3dc92edb745ae3 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Tue, 29 Jun 2021 08:50:45 +0900 Subject: [PATCH 35/37] Remove all guards --- plugins/thunar-apr/thunar-apr-desktop-page.c | 1 + thunar/thunar-dialogs.c | 2 -- thunar/thunar-file.c | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 8872a0eaf..2d404fa54 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -435,6 +435,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1); gtk_widget_show (label); + /* same function as in thunar-permission-chooser.c */ desktop_page->program_button = gtk_check_button_new_with_mnemonic (_("Allow this file to _run as a .desktop file")); gtk_widget_set_tooltip_text (desktop_page->program_button, _("Select this option to trust this .desktop file. This will generate a checksum of the file and store it via gvfs. The additional check will protect from malicious launchers which e.g. pretend to be a picture, having the executable flag pre-set")); g_signal_connect (G_OBJECT (desktop_page->program_button), "toggled", diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index 2232d403e..e3c4ec750 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -1082,14 +1082,12 @@ thunar_dialogs_show_insecure_program (gpointer parent, g_clear_error (&err); } - #ifdef __XFCE_GIO_EXTENSIONS_H__ if (thunar_g_vfs_metadata_is_supported ()) if (!xfce_g_file_set_trusted (thunar_file_get_file (file), TRUE, NULL, &err)) { thunar_dialogs_show_error (parent, err, ("Unable to mark launcher as trusted")); g_clear_error (&err); } - #endif /* __XFCE_GIO_EXTENSIONS_H__ */ /* just launch */ response = GTK_RESPONSE_OK; diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 864aa8d80..93f453b89 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1609,10 +1609,8 @@ thunar_file_execute (ThunarFile *file, if (thunar_file_is_desktop_file (file, &is_secure)) { - #ifdef __XFCE_GIO_EXTENSIONS_H__ if (thunar_g_vfs_metadata_is_supported ()) is_secure = is_secure && xfce_g_file_is_trusted (file->gfile, NULL, NULL); - #endif /* __XFCE_GIO_EXTENSIONS_H__ */ /* parse file first, even if it is insecure */ key_file = thunar_g_file_query_key_file (file->gfile, NULL, &err); -- GitLab From 479d26b07e5e863022fd67c5e273d4de82d8044d Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Tue, 29 Jun 2021 08:52:29 +0900 Subject: [PATCH 36/37] Update dependency Require Exo/libxfce4ui/libxfce4util 4.17.0 --- configure.ac.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac.in b/configure.ac.in index 7f3cb4937..cf90f673f 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -145,15 +145,15 @@ GTK_DOC_CHECK([1.9]) dnl *********************************** dnl *** Check for required packages *** dnl *********************************** -XDT_CHECK_PACKAGE([EXO], [exo-2], [4.15.3]) +XDT_CHECK_PACKAGE([EXO], [exo-2], [4.17.0]) XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.50.0]) XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.50.0]) XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.50.0]) XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [2.50.0]) XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.22.0]) XDT_CHECK_PACKAGE([GDK_PIXBUF], [gdk-pixbuf-2.0], [2.14.0]) -XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.15.2]) -XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.15.3]) +XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.17.0]) +XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.17.0]) XDT_CHECK_PACKAGE([LIBXFCE4KBD_PRIVATE], [libxfce4kbd-private-3], [4.12.0]) XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.12.0]) XDT_CHECK_PACKAGE([PANGO], [pango], [1.38.0]) -- GitLab From 57a3d79c949b8061a61d803c4fae2ef628fbe940 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Wed, 30 Jun 2021 11:37:24 +0900 Subject: [PATCH 37/37] Rewrite tooltip --- plugins/thunar-apr/thunar-apr-desktop-page.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c index 2d404fa54..9b820f4de 100644 --- a/plugins/thunar-apr/thunar-apr-desktop-page.c +++ b/plugins/thunar-apr/thunar-apr-desktop-page.c @@ -437,7 +437,7 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) /* same function as in thunar-permission-chooser.c */ desktop_page->program_button = gtk_check_button_new_with_mnemonic (_("Allow this file to _run as a .desktop file")); - gtk_widget_set_tooltip_text (desktop_page->program_button, _("Select this option to trust this .desktop file. This will generate a checksum of the file and store it via gvfs. The additional check will protect from malicious launchers which e.g. pretend to be a picture, having the executable flag pre-set")); + gtk_widget_set_tooltip_text (desktop_page->program_button, _("Select this to enable executable permission bit(+x). Thunar will not launch the .desktop file if not set.")); g_signal_connect (G_OBJECT (desktop_page->program_button), "toggled", G_CALLBACK (thunar_apr_desktop_page_program_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->program_button, TRUE); @@ -454,9 +454,8 @@ thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page) g_object_unref (gfile); if (metadata_supported) { - /* same function as in thunar-permission-chooser.c */ desktop_page->trusted_button = gtk_check_button_new_with_mnemonic (_("Set this file as trusted")); - gtk_widget_set_tooltip_text (desktop_page->trusted_button, _("Select this option to trust this .desktop file. This \"safety flag\" can assure that .desktop file is approved by a user and not by a program.")); + gtk_widget_set_tooltip_text (desktop_page->trusted_button, _("Select this option to trust this .desktop file. This will generate a checksum of the file and store it via gvfs. The additional check will protect from malicious launchers which e.g. pretend to be a picture, having the executable flag pre-set")); g_signal_connect (G_OBJECT (desktop_page->trusted_button), "toggled", G_CALLBACK (thunar_apr_desktop_page_trusted_toggled), desktop_page); gtk_widget_set_hexpand (desktop_page->trusted_button, TRUE); -- GitLab