From: Georges Basile Stavracas Neto Date: Mon, 10 Apr 2017 21:59:33 +0000 (-0300) Subject: places-view: monitor network X-Git-Tag: archive/raspbian/3.24.39-1+rpi1~1^2~65^2~39^2~629 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=dfb5d11a53249bfeb03fac7ec201439d7d9e3d2f;p=gtk%2B3.0.git places-view: monitor network GtkPlacesView exposes local access points and network shares transparently by using the 'network:///' URI, which is handled by GIO. Currently, however, it doesn't monitor the network for new available points, such as computers that just join the network. It may happen too that the backend won't find all the networks before the network enumeration finishes. Fix that by keeping a file monitor inspecting the network uri, and update the places list when that happens. https://bugzilla.gnome.org/show_bug.cgi?id=781162 --- diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c index 15d95ccec2..f4437b73fc 100644 --- a/gtk/gtkplacesview.c +++ b/gtk/gtkplacesview.c @@ -56,6 +56,7 @@ struct _GtkPlacesViewPrivate GFile *server_list_file; GFileMonitor *server_list_monitor; + GFileMonitor *network_monitor; GCancellable *cancellable; @@ -397,6 +398,7 @@ gtk_places_view_destroy (GtkWidget *widget) priv->destroyed = 1; g_signal_handlers_disconnect_by_func (priv->volume_monitor, update_places, widget); + g_signal_handlers_disconnect_by_func (priv->network_monitor, update_places, widget); g_cancellable_cancel (priv->cancellable); g_cancellable_cancel (priv->networks_fetching_cancellable); @@ -417,6 +419,7 @@ gtk_places_view_finalize (GObject *object) g_clear_object (&priv->server_list_file); g_clear_object (&priv->server_list_monitor); g_clear_object (&priv->volume_monitor); + g_clear_object (&priv->network_monitor); g_clear_object (&priv->cancellable); g_clear_object (&priv->networks_fetching_cancellable); g_clear_object (&priv->path_size_group); @@ -901,6 +904,40 @@ update_network_state (GtkPlacesView *view) } } +static void +monitor_network (GtkPlacesView *self) +{ + GtkPlacesViewPrivate *priv; + GFile *network_file; + GError *error; + + priv = gtk_places_view_get_instance_private (self); + + if (priv->network_monitor) + return; + + error = NULL; + network_file = g_file_new_for_uri ("network:///"); + priv->network_monitor = g_file_monitor (network_file, + G_FILE_MONITOR_NONE, + NULL, + &error); + + g_clear_object (&network_file); + + if (error) + { + g_warning ("Error monitoring network: %s", error->message); + g_clear_error (&error); + return; + } + + g_signal_connect_swapped (priv->network_monitor, + "changed", + G_CALLBACK (update_places), + self); +} + static void populate_networks (GtkPlacesView *view, GFileEnumerator *enumerator, @@ -974,6 +1011,7 @@ network_enumeration_next_files_finished (GObject *source_object, if (!priv->destroyed) { update_network_state (view); + monitor_network (view); update_loading (view); } }