sharing: Add shortcut to open the Public folder in the "File Sharing" dialog

Add a shortcut to open the Public folder in the File Sharing dialog,
as this folder is crucial for the file sharing functionality. Also,
this change improves the discoverability of that folder and offers a
convenience of opening it directly from the dialog.
This commit is contained in:
Automeris naranja 2024-05-14 13:13:11 -03:00 committed by Matthijs Velsink
parent fa2cf5a5f2
commit 90e7a9cfd3
2 changed files with 29 additions and 0 deletions

View file

@ -111,6 +111,22 @@ on_copy_personal_file_sharing_address_clicked (CcSharingPanel *self)
adw_toast_overlay_add_toast (self->personal_file_sharing_toast_overlay, adw_toast_new (_("Address copied to clipboard")));
}
static void
on_public_folder_row_clicked (CcSharingPanel *self)
{
GtkWidget *toplevel;
g_autoptr(GFile) file = NULL;
g_autoptr(GtkFileLauncher) launcher = NULL;
const char *public_folder_uri;
public_folder_uri = g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE);
file = g_file_new_for_path (public_folder_uri);
launcher = gtk_file_launcher_new (file);
toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (self)));
gtk_file_launcher_launch (launcher, GTK_WINDOW (toplevel), NULL, NULL, NULL);
}
static void
cc_sharing_panel_class_init (CcSharingPanelClass *klass)
{
@ -142,6 +158,7 @@ cc_sharing_panel_class_init (CcSharingPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, shared_folders_listbox);
gtk_widget_class_bind_template_callback (widget_class, on_copy_personal_file_sharing_address_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_public_folder_row_clicked);
g_type_ensure (CC_TYPE_LIST_ROW);
g_type_ensure (CC_TYPE_HOSTNAME_ENTRY);

View file

@ -95,6 +95,18 @@
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwButtonRow">
<property name="title" translatable="yes">_Open Public Folder</property>
<property name="end-icon-name">adw-external-link-symbolic</property>
<property name="use-underline">True</property>
<signal name="activated" handler="on_public_folder_row_clicked" object="CcSharingPanel" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<child>