From 4bdf968702ffb275aa5c96bea17e6330265050f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Fernandes?= Date: Sat, 24 Nov 2018 00:31:07 +0000 Subject: [PATCH 1/2] placesview: Set .error style if unsupported protocol When the user types an address with a schema that is not supported, the Connect button doesn't become sensitive, but there is no visible feedback at all. This feels unresponsive and leaves the user clueless. While it doesn't help explain why the address doesn't work, this will provide a hint that the input was acknowledged but doesn't work. https://gitlab.gnome.org/GNOME/gtk/issues/1476 --- gtk/gtkplacesview.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c index 7401245da3..14b568dce4 100644 --- a/gtk/gtkplacesview.c +++ b/gtk/gtkplacesview.c @@ -1855,6 +1855,13 @@ on_address_entry_text_changed (GtkPlacesView *view) out: gtk_widget_set_sensitive (priv->connect_button, supported); + if (scheme && !supported) + gtk_style_context_add_class (gtk_widget_get_style_context (priv->address_entry), + GTK_STYLE_CLASS_ERROR); + else + gtk_style_context_remove_class (gtk_widget_get_style_context (priv->address_entry), + GTK_STYLE_CLASS_ERROR); + g_free (address); g_free (scheme); } From bb3653ad7d6f092467ad1d8ca89910eecb809133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Fernandes?= Date: Sat, 24 Nov 2018 01:49:43 +0000 Subject: [PATCH 2/2] placesview: List only available protocols as available We display a list of supported protocols in the server_addresses_popover. However, this curated list contains protocols which may or may not be available, depending on the respective gvfs backend being installed. So, populate the list only with protocols which are available. https://gitlab.gnome.org/GNOME/gtk/issues/1476 --- gtk/gtkplacesview.c | 52 ++++++++++++++++ gtk/ui/gtkplacesview.ui | 134 +--------------------------------------- 2 files changed, 53 insertions(+), 133 deletions(-) diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c index 14b568dce4..96ddeaedc8 100644 --- a/gtk/gtkplacesview.c +++ b/gtk/gtkplacesview.c @@ -72,6 +72,7 @@ struct _GtkPlacesViewPrivate GtkWidget *recent_servers_stack; GtkWidget *stack; GtkWidget *server_adresses_popover; + GtkWidget *available_protocols_grid; GtkWidget *network_placeholder; GtkWidget *network_placeholder_label; @@ -1605,6 +1606,54 @@ unmount_cb (GtkMenuItem *item, unmount_mount (GTK_PLACES_VIEW (view), mount); } +static void +attach_protocol_row_to_grid (GtkGrid *grid, + const gchar *protocol_name, + const gchar *protocol_prefix) +{ + GtkWidget *name_label; + GtkWidget *prefix_label; + + name_label = gtk_label_new (protocol_name); + gtk_widget_set_halign (name_label, GTK_ALIGN_START); + gtk_grid_attach_next_to (grid, name_label, NULL, GTK_POS_BOTTOM, 1, 1); + + prefix_label = gtk_label_new (protocol_prefix); + gtk_widget_set_halign (prefix_label, GTK_ALIGN_START); + gtk_grid_attach_next_to (grid, prefix_label, name_label, GTK_POS_RIGHT, 1, 1); +} + +static void +populate_available_protocols_grid (GtkGrid *grid) +{ + const gchar* const *supported_protocols; + + supported_protocols = g_vfs_get_supported_uri_schemes (g_vfs_get_default ()); + + if (g_strv_contains (supported_protocols, "afp")) + attach_protocol_row_to_grid (grid, _("AppleTalk"), "afp://"); + + if (g_strv_contains (supported_protocols, "ftp")) + /* Translators: do not translate ftp:// and ftps:// */ + attach_protocol_row_to_grid (grid, _("File Transfer Protocol"), _("ftp:// or ftps://")); + + if (g_strv_contains (supported_protocols, "nfs")) + attach_protocol_row_to_grid (grid, _("Network File System"), "nfs://"); + + if (g_strv_contains (supported_protocols, "smb")) + attach_protocol_row_to_grid (grid, _("Samba"), "smb://"); + + if (g_strv_contains (supported_protocols, "ssh")) + /* Translators: do not translate sftp:// and ssh:// */ + attach_protocol_row_to_grid (grid, _("SSH File Transfer Protocol"), _("sftp:// or ssh://")); + + if (g_strv_contains (supported_protocols, "dav")) + /* Translators: do not translate dav:// and davs:// */ + attach_protocol_row_to_grid (grid, _("WebDAV"), _("dav:// or davs://")); + + gtk_widget_show_all (GTK_WIDGET (grid)); +} + /* Constructs the popup menu if needed */ static void build_popup_menu (GtkPlacesView *view, @@ -2309,6 +2358,7 @@ gtk_places_view_class_init (GtkPlacesViewClass *klass) gtk_widget_class_bind_template_child_private (widget_class, GtkPlacesView, recent_servers_stack); gtk_widget_class_bind_template_child_private (widget_class, GtkPlacesView, stack); gtk_widget_class_bind_template_child_private (widget_class, GtkPlacesView, server_adresses_popover); + gtk_widget_class_bind_template_child_private (widget_class, GtkPlacesView, available_protocols_grid); gtk_widget_class_bind_template_callback (widget_class, on_address_entry_text_changed); gtk_widget_class_bind_template_callback (widget_class, on_address_entry_show_help_pressed); @@ -2333,6 +2383,8 @@ gtk_places_view_init (GtkPlacesView *self) priv->space_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); gtk_widget_init_template (GTK_WIDGET (self)); + + populate_available_protocols_grid (GTK_GRID (priv->available_protocols_grid)); } /** diff --git a/gtk/ui/gtkplacesview.ui b/gtk/ui/gtkplacesview.ui index 5990c78406..5ede5900ba 100644 --- a/gtk/ui/gtkplacesview.ui +++ b/gtk/ui/gtkplacesview.ui @@ -65,7 +65,7 @@ - + 1 12 1 @@ -86,72 +86,6 @@ 0 - - - 1 - AppleTalk - 0 - - - 0 - 1 - - - - - 1 - File Transfer Protocol - 0 - - - 0 - 2 - - - - - 1 - Network File System - 0 - - - 0 - 3 - - - - - 1 - Samba - 0 - - - 0 - 4 - - - - - 1 - SSH File Transfer Protocol - 0 - - - 0 - 5 - - - - - 1 - WebDAV - 0 - - - 0 - 6 - - 1 @@ -166,72 +100,6 @@ 0 - - - 1 - afp:// - 0 - - - 1 - 1 - - - - - 1 - ftp:// or ftps:// - 0 - - - 1 - 2 - - - - - 1 - nfs:// - 0 - - - 1 - 3 - - - - - 1 - smb:// - 0 - - - 1 - 4 - - - - - 1 - sftp:// or ssh:// - 0 - - - 1 - 5 - - - - - 1 - dav:// or davs:// - 0 - - - 1 - 6 - - 3