summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2017-04-22 19:12:45 +0200
committerCarlos Soriano <csoriano@gnome.org>2017-04-22 19:12:45 +0200
commit450aafda3e482ce55b0ab7695873e4439ffc3f53 (patch)
tree09b65423c2b0cf6b2d82960a9fe18840b15bae3e
parent2d6378e28013ebcdaaeaf348d385d717875bf3a2 (diff)
downloadnautilus-wip/csoriano/nautilus-3.24.1.tar.gz
update to last gtk+wip/csoriano/nautilus-3.24.1
-rw-r--r--src/gtk/nautilusgtkplacesview.c3180
-rw-r--r--src/gtk/nautilusgtkplacesview.ui51
-rw-r--r--src/gtk/nautilusgtkplacesviewrow.c611
-rw-r--r--src/gtk/nautilusgtkplacesviewrow.ui2
4 files changed, 1794 insertions, 2050 deletions
diff --git a/src/gtk/nautilusgtkplacesview.c b/src/gtk/nautilusgtkplacesview.c
index 523008b7d..4eb027576 100644
--- a/src/gtk/nautilusgtkplacesview.c
+++ b/src/gtk/nautilusgtkplacesview.c
@@ -27,7 +27,7 @@
#include "nautilusgtkplacesviewprivate.h"
#include "nautilusgtkplacesviewrowprivate.h"
-/**
+/*
* SECTION:nautilusgtkplacesview
* @Short_description: Widget that displays persistent drives and manages mounted networks
* @Title: NautilusGtkPlacesView
@@ -49,360 +49,340 @@
struct _NautilusGtkPlacesViewPrivate
{
- GVolumeMonitor *volume_monitor;
- GtkPlacesOpenFlags open_flags;
- GtkPlacesOpenFlags current_open_flags;
-
- GFile *server_list_file;
- GFileMonitor *server_list_monitor;
- GFileMonitor *network_monitor;
-
- GCancellable *cancellable;
-
- gchar *search_query;
-
- GtkWidget *actionbar;
- GtkWidget *address_entry;
- GtkWidget *connect_button;
- GtkWidget *listbox;
- GtkWidget *popup_menu;
- GtkWidget *recent_servers_listbox;
- GtkWidget *recent_servers_popover;
- GtkWidget *recent_servers_stack;
- GtkWidget *stack;
- GtkWidget *server_adresses_popover;
- GtkWidget *network_placeholder;
- GtkWidget *network_placeholder_label;
-
- GtkSizeGroup *path_size_group;
- GtkSizeGroup *space_size_group;
-
- GtkEntryCompletion *address_entry_completion;
- GtkListStore *completion_store;
-
- GCancellable *networks_fetching_cancellable;
-
- guint local_only : 1;
- guint should_open_location : 1;
- guint should_pulse_entry : 1;
- guint entry_pulse_timeout_id;
- guint connecting_to_server : 1;
- guint mounting_volume : 1;
- guint unmounting_mount : 1;
- guint fetching_networks : 1;
- guint loading : 1;
- guint destroyed : 1;
+ GVolumeMonitor *volume_monitor;
+ GtkPlacesOpenFlags open_flags;
+ GtkPlacesOpenFlags current_open_flags;
+
+ GFile *server_list_file;
+ GFileMonitor *server_list_monitor;
+ GFileMonitor *network_monitor;
+
+ GCancellable *cancellable;
+
+ gchar *search_query;
+
+ GtkWidget *actionbar;
+ GtkWidget *address_entry;
+ GtkWidget *connect_button;
+ GtkWidget *listbox;
+ GtkWidget *popup_menu;
+ GtkWidget *recent_servers_listbox;
+ GtkWidget *recent_servers_popover;
+ GtkWidget *recent_servers_stack;
+ GtkWidget *stack;
+ GtkWidget *server_adresses_popover;
+ GtkWidget *network_placeholder;
+ GtkWidget *network_placeholder_label;
+
+ GtkSizeGroup *path_size_group;
+ GtkSizeGroup *space_size_group;
+
+ GtkEntryCompletion *address_entry_completion;
+ GtkListStore *completion_store;
+
+ GCancellable *networks_fetching_cancellable;
+
+ guint local_only : 1;
+ guint should_open_location : 1;
+ guint should_pulse_entry : 1;
+ guint entry_pulse_timeout_id;
+ guint connecting_to_server : 1;
+ guint mounting_volume : 1;
+ guint unmounting_mount : 1;
+ guint fetching_networks : 1;
+ guint loading : 1;
+ guint destroyed : 1;
};
-static void mount_volume (NautilusGtkPlacesView *view,
- GVolume *volume);
+static void mount_volume (NautilusGtkPlacesView *view,
+ GVolume *volume);
-static gboolean on_button_press_event (NautilusGtkPlacesViewRow *row,
- GdkEventButton *event);
+static gboolean on_button_press_event (NautilusGtkPlacesViewRow *row,
+ GdkEventButton *event);
-static void on_eject_button_clicked (GtkWidget *widget,
- NautilusGtkPlacesViewRow *row);
+static void on_eject_button_clicked (GtkWidget *widget,
+ NautilusGtkPlacesViewRow *row);
-static gboolean on_row_popup_menu (NautilusGtkPlacesViewRow *row);
+static gboolean on_row_popup_menu (NautilusGtkPlacesViewRow *row);
-static void populate_servers (NautilusGtkPlacesView *view);
+static void populate_servers (NautilusGtkPlacesView *view);
-static gboolean nautilus_gtk_places_view_get_fetching_networks (NautilusGtkPlacesView *view);
+static gboolean nautilus_gtk_places_view_get_fetching_networks (NautilusGtkPlacesView *view);
-static void nautilus_gtk_places_view_set_fetching_networks (NautilusGtkPlacesView *view,
- gboolean fetching_networks);
+static void nautilus_gtk_places_view_set_fetching_networks (NautilusGtkPlacesView *view,
+ gboolean fetching_networks);
-static void nautilus_gtk_places_view_set_loading (NautilusGtkPlacesView *view,
- gboolean loading);
+static void nautilus_gtk_places_view_set_loading (NautilusGtkPlacesView *view,
+ gboolean loading);
-static void update_loading (NautilusGtkPlacesView *view);
+static void update_loading (NautilusGtkPlacesView *view);
G_DEFINE_TYPE_WITH_PRIVATE (NautilusGtkPlacesView, nautilus_gtk_places_view, GTK_TYPE_BOX)
/* NautilusGtkPlacesView properties & signals */
-enum
-{
- PROP_0,
- PROP_LOCAL_ONLY,
- PROP_OPEN_FLAGS,
- PROP_FETCHING_NETWORKS,
- PROP_LOADING,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_LOCAL_ONLY,
+ PROP_OPEN_FLAGS,
+ PROP_FETCHING_NETWORKS,
+ PROP_LOADING,
+ LAST_PROP
};
-enum
-{
- OPEN_LOCATION,
- SHOW_ERROR_MESSAGE,
- LAST_SIGNAL
+enum {
+ OPEN_LOCATION,
+ SHOW_ERROR_MESSAGE,
+ LAST_SIGNAL
};
const gchar *unsupported_protocols [] =
{
- "file", "afc", "obex", "http",
- "trash", "burn", "computer",
- "archive", "recent", "localtest",
- NULL
+ "file", "afc", "obex", "http",
+ "trash", "burn", "computer",
+ "archive", "recent", "localtest",
+ NULL
};
static guint places_view_signals [LAST_SIGNAL] = { 0 };
static GParamSpec *properties [LAST_PROP];
static void
-emit_open_location (NautilusGtkPlacesView *view,
- GFile *location,
- GtkPlacesOpenFlags open_flags)
+emit_open_location (NautilusGtkPlacesView *view,
+ GFile *location,
+ GtkPlacesOpenFlags open_flags)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- if ((open_flags & priv->open_flags) == 0)
- {
- open_flags = GTK_PLACES_OPEN_NORMAL;
- }
+ if ((open_flags & priv->open_flags) == 0)
+ open_flags = GTK_PLACES_OPEN_NORMAL;
- g_signal_emit (view, places_view_signals[OPEN_LOCATION], 0, location, open_flags);
+ g_signal_emit (view, places_view_signals[OPEN_LOCATION], 0, location, open_flags);
}
static void
emit_show_error_message (NautilusGtkPlacesView *view,
- gchar *primary_message,
- gchar *secondary_message)
+ gchar *primary_message,
+ gchar *secondary_message)
{
- g_signal_emit (view, places_view_signals[SHOW_ERROR_MESSAGE],
- 0, primary_message, secondary_message);
+ g_signal_emit (view, places_view_signals[SHOW_ERROR_MESSAGE],
+ 0, primary_message, secondary_message);
}
static void
server_file_changed_cb (NautilusGtkPlacesView *view)
{
- populate_servers (view);
+ populate_servers (view);
}
static GBookmarkFile *
server_list_load (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
- GBookmarkFile *bookmarks;
- GError *error = NULL;
- gchar *datadir;
- gchar *filename;
+ NautilusGtkPlacesViewPrivate *priv;
+ GBookmarkFile *bookmarks;
+ GError *error = NULL;
+ gchar *datadir;
+ gchar *filename;
- priv = nautilus_gtk_places_view_get_instance_private (view);
- bookmarks = g_bookmark_file_new ();
- datadir = g_build_filename (g_get_user_config_dir (), "gtk-3.0", NULL);
- filename = g_build_filename (datadir, "servers", NULL);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ bookmarks = g_bookmark_file_new ();
+ datadir = g_build_filename (g_get_user_config_dir (), "gtk-4.0", NULL);
+ filename = g_build_filename (datadir, "servers", NULL);
- g_mkdir_with_parents (datadir, 0700);
- g_bookmark_file_load_from_file (bookmarks, filename, &error);
+ g_mkdir_with_parents (datadir, 0700);
+ g_bookmark_file_load_from_file (bookmarks, filename, &error);
- if (error)
+ if (error)
{
- if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
+ if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
{
- /* only warn if the file exists */
- g_warning ("Unable to open server bookmarks: %s", error->message);
- g_clear_pointer (&bookmarks, g_bookmark_file_free);
+ /* only warn if the file exists */
+ g_warning ("Unable to open server bookmarks: %s", error->message);
+ g_clear_pointer (&bookmarks, g_bookmark_file_free);
}
- g_clear_error (&error);
+ g_clear_error (&error);
}
- /* Monitor the file in case it's modified outside this code */
- if (!priv->server_list_monitor)
+ /* Monitor the file in case it's modified outside this code */
+ if (!priv->server_list_monitor)
{
- priv->server_list_file = g_file_new_for_path (filename);
+ priv->server_list_file = g_file_new_for_path (filename);
- if (priv->server_list_file)
+ if (priv->server_list_file)
{
- priv->server_list_monitor = g_file_monitor_file (priv->server_list_file,
- G_FILE_MONITOR_NONE,
- NULL,
- &error);
+ priv->server_list_monitor = g_file_monitor_file (priv->server_list_file,
+ G_FILE_MONITOR_NONE,
+ NULL,
+ &error);
- if (error)
+ if (error)
{
- g_warning ("Cannot monitor server file: %s", error->message);
- g_clear_error (&error);
+ g_warning ("Cannot monitor server file: %s", error->message);
+ g_clear_error (&error);
}
- else
+ else
{
- g_signal_connect_swapped (priv->server_list_monitor,
- "changed",
- G_CALLBACK (server_file_changed_cb),
- view);
+ g_signal_connect_swapped (priv->server_list_monitor,
+ "changed",
+ G_CALLBACK (server_file_changed_cb),
+ view);
}
}
- g_clear_object (&priv->server_list_file);
+ g_clear_object (&priv->server_list_file);
}
- g_free (datadir);
- g_free (filename);
+ g_free (datadir);
+ g_free (filename);
- return bookmarks;
+ return bookmarks;
}
static void
server_list_save (GBookmarkFile *bookmarks)
{
- gchar *filename;
+ gchar *filename;
- filename = g_build_filename (g_get_user_config_dir (), "gtk-3.0", "servers", NULL);
- g_bookmark_file_to_file (bookmarks, filename, NULL);
- g_free (filename);
+ filename = g_build_filename (g_get_user_config_dir (), "gtk-4.0", "servers", NULL);
+ g_bookmark_file_to_file (bookmarks, filename, NULL);
+ g_free (filename);
}
static void
server_list_add_server (NautilusGtkPlacesView *view,
- GFile *file)
+ GFile *file)
{
- GBookmarkFile *bookmarks;
- GFileInfo *info;
- GError *error;
- gchar *title;
- gchar *uri;
+ GBookmarkFile *bookmarks;
+ GFileInfo *info;
+ GError *error;
+ gchar *title;
+ gchar *uri;
- error = NULL;
- bookmarks = server_list_load (view);
+ error = NULL;
+ bookmarks = server_list_load (view);
- if (!bookmarks)
- {
- return;
- }
+ if (!bookmarks)
+ return;
- uri = g_file_get_uri (file);
+ uri = g_file_get_uri (file);
- info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
- G_FILE_QUERY_INFO_NONE,
- NULL,
- &error);
- title = g_file_info_get_attribute_as_string (info, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ &error);
+ title = g_file_info_get_attribute_as_string (info, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
- g_bookmark_file_set_title (bookmarks, uri, title);
- g_bookmark_file_set_visited (bookmarks, uri, -1);
- g_bookmark_file_add_application (bookmarks, uri, NULL, NULL);
+ g_bookmark_file_set_title (bookmarks, uri, title);
+ g_bookmark_file_set_visited (bookmarks, uri, -1);
+ g_bookmark_file_add_application (bookmarks, uri, NULL, NULL);
- server_list_save (bookmarks);
+ server_list_save (bookmarks);
- g_bookmark_file_free (bookmarks);
- g_clear_object (&info);
- g_free (title);
- g_free (uri);
+ g_bookmark_file_free (bookmarks);
+ g_clear_object (&info);
+ g_free (title);
+ g_free (uri);
}
static void
server_list_remove_server (NautilusGtkPlacesView *view,
- const gchar *uri)
+ const gchar *uri)
{
- GBookmarkFile *bookmarks;
+ GBookmarkFile *bookmarks;
- bookmarks = server_list_load (view);
+ bookmarks = server_list_load (view);
- if (!bookmarks)
- {
- return;
- }
+ if (!bookmarks)
+ return;
- g_bookmark_file_remove_item (bookmarks, uri, NULL);
- server_list_save (bookmarks);
+ g_bookmark_file_remove_item (bookmarks, uri, NULL);
+ server_list_save (bookmarks);
- g_bookmark_file_free (bookmarks);
+ g_bookmark_file_free (bookmarks);
}
/* Returns a toplevel GtkWindow, or NULL if none */
static GtkWindow *
get_toplevel (GtkWidget *widget)
{
- GtkWidget *toplevel;
+ GtkWidget *toplevel;
- toplevel = gtk_widget_get_toplevel (widget);
- if (!gtk_widget_is_toplevel (toplevel))
- {
- return NULL;
- }
- else
- {
- return GTK_WINDOW (toplevel);
- }
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (!gtk_widget_is_toplevel (toplevel))
+ return NULL;
+ else
+ return GTK_WINDOW (toplevel);
}
static void
set_busy_cursor (NautilusGtkPlacesView *view,
- gboolean busy)
+ gboolean busy)
{
- GtkWidget *widget;
- GtkWindow *toplevel;
- GdkDisplay *display;
- GdkCursor *cursor;
+ GtkWidget *widget;
+ GtkWindow *toplevel;
+ GdkDisplay *display;
+ GdkCursor *cursor;
- toplevel = get_toplevel (GTK_WIDGET (view));
- widget = GTK_WIDGET (toplevel);
- if (!toplevel || !gtk_widget_get_realized (widget))
- {
- return;
- }
+ toplevel = get_toplevel (GTK_WIDGET (view));
+ widget = GTK_WIDGET (toplevel);
+ if (!toplevel || !gtk_widget_get_realized (widget))
+ return;
- display = gtk_widget_get_display (widget);
+ display = gtk_widget_get_display (widget);
- if (busy)
- {
- cursor = gdk_cursor_new_from_name (display, "progress");
- }
- else
- {
- cursor = NULL;
- }
+ if (busy)
+ cursor = gdk_cursor_new_from_name (display, "progress");
+ else
+ cursor = NULL;
- gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
- gdk_display_flush (display);
+ gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
+ gdk_display_flush (display);
- if (cursor)
- {
- g_object_unref (cursor);
- }
+ if (cursor)
+ g_object_unref (cursor);
}
/* Activates the given row, with the given flags as parameter */
static void
-activate_row (NautilusGtkPlacesView *view,
- NautilusGtkPlacesViewRow *row,
- GtkPlacesOpenFlags flags)
+activate_row (NautilusGtkPlacesView *view,
+ NautilusGtkPlacesViewRow *row,
+ GtkPlacesOpenFlags flags)
{
- NautilusGtkPlacesViewPrivate *priv;
- GVolume *volume;
- GMount *mount;
- GFile *file;
+ NautilusGtkPlacesViewPrivate *priv;
+ GVolume *volume;
+ GMount *mount;
+ GFile *file;
- priv = nautilus_gtk_places_view_get_instance_private (view);
- mount = nautilus_gtk_places_view_row_get_mount (row);
- volume = nautilus_gtk_places_view_row_get_volume (row);
- file = nautilus_gtk_places_view_row_get_file (row);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ mount = nautilus_gtk_places_view_row_get_mount (row);
+ volume = nautilus_gtk_places_view_row_get_volume (row);
+ file = nautilus_gtk_places_view_row_get_file (row);
- if (file)
+ if (file)
{
- emit_open_location (view, file, flags);
+ emit_open_location (view, file, flags);
}
- else if (mount)
+ else if (mount)
{
- GFile *location = g_mount_get_default_location (mount);
+ GFile *location = g_mount_get_default_location (mount);
- emit_open_location (view, location, flags);
+ emit_open_location (view, location, flags);
- g_object_unref (location);
+ g_object_unref (location);
}
- else if (volume && g_volume_can_mount (volume))
+ else if (volume && g_volume_can_mount (volume))
{
- /*
- * When the row is activated, the unmounted volume shall
- * be mounted and opened right after.
- */
- priv->should_open_location = TRUE;
-
- nautilus_gtk_places_view_row_set_busy (row, TRUE);
- mount_volume (view, volume);
+ /*
+ * When the row is activated, the unmounted volume shall
+ * be mounted and opened right after.
+ */
+ priv->should_open_location = TRUE;
+
+ nautilus_gtk_places_view_row_set_busy (row, TRUE);
+ mount_volume (view, volume);
}
}
@@ -411,542 +391,514 @@ static void update_places (NautilusGtkPlacesView *view);
static void
nautilus_gtk_places_view_destroy (GtkWidget *widget)
{
- NautilusGtkPlacesView *self = NAUTILUS_GTK_PLACES_VIEW (widget);
- NautilusGtkPlacesViewPrivate *priv = nautilus_gtk_places_view_get_instance_private (self);
+ NautilusGtkPlacesView *self = NAUTILUS_GTK_PLACES_VIEW (widget);
+ NautilusGtkPlacesViewPrivate *priv = nautilus_gtk_places_view_get_instance_private (self);
- priv->destroyed = 1;
+ priv->destroyed = 1;
- g_signal_handlers_disconnect_by_func (priv->volume_monitor, update_places, widget);
+ g_signal_handlers_disconnect_by_func (priv->volume_monitor, update_places, widget);
- if (priv->network_monitor)
- {
- g_signal_handlers_disconnect_by_func (priv->network_monitor, update_places, widget);
- }
+ if (priv->network_monitor)
+ g_signal_handlers_disconnect_by_func (priv->network_monitor, update_places, widget);
- g_cancellable_cancel (priv->cancellable);
- g_cancellable_cancel (priv->networks_fetching_cancellable);
+ g_cancellable_cancel (priv->cancellable);
+ g_cancellable_cancel (priv->networks_fetching_cancellable);
- GTK_WIDGET_CLASS (nautilus_gtk_places_view_parent_class)->destroy (widget);
+ GTK_WIDGET_CLASS (nautilus_gtk_places_view_parent_class)->destroy (widget);
}
static void
nautilus_gtk_places_view_finalize (GObject *object)
{
- NautilusGtkPlacesView *self = (NautilusGtkPlacesView *) object;
- NautilusGtkPlacesViewPrivate *priv = nautilus_gtk_places_view_get_instance_private (self);
+ NautilusGtkPlacesView *self = (NautilusGtkPlacesView *)object;
+ NautilusGtkPlacesViewPrivate *priv = nautilus_gtk_places_view_get_instance_private (self);
- if (priv->entry_pulse_timeout_id > 0)
- {
- g_source_remove (priv->entry_pulse_timeout_id);
- }
+ if (priv->entry_pulse_timeout_id > 0)
+ g_source_remove (priv->entry_pulse_timeout_id);
- g_clear_pointer (&priv->search_query, g_free);
- 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);
- g_clear_object (&priv->space_size_group);
+ g_clear_pointer (&priv->search_query, g_free);
+ 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);
+ g_clear_object (&priv->space_size_group);
- G_OBJECT_CLASS (nautilus_gtk_places_view_parent_class)->finalize (object);
+ G_OBJECT_CLASS (nautilus_gtk_places_view_parent_class)->finalize (object);
}
static void
nautilus_gtk_places_view_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- NautilusGtkPlacesView *self = NAUTILUS_GTK_PLACES_VIEW (object);
+ NautilusGtkPlacesView *self = NAUTILUS_GTK_PLACES_VIEW (object);
- switch (prop_id)
+ switch (prop_id)
{
- case PROP_LOCAL_ONLY:
- {
- g_value_set_boolean (value, nautilus_gtk_places_view_get_local_only (self));
- }
- break;
+ case PROP_LOCAL_ONLY:
+ g_value_set_boolean (value, nautilus_gtk_places_view_get_local_only (self));
+ break;
- case PROP_LOADING:
- {
- g_value_set_boolean (value, nautilus_gtk_places_view_get_loading (self));
- }
- break;
+ case PROP_LOADING:
+ g_value_set_boolean (value, nautilus_gtk_places_view_get_loading (self));
+ break;
- case PROP_FETCHING_NETWORKS:
- {
- g_value_set_boolean (value, nautilus_gtk_places_view_get_fetching_networks (self));
- }
- break;
+ case PROP_FETCHING_NETWORKS:
+ g_value_set_boolean (value, nautilus_gtk_places_view_get_fetching_networks (self));
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
nautilus_gtk_places_view_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- NautilusGtkPlacesView *self = NAUTILUS_GTK_PLACES_VIEW (object);
+ NautilusGtkPlacesView *self = NAUTILUS_GTK_PLACES_VIEW (object);
- switch (prop_id)
+ switch (prop_id)
{
- case PROP_LOCAL_ONLY:
- {
- nautilus_gtk_places_view_set_local_only (self, g_value_get_boolean (value));
- }
- break;
+ case PROP_LOCAL_ONLY:
+ nautilus_gtk_places_view_set_local_only (self, g_value_get_boolean (value));
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static gboolean
is_external_volume (GVolume *volume)
{
- gboolean is_external;
- GDrive *drive;
- gchar *id;
+ gboolean is_external;
+ GDrive *drive;
+ gchar *id;
- drive = g_volume_get_drive (volume);
- id = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_CLASS);
+ drive = g_volume_get_drive (volume);
+ id = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_CLASS);
- is_external = g_volume_can_eject (volume);
+ is_external = g_volume_can_eject (volume);
- /* NULL volume identifier only happens on removable devices */
- is_external |= !id;
+ /* NULL volume identifier only happens on removable devices */
+ is_external |= !id;
- if (drive)
- {
- is_external |= g_drive_is_removable (drive);
- }
+ if (drive)
+ is_external |= g_drive_is_removable (drive);
- g_clear_object (&drive);
- g_free (id);
+ g_clear_object (&drive);
+ g_free (id);
- return is_external;
+ return is_external;
}
typedef struct
{
- gchar *uri;
- NautilusGtkPlacesView *view;
+ gchar *uri;
+ NautilusGtkPlacesView *view;
} RemoveServerData;
static void
on_remove_server_button_clicked (RemoveServerData *data)
{
- server_list_remove_server (data->view, data->uri);
+ server_list_remove_server (data->view, data->uri);
- populate_servers (data->view);
+ populate_servers (data->view);
}
static void
populate_servers (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
- GBookmarkFile *server_list;
- GList *children;
- gchar **uris;
- gsize num_uris;
- gint i;
+ NautilusGtkPlacesViewPrivate *priv;
+ GBookmarkFile *server_list;
+ GList *children;
+ gchar **uris;
+ gsize num_uris;
+ gint i;
- priv = nautilus_gtk_places_view_get_instance_private (view);
- server_list = server_list_load (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ server_list = server_list_load (view);
- if (!server_list)
- {
- return;
- }
+ if (!server_list)
+ return;
- uris = g_bookmark_file_get_uris (server_list, &num_uris);
+ uris = g_bookmark_file_get_uris (server_list, &num_uris);
- gtk_stack_set_visible_child_name (GTK_STACK (priv->recent_servers_stack),
- num_uris > 0 ? "list" : "empty");
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->recent_servers_stack),
+ num_uris > 0 ? "list" : "empty");
- if (!uris)
+ if (!uris)
{
- g_bookmark_file_free (server_list);
- return;
+ g_bookmark_file_free (server_list);
+ return;
}
- /* clear previous items */
- children = gtk_container_get_children (GTK_CONTAINER (priv->recent_servers_listbox));
- g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy);
+ /* clear previous items */
+ children = gtk_container_get_children (GTK_CONTAINER (priv->recent_servers_listbox));
+ g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy);
- gtk_list_store_clear (priv->completion_store);
+ gtk_list_store_clear (priv->completion_store);
- for (i = 0; i < num_uris; i++)
+ for (i = 0; i < num_uris; i++)
{
- RemoveServerData *data;
- GtkTreeIter iter;
- GtkWidget *row;
- GtkWidget *grid;
- GtkWidget *button;
- GtkWidget *label;
- gchar *name;
- gchar *dup_uri;
-
- name = g_bookmark_file_get_title (server_list, uris[i], NULL);
- dup_uri = g_strdup (uris[i]);
-
- /* add to the completion list */
- gtk_list_store_append (priv->completion_store, &iter);
- gtk_list_store_set (priv->completion_store,
- &iter,
- 0, name,
- 1, uris[i],
- -1);
-
- /* add to the recent servers listbox */
- row = gtk_list_box_row_new ();
-
- grid = g_object_new (GTK_TYPE_GRID,
- "orientation", GTK_ORIENTATION_VERTICAL,
- "border-width", 3,
- NULL);
-
- /* name of the connected uri, if any */
- label = gtk_label_new (name);
- gtk_widget_set_hexpand (label, TRUE);
- gtk_label_set_xalign (GTK_LABEL (label), 0.0);
- gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
- gtk_container_add (GTK_CONTAINER (grid), label);
-
- /* the uri itself */
- label = gtk_label_new (uris[i]);
- gtk_widget_set_hexpand (label, TRUE);
- gtk_label_set_xalign (GTK_LABEL (label), 0.0);
- gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
- gtk_style_context_add_class (gtk_widget_get_style_context (label), "dim-label");
- gtk_container_add (GTK_CONTAINER (grid), label);
-
- /* remove button */
- button = gtk_button_new ();
- gtk_widget_set_halign (button, GTK_ALIGN_END);
- gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_style_context_add_class (gtk_widget_get_style_context (button), "image-button");
- gtk_style_context_add_class (gtk_widget_get_style_context (button), "sidebar-button");
- gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 2);
- gtk_container_add (GTK_CONTAINER (button),
- gtk_image_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_BUTTON));
-
- gtk_container_add (GTK_CONTAINER (row), grid);
- gtk_container_add (GTK_CONTAINER (priv->recent_servers_listbox), row);
-
- /* custom data */
- data = g_new0 (RemoveServerData, 1);
- data->view = view;
- data->uri = dup_uri;
-
- g_object_set_data_full (G_OBJECT (row), "uri", dup_uri, g_free);
- g_object_set_data_full (G_OBJECT (row), "remove-server-data", data, g_free);
-
- g_signal_connect_swapped (button,
- "clicked",
- G_CALLBACK (on_remove_server_button_clicked),
- data);
-
- gtk_widget_show_all (row);
-
- g_free (name);
+ RemoveServerData *data;
+ GtkTreeIter iter;
+ GtkWidget *row;
+ GtkWidget *grid;
+ GtkWidget *button;
+ GtkWidget *label;
+ gchar *name;
+ gchar *dup_uri;
+
+ name = g_bookmark_file_get_title (server_list, uris[i], NULL);
+ dup_uri = g_strdup (uris[i]);
+
+ /* add to the completion list */
+ gtk_list_store_append (priv->completion_store, &iter);
+ gtk_list_store_set (priv->completion_store,
+ &iter,
+ 0, name,
+ 1, uris[i],
+ -1);
+
+ /* add to the recent servers listbox */
+ row = gtk_list_box_row_new ();
+
+ grid = g_object_new (GTK_TYPE_GRID,
+ "orientation", GTK_ORIENTATION_VERTICAL,
+ NULL);
+
+ /* name of the connected uri, if any */
+ label = gtk_label_new (name);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ gtk_container_add (GTK_CONTAINER (grid), label);
+
+ /* the uri itself */
+ label = gtk_label_new (uris[i]);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ gtk_style_context_add_class (gtk_widget_get_style_context (label), "dim-label");
+ gtk_container_add (GTK_CONTAINER (grid), label);
+
+ /* remove button */
+ button = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_set_halign (button, GTK_ALIGN_END);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_style_context_add_class (gtk_widget_get_style_context (button), "sidebar-button");
+ gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 2);
+
+ gtk_container_add (GTK_CONTAINER (row), grid);
+ gtk_container_add (GTK_CONTAINER (priv->recent_servers_listbox), row);
+
+ /* custom data */
+ data = g_new0 (RemoveServerData, 1);
+ data->view = view;
+ data->uri = dup_uri;
+
+ g_object_set_data_full (G_OBJECT (row), "uri", dup_uri, g_free);
+ g_object_set_data_full (G_OBJECT (row), "remove-server-data", data, g_free);
+
+ g_signal_connect_swapped (button,
+ "clicked",
+ G_CALLBACK (on_remove_server_button_clicked),
+ data);
+
+ g_free (name);
}
- g_strfreev (uris);
- g_bookmark_file_free (server_list);
+ g_strfreev (uris);
+ g_bookmark_file_free (server_list);
}
static void
update_view_mode (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
- GList *children;
- GList *l;
- gboolean show_listbox;
+ NautilusGtkPlacesViewPrivate *priv;
+ GList *children;
+ GList *l;
+ gboolean show_listbox;
- priv = nautilus_gtk_places_view_get_instance_private (view);
- show_listbox = FALSE;
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ show_listbox = FALSE;
- /* drives */
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
+ /* drives */
+ children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
- for (l = children; l; l = l->next)
+ for (l = children; l; l = l->next)
{
- /* GtkListBox filter rows by changing their GtkWidget::child-visible property */
- if (gtk_widget_get_child_visible (l->data))
+ /* GtkListBox filter rows by changing their GtkWidget::child-visible property */
+ if (gtk_widget_get_child_visible (l->data))
{
- show_listbox = TRUE;
- break;
+ show_listbox = TRUE;
+ break;
}
}
- g_list_free (children);
+ g_list_free (children);
- if (!show_listbox &&
- priv->search_query &&
- priv->search_query[0] != '\0')
+ if (!show_listbox &&
+ priv->search_query &&
+ priv->search_query[0] != '\0')
{
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "empty-search");
}
- else
+ else
{
- gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "browse");
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "browse");
}
}
static void
insert_row (NautilusGtkPlacesView *view,
- GtkWidget *row,
- gboolean is_network)
+ GtkWidget *row,
+ gboolean is_network)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- g_object_set_data (G_OBJECT (row), "is-network", GINT_TO_POINTER (is_network));
+ g_object_set_data (G_OBJECT (row), "is-network", GINT_TO_POINTER (is_network));
- g_signal_connect_swapped (nautilus_gtk_places_view_row_get_event_box (NAUTILUS_GTK_PLACES_VIEW_ROW (row)),
- "button-press-event",
- G_CALLBACK (on_button_press_event),
- row);
+ g_signal_connect_swapped (nautilus_gtk_places_view_row_get_event_box (NAUTILUS_GTK_PLACES_VIEW_ROW (row)),
+ "button-press-event",
+ G_CALLBACK (on_button_press_event),
+ row);
- g_signal_connect (row,
- "popup-menu",
- G_CALLBACK (on_row_popup_menu),
- row);
+ g_signal_connect (row,
+ "popup-menu",
+ G_CALLBACK (on_row_popup_menu),
+ row);
- g_signal_connect (nautilus_gtk_places_view_row_get_eject_button (NAUTILUS_GTK_PLACES_VIEW_ROW (row)),
- "clicked",
- G_CALLBACK (on_eject_button_clicked),
- row);
+ g_signal_connect (nautilus_gtk_places_view_row_get_eject_button (NAUTILUS_GTK_PLACES_VIEW_ROW (row)),
+ "clicked",
+ G_CALLBACK (on_eject_button_clicked),
+ row);
- nautilus_gtk_places_view_row_set_path_size_group (NAUTILUS_GTK_PLACES_VIEW_ROW (row), priv->path_size_group);
- nautilus_gtk_places_view_row_set_space_size_group (NAUTILUS_GTK_PLACES_VIEW_ROW (row), priv->space_size_group);
+ nautilus_gtk_places_view_row_set_path_size_group (NAUTILUS_GTK_PLACES_VIEW_ROW (row), priv->path_size_group);
+ nautilus_gtk_places_view_row_set_space_size_group (NAUTILUS_GTK_PLACES_VIEW_ROW (row), priv->space_size_group);
- gtk_container_add (GTK_CONTAINER (priv->listbox), row);
+ gtk_container_add (GTK_CONTAINER (priv->listbox), row);
}
static void
add_volume (NautilusGtkPlacesView *view,
- GVolume *volume)
+ GVolume *volume)
{
- gboolean is_network;
- GMount *mount;
- GFile *root;
- GIcon *icon;
- gchar *identifier;
- gchar *name;
- gchar *path;
+ gboolean is_network;
+ GMount *mount;
+ GFile *root;
+ GIcon *icon;
+ gchar *identifier;
+ gchar *name;
+ gchar *path;
- if (is_external_volume (volume))
- {
- return;
- }
+ if (is_external_volume (volume))
+ return;
- identifier = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_CLASS);
- is_network = g_strcmp0 (identifier, "network") == 0;
+ identifier = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_CLASS);
+ is_network = g_strcmp0 (identifier, "network") == 0;
- mount = g_volume_get_mount (volume);
- root = mount ? g_mount_get_default_location (mount) : NULL;
- icon = g_volume_get_icon (volume);
- name = g_volume_get_name (volume);
- path = !is_network ? g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) : NULL;
+ mount = g_volume_get_mount (volume);
+ root = mount ? g_mount_get_default_location (mount) : NULL;
+ icon = g_volume_get_icon (volume);
+ name = g_volume_get_name (volume);
+ path = !is_network ? g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) : NULL;
- if (!mount || !g_mount_is_shadowed (mount))
+ if (!mount || !g_mount_is_shadowed (mount))
{
- GtkWidget *row;
-
- row = g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW_ROW,
- "icon", icon,
- "name", name,
- "path", path ? path : "",
- "volume", volume,
- "mount", mount,
- "file", NULL,
- "is-network", is_network,
- NULL);
+ GtkWidget *row;
- insert_row (view, row, is_network);
+ row = g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW_ROW,
+ "icon", icon,
+ "name", name,
+ "path", path ? path : "",
+ "volume", volume,
+ "mount", mount,
+ "file", NULL,
+ "is-network", is_network,
+ NULL);
+
+ insert_row (view, row, is_network);
}
- g_clear_object (&root);
- g_clear_object (&icon);
- g_clear_object (&mount);
- g_free (identifier);
- g_free (name);
- g_free (path);
+ g_clear_object (&root);
+ g_clear_object (&icon);
+ g_clear_object (&mount);
+ g_free (identifier);
+ g_free (name);
+ g_free (path);
}
static void
add_mount (NautilusGtkPlacesView *view,
- GMount *mount)
-{
- gboolean is_network;
- GFile *root;
- GIcon *icon;
- gchar *name;
- gchar *path;
- gchar *uri;
- gchar *schema;
-
- icon = g_mount_get_icon (mount);
- name = g_mount_get_name (mount);
- root = g_mount_get_default_location (mount);
- path = root ? g_file_get_parse_name (root) : NULL;
- uri = g_file_get_uri (root);
- schema = g_uri_parse_scheme (uri);
- is_network = g_strcmp0 (schema, "file") != 0;
-
- if (is_network)
- {
- g_clear_pointer (&path, g_free);
- }
-
- if (!g_mount_is_shadowed (mount))
- {
- GtkWidget *row;
-
- row = g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW_ROW,
- "icon", icon,
- "name", name,
- "path", path ? path : "",
- "volume", NULL,
- "mount", mount,
- "file", NULL,
- "is-network", is_network,
- NULL);
+ GMount *mount)
+{
+ gboolean is_network;
+ GFile *root;
+ GIcon *icon;
+ gchar *name;
+ gchar *path;
+ gchar *uri;
+ gchar *schema;
+
+ icon = g_mount_get_icon (mount);
+ name = g_mount_get_name (mount);
+ root = g_mount_get_default_location (mount);
+ path = root ? g_file_get_parse_name (root) : NULL;
+ uri = g_file_get_uri (root);
+ schema = g_uri_parse_scheme (uri);
+ is_network = g_strcmp0 (schema, "file") != 0;
+
+ if (is_network)
+ g_clear_pointer (&path, g_free);
+
+ if (!g_mount_is_shadowed (mount))
+ {
+ GtkWidget *row;
+
+ row = g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW_ROW,
+ "icon", icon,
+ "name", name,
+ "path", path ? path : "",
+ "volume", NULL,
+ "mount", mount,
+ "file", NULL,
+ "is-network", is_network,
+ NULL);
- insert_row (view, row, is_network);
+ insert_row (view, row, is_network);
}
- g_clear_object (&root);
- g_clear_object (&icon);
- g_free (name);
- g_free (path);
- g_free (uri);
- g_free (schema);
+ g_clear_object (&root);
+ g_clear_object (&icon);
+ g_free (name);
+ g_free (path);
+ g_free (uri);
+ g_free (schema);
}
static void
add_drive (NautilusGtkPlacesView *view,
- GDrive *drive)
+ GDrive *drive)
{
- GList *volumes;
- GList *l;
+ GList *volumes;
+ GList *l;
- volumes = g_drive_get_volumes (drive);
+ volumes = g_drive_get_volumes (drive);
- for (l = volumes; l != NULL; l = l->next)
- {
- add_volume (view, l->data);
- }
+ for (l = volumes; l != NULL; l = l->next)
+ add_volume (view, l->data);
- g_list_free_full (volumes, g_object_unref);
+ g_list_free_full (volumes, g_object_unref);
}
static void
add_file (NautilusGtkPlacesView *view,
- GFile *file,
- GIcon *icon,
- const gchar *display_name,
- const gchar *path,
- gboolean is_network)
-{
- GtkWidget *row;
- row = g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW_ROW,
- "icon", icon,
- "name", display_name,
- "path", path,
- "volume", NULL,
- "mount", NULL,
- "file", file,
- "is_network", is_network,
- NULL);
-
- insert_row (view, row, is_network);
+ GFile *file,
+ GIcon *icon,
+ const gchar *display_name,
+ const gchar *path,
+ gboolean is_network)
+{
+ GtkWidget *row;
+ row = g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW_ROW,
+ "icon", icon,
+ "name", display_name,
+ "path", path,
+ "volume", NULL,
+ "mount", NULL,
+ "file", file,
+ "is_network", is_network,
+ NULL);
+
+ insert_row (view, row, is_network);
}
static gboolean
has_networks (NautilusGtkPlacesView *view)
{
- GList *l;
- NautilusGtkPlacesViewPrivate *priv;
- GList *children;
- gboolean has_network = FALSE;
+ GList *l;
+ NautilusGtkPlacesViewPrivate *priv;
+ GList *children;
+ gboolean has_network = FALSE;
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
- for (l = children; l != NULL; l = l->next)
+ children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
+ for (l = children; l != NULL; l = l->next)
{
- if (GPOINTER_TO_INT (g_object_get_data (l->data, "is-network")) == TRUE &&
- g_object_get_data (l->data, "is-placeholder") == NULL)
- {
- has_network = TRUE;
- break;
- }
+ if (GPOINTER_TO_INT (g_object_get_data (l->data, "is-network")) == TRUE &&
+ g_object_get_data (l->data, "is-placeholder") == NULL)
+ {
+ has_network = TRUE;
+ break;
+ }
}
- g_list_free (children);
+ g_list_free (children);
- return has_network;
+ return has_network;
}
static void
update_network_state (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
-
- priv = nautilus_gtk_places_view_get_instance_private (view);
-
- if (priv->network_placeholder == NULL)
- {
- priv->network_placeholder = gtk_list_box_row_new ();
- priv->network_placeholder_label = gtk_label_new ("");
- gtk_label_set_xalign (GTK_LABEL (priv->network_placeholder_label), 0.0);
- gtk_widget_set_margin_start (priv->network_placeholder_label, 12);
- gtk_widget_set_margin_end (priv->network_placeholder_label, 12);
- gtk_widget_set_margin_top (priv->network_placeholder_label, 6);
- gtk_widget_set_margin_bottom (priv->network_placeholder_label, 6);
- gtk_widget_set_hexpand (priv->network_placeholder_label, TRUE);
- gtk_widget_set_sensitive (priv->network_placeholder, FALSE);
- gtk_container_add (GTK_CONTAINER (priv->network_placeholder),
- priv->network_placeholder_label);
- g_object_set_data (G_OBJECT (priv->network_placeholder),
- "is-network", GINT_TO_POINTER (TRUE));
- /* mark the row as placeholder, so it always goes first */
- g_object_set_data (G_OBJECT (priv->network_placeholder),
- "is-placeholder", GINT_TO_POINTER (TRUE));
- gtk_container_add (GTK_CONTAINER (priv->listbox), priv->network_placeholder);
- }
+ NautilusGtkPlacesViewPrivate *priv;
- if (nautilus_gtk_places_view_get_fetching_networks (view))
- {
- /* only show a placeholder with a message if the list is empty.
- * otherwise just show the spinner in the header */
- if (!has_networks (view))
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+
+ if (priv->network_placeholder == NULL)
+ {
+ priv->network_placeholder = gtk_list_box_row_new ();
+ priv->network_placeholder_label = gtk_label_new ("");
+ gtk_label_set_xalign (GTK_LABEL (priv->network_placeholder_label), 0.0);
+ gtk_widget_set_margin_start (priv->network_placeholder_label, 12);
+ gtk_widget_set_margin_end (priv->network_placeholder_label, 12);
+ gtk_widget_set_margin_top (priv->network_placeholder_label, 6);
+ gtk_widget_set_margin_bottom (priv->network_placeholder_label, 6);
+ gtk_widget_set_hexpand (priv->network_placeholder_label, TRUE);
+ gtk_widget_set_sensitive (priv->network_placeholder, FALSE);
+ gtk_container_add (GTK_CONTAINER (priv->network_placeholder),
+ priv->network_placeholder_label);
+ g_object_set_data (G_OBJECT (priv->network_placeholder),
+ "is-network", GINT_TO_POINTER (TRUE));
+ /* mark the row as placeholder, so it always goes first */
+ g_object_set_data (G_OBJECT (priv->network_placeholder),
+ "is-placeholder", GINT_TO_POINTER (TRUE));
+ gtk_container_add (GTK_CONTAINER (priv->listbox), priv->network_placeholder);
+ }
+
+ if (nautilus_gtk_places_view_get_fetching_networks (view))
+ {
+ /* only show a placeholder with a message if the list is empty.
+ * otherwise just show the spinner in the header */
+ if (!has_networks (view))
{
- gtk_widget_show_all (priv->network_placeholder);
- gtk_label_set_text (GTK_LABEL (priv->network_placeholder_label),
- _("Searching for network locations"));
+ gtk_widget_show (priv->network_placeholder);
+ gtk_label_set_text (GTK_LABEL (priv->network_placeholder_label),
+ _("Searching for network locations"));
}
}
- else if (!has_networks (view))
+ else if (!has_networks (view))
{
- gtk_widget_show_all (priv->network_placeholder);
- gtk_label_set_text (GTK_LABEL (priv->network_placeholder_label),
- _("No network locations found"));
+ gtk_widget_show (priv->network_placeholder);
+ gtk_label_set_text (GTK_LABEL (priv->network_placeholder_label),
+ _("No network locations found"));
}
- else
+ else
{
- gtk_widget_hide (priv->network_placeholder);
+ gtk_widget_hide (priv->network_placeholder);
}
}
@@ -972,11 +924,11 @@ monitor_network (NautilusGtkPlacesView *self)
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",
@@ -985,40 +937,36 @@ monitor_network (NautilusGtkPlacesView *self)
}
static void
-populate_networks (NautilusGtkPlacesView *view,
- GFileEnumerator *enumerator,
- GList *detected_networks)
-{
- GList *l;
- GFile *file;
- GFile *activatable_file;
- gchar *uri;
- GFileType type;
- GIcon *icon;
- gchar *display_name;
-
- for (l = detected_networks; l != NULL; l = l->next)
+populate_networks (NautilusGtkPlacesView *view,
+ GFileEnumerator *enumerator,
+ GList *detected_networks)
+{
+ GList *l;
+ GFile *file;
+ GFile *activatable_file;
+ gchar *uri;
+ GFileType type;
+ GIcon *icon;
+ gchar *display_name;
+
+ for (l = detected_networks; l != NULL; l = l->next)
{
- file = g_file_enumerator_get_child (enumerator, l->data);
- type = g_file_info_get_file_type (l->data);
- if (type == G_FILE_TYPE_SHORTCUT || type == G_FILE_TYPE_MOUNTABLE)
- {
- uri = g_file_info_get_attribute_as_string (l->data, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
- }
- else
- {
- uri = g_file_get_uri (file);
- }
- activatable_file = g_file_new_for_uri (uri);
- display_name = g_file_info_get_attribute_as_string (l->data, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
- icon = g_file_info_get_icon (l->data);
+ file = g_file_enumerator_get_child (enumerator, l->data);
+ type = g_file_info_get_file_type (l->data);
+ if (type == G_FILE_TYPE_SHORTCUT || type == G_FILE_TYPE_MOUNTABLE)
+ uri = g_file_info_get_attribute_as_string (l->data, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
+ else
+ uri = g_file_get_uri (file);
+ activatable_file = g_file_new_for_uri (uri);
+ display_name = g_file_info_get_attribute_as_string (l->data, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
+ icon = g_file_info_get_icon (l->data);
- add_file (view, activatable_file, icon, display_name, NULL, TRUE);
+ add_file (view, activatable_file, icon, display_name, NULL, TRUE);
- g_free (uri);
- g_free (display_name);
- g_clear_object (&file);
- g_clear_object (&activatable_file);
+ g_free (uri);
+ g_free (display_name);
+ g_clear_object (&file);
+ g_clear_object (&activatable_file);
}
}
@@ -1027,44 +975,42 @@ network_enumeration_next_files_finished (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- NautilusGtkPlacesViewPrivate *priv;
- NautilusGtkPlacesView *view;
- GList *detected_networks;
- GError *error;
+ NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesView *view;
+ GList *detected_networks;
+ GError *error;
- view = NAUTILUS_GTK_PLACES_VIEW (user_data);
- priv = nautilus_gtk_places_view_get_instance_private (view);
- error = NULL;
+ view = NAUTILUS_GTK_PLACES_VIEW (user_data);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ error = NULL;
- detected_networks = g_file_enumerator_next_files_finish (G_FILE_ENUMERATOR (source_object),
- res, &error);
+ detected_networks = g_file_enumerator_next_files_finish (G_FILE_ENUMERATOR (source_object),
+ res, &error);
- if (error)
+ if (error)
{
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- {
- g_warning ("Failed to fetch network locations: %s", error->message);
- }
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to fetch network locations: %s", error->message);
- g_clear_error (&error);
+ g_clear_error (&error);
}
- else
+ else
{
- nautilus_gtk_places_view_set_fetching_networks (view, FALSE);
- populate_networks (view, G_FILE_ENUMERATOR (source_object), detected_networks);
+ nautilus_gtk_places_view_set_fetching_networks (view, FALSE);
+ populate_networks (view, G_FILE_ENUMERATOR (source_object), detected_networks);
- g_list_free_full (detected_networks, g_object_unref);
+ g_list_free_full (detected_networks, g_object_unref);
}
- g_object_unref (view);
+ g_object_unref (view);
- /* avoid to update widgets if we are already destroyed
- * (and got cancelled s a result of that) */
- if (!priv->destroyed)
+ /* avoid to update widgets if we are already destroyed
+ (and got cancelled s a result of that) */
+ if (!priv->destroyed)
{
- update_network_state (view);
- monitor_network (view);
- update_loading (view);
+ update_network_state (view);
+ monitor_network (view);
+ update_loading (view);
}
}
@@ -1073,183 +1019,172 @@ network_enumeration_finished (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- NautilusGtkPlacesViewPrivate *priv;
- GFileEnumerator *enumerator;
- GError *error;
+ NautilusGtkPlacesViewPrivate *priv;
+ GFileEnumerator *enumerator;
+ GError *error;
- error = NULL;
- enumerator = g_file_enumerate_children_finish (G_FILE (source_object), res, &error);
+ error = NULL;
+ enumerator = g_file_enumerate_children_finish (G_FILE (source_object), res, &error);
- if (error)
+ if (error)
{
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) &&
- !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
- {
- g_warning ("Failed to fetch network locations: %s", error->message);
- }
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) &&
+ !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
+ g_warning ("Failed to fetch network locations: %s", error->message);
- g_clear_error (&error);
- g_object_unref (NAUTILUS_GTK_PLACES_VIEW (user_data));
+ g_clear_error (&error);
+ g_object_unref (NAUTILUS_GTK_PLACES_VIEW (user_data));
}
- else
+ else
{
- priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (user_data));
- g_file_enumerator_next_files_async (enumerator,
- G_MAXINT32,
- G_PRIORITY_DEFAULT,
- priv->networks_fetching_cancellable,
- network_enumeration_next_files_finished,
- user_data);
+ priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (user_data));
+ g_file_enumerator_next_files_async (enumerator,
+ G_MAXINT32,
+ G_PRIORITY_DEFAULT,
+ priv->networks_fetching_cancellable,
+ network_enumeration_next_files_finished,
+ user_data);
+ g_object_unref (enumerator);
}
}
static void
fetch_networks (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
- GFile *network_file;
- const gchar * const *supported_uris;
- gboolean found;
-
- priv = nautilus_gtk_places_view_get_instance_private (view);
- supported_uris = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
+ NautilusGtkPlacesViewPrivate *priv;
+ GFile *network_file;
+ const gchar * const *supported_uris;
+ gboolean found;
- for (found = FALSE; !found && supported_uris && supported_uris[0]; supported_uris++)
- {
- if (g_strcmp0 (supported_uris[0], "network") == 0)
- {
- found = TRUE;
- }
- }
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ supported_uris = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
- if (!found)
- {
- return;
- }
+ for (found = FALSE; !found && supported_uris && supported_uris[0]; supported_uris++)
+ if (g_strcmp0 (supported_uris[0], "network") == 0)
+ found = TRUE;
- network_file = g_file_new_for_uri ("network:///");
+ if (!found)
+ return;
- g_cancellable_cancel (priv->networks_fetching_cancellable);
- g_clear_object (&priv->networks_fetching_cancellable);
- priv->networks_fetching_cancellable = g_cancellable_new ();
- nautilus_gtk_places_view_set_fetching_networks (view, TRUE);
- update_network_state (view);
+ network_file = g_file_new_for_uri ("network:///");
- g_object_ref (view);
- g_file_enumerate_children_async (network_file,
- "standard::type,standard::target-uri,standard::name,standard::display-name,standard::icon",
- G_FILE_QUERY_INFO_NONE,
- G_PRIORITY_DEFAULT,
- priv->networks_fetching_cancellable,
- network_enumeration_finished,
- view);
+ g_cancellable_cancel (priv->networks_fetching_cancellable);
+ g_clear_object (&priv->networks_fetching_cancellable);
+ priv->networks_fetching_cancellable = g_cancellable_new ();
+ nautilus_gtk_places_view_set_fetching_networks (view, TRUE);
+ update_network_state (view);
+
+ g_object_ref (view);
+ g_file_enumerate_children_async (network_file,
+ "standard::type,standard::target-uri,standard::name,standard::display-name,standard::icon",
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ priv->networks_fetching_cancellable,
+ network_enumeration_finished,
+ view);
- g_clear_object (&network_file);
+ g_clear_object (&network_file);
}
static void
update_places (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
- GList *children;
- GList *mounts;
- GList *volumes;
- GList *drives;
- GList *l;
- GIcon *icon;
- GFile *file;
+ NautilusGtkPlacesViewPrivate *priv;
+ GList *children;
+ GList *mounts;
+ GList *volumes;
+ GList *drives;
+ GList *l;
+ GIcon *icon;
+ GFile *file;
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- /* Clear all previously added items */
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
- g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy);
- priv->network_placeholder = NULL;
- /* Inform clients that we started loading */
- nautilus_gtk_places_view_set_loading (view, TRUE);
+ /* Clear all previously added items */
+ children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
+ g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy);
+ priv->network_placeholder = NULL;
+ /* Inform clients that we started loading */
+ nautilus_gtk_places_view_set_loading (view, TRUE);
- /* Add "Computer" row */
- file = g_file_new_for_path ("/");
- icon = g_themed_icon_new_with_default_fallbacks ("drive-harddisk");
+ /* Add "Computer" row */
+ file = g_file_new_for_path ("/");
+ icon = g_themed_icon_new_with_default_fallbacks ("drive-harddisk");
- add_file (view, file, icon, _("Computer"), "/", FALSE);
+ add_file (view, file, icon, _("Computer"), "/", FALSE);
- g_clear_object (&file);
- g_clear_object (&icon);
+ g_clear_object (&file);
+ g_clear_object (&icon);
- /* Add currently connected drives */
- drives = g_volume_monitor_get_connected_drives (priv->volume_monitor);
+ /* Add currently connected drives */
+ drives = g_volume_monitor_get_connected_drives (priv->volume_monitor);
- for (l = drives; l != NULL; l = l->next)
- {
- add_drive (view, l->data);
- }
+ for (l = drives; l != NULL; l = l->next)
+ add_drive (view, l->data);
- g_list_free_full (drives, g_object_unref);
+ g_list_free_full (drives, g_object_unref);
- /*
- * Since all volumes with an associated GDrive were already added with
- * add_drive before, add all volumes that aren't associated with a
- * drive.
- */
- volumes = g_volume_monitor_get_volumes (priv->volume_monitor);
+ /*
+ * Since all volumes with an associated GDrive were already added with
+ * add_drive before, add all volumes that aren't associated with a
+ * drive.
+ */
+ volumes = g_volume_monitor_get_volumes (priv->volume_monitor);
- for (l = volumes; l != NULL; l = l->next)
+ for (l = volumes; l != NULL; l = l->next)
{
- GVolume *volume;
- GDrive *drive;
+ GVolume *volume;
+ GDrive *drive;
- volume = l->data;
- drive = g_volume_get_drive (volume);
+ volume = l->data;
+ drive = g_volume_get_drive (volume);
- if (drive)
+ if (drive)
{
- g_object_unref (drive);
- continue;
+ g_object_unref (drive);
+ continue;
}
- add_volume (view, volume);
+ add_volume (view, volume);
}
- g_list_free_full (volumes, g_object_unref);
+ g_list_free_full (volumes, g_object_unref);
- /*
- * Now that all necessary drives and volumes were already added, add mounts
- * that have no volume, such as /etc/mtab mounts, ftp, sftp, etc.
- */
- mounts = g_volume_monitor_get_mounts (priv->volume_monitor);
+ /*
+ * Now that all necessary drives and volumes were already added, add mounts
+ * that have no volume, such as /etc/mtab mounts, ftp, sftp, etc.
+ */
+ mounts = g_volume_monitor_get_mounts (priv->volume_monitor);
- for (l = mounts; l != NULL; l = l->next)
+ for (l = mounts; l != NULL; l = l->next)
{
- GMount *mount;
- GVolume *volume;
+ GMount *mount;
+ GVolume *volume;
- mount = l->data;
- volume = g_mount_get_volume (mount);
+ mount = l->data;
+ volume = g_mount_get_volume (mount);
- if (volume)
+ if (volume)
{
- g_object_unref (volume);
- continue;
+ g_object_unref (volume);
+ continue;
}
- add_mount (view, mount);
+ add_mount (view, mount);
}
- g_list_free_full (mounts, g_object_unref);
+ g_list_free_full (mounts, g_object_unref);
- /* load saved servers */
- populate_servers (view);
+ /* load saved servers */
+ populate_servers (view);
- /* fetch networks and add them asynchronously */
- if (!nautilus_gtk_places_view_get_local_only (view))
- {
- fetch_networks (view);
- }
+ /* fetch networks and add them asynchronously */
+ if (!nautilus_gtk_places_view_get_local_only (view))
+ fetch_networks (view);
- update_view_mode (view);
- /* Check whether we still are in a loading state */
- update_loading (view);
+ update_view_mode (view);
+ /* Check whether we still are in a loading state */
+ update_loading (view);
}
static void
@@ -1257,78 +1192,75 @@ server_mount_ready_cb (GObject *source_file,
GAsyncResult *res,
gpointer user_data)
{
- NautilusGtkPlacesViewPrivate *priv;
- NautilusGtkPlacesView *view;
- gboolean should_show;
- GError *error;
- GFile *location;
+ NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesView *view;
+ gboolean should_show;
+ GError *error;
+ GFile *location;
- location = G_FILE (source_file);
- should_show = TRUE;
- error = NULL;
+ location = G_FILE (source_file);
+ should_show = TRUE;
+ error = NULL;
- view = NAUTILUS_GTK_PLACES_VIEW (user_data);
+ view = NAUTILUS_GTK_PLACES_VIEW (user_data);
- g_file_mount_enclosing_volume_finish (location, res, &error);
- if (error)
+ g_file_mount_enclosing_volume_finish (location, res, &error);
+ if (error)
{
- should_show = FALSE;
+ should_show = FALSE;
- if (error->code == G_IO_ERROR_ALREADY_MOUNTED)
+ if (error->code == G_IO_ERROR_ALREADY_MOUNTED)
{
- /*
- * Already mounted volume is not a critical error
- * and we can still continue with the operation.
- */
- should_show = TRUE;
+ /*
+ * Already mounted volume is not a critical error
+ * and we can still continue with the operation.
+ */
+ should_show = TRUE;
}
- else if (error->domain != G_IO_ERROR ||
- (error->code != G_IO_ERROR_CANCELLED &&
- error->code != G_IO_ERROR_FAILED_HANDLED))
+ else if (error->domain != G_IO_ERROR ||
+ (error->code != G_IO_ERROR_CANCELLED &&
+ error->code != G_IO_ERROR_FAILED_HANDLED))
{
- /* if it wasn't cancelled show a dialog */
- emit_show_error_message (view, _("Unable to access location"), error->message);
+ /* if it wasn't cancelled show a dialog */
+ emit_show_error_message (view, _("Unable to access location"), error->message);
}
- /* The operation got cancelled by the user and or the error
- * has been handled already. */
- g_clear_error (&error);
+ /* The operation got cancelled by the user and or the error
+ has been handled already. */
+ g_clear_error (&error);
}
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- if (priv->destroyed)
- {
- g_object_unref (view);
- return;
- }
+ if (priv->destroyed) {
+ g_object_unref (view);
+ return;
+ }
- priv->should_pulse_entry = FALSE;
+ priv->should_pulse_entry = FALSE;
- /* Restore from Cancel to Connect */
- gtk_button_set_label (GTK_BUTTON (priv->connect_button), _("Con_nect"));
- gtk_widget_set_sensitive (priv->address_entry, TRUE);
- priv->connecting_to_server = FALSE;
+ /* Restore from Cancel to Connect */
+ gtk_button_set_label (GTK_BUTTON (priv->connect_button), _("Con_nect"));
+ gtk_widget_set_sensitive (priv->address_entry, TRUE);
+ priv->connecting_to_server = FALSE;
- if (should_show)
+ if (should_show)
{
- server_list_add_server (view, location);
+ server_list_add_server (view, location);
- /*
- * Only clear the entry if it successfully connects to the server.
- * Otherwise, the user would lost the typed address even if it fails
- * to connect.
- */
- gtk_entry_set_text (GTK_ENTRY (priv->address_entry), "");
+ /*
+ * Only clear the entry if it successfully connects to the server.
+ * Otherwise, the user would lost the typed address even if it fails
+ * to connect.
+ */
+ gtk_entry_set_text (GTK_ENTRY (priv->address_entry), "");
- if (priv->should_open_location)
- {
- emit_open_location (view, location, priv->open_flags);
- }
+ if (priv->should_open_location)
+ emit_open_location (view, location, priv->open_flags);
}
- update_places (view);
- g_object_unref (view);
+ update_places (view);
+ g_object_unref (view);
}
static void
@@ -1336,75 +1268,73 @@ volume_mount_ready_cb (GObject *source_volume,
GAsyncResult *res,
gpointer user_data)
{
- NautilusGtkPlacesViewPrivate *priv;
- NautilusGtkPlacesView *view;
- gboolean should_show;
- GVolume *volume;
- GError *error;
+ NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesView *view;
+ gboolean should_show;
+ GVolume *volume;
+ GError *error;
- volume = G_VOLUME (source_volume);
- should_show = TRUE;
- error = NULL;
+ volume = G_VOLUME (source_volume);
+ should_show = TRUE;
+ error = NULL;
- g_volume_mount_finish (volume, res, &error);
+ g_volume_mount_finish (volume, res, &error);
- if (error)
+ if (error)
{
- should_show = FALSE;
+ should_show = FALSE;
- if (error->code == G_IO_ERROR_ALREADY_MOUNTED)
+ if (error->code == G_IO_ERROR_ALREADY_MOUNTED)
{
- /*
- * If the volume was already mounted, it's not a hard error
- * and we can still continue with the operation.
- */
- should_show = TRUE;
+ /*
+ * If the volume was already mounted, it's not a hard error
+ * and we can still continue with the operation.
+ */
+ should_show = TRUE;
}
- else if (error->domain != G_IO_ERROR ||
- (error->code != G_IO_ERROR_CANCELLED &&
- error->code != G_IO_ERROR_FAILED_HANDLED))
+ else if (error->domain != G_IO_ERROR ||
+ (error->code != G_IO_ERROR_CANCELLED &&
+ error->code != G_IO_ERROR_FAILED_HANDLED))
{
- /* if it wasn't cancelled show a dialog */
- emit_show_error_message (NAUTILUS_GTK_PLACES_VIEW (user_data), _("Unable to access location"), error->message);
- should_show = FALSE;
+ /* if it wasn't cancelled show a dialog */
+ emit_show_error_message (NAUTILUS_GTK_PLACES_VIEW (user_data), _("Unable to access location"), error->message);
+ should_show = FALSE;
}
- /* The operation got cancelled by the user and or the error
- * has been handled already. */
- g_clear_error (&error);
+ /* The operation got cancelled by the user and or the error
+ has been handled already. */
+ g_clear_error (&error);
}
- view = NAUTILUS_GTK_PLACES_VIEW (user_data);
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ view = NAUTILUS_GTK_PLACES_VIEW (user_data);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- if (priv->destroyed)
+ if (priv->destroyed)
{
- g_object_unref (view);
- return;
+ g_object_unref(view);
+ return;
}
- priv->mounting_volume = FALSE;
- update_loading (view);
+ priv->mounting_volume = FALSE;
+ update_loading (view);
- if (should_show)
+ if (should_show)
{
- GMount *mount;
- GFile *root;
+ GMount *mount;
+ GFile *root;
- mount = g_volume_get_mount (volume);
- root = g_mount_get_default_location (mount);
+ mount = g_volume_get_mount (volume);
+ root = g_mount_get_default_location (mount);
- if (priv->should_open_location)
- {
- emit_open_location (NAUTILUS_GTK_PLACES_VIEW (user_data), root, priv->open_flags);
- }
+ if (priv->should_open_location)
+ emit_open_location (NAUTILUS_GTK_PLACES_VIEW (user_data), root, priv->open_flags);
- g_object_unref (mount);
- g_object_unref (root);
+ g_object_unref (mount);
+ g_object_unref (root);
}
- update_places (view);
- g_object_unref (view);
+ update_places (view);
+ g_object_unref (view);
}
static void
@@ -1412,187 +1342,182 @@ unmount_ready_cb (GObject *source_mount,
GAsyncResult *res,
gpointer user_data)
{
- NautilusGtkPlacesView *view;
- NautilusGtkPlacesViewPrivate *priv;
- GMount *mount;
- GError *error;
+ NautilusGtkPlacesView *view;
+ NautilusGtkPlacesViewPrivate *priv;
+ GMount *mount;
+ GError *error;
- view = NAUTILUS_GTK_PLACES_VIEW (user_data);
- mount = G_MOUNT (source_mount);
- error = NULL;
+ view = NAUTILUS_GTK_PLACES_VIEW (user_data);
+ mount = G_MOUNT (source_mount);
+ error = NULL;
- g_mount_unmount_with_operation_finish (mount, res, &error);
+ g_mount_unmount_with_operation_finish (mount, res, &error);
- if (error)
+ if (error)
{
- if (error->domain != G_IO_ERROR ||
- (error->code != G_IO_ERROR_CANCELLED &&
- error->code != G_IO_ERROR_FAILED_HANDLED))
+ if (error->domain != G_IO_ERROR ||
+ (error->code != G_IO_ERROR_CANCELLED &&
+ error->code != G_IO_ERROR_FAILED_HANDLED))
{
- /* if it wasn't cancelled show a dialog */
- emit_show_error_message (view, _("Unable to unmount volume"), error->message);
+ /* if it wasn't cancelled show a dialog */
+ emit_show_error_message (view, _("Unable to unmount volume"), error->message);
}
- g_clear_error (&error);
+ g_clear_error (&error);
}
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- if (priv->destroyed)
- {
- g_object_unref (view);
- return;
- }
+ if (priv->destroyed) {
+ g_object_unref (view);
+ return;
+ }
- priv->unmounting_mount = FALSE;
- update_loading (view);
+ priv->unmounting_mount = FALSE;
+ update_loading (view);
- g_object_unref (view);
+ g_object_unref (view);
}
static gboolean
pulse_entry_cb (gpointer user_data)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (user_data));
+ priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (user_data));
- if (priv->destroyed)
+ if (priv->destroyed)
{
- priv->entry_pulse_timeout_id = 0;
+ priv->entry_pulse_timeout_id = 0;
- return G_SOURCE_REMOVE;
+ return G_SOURCE_REMOVE;
}
- else if (priv->should_pulse_entry)
+ else if (priv->should_pulse_entry)
{
- gtk_entry_progress_pulse (GTK_ENTRY (priv->address_entry));
+ gtk_entry_progress_pulse (GTK_ENTRY (priv->address_entry));
- return G_SOURCE_CONTINUE;
+ return G_SOURCE_CONTINUE;
}
- else
+ else
{
- gtk_entry_set_progress_pulse_step (GTK_ENTRY (priv->address_entry), 0.0);
- gtk_entry_set_progress_fraction (GTK_ENTRY (priv->address_entry), 0.0);
+ gtk_entry_set_progress_pulse_step (GTK_ENTRY (priv->address_entry), 0.0);
+ gtk_entry_set_progress_fraction (GTK_ENTRY (priv->address_entry), 0.0);
- return G_SOURCE_REMOVE;
+ return G_SOURCE_REMOVE;
}
}
static void
unmount_mount (NautilusGtkPlacesView *view,
- GMount *mount)
+ GMount *mount)
{
- NautilusGtkPlacesViewPrivate *priv;
- GMountOperation *operation;
- GtkWidget *toplevel;
+ NautilusGtkPlacesViewPrivate *priv;
+ GMountOperation *operation;
+ GtkWidget *toplevel;
- priv = nautilus_gtk_places_view_get_instance_private (view);
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
- operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
- g_cancellable_cancel (priv->cancellable);
- g_clear_object (&priv->cancellable);
- priv->cancellable = g_cancellable_new ();
+ g_cancellable_cancel (priv->cancellable);
+ g_clear_object (&priv->cancellable);
+ priv->cancellable = g_cancellable_new ();
- priv->unmounting_mount = TRUE;
- update_loading (view);
+ priv->unmounting_mount = TRUE;
+ update_loading (view);
- g_object_ref (view);
+ g_object_ref (view);
- operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
- g_mount_unmount_with_operation (mount,
- 0,
- operation,
- priv->cancellable,
- unmount_ready_cb,
- view);
- g_object_unref (operation);
+ operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
+ g_mount_unmount_with_operation (mount,
+ 0,
+ operation,
+ priv->cancellable,
+ unmount_ready_cb,
+ view);
+ g_object_unref (operation);
}
static void
mount_server (NautilusGtkPlacesView *view,
- GFile *location)
+ GFile *location)
{
- NautilusGtkPlacesViewPrivate *priv;
- GMountOperation *operation;
- GtkWidget *toplevel;
+ NautilusGtkPlacesViewPrivate *priv;
+ GMountOperation *operation;
+ GtkWidget *toplevel;
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- g_cancellable_cancel (priv->cancellable);
- g_clear_object (&priv->cancellable);
- /* User cliked when the operation was ongoing, so wanted to cancel it */
- if (priv->connecting_to_server)
- {
- return;
- }
+ g_cancellable_cancel (priv->cancellable);
+ g_clear_object (&priv->cancellable);
+ /* User cliked when the operation was ongoing, so wanted to cancel it */
+ if (priv->connecting_to_server)
+ return;
- priv->cancellable = g_cancellable_new ();
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
- operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
+ priv->cancellable = g_cancellable_new ();
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
- priv->should_pulse_entry = TRUE;
- gtk_entry_set_progress_pulse_step (GTK_ENTRY (priv->address_entry), 0.1);
- /* Allow to cancel the operation */
- gtk_button_set_label (GTK_BUTTON (priv->connect_button), _("Cance_l"));
- gtk_widget_set_sensitive (priv->address_entry, FALSE);
- priv->connecting_to_server = TRUE;
- update_loading (view);
+ priv->should_pulse_entry = TRUE;
+ gtk_entry_set_progress_pulse_step (GTK_ENTRY (priv->address_entry), 0.1);
+ /* Allow to cancel the operation */
+ gtk_button_set_label (GTK_BUTTON (priv->connect_button), _("Cance_l"));
+ gtk_widget_set_sensitive (priv->address_entry, FALSE);
+ priv->connecting_to_server = TRUE;
+ update_loading (view);
- if (priv->entry_pulse_timeout_id == 0)
- {
- priv->entry_pulse_timeout_id = g_timeout_add (100, (GSourceFunc) pulse_entry_cb, view);
- }
+ if (priv->entry_pulse_timeout_id == 0)
+ priv->entry_pulse_timeout_id = g_timeout_add (100, (GSourceFunc) pulse_entry_cb, view);
- g_mount_operation_set_password_save (operation, G_PASSWORD_SAVE_FOR_SESSION);
+ g_mount_operation_set_password_save (operation, G_PASSWORD_SAVE_FOR_SESSION);
- /* make sure we keep the view around for as long as we are running */
- g_object_ref (view);
+ /* make sure we keep the view around for as long as we are running */
+ g_object_ref (view);
- g_file_mount_enclosing_volume (location,
- 0,
- operation,
- priv->cancellable,
- server_mount_ready_cb,
- view);
+ g_file_mount_enclosing_volume (location,
+ 0,
+ operation,
+ priv->cancellable,
+ server_mount_ready_cb,
+ view);
- /* unref operation here - g_file_mount_enclosing_volume() does ref for itself */
- g_object_unref (operation);
+ /* unref operation here - g_file_mount_enclosing_volume() does ref for itself */
+ g_object_unref (operation);
}
static void
mount_volume (NautilusGtkPlacesView *view,
- GVolume *volume)
+ GVolume *volume)
{
- NautilusGtkPlacesViewPrivate *priv;
- GMountOperation *operation;
- GtkWidget *toplevel;
+ NautilusGtkPlacesViewPrivate *priv;
+ GMountOperation *operation;
+ GtkWidget *toplevel;
- priv = nautilus_gtk_places_view_get_instance_private (view);
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
- operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
- g_cancellable_cancel (priv->cancellable);
- g_clear_object (&priv->cancellable);
- priv->cancellable = g_cancellable_new ();
+ g_cancellable_cancel (priv->cancellable);
+ g_clear_object (&priv->cancellable);
+ priv->cancellable = g_cancellable_new ();
- priv->mounting_volume = TRUE;
- update_loading (view);
+ priv->mounting_volume = TRUE;
+ update_loading (view);
- g_mount_operation_set_password_save (operation, G_PASSWORD_SAVE_FOR_SESSION);
+ g_mount_operation_set_password_save (operation, G_PASSWORD_SAVE_FOR_SESSION);
- /* make sure we keep the view around for as long as we are running */
- g_object_ref (view);
+ /* make sure we keep the view around for as long as we are running */
+ g_object_ref (view);
- g_volume_mount (volume,
- 0,
- operation,
- priv->cancellable,
- volume_mount_ready_cb,
- view);
+ g_volume_mount (volume,
+ 0,
+ operation,
+ priv->cancellable,
+ volume_mount_ready_cb,
+ view);
- /* unref operation here - g_file_mount_enclosing_volume() does ref for itself */
- g_object_unref (operation);
+ /* unref operation here - g_file_mount_enclosing_volume() does ref for itself */
+ g_object_unref (operation);
}
/* Callback used when the file list's popup menu is detached */
@@ -1600,136 +1525,78 @@ static void
popup_menu_detach_cb (GtkWidget *attach_widget,
GtkMenu *menu)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (attach_widget));
- priv->popup_menu = NULL;
+ priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (attach_widget));
+ priv->popup_menu = NULL;
}
static void
-get_view_and_file (NautilusGtkPlacesViewRow *row,
- GtkWidget **view,
- GFile **file)
-{
- if (view)
- {
- *view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW);
- }
-
- if (file)
- {
- GVolume *volume;
- GMount *mount;
-
- volume = nautilus_gtk_places_view_row_get_volume (row);
- mount = nautilus_gtk_places_view_row_get_mount (row);
-
- if (mount)
- {
- *file = g_mount_get_default_location (mount);
- }
- else if (volume)
- {
- *file = g_volume_get_activation_root (volume);
- }
- else
- {
- *file = nautilus_gtk_places_view_row_get_file (row);
- if (*file)
- {
- g_object_ref (*file);
- }
- }
- }
-}
-
-static void
-open_cb (GtkMenuItem *item,
+open_cb (GtkMenuItem *item,
NautilusGtkPlacesViewRow *row)
{
- GtkWidget *view;
- GFile *file;
-
- get_view_and_file (row, &view, &file);
-
- if (file)
- {
- emit_open_location (NAUTILUS_GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NORMAL);
- }
+ NautilusGtkPlacesView *self;
- g_clear_object (&file);
+ self = NAUTILUS_GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW));
+ activate_row (self, row, GTK_PLACES_OPEN_NORMAL);
}
static void
-open_in_new_tab_cb (GtkMenuItem *item,
+open_in_new_tab_cb (GtkMenuItem *item,
NautilusGtkPlacesViewRow *row)
{
- GtkWidget *view;
- GFile *file;
+ NautilusGtkPlacesView *self;
- get_view_and_file (row, &view, &file);
-
- if (file)
- {
- emit_open_location (NAUTILUS_GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NEW_TAB);
- }
-
- g_clear_object (&file);
+ self = NAUTILUS_GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW));
+ activate_row (self, row, GTK_PLACES_OPEN_NEW_TAB);
}
static void
-open_in_new_window_cb (GtkMenuItem *item,
+open_in_new_window_cb (GtkMenuItem *item,
NautilusGtkPlacesViewRow *row)
{
- GtkWidget *view;
- GFile *file;
-
- get_view_and_file (row, &view, &file);
+ NautilusGtkPlacesView *self;
- if (file)
- {
- emit_open_location (NAUTILUS_GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NEW_WINDOW);
- }
-
- g_clear_object (&file);
+ self = NAUTILUS_GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW));
+ activate_row (self, row, GTK_PLACES_OPEN_NEW_WINDOW);
}
static void
-mount_cb (GtkMenuItem *item,
+mount_cb (GtkMenuItem *item,
NautilusGtkPlacesViewRow *row)
{
- NautilusGtkPlacesViewPrivate *priv;
- GtkWidget *view;
- GVolume *volume;
+ NautilusGtkPlacesViewPrivate *priv;
+ GtkWidget *view;
+ GVolume *volume;
- view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW);
- priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (view));
- volume = nautilus_gtk_places_view_row_get_volume (row);
+ view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW);
+ priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (view));
+ volume = nautilus_gtk_places_view_row_get_volume (row);
- /*
- * When the mount item is activated, it's expected that
- * the volume only gets mounted, without opening it after
- * the operation is complete.
- */
- priv->should_open_location = FALSE;
+ /*
+ * When the mount item is activated, it's expected that
+ * the volume only gets mounted, without opening it after
+ * the operation is complete.
+ */
+ priv->should_open_location = FALSE;
- nautilus_gtk_places_view_row_set_busy (row, TRUE);
- mount_volume (NAUTILUS_GTK_PLACES_VIEW (view), volume);
+ nautilus_gtk_places_view_row_set_busy (row, TRUE);
+ mount_volume (NAUTILUS_GTK_PLACES_VIEW (view), volume);
}
static void
-unmount_cb (GtkMenuItem *item,
+unmount_cb (GtkMenuItem *item,
NautilusGtkPlacesViewRow *row)
{
- GtkWidget *view;
- GMount *mount;
+ GtkWidget *view;
+ GMount *mount;
- view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW);
- mount = nautilus_gtk_places_view_row_get_mount (row);
+ view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW);
+ mount = nautilus_gtk_places_view_row_get_mount (row);
- nautilus_gtk_places_view_row_set_busy (row, TRUE);
+ nautilus_gtk_places_view_row_set_busy (row, TRUE);
- unmount_mount (NAUTILUS_GTK_PLACES_VIEW (view), mount);
+ unmount_mount (NAUTILUS_GTK_PLACES_VIEW (view), mount);
}
/* Constructs the popup menu if needed */
@@ -1737,374 +1604,340 @@ static void
build_popup_menu (NautilusGtkPlacesView *view,
NautilusGtkPlacesViewRow *row)
{
- NautilusGtkPlacesViewPrivate *priv;
- GtkWidget *item;
- GMount *mount;
- GFile *file;
- gboolean is_network;
-
- priv = nautilus_gtk_places_view_get_instance_private (view);
- mount = nautilus_gtk_places_view_row_get_mount (row);
- file = nautilus_gtk_places_view_row_get_file (row);
- is_network = nautilus_gtk_places_view_row_get_is_network (row);
-
- priv->popup_menu = gtk_menu_new ();
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->popup_menu),
- GTK_STYLE_CLASS_CONTEXT_MENU);
-
- gtk_menu_attach_to_widget (GTK_MENU (priv->popup_menu),
- GTK_WIDGET (view),
- popup_menu_detach_cb);
-
- /* Open item is always present */
- item = gtk_menu_item_new_with_mnemonic (_("_Open"));
- g_signal_connect (item,
- "activate",
- G_CALLBACK (open_cb),
- row);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item);
-
- if (priv->open_flags & GTK_PLACES_OPEN_NEW_TAB)
- {
- item = gtk_menu_item_new_with_mnemonic (_("Open in New _Tab"));
- g_signal_connect (item,
- "activate",
- G_CALLBACK (open_in_new_tab_cb),
- row);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item);
- }
-
- if (priv->open_flags & GTK_PLACES_OPEN_NEW_WINDOW)
- {
- item = gtk_menu_item_new_with_mnemonic (_("Open in New _Window"));
- g_signal_connect (item,
- "activate",
- G_CALLBACK (open_in_new_window_cb),
- row);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item);
- }
-
- /*
- * The only item that contains a file up to now is the Computer
- * item, which cannot be mounted or unmounted.
- */
- if (file)
- {
- return;
- }
+ NautilusGtkPlacesViewPrivate *priv;
+ GtkWidget *item;
+ GMount *mount;
+ GFile *file;
+ gboolean is_network;
+
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ mount = nautilus_gtk_places_view_row_get_mount (row);
+ file = nautilus_gtk_places_view_row_get_file (row);
+ is_network = nautilus_gtk_places_view_row_get_is_network (row);
+
+ priv->popup_menu = gtk_menu_new ();
+ gtk_style_context_add_class (gtk_widget_get_style_context (priv->popup_menu),
+ GTK_STYLE_CLASS_CONTEXT_MENU);
+
+ gtk_menu_attach_to_widget (GTK_MENU (priv->popup_menu),
+ GTK_WIDGET (view),
+ popup_menu_detach_cb);
+
+ /* Open item is always present */
+ item = gtk_menu_item_new_with_mnemonic (_("_Open"));
+ g_signal_connect (item,
+ "activate",
+ G_CALLBACK (open_cb),
+ row);
+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item);
+
+ if (priv->open_flags & GTK_PLACES_OPEN_NEW_TAB)
+ {
+ item = gtk_menu_item_new_with_mnemonic (_("Open in New _Tab"));
+ g_signal_connect (item,
+ "activate",
+ G_CALLBACK (open_in_new_tab_cb),
+ row);
+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item);
+ }
+
+ if (priv->open_flags & GTK_PLACES_OPEN_NEW_WINDOW)
+ {
+ item = gtk_menu_item_new_with_mnemonic (_("Open in New _Window"));
+ g_signal_connect (item,
+ "activate",
+ G_CALLBACK (open_in_new_window_cb),
+ row);
+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item);
+ }
+
+ /*
+ * The only item that contains a file up to now is the Computer
+ * item, which cannot be mounted or unmounted.
+ */
+ if (file)
+ return;
- /* Separator */
- item = gtk_separator_menu_item_new ();
- gtk_widget_show (item);
- gtk_menu_shell_insert (GTK_MENU_SHELL (priv->popup_menu), item, -1);
+ /* Separator */
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_insert (GTK_MENU_SHELL (priv->popup_menu), item, -1);
- /* Mount/Unmount items */
- if (mount)
+ /* Mount/Unmount items */
+ if (mount)
{
- item = gtk_menu_item_new_with_mnemonic (is_network ? _("_Disconnect") : _("_Unmount"));
- g_signal_connect (item,
- "activate",
- G_CALLBACK (unmount_cb),
- row);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item);
+ item = gtk_menu_item_new_with_mnemonic (is_network ? _("_Disconnect") : _("_Unmount"));
+ g_signal_connect (item,
+ "activate",
+ G_CALLBACK (unmount_cb),
+ row);
+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item);
}
- else
+ else
{
- item = gtk_menu_item_new_with_mnemonic (is_network ? _("_Connect") : _("_Mount"));
- g_signal_connect (item,
- "activate",
- G_CALLBACK (mount_cb),
- row);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item);
+ item = gtk_menu_item_new_with_mnemonic (is_network ? _("_Connect") : _("_Mount"));
+ g_signal_connect (item,
+ "activate",
+ G_CALLBACK (mount_cb),
+ row);
+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item);
}
}
static void
popup_menu (NautilusGtkPlacesViewRow *row,
- GdkEventButton *event)
+ GdkEventButton *event)
{
- NautilusGtkPlacesViewPrivate *priv;
- GtkWidget *view;
+ NautilusGtkPlacesViewPrivate *priv;
+ GtkWidget *view;
- view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW);
- priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (view));
+ view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW);
+ priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (view));
- g_clear_pointer (&priv->popup_menu, gtk_widget_destroy);
+ g_clear_pointer (&priv->popup_menu, gtk_widget_destroy);
- build_popup_menu (NAUTILUS_GTK_PLACES_VIEW (view), row);
+ build_popup_menu (NAUTILUS_GTK_PLACES_VIEW (view), row);
- gtk_menu_popup_at_pointer (GTK_MENU (priv->popup_menu), (GdkEvent *) event);
+ gtk_menu_popup_at_pointer (GTK_MENU (priv->popup_menu), (GdkEvent *) event);
}
static gboolean
on_row_popup_menu (NautilusGtkPlacesViewRow *row)
{
- popup_menu (row, NULL);
- return TRUE;
+ popup_menu (row, NULL);
+ return TRUE;
}
static gboolean
on_button_press_event (NautilusGtkPlacesViewRow *row,
- GdkEventButton *event)
+ GdkEventButton *event)
{
- if (row &&
- gdk_event_triggers_context_menu ((GdkEvent *) event) &&
- event->type == GDK_BUTTON_PRESS)
+ if (row &&
+ gdk_event_triggers_context_menu ((GdkEvent*) event) &&
+ event->type == GDK_BUTTON_PRESS)
{
- popup_menu (row, event);
+ popup_menu (row, event);
- return TRUE;
+ return TRUE;
}
- return FALSE;
+ return FALSE;
}
static gboolean
-on_key_press_event (GtkWidget *widget,
- GdkEventKey *event,
+on_key_press_event (GtkWidget *widget,
+ GdkEventKey *event,
NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- if (event)
+ if (event)
{
- guint modifiers;
+ guint modifiers;
- modifiers = gtk_accelerator_get_default_mod_mask ();
+ modifiers = gtk_accelerator_get_default_mod_mask ();
- if (event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter ||
- event->keyval == GDK_KEY_ISO_Enter ||
- event->keyval == GDK_KEY_space)
+ if (event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_ISO_Enter ||
+ event->keyval == GDK_KEY_space)
{
- GtkWidget *focus_widget;
- GtkWindow *toplevel;
+ GtkWidget *focus_widget;
+ GtkWindow *toplevel;
- priv->current_open_flags = GTK_PLACES_OPEN_NORMAL;
- toplevel = get_toplevel (GTK_WIDGET (view));
+ priv->current_open_flags = GTK_PLACES_OPEN_NORMAL;
+ toplevel = get_toplevel (GTK_WIDGET (view));
- if (!toplevel)
- {
- return FALSE;
- }
+ if (!toplevel)
+ return FALSE;
- focus_widget = gtk_window_get_focus (toplevel);
+ focus_widget = gtk_window_get_focus (toplevel);
- if (!NAUTILUS_IS_GTK_PLACES_VIEW_ROW (focus_widget))
- {
- return FALSE;
- }
+ if (!NAUTILUS_IS_GTK_PLACES_VIEW_ROW (focus_widget))
+ return FALSE;
- if ((event->state & modifiers) == GDK_SHIFT_MASK)
- {
- priv->current_open_flags = GTK_PLACES_OPEN_NEW_TAB;
- }
- else if ((event->state & modifiers) == GDK_CONTROL_MASK)
- {
- priv->current_open_flags = GTK_PLACES_OPEN_NEW_WINDOW;
- }
+ if ((event->state & modifiers) == GDK_SHIFT_MASK)
+ priv->current_open_flags = GTK_PLACES_OPEN_NEW_TAB;
+ else if ((event->state & modifiers) == GDK_CONTROL_MASK)
+ priv->current_open_flags = GTK_PLACES_OPEN_NEW_WINDOW;
- activate_row (view, NAUTILUS_GTK_PLACES_VIEW_ROW (focus_widget), priv->current_open_flags);
+ activate_row (view, NAUTILUS_GTK_PLACES_VIEW_ROW (focus_widget), priv->current_open_flags);
- return TRUE;
+ return TRUE;
}
}
- return FALSE;
+ return FALSE;
}
static void
-on_eject_button_clicked (GtkWidget *widget,
+on_eject_button_clicked (GtkWidget *widget,
NautilusGtkPlacesViewRow *row)
{
- if (row)
+ if (row)
{
- GtkWidget *view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW);
+ GtkWidget *view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW);
- unmount_mount (NAUTILUS_GTK_PLACES_VIEW (view), nautilus_gtk_places_view_row_get_mount (row));
+ unmount_mount (NAUTILUS_GTK_PLACES_VIEW (view), nautilus_gtk_places_view_row_get_mount (row));
}
}
static void
on_connect_button_clicked (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
- const gchar *uri;
- GFile *file;
-
- priv = nautilus_gtk_places_view_get_instance_private (view);
- file = NULL;
-
- /*
- * Since the 'Connect' button is updated whenever the typed
- * address changes, it is sufficient to check if it's sensitive
- * or not, in order to determine if the given address is valid.
- */
- if (!gtk_widget_get_sensitive (priv->connect_button))
- {
- return;
- }
+ NautilusGtkPlacesViewPrivate *priv;
+ const gchar *uri;
+ GFile *file;
+
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ file = NULL;
+
+ /*
+ * Since the 'Connect' button is updated whenever the typed
+ * address changes, it is sufficient to check if it's sensitive
+ * or not, in order to determine if the given address is valid.
+ */
+ if (!gtk_widget_get_sensitive (priv->connect_button))
+ return;
- uri = gtk_entry_get_text (GTK_ENTRY (priv->address_entry));
+ uri = gtk_entry_get_text (GTK_ENTRY (priv->address_entry));
- if (uri != NULL && uri[0] != '\0')
- {
- file = g_file_new_for_commandline_arg (uri);
- }
+ if (uri != NULL && uri[0] != '\0')
+ file = g_file_new_for_commandline_arg (uri);
- if (file)
+ if (file)
{
- priv->should_open_location = TRUE;
+ priv->should_open_location = TRUE;
- mount_server (view, file);
+ mount_server (view, file);
}
- else
+ else
{
- emit_show_error_message (view, _("Unable to get remote server location"), NULL);
+ emit_show_error_message (view, _("Unable to get remote server location"), NULL);
}
}
static void
on_address_entry_text_changed (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
- const gchar * const *supported_protocols;
- gchar *address, *scheme;
- gboolean supported;
+ NautilusGtkPlacesViewPrivate *priv;
+ const gchar* const *supported_protocols;
+ gchar *address, *scheme;
+ gboolean supported;
- priv = nautilus_gtk_places_view_get_instance_private (view);
- supported = FALSE;
- supported_protocols = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
- address = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->address_entry)));
- scheme = g_uri_parse_scheme (address);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ supported = FALSE;
+ supported_protocols = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
+ address = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->address_entry)));
+ scheme = g_uri_parse_scheme (address);
- if (!supported_protocols)
- {
- goto out;
- }
+ if (!supported_protocols)
+ goto out;
- if (!scheme)
- {
- goto out;
- }
+ if (!scheme)
+ goto out;
- supported = g_strv_contains (supported_protocols, scheme) &&
- !g_strv_contains (unsupported_protocols, scheme);
+ supported = g_strv_contains (supported_protocols, scheme) &&
+ !g_strv_contains (unsupported_protocols, scheme);
out:
- gtk_widget_set_sensitive (priv->connect_button, supported);
- g_free (address);
- g_free (scheme);
+ gtk_widget_set_sensitive (priv->connect_button, supported);
+ g_free (address);
+ g_free (scheme);
}
static void
-on_address_entry_show_help_pressed (NautilusGtkPlacesView *view,
- GtkEntryIconPosition icon_pos,
- GdkEvent *event,
- GtkEntry *entry)
+on_address_entry_show_help_pressed (NautilusGtkPlacesView *view,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent *event,
+ GtkEntry *entry)
{
- NautilusGtkPlacesViewPrivate *priv;
- GdkRectangle rect;
+ NautilusGtkPlacesViewPrivate *priv;
+ GdkRectangle rect;
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- /* Setup the auxiliary popover's rectangle */
- gtk_entry_get_icon_area (GTK_ENTRY (priv->address_entry),
- GTK_ENTRY_ICON_SECONDARY,
- &rect);
+ /* Setup the auxiliary popover's rectangle */
+ gtk_entry_get_icon_area (GTK_ENTRY (priv->address_entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ &rect);
- gtk_popover_set_pointing_to (GTK_POPOVER (priv->server_adresses_popover), &rect);
- gtk_widget_set_visible (priv->server_adresses_popover, TRUE);
+ gtk_popover_set_pointing_to (GTK_POPOVER (priv->server_adresses_popover), &rect);
+ gtk_widget_set_visible (priv->server_adresses_popover, TRUE);
}
static void
on_recent_servers_listbox_row_activated (NautilusGtkPlacesView *view,
NautilusGtkPlacesViewRow *row,
- GtkWidget *listbox)
+ GtkWidget *listbox)
{
- NautilusGtkPlacesViewPrivate *priv;
- gchar *uri;
+ NautilusGtkPlacesViewPrivate *priv;
+ gchar *uri;
- priv = nautilus_gtk_places_view_get_instance_private (view);
- uri = g_object_get_data (G_OBJECT (row), "uri");
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ uri = g_object_get_data (G_OBJECT (row), "uri");
- gtk_entry_set_text (GTK_ENTRY (priv->address_entry), uri);
+ gtk_entry_set_text (GTK_ENTRY (priv->address_entry), uri);
- gtk_widget_hide (priv->recent_servers_popover);
+ gtk_widget_hide (priv->recent_servers_popover);
}
static void
on_listbox_row_activated (NautilusGtkPlacesView *view,
NautilusGtkPlacesViewRow *row,
- GtkWidget *listbox)
+ GtkWidget *listbox)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- activate_row (view, row, priv->current_open_flags);
+ activate_row (view, row, priv->current_open_flags);
}
static gboolean
listbox_filter_func (GtkListBoxRow *row,
gpointer user_data)
{
- NautilusGtkPlacesViewPrivate *priv;
- gboolean is_network;
- gboolean is_placeholder;
- gboolean retval;
- gboolean searching;
- gchar *name;
- gchar *path;
+ NautilusGtkPlacesViewPrivate *priv;
+ gboolean is_network;
+ gboolean is_placeholder;
+ gboolean retval;
+ gboolean searching;
+ gchar *name;
+ gchar *path;
- priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (user_data));
- retval = FALSE;
- searching = priv->search_query && priv->search_query[0] != '\0';
+ priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (user_data));
+ retval = FALSE;
+ searching = priv->search_query && priv->search_query[0] != '\0';
- is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "is-network"));
- is_placeholder = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "is-placeholder"));
+ is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "is-network"));
+ is_placeholder = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "is-placeholder"));
- if (is_network && priv->local_only)
- {
- return FALSE;
- }
+ if (is_network && priv->local_only)
+ return FALSE;
- if (is_placeholder && searching)
- {
- return FALSE;
- }
+ if (is_placeholder && searching)
+ return FALSE;
- if (!searching)
- {
- return TRUE;
- }
+ if (!searching)
+ return TRUE;
- g_object_get (row,
- "name", &name,
- "path", &path,
- NULL);
+ g_object_get (row,
+ "name", &name,
+ "path", &path,
+ NULL);
- if (name)
- {
- retval |= strstr (name, priv->search_query) != NULL;
- }
+ if (name)
+ retval |= strstr (name, priv->search_query) != NULL;
- if (path)
- {
- retval |= strstr (path, priv->search_query) != NULL;
- }
+ if (path)
+ retval |= strstr (path, priv->search_query) != NULL;
- g_free (name);
- g_free (path);
+ g_free (name);
+ g_free (path);
- return retval;
+ return retval;
}
static void
@@ -2112,88 +1945,85 @@ listbox_header_func (GtkListBoxRow *row,
GtkListBoxRow *before,
gpointer user_data)
{
- gboolean row_is_network;
- gchar *text;
+ gboolean row_is_network;
+ gchar *text;
- text = NULL;
- row_is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "is-network"));
+ text = NULL;
+ row_is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "is-network"));
- if (!before)
+ if (!before)
{
- text = g_strdup_printf ("<b>%s</b>", row_is_network ? _("Networks") : _("On This Computer"));
+ text = g_strdup_printf ("<b>%s</b>", row_is_network ? _("Networks") : _("On This Computer"));
}
- else
+ else
{
- gboolean before_is_network;
+ gboolean before_is_network;
- before_is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (before), "is-network"));
+ before_is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (before), "is-network"));
- if (before_is_network != row_is_network)
- {
- text = g_strdup_printf ("<b>%s</b>", row_is_network ? _("Networks") : _("On This Computer"));
- }
+ if (before_is_network != row_is_network)
+ text = g_strdup_printf ("<b>%s</b>", row_is_network ? _("Networks") : _("On This Computer"));
}
- if (text)
+ if (text)
{
- GtkWidget *header;
- GtkWidget *label;
- GtkWidget *separator;
+ GtkWidget *header;
+ GtkWidget *label;
+ GtkWidget *separator;
- header = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_widget_set_margin_top (header, 6);
+ header = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_widget_set_margin_top (header, 6);
- separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- label = g_object_new (GTK_TYPE_LABEL,
- "use_markup", TRUE,
- "margin-start", 12,
- "label", text,
- "xalign", 0.0f,
- NULL);
- if (row_is_network)
+ label = g_object_new (GTK_TYPE_LABEL,
+ "use_markup", TRUE,
+ "margin-start", 12,
+ "label", text,
+ "xalign", 0.0f,
+ NULL);
+ if (row_is_network)
{
- GtkWidget *header_name;
- GtkWidget *network_header_spinner;
+ GtkWidget *header_name;
+ GtkWidget *network_header_spinner;
- g_object_set (label,
- "margin-end", 6,
- NULL);
+ g_object_set (label,
+ "margin-end", 6,
+ NULL);
- header_name = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- network_header_spinner = gtk_spinner_new ();
- g_object_set (network_header_spinner,
- "margin-end", 12,
- NULL);
- g_object_bind_property (NAUTILUS_GTK_PLACES_VIEW (user_data),
- "fetching-networks",
- network_header_spinner,
- "active",
- G_BINDING_SYNC_CREATE);
-
- gtk_container_add (GTK_CONTAINER (header_name), label);
- gtk_container_add (GTK_CONTAINER (header_name), network_header_spinner);
- gtk_container_add (GTK_CONTAINER (header), header_name);
+ header_name = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ network_header_spinner = gtk_spinner_new ();
+ g_object_set (network_header_spinner,
+ "margin-end", 12,
+ NULL);
+ g_object_bind_property (NAUTILUS_GTK_PLACES_VIEW (user_data),
+ "fetching-networks",
+ network_header_spinner,
+ "active",
+ G_BINDING_SYNC_CREATE);
+
+ gtk_container_add (GTK_CONTAINER (header_name), label);
+ gtk_container_add (GTK_CONTAINER (header_name), network_header_spinner);
+ gtk_container_add (GTK_CONTAINER (header), header_name);
}
- else
+ else
{
- g_object_set (label,
- "hexpand", TRUE,
- "margin-end", 12,
- NULL);
- gtk_container_add (GTK_CONTAINER (header), label);
+ g_object_set (label,
+ "hexpand", TRUE,
+ "margin-end", 12,
+ NULL);
+ gtk_container_add (GTK_CONTAINER (header), label);
}
- gtk_container_add (GTK_CONTAINER (header), separator);
- gtk_widget_show_all (header);
+ gtk_container_add (GTK_CONTAINER (header), separator);
- gtk_list_box_row_set_header (row, header);
+ gtk_list_box_row_set_header (row, header);
- g_free (text);
+ g_free (text);
}
- else
+ else
{
- gtk_list_box_row_set_header (row, NULL);
+ gtk_list_box_row_set_header (row, NULL);
}
}
@@ -2202,247 +2032,241 @@ listbox_sort_func (GtkListBoxRow *row1,
GtkListBoxRow *row2,
gpointer user_data)
{
- gboolean row1_is_network;
- gboolean row2_is_network;
- gchar *path1;
- gchar *path2;
- gboolean *is_placeholder1;
- gboolean *is_placeholder2;
- gint retval;
+ gboolean row1_is_network;
+ gboolean row2_is_network;
+ gchar *path1;
+ gchar *path2;
+ gboolean *is_placeholder1;
+ gboolean *is_placeholder2;
+ gint retval;
- row1_is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row1), "is-network"));
- row2_is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row2), "is-network"));
+ row1_is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row1), "is-network"));
+ row2_is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row2), "is-network"));
- retval = row1_is_network - row2_is_network;
+ retval = row1_is_network - row2_is_network;
- if (retval != 0)
- {
- return retval;
- }
+ if (retval != 0)
+ return retval;
- is_placeholder1 = g_object_get_data (G_OBJECT (row1), "is-placeholder");
- is_placeholder2 = g_object_get_data (G_OBJECT (row2), "is-placeholder");
+ is_placeholder1 = g_object_get_data (G_OBJECT (row1), "is-placeholder");
+ is_placeholder2 = g_object_get_data (G_OBJECT (row2), "is-placeholder");
- /* we can't have two placeholders for the same section */
- g_assert (!(is_placeholder1 != NULL && is_placeholder2 != NULL));
+ /* we can't have two placeholders for the same section */
+ g_assert (!(is_placeholder1 != NULL && is_placeholder2 != NULL));
- if (is_placeholder1)
- {
- return -1;
- }
- if (is_placeholder2)
- {
- return 1;
- }
+ if (is_placeholder1)
+ return -1;
+ if (is_placeholder2)
+ return 1;
- g_object_get (row1, "path", &path1, NULL);
- g_object_get (row2, "path", &path2, NULL);
+ g_object_get (row1, "path", &path1, NULL);
+ g_object_get (row2, "path", &path2, NULL);
- retval = g_utf8_collate (path1, path2);
+ retval = g_utf8_collate (path1, path2);
- g_free (path1);
- g_free (path2);
+ g_free (path1);
+ g_free (path2);
- return retval;
+ return retval;
}
static void
nautilus_gtk_places_view_constructed (GObject *object)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (object));
+ priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (object));
- G_OBJECT_CLASS (nautilus_gtk_places_view_parent_class)->constructed (object);
+ G_OBJECT_CLASS (nautilus_gtk_places_view_parent_class)->constructed (object);
- gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->listbox),
- listbox_sort_func,
+ gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->listbox),
+ listbox_sort_func,
+ object,
+ NULL);
+ gtk_list_box_set_filter_func (GTK_LIST_BOX (priv->listbox),
+ listbox_filter_func,
+ object,
+ NULL);
+ gtk_list_box_set_header_func (GTK_LIST_BOX (priv->listbox),
+ listbox_header_func,
object,
NULL);
- gtk_list_box_set_filter_func (GTK_LIST_BOX (priv->listbox),
- listbox_filter_func,
- object,
- NULL);
- gtk_list_box_set_header_func (GTK_LIST_BOX (priv->listbox),
- listbox_header_func,
- object,
- NULL);
-
- /* load drives */
- update_places (NAUTILUS_GTK_PLACES_VIEW (object));
-
- g_signal_connect_swapped (priv->volume_monitor,
- "mount-added",
- G_CALLBACK (update_places),
- object);
- g_signal_connect_swapped (priv->volume_monitor,
- "mount-changed",
- G_CALLBACK (update_places),
- object);
- g_signal_connect_swapped (priv->volume_monitor,
- "mount-removed",
- G_CALLBACK (update_places),
- object);
- g_signal_connect_swapped (priv->volume_monitor,
- "volume-added",
- G_CALLBACK (update_places),
- object);
- g_signal_connect_swapped (priv->volume_monitor,
- "volume-changed",
- G_CALLBACK (update_places),
- object);
- g_signal_connect_swapped (priv->volume_monitor,
- "volume-removed",
- G_CALLBACK (update_places),
- object);
+
+ /* load drives */
+ update_places (NAUTILUS_GTK_PLACES_VIEW (object));
+
+ g_signal_connect_swapped (priv->volume_monitor,
+ "mount-added",
+ G_CALLBACK (update_places),
+ object);
+ g_signal_connect_swapped (priv->volume_monitor,
+ "mount-changed",
+ G_CALLBACK (update_places),
+ object);
+ g_signal_connect_swapped (priv->volume_monitor,
+ "mount-removed",
+ G_CALLBACK (update_places),
+ object);
+ g_signal_connect_swapped (priv->volume_monitor,
+ "volume-added",
+ G_CALLBACK (update_places),
+ object);
+ g_signal_connect_swapped (priv->volume_monitor,
+ "volume-changed",
+ G_CALLBACK (update_places),
+ object);
+ g_signal_connect_swapped (priv->volume_monitor,
+ "volume-removed",
+ G_CALLBACK (update_places),
+ object);
}
static void
nautilus_gtk_places_view_map (GtkWidget *widget)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (widget));
+ priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (widget));
- gtk_entry_set_text (GTK_ENTRY (priv->address_entry), "");
+ gtk_entry_set_text (GTK_ENTRY (priv->address_entry), "");
- GTK_WIDGET_CLASS (nautilus_gtk_places_view_parent_class)->map (widget);
+ GTK_WIDGET_CLASS (nautilus_gtk_places_view_parent_class)->map (widget);
}
static void
nautilus_gtk_places_view_class_init (NautilusGtkPlacesViewClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->finalize = nautilus_gtk_places_view_finalize;
- object_class->constructed = nautilus_gtk_places_view_constructed;
- object_class->get_property = nautilus_gtk_places_view_get_property;
- object_class->set_property = nautilus_gtk_places_view_set_property;
-
- widget_class->destroy = nautilus_gtk_places_view_destroy;
- widget_class->map = nautilus_gtk_places_view_map;
-
- /**
- * NautilusGtkPlacesView::open-location:
- * @view: the object which received the signal.
- * @location: (type Gio.File): #GFile to which the caller should switch.
- * @open_flags: a single value from #GtkPlacesOpenFlags specifying how the @location
- * should be opened.
- *
- * The places view emits this signal when the user selects a location
- * in it. The calling application should display the contents of that
- * location; for example, a file manager should show a list of files in
- * the specified location.
- *
- * Since: 3.18
- */
- places_view_signals [OPEN_LOCATION] =
- g_signal_new ("open-location",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NautilusGtkPlacesViewClass, open_location),
- NULL, NULL, NULL,
- G_TYPE_NONE, 2,
- G_TYPE_OBJECT,
- GTK_TYPE_PLACES_OPEN_FLAGS);
-
- /**
- * NautilusGtkPlacesView::show-error-message:
- * @view: the object which received the signal.
- * @primary: primary message with a summary of the error to show.
- * @secondary: secondary message with details of the error to show.
- *
- * The places view emits this signal when it needs the calling
- * application to present an error message. Most of these messages
- * refer to mounting or unmounting media, for example, when a drive
- * cannot be started for some reason.
- *
- * Since: 3.18
- */
- places_view_signals [SHOW_ERROR_MESSAGE] =
- g_signal_new ("show-error-message",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NautilusGtkPlacesViewClass, show_error_message),
- NULL, NULL,
- NULL,
- G_TYPE_NONE, 2,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- properties[PROP_LOCAL_ONLY] =
- g_param_spec_boolean ("local-only",
- "Local Only",
- "Whether the sidebar only includes local files",
- FALSE,
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = nautilus_gtk_places_view_finalize;
+ object_class->constructed = nautilus_gtk_places_view_constructed;
+ object_class->get_property = nautilus_gtk_places_view_get_property;
+ object_class->set_property = nautilus_gtk_places_view_set_property;
+
+ widget_class->destroy = nautilus_gtk_places_view_destroy;
+ widget_class->map = nautilus_gtk_places_view_map;
+
+ /*
+ * NautilusGtkPlacesView::open-location:
+ * @view: the object which received the signal.
+ * @location: (type Gio.File): #GFile to which the caller should switch.
+ * @open_flags: a single value from #GtkPlacesOpenFlags specifying how the @location
+ * should be opened.
+ *
+ * The places view emits this signal when the user selects a location
+ * in it. The calling application should display the contents of that
+ * location; for example, a file manager should show a list of files in
+ * the specified location.
+ *
+ * Since: 3.18
+ */
+ places_view_signals [OPEN_LOCATION] =
+ g_signal_new ("open-location",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NautilusGtkPlacesViewClass, open_location),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 2,
+ G_TYPE_OBJECT,
+ GTK_TYPE_PLACES_OPEN_FLAGS);
+
+ /*
+ * NautilusGtkPlacesView::show-error-message:
+ * @view: the object which received the signal.
+ * @primary: primary message with a summary of the error to show.
+ * @secondary: secondary message with details of the error to show.
+ *
+ * The places view emits this signal when it needs the calling
+ * application to present an error message. Most of these messages
+ * refer to mounting or unmounting media, for example, when a drive
+ * cannot be started for some reason.
+ *
+ * Since: 3.18
+ */
+ places_view_signals [SHOW_ERROR_MESSAGE] =
+ g_signal_new ("show-error-message",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NautilusGtkPlacesViewClass, show_error_message),
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE, 2,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+
+ properties[PROP_LOCAL_ONLY] =
+ g_param_spec_boolean ("local-only",
+ "Local Only",
+ "Whether the sidebar only includes local files",
+ FALSE,
+ G_PARAM_READWRITE);
+
+ properties[PROP_LOADING] =
+ g_param_spec_boolean ("loading",
+ "Loading",
+ "Whether the view is loading locations",
+ FALSE,
+ G_PARAM_READABLE);
+
+ properties[PROP_FETCHING_NETWORKS] =
+ g_param_spec_boolean ("fetching-networks",
+ "Fetching networks",
+ "Whether the view is fetching networks",
+ FALSE,
+ G_PARAM_READABLE);
+
+ properties[PROP_OPEN_FLAGS] =
+ g_param_spec_flags ("open-flags",
+ "Open Flags",
+ "Modes in which the calling application can open locations selected in the sidebar",
+ GTK_TYPE_PLACES_OPEN_FLAGS,
+ GTK_PLACES_OPEN_NORMAL,
G_PARAM_READWRITE);
- properties[PROP_LOADING] =
- g_param_spec_boolean ("loading",
- "Loading",
- "Whether the view is loading locations",
- FALSE,
- G_PARAM_READABLE);
-
- properties[PROP_FETCHING_NETWORKS] =
- g_param_spec_boolean ("fetching-networks",
- "Fetching networks",
- "Whether the view is fetching networks",
- FALSE,
- G_PARAM_READABLE);
-
- properties[PROP_OPEN_FLAGS] =
- g_param_spec_flags ("open-flags",
- "Open Flags",
- "Modes in which the calling application can open locations selected in the sidebar",
- GTK_TYPE_PLACES_OPEN_FLAGS,
- GTK_PLACES_OPEN_NORMAL,
- G_PARAM_READWRITE);
-
- g_object_class_install_properties (object_class, LAST_PROP, properties);
-
- /* Bind class to template */
- gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/nautilus/gtk/ui/nautilusgtkplacesview.ui");
-
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, actionbar);
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, address_entry);
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, address_entry_completion);
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, completion_store);
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, connect_button);
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, listbox);
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, recent_servers_listbox);
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, recent_servers_popover);
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, recent_servers_stack);
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, stack);
- gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, server_adresses_popover);
-
- 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);
- gtk_widget_class_bind_template_callback (widget_class, on_connect_button_clicked);
- gtk_widget_class_bind_template_callback (widget_class, on_key_press_event);
- gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated);
- gtk_widget_class_bind_template_callback (widget_class, on_recent_servers_listbox_row_activated);
-
- gtk_widget_class_set_css_name (widget_class, "placesview");
+ g_object_class_install_properties (object_class, LAST_PROP, properties);
+
+ /* Bind class to template */
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/nautilus/gtk/ui/nautilusgtkplacesview.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, actionbar);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, address_entry);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, address_entry_completion);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, completion_store);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, connect_button);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, listbox);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, recent_servers_listbox);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, recent_servers_popover);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, recent_servers_stack);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, stack);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, server_adresses_popover);
+
+ 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);
+ gtk_widget_class_bind_template_callback (widget_class, on_connect_button_clicked);
+ gtk_widget_class_bind_template_callback (widget_class, on_key_press_event);
+ gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated);
+ gtk_widget_class_bind_template_callback (widget_class, on_recent_servers_listbox_row_activated);
+
+ gtk_widget_class_set_css_name (widget_class, "placesview");
}
static void
nautilus_gtk_places_view_init (NautilusGtkPlacesView *self)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- priv = nautilus_gtk_places_view_get_instance_private (self);
+ priv = nautilus_gtk_places_view_get_instance_private (self);
- priv->volume_monitor = g_volume_monitor_get ();
- priv->open_flags = GTK_PLACES_OPEN_NORMAL;
- priv->path_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- priv->space_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ priv->volume_monitor = g_volume_monitor_get ();
+ priv->open_flags = GTK_PLACES_OPEN_NORMAL;
+ priv->path_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ priv->space_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- gtk_widget_init_template (GTK_WIDGET (self));
+ gtk_widget_init_template (GTK_WIDGET (self));
}
-/**
+/*
* nautilus_gtk_places_view_new:
*
* Creates a new #NautilusGtkPlacesView widget.
@@ -2458,10 +2282,10 @@ nautilus_gtk_places_view_init (NautilusGtkPlacesView *self)
GtkWidget *
nautilus_gtk_places_view_new (void)
{
- return g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW, NULL);
+ return g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW, NULL);
}
-/**
+/*
* nautilus_gtk_places_view_set_open_flags:
* @view: a #NautilusGtkPlacesView
* @flags: Bitmask of modes in which the calling application can open locations
@@ -2485,23 +2309,23 @@ nautilus_gtk_places_view_new (void)
* Since: 3.18
*/
void
-nautilus_gtk_places_view_set_open_flags (NautilusGtkPlacesView *view,
- GtkPlacesOpenFlags flags)
+nautilus_gtk_places_view_set_open_flags (NautilusGtkPlacesView *view,
+ GtkPlacesOpenFlags flags)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
+ g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- if (priv->open_flags != flags)
+ if (priv->open_flags != flags)
{
- priv->open_flags = flags;
- g_object_notify_by_pspec (G_OBJECT (view), properties[PROP_OPEN_FLAGS]);
+ priv->open_flags = flags;
+ g_object_notify_by_pspec (G_OBJECT (view), properties[PROP_OPEN_FLAGS]);
}
}
-/**
+/*
* nautilus_gtk_places_view_get_open_flags:
* @view: a #GtkPlacesSidebar
*
@@ -2514,16 +2338,16 @@ nautilus_gtk_places_view_set_open_flags (NautilusGtkPlacesView *view,
GtkPlacesOpenFlags
nautilus_gtk_places_view_get_open_flags (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), 0);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), 0);
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- return priv->open_flags;
+ return priv->open_flags;
}
-/**
+/*
* nautilus_gtk_places_view_get_search_query:
* @view: a #NautilusGtkPlacesView
*
@@ -2531,19 +2355,19 @@ nautilus_gtk_places_view_get_open_flags (NautilusGtkPlacesView *view)
*
* Returns: (transfer none): the current search query.
*/
-const gchar *
+const gchar*
nautilus_gtk_places_view_get_search_query (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), NULL);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), NULL);
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- return priv->search_query;
+ return priv->search_query;
}
-/**
+/*
* nautilus_gtk_places_view_set_search_query:
* @view: a #NautilusGtkPlacesView
* @query_text: the query, or NULL.
@@ -2553,27 +2377,27 @@ nautilus_gtk_places_view_get_search_query (NautilusGtkPlacesView *view)
*/
void
nautilus_gtk_places_view_set_search_query (NautilusGtkPlacesView *view,
- const gchar *query_text)
+ const gchar *query_text)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
+ g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- if (g_strcmp0 (priv->search_query, query_text) != 0)
+ if (g_strcmp0 (priv->search_query, query_text) != 0)
{
- g_clear_pointer (&priv->search_query, g_free);
- priv->search_query = g_strdup (query_text);
+ g_clear_pointer (&priv->search_query, g_free);
+ priv->search_query = g_strdup (query_text);
- gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->listbox));
- gtk_list_box_invalidate_headers (GTK_LIST_BOX (priv->listbox));
+ gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->listbox));
+ gtk_list_box_invalidate_headers (GTK_LIST_BOX (priv->listbox));
- update_view_mode (view);
+ update_view_mode (view);
}
}
-/**
+/*
* nautilus_gtk_places_view_get_loading:
* @view: a #NautilusGtkPlacesView
*
@@ -2584,78 +2408,78 @@ nautilus_gtk_places_view_set_search_query (NautilusGtkPlacesView *view,
gboolean
nautilus_gtk_places_view_get_loading (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), FALSE);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), FALSE);
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- return priv->loading;
+ return priv->loading;
}
static void
update_loading (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
- gboolean loading;
+ NautilusGtkPlacesViewPrivate *priv;
+ gboolean loading;
- g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
+ g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
- priv = nautilus_gtk_places_view_get_instance_private (view);
- loading = priv->fetching_networks || priv->connecting_to_server ||
- priv->mounting_volume || priv->unmounting_mount;
+ priv = nautilus_gtk_places_view_get_instance_private (view);
+ loading = priv->fetching_networks || priv->connecting_to_server ||
+ priv->mounting_volume || priv->unmounting_mount;
- set_busy_cursor (view, loading);
- nautilus_gtk_places_view_set_loading (view, loading);
+ set_busy_cursor (view, loading);
+ nautilus_gtk_places_view_set_loading (view, loading);
}
static void
nautilus_gtk_places_view_set_loading (NautilusGtkPlacesView *view,
- gboolean loading)
+ gboolean loading)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
+ g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- if (priv->loading != loading)
+ if (priv->loading != loading)
{
- priv->loading = loading;
- g_object_notify_by_pspec (G_OBJECT (view), properties [PROP_LOADING]);
+ priv->loading = loading;
+ g_object_notify_by_pspec (G_OBJECT (view), properties [PROP_LOADING]);
}
}
static gboolean
nautilus_gtk_places_view_get_fetching_networks (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), FALSE);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), FALSE);
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- return priv->fetching_networks;
+ return priv->fetching_networks;
}
static void
nautilus_gtk_places_view_set_fetching_networks (NautilusGtkPlacesView *view,
- gboolean fetching_networks)
+ gboolean fetching_networks)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
+ g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- if (priv->fetching_networks != fetching_networks)
+ if (priv->fetching_networks != fetching_networks)
{
- priv->fetching_networks = fetching_networks;
- g_object_notify_by_pspec (G_OBJECT (view), properties [PROP_FETCHING_NETWORKS]);
+ priv->fetching_networks = fetching_networks;
+ g_object_notify_by_pspec (G_OBJECT (view), properties [PROP_FETCHING_NETWORKS]);
}
}
-/**
+/*
* nautilus_gtk_places_view_get_local_only:
* @view: a #NautilusGtkPlacesView
*
@@ -2669,16 +2493,16 @@ nautilus_gtk_places_view_set_fetching_networks (NautilusGtkPlacesView *view,
gboolean
nautilus_gtk_places_view_get_local_only (NautilusGtkPlacesView *view)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), FALSE);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), FALSE);
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- return priv->local_only;
+ return priv->local_only;
}
-/**
+/*
* nautilus_gtk_places_view_set_local_only:
* @view: a #NautilusGtkPlacesView
* @local_only: %TRUE to hide remote locations, %FALSE to show.
@@ -2689,23 +2513,23 @@ nautilus_gtk_places_view_get_local_only (NautilusGtkPlacesView *view)
*/
void
nautilus_gtk_places_view_set_local_only (NautilusGtkPlacesView *view,
- gboolean local_only)
+ gboolean local_only)
{
- NautilusGtkPlacesViewPrivate *priv;
+ NautilusGtkPlacesViewPrivate *priv;
- g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
+ g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view));
- priv = nautilus_gtk_places_view_get_instance_private (view);
+ priv = nautilus_gtk_places_view_get_instance_private (view);
- if (priv->local_only != local_only)
+ if (priv->local_only != local_only)
{
- priv->local_only = local_only;
+ priv->local_only = local_only;
- gtk_widget_set_visible (priv->actionbar, !local_only);
- update_places (view);
+ gtk_widget_set_visible (priv->actionbar, !local_only);
+ update_places (view);
- update_view_mode (view);
+ update_view_mode (view);
- g_object_notify_by_pspec (G_OBJECT (view), properties [PROP_LOCAL_ONLY]);
+ g_object_notify_by_pspec (G_OBJECT (view), properties [PROP_LOCAL_ONLY]);
}
}
diff --git a/src/gtk/nautilusgtkplacesview.ui b/src/gtk/nautilusgtkplacesview.ui
index d897638ca..39a1c5d5c 100644
--- a/src/gtk/nautilusgtkplacesview.ui
+++ b/src/gtk/nautilusgtkplacesview.ui
@@ -19,13 +19,11 @@
<property name="relative-to">address_entry</property>
<child>
<object class="GtkBox">
- <property name="visible">1</property>
- <property name="border-width">18</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
+ <property name="margin">18</property>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">Server Addresses</property>
<attributes>
@@ -38,7 +36,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">Server addresses are made up of a protocol prefix and an address. Examples:</property>
<property name="wrap">1</property>
@@ -52,9 +49,8 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="hexpand">1</property>
- <property name="label" translatable="yes">smb://foo.example.com, ssh://192.168.0.1</property>
+ <property name="label" translatable="yes">smb://foo.example.com, ssh://192.168.0.1, ftp://[2001:db8::1]</property>
<property name="wrap">1</property>
<property name="width-chars">40</property>
<property name="max-width-chars">40</property>
@@ -66,14 +62,12 @@
</child>
<child>
<object class="GtkGrid">
- <property name="visible">1</property>
<property name="margin-top">12</property>
<property name="hexpand">1</property>
<property name="row-spacing">6</property>
<property name="column-spacing">12</property>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">Available Protocols</property>
<property name="xalign">0</property>
@@ -88,7 +82,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">AppleTalk</property>
<property name="xalign">0</property>
</object>
@@ -99,7 +92,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">File Transfer Protocol</property>
<property name="xalign">0</property>
</object>
@@ -110,7 +102,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">Network File System</property>
<property name="xalign">0</property>
</object>
@@ -121,7 +112,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">Samba</property>
<property name="xalign">0</property>
</object>
@@ -132,7 +122,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">SSH File Transfer Protocol</property>
<property name="xalign">0</property>
</object>
@@ -143,7 +132,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">WebDAV</property>
<property name="xalign">0</property>
</object>
@@ -154,7 +142,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">Prefix</property>
<property name="xalign">0</property>
<attributes>
@@ -168,7 +155,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label">afp://</property>
<property name="xalign">0</property>
</object>
@@ -179,7 +165,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes" comments="Translators: do not translate ftp:// and ftps://">ftp:// or ftps://</property>
<property name="xalign">0</property>
</object>
@@ -190,7 +175,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label">nfs://</property>
<property name="xalign">0</property>
</object>
@@ -201,7 +185,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">smb://</property>
<property name="xalign">0</property>
</object>
@@ -212,7 +195,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes" comments="Translators: do not translate sftp:// and ssh://">sftp:// or ssh://</property>
<property name="xalign">0</property>
</object>
@@ -223,7 +205,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes" comments="Translators: do not translate dav:// and davs://">dav:// or davs://</property>
<property name="xalign">0</property>
</object>
@@ -243,17 +224,14 @@
<object class="GtkPopover" id="recent_servers_popover">
<child>
<object class="GtkStack" id="recent_servers_stack">
- <property name="visible">1</property>
<child>
<object class="GtkBox">
- <property name="visible">1</property>
<property name="vexpand">1</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="GtkImage">
- <property name="visible">1</property>
<property name="pixel-size">48</property>
<property name="icon-name">network-server-symbolic</property>
<style>
@@ -263,7 +241,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes" comments="Translators: Server as any successfully connected network address">No recent servers found</property>
<style>
<class name="dim-label"/>
@@ -280,13 +257,11 @@
</child>
<child>
<object class="GtkBox">
- <property name="visible">1</property>
- <property name="border-width">12</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
+ <property name="margin">12</property>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">Recent Servers</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -295,7 +270,6 @@
</child>
<child>
<object class="GtkScrolledWindow">
- <property name="visible">1</property>
<property name="can-focus">1</property>
<property name="vexpand">1</property>
<property name="shadow-type">in</property>
@@ -303,11 +277,9 @@
<property name="min-content-height">200</property>
<child>
<object class="GtkViewport">
- <property name="visible">1</property>
<property name="shadow-type">none</property>
<child>
<object class="GtkListBox" id="recent_servers_listbox">
- <property name="visible">1</property>
<property name="can-focus">1</property>
<property name="selection-mode">none</property>
<signal name="row-activated" handler="on_recent_servers_listbox_row_activated" object="NautilusGtkPlacesView" swapped="yes"/>
@@ -329,31 +301,25 @@
</child>
</object>
<template class="NautilusGtkPlacesView" parent="GtkBox">
- <property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<signal name="key-press-event" handler="on_key_press_event" object="NautilusGtkPlacesView" swapped="no"/>
<child>
<object class="GtkStack" id="stack">
- <property name="visible">1</property>
<property name="vhomogeneous">0</property>
<property name="transition-type">crossfade</property>
<child>
<object class="GtkFrame">
- <property name="visible">1</property>
<property name="shadow-type">none</property>
<child>
<object class="GtkScrolledWindow">
- <property name="visible">1</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkViewport">
- <property name="visible">1</property>
<property name="shadow-type">none</property>
<child>
<object class="GtkListBox" id="listbox">
- <property name="visible">1</property>
<property name="can-focus">1</property>
<property name="selection-mode">none</property>
<signal name="row-activated" handler="on_listbox_row_activated" object="NautilusGtkPlacesView" swapped="yes"/>
@@ -370,7 +336,6 @@
</child>
<child>
<object class="GtkBox">
- <property name="visible">1</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
@@ -379,7 +344,6 @@
<property name="spacing">12</property>
<child>
<object class="GtkImage">
- <property name="visible">1</property>
<property name="pixel-size">72</property>
<property name="icon-name">edit-find-symbolic</property>
<style>
@@ -389,7 +353,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">No results found</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -402,7 +365,6 @@
</child>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="label" translatable="yes">Try a different search</property>
<style>
<class name="dim-label"/>
@@ -426,14 +388,12 @@
</child>
<child>
<object class="GtkActionBar" id="actionbar">
- <property name="visible">1</property>
<property name="hexpand">1</property>
<style>
<class name="background"/>
</style>
<child>
<object class="GtkLabel">
- <property name="visible">1</property>
<property name="hexpand">1</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Connect to _Server</property>
@@ -448,7 +408,6 @@
<object class="GtkButton" id="connect_button">
<property name="label" translatable="yes">Con_nect</property>
<property name="use-underline">1</property>
- <property name="visible">1</property>
<property name="can-focus">1</property>
<property name="sensitive">0</property>
<property name="receives-default">1</property>
@@ -461,11 +420,9 @@
</child>
<child>
<object class="GtkBox">
- <property name="visible">1</property>
<property name="hexpand">1</property>
<child>
<object class="GtkEntry" id="address_entry">
- <property name="visible">1</property>
<property name="can-focus">1</property>
<property name="hexpand">1</property>
<property name="width-chars">20</property>
@@ -479,7 +436,6 @@
</child>
<child>
<object class="GtkMenuButton" id="server_list_button">
- <property name="visible">1</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="direction">up</property>
@@ -489,7 +445,6 @@
</style>
<child>
<object class="GtkImage">
- <property name="visible">1</property>
<property name="icon-name">pan-down-symbolic</property>
</object>
</child>
diff --git a/src/gtk/nautilusgtkplacesviewrow.c b/src/gtk/nautilusgtkplacesviewrow.c
index e5d86d321..121c5823b 100644
--- a/src/gtk/nautilusgtkplacesviewrow.c
+++ b/src/gtk/nautilusgtkplacesviewrow.c
@@ -43,40 +43,39 @@
struct _NautilusGtkPlacesViewRow
{
- GtkListBoxRow parent_instance;
+ GtkListBoxRow parent_instance;
- GtkLabel *available_space_label;
- GtkStack *mount_stack;
- GtkSpinner *busy_spinner;
- GtkButton *eject_button;
- GtkImage *eject_icon;
- GtkEventBox *event_box;
- GtkImage *icon_image;
- GtkLabel *name_label;
- GtkLabel *path_label;
+ GtkLabel *available_space_label;
+ GtkStack *mount_stack;
+ GtkSpinner *busy_spinner;
+ GtkButton *eject_button;
+ GtkImage *eject_icon;
+ GtkEventBox *event_box;
+ GtkImage *icon_image;
+ GtkLabel *name_label;
+ GtkLabel *path_label;
- GVolume *volume;
- GMount *mount;
- GFile *file;
+ GVolume *volume;
+ GMount *mount;
+ GFile *file;
- GCancellable *cancellable;
+ GCancellable *cancellable;
- gint is_network : 1;
+ gint is_network : 1;
};
G_DEFINE_TYPE (NautilusGtkPlacesViewRow, nautilus_gtk_places_view_row, GTK_TYPE_LIST_BOX_ROW)
-enum
-{
- PROP_0,
- PROP_ICON,
- PROP_NAME,
- PROP_PATH,
- PROP_VOLUME,
- PROP_MOUNT,
- PROP_FILE,
- PROP_IS_NETWORK,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ICON,
+ PROP_NAME,
+ PROP_PATH,
+ PROP_VOLUME,
+ PROP_MOUNT,
+ PROP_FILE,
+ PROP_IS_NETWORK,
+ LAST_PROP
};
static GParamSpec *properties [LAST_PROP];
@@ -86,115 +85,113 @@ measure_available_space_finished (GObject *object,
GAsyncResult *res,
gpointer user_data)
{
- NautilusGtkPlacesViewRow *row = user_data;
- GFileInfo *info;
- GError *error;
- guint64 free_space;
- guint64 total_space;
- gchar *formatted_free_size;
- gchar *formatted_total_size;
- gchar *label;
- guint plural_form;
-
- error = NULL;
-
- info = g_file_query_filesystem_info_finish (G_FILE (object),
- res,
- &error);
-
- if (error)
+ NautilusGtkPlacesViewRow *row = user_data;
+ GFileInfo *info;
+ GError *error;
+ guint64 free_space;
+ guint64 total_space;
+ gchar *formatted_free_size;
+ gchar *formatted_total_size;
+ gchar *label;
+ guint plural_form;
+
+ error = NULL;
+
+ info = g_file_query_filesystem_info_finish (G_FILE (object),
+ res,
+ &error);
+
+ if (error)
{
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) &&
- !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_MOUNTED))
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) &&
+ !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_MOUNTED))
{
- g_warning ("Failed to measure available space: %s", error->message);
+ g_warning ("Failed to measure available space: %s", error->message);
}
- g_clear_error (&error);
- goto out;
+ g_clear_error (&error);
+ goto out;
}
- if (!g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE) ||
- !g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE))
+ if (!g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE) ||
+ !g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE))
{
- g_object_unref (info);
- goto out;
+ g_object_unref (info);
+ goto out;
}
- free_space = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
- total_space = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE);
+ free_space = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
+ total_space = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE);
- formatted_free_size = g_format_size (free_space);
- formatted_total_size = g_format_size (total_space);
+ formatted_free_size = g_format_size (free_space);
+ formatted_total_size = g_format_size (total_space);
- /* read g_format_size code in glib for further understanding */
- plural_form = free_space < 1000 ? free_space : free_space % 1000 + 1000;
+ /* read g_format_size code in glib for further understanding */
+ plural_form = free_space < 1000 ? free_space : free_space % 1000 + 1000;
- /* Translators: respectively, free and total space of the drive. The plural form
- * should be based on the free space available.
- * i.e. 1 GB / 24 GB available.
- */
- label = g_strdup_printf (dngettext (GETTEXT_PACKAGE, "%s / %s available", "%s / %s available", plural_form),
- formatted_free_size, formatted_total_size);
+ /* Translators: respectively, free and total space of the drive. The plural form
+ * should be based on the free space available.
+ * i.e. 1 GB / 24 GB available.
+ */
+ label = g_strdup_printf (dngettext (GETTEXT_PACKAGE, "%s / %s available", "%s / %s available", plural_form),
+ formatted_free_size, formatted_total_size);
- gtk_label_set_label (row->available_space_label, label);
+ gtk_label_set_label (row->available_space_label, label);
- g_object_unref (info);
- g_free (formatted_total_size);
- g_free (formatted_free_size);
- g_free (label);
+ g_object_unref (info);
+ g_free (formatted_total_size);
+ g_free (formatted_free_size);
+ g_free (label);
out:
- g_object_unref (object);
+ g_object_unref (object);
}
static void
measure_available_space (NautilusGtkPlacesViewRow *row)
{
- gboolean should_measure;
+ gboolean should_measure;
- should_measure = (!row->is_network && (row->volume || row->mount || row->file));
+ should_measure = (!row->is_network && (row->volume || row->mount || row->file));
- gtk_label_set_label (row->available_space_label, "");
- gtk_widget_set_visible (GTK_WIDGET (row->available_space_label), should_measure);
+ gtk_label_set_label (row->available_space_label, "");
+ gtk_widget_set_visible (GTK_WIDGET (row->available_space_label), should_measure);
- if (should_measure)
+ if (should_measure)
{
- GFile *file = NULL;
+ GFile *file = NULL;
- if (row->file)
+ if (row->file)
{
- file = g_object_ref (row->file);
+ file = g_object_ref (row->file);
}
- else if (row->mount)
+ else if (row->mount)
{
- file = g_mount_get_root (row->mount);
+ file = g_mount_get_root (row->mount);
}
- else if (row->volume)
+ else if (row->volume)
{
- GMount *mount;
+ GMount *mount;
- mount = g_volume_get_mount (row->volume);
+ mount = g_volume_get_mount (row->volume);
- if (mount)
- {
- file = g_mount_get_root (row->mount);
- }
+ if (mount)
+ file = g_mount_get_root (row->mount);
- g_clear_object (&mount);
+ g_clear_object (&mount);
}
- if (file)
+ if (file)
{
- g_cancellable_cancel (row->cancellable);
- g_clear_object (&row->cancellable);
- row->cancellable = g_cancellable_new ();
-
- g_file_query_filesystem_info_async (file,
- G_FILE_ATTRIBUTE_FILESYSTEM_FREE "," G_FILE_ATTRIBUTE_FILESYSTEM_SIZE,
- G_PRIORITY_DEFAULT,
- row->cancellable,
- measure_available_space_finished,
- row);
+ g_cancellable_cancel (row->cancellable);
+ g_clear_object (&row->cancellable);
+ row->cancellable = g_cancellable_new ();
+
+ g_file_query_filesystem_info_async (file,
+ G_FILE_ATTRIBUTE_FILESYSTEM_FREE "," G_FILE_ATTRIBUTE_FILESYSTEM_SIZE,
+ G_PRIORITY_DEFAULT,
+ row->cancellable,
+ measure_available_space_finished,
+ row);
}
}
}
@@ -202,335 +199,303 @@ measure_available_space (NautilusGtkPlacesViewRow *row)
static void
nautilus_gtk_places_view_row_finalize (GObject *object)
{
- NautilusGtkPlacesViewRow *self = NAUTILUS_GTK_PLACES_VIEW_ROW (object);
+ NautilusGtkPlacesViewRow *self = NAUTILUS_GTK_PLACES_VIEW_ROW (object);
- g_cancellable_cancel (self->cancellable);
+ g_cancellable_cancel (self->cancellable);
- g_clear_object (&self->volume);
- g_clear_object (&self->mount);
- g_clear_object (&self->file);
- g_clear_object (&self->cancellable);
+ g_clear_object (&self->volume);
+ g_clear_object (&self->mount);
+ g_clear_object (&self->file);
+ g_clear_object (&self->cancellable);
- G_OBJECT_CLASS (nautilus_gtk_places_view_row_parent_class)->finalize (object);
+ G_OBJECT_CLASS (nautilus_gtk_places_view_row_parent_class)->finalize (object);
}
static void
nautilus_gtk_places_view_row_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- NautilusGtkPlacesViewRow *self;
- GIcon *icon;
+ NautilusGtkPlacesViewRow *self;
+ GIcon *icon;
- self = NAUTILUS_GTK_PLACES_VIEW_ROW (object);
- icon = NULL;
+ self = NAUTILUS_GTK_PLACES_VIEW_ROW (object);
+ icon = NULL;
- switch (prop_id)
+ switch (prop_id)
{
- case PROP_ICON:
- {
- gtk_image_get_gicon (self->icon_image, &icon, NULL);
- g_value_set_object (value, icon);
- }
- break;
+ case PROP_ICON:
+ gtk_image_get_gicon (self->icon_image, &icon, NULL);
+ g_value_set_object (value, icon);
+ break;
- case PROP_NAME:
- {
- g_value_set_string (value, gtk_label_get_label (self->name_label));
- }
- break;
+ case PROP_NAME:
+ g_value_set_string (value, gtk_label_get_label (self->name_label));
+ break;
- case PROP_PATH:
- {
- g_value_set_string (value, gtk_label_get_label (self->path_label));
- }
- break;
+ case PROP_PATH:
+ g_value_set_string (value, gtk_label_get_label (self->path_label));
+ break;
- case PROP_VOLUME:
- {
- g_value_set_object (value, self->volume);
- }
- break;
+ case PROP_VOLUME:
+ g_value_set_object (value, self->volume);
+ break;
- case PROP_MOUNT:
- {
- g_value_set_object (value, self->mount);
- }
- break;
+ case PROP_MOUNT:
+ g_value_set_object (value, self->mount);
+ break;
- case PROP_FILE:
- {
- g_value_set_object (value, self->file);
- }
- break;
+ case PROP_FILE:
+ g_value_set_object (value, self->file);
+ break;
- case PROP_IS_NETWORK:
- {
- g_value_set_boolean (value, self->is_network);
- }
- break;
+ case PROP_IS_NETWORK:
+ g_value_set_boolean (value, self->is_network);
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
nautilus_gtk_places_view_row_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- NautilusGtkPlacesViewRow *self = NAUTILUS_GTK_PLACES_VIEW_ROW (object);
+ NautilusGtkPlacesViewRow *self = NAUTILUS_GTK_PLACES_VIEW_ROW (object);
- switch (prop_id)
+ switch (prop_id)
{
- case PROP_ICON:
+ case PROP_ICON:
+ gtk_image_set_from_gicon (self->icon_image,
+ g_value_get_object (value),
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
+ break;
+
+ case PROP_NAME:
+ gtk_label_set_label (self->name_label, g_value_get_string (value));
+ break;
+
+ case PROP_PATH:
+ gtk_label_set_label (self->path_label, g_value_get_string (value));
+ break;
+
+ case PROP_VOLUME:
+ g_set_object (&self->volume, g_value_get_object (value));
+ break;
+
+ case PROP_MOUNT:
+ g_set_object (&self->mount, g_value_get_object (value));
+ if (self->mount != NULL)
{
- gtk_image_set_from_gicon (self->icon_image,
- g_value_get_object (value),
- GTK_ICON_SIZE_LARGE_TOOLBAR);
+ gtk_stack_set_visible_child (self->mount_stack, GTK_WIDGET (self->eject_button));
+ gtk_widget_set_child_visible (GTK_WIDGET (self->mount_stack), TRUE);
}
- break;
-
- case PROP_NAME:
+ else
{
- gtk_label_set_label (self->name_label, g_value_get_string (value));
+ gtk_widget_set_child_visible (GTK_WIDGET (self->mount_stack), FALSE);
}
- break;
+ measure_available_space (self);
+ break;
- case PROP_PATH:
- {
- gtk_label_set_label (self->path_label, g_value_get_string (value));
- }
- break;
+ case PROP_FILE:
+ g_set_object (&self->file, g_value_get_object (value));
+ measure_available_space (self);
+ break;
- case PROP_VOLUME:
- {
- g_set_object (&self->volume, g_value_get_object (value));
- }
- break;
+ case PROP_IS_NETWORK:
+ nautilus_gtk_places_view_row_set_is_network (self, g_value_get_boolean (value));
+ measure_available_space (self);
+ break;
- case PROP_MOUNT:
- {
- g_set_object (&self->mount, g_value_get_object (value));
- if (self->mount != NULL)
- {
- gtk_stack_set_visible_child (self->mount_stack, GTK_WIDGET (self->eject_button));
- gtk_widget_set_child_visible (GTK_WIDGET (self->mount_stack), TRUE);
- }
- else
- {
- gtk_widget_set_child_visible (GTK_WIDGET (self->mount_stack), FALSE);
- }
- measure_available_space (self);
- }
- break;
-
- case PROP_FILE:
- {
- g_set_object (&self->file, g_value_get_object (value));
- measure_available_space (self);
- }
- break;
-
- case PROP_IS_NETWORK:
- {
- nautilus_gtk_places_view_row_set_is_network (self, g_value_get_boolean (value));
- measure_available_space (self);
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
nautilus_gtk_places_view_row_class_init (NautilusGtkPlacesViewRowClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->finalize = nautilus_gtk_places_view_row_finalize;
- object_class->get_property = nautilus_gtk_places_view_row_get_property;
- object_class->set_property = nautilus_gtk_places_view_row_set_property;
-
- properties[PROP_ICON] =
- g_param_spec_object ("icon",
- "Icon of the row",
- "The icon representing the volume",
- G_TYPE_ICON,
- G_PARAM_READWRITE);
-
- properties[PROP_NAME] =
- g_param_spec_string ("name",
- "Name of the volume",
- "The name of the volume",
- "",
- G_PARAM_READWRITE);
-
- properties[PROP_PATH] =
- g_param_spec_string ("path",
- "Path of the volume",
- "The path of the volume",
- "",
- G_PARAM_READWRITE);
-
- properties[PROP_VOLUME] =
- g_param_spec_object ("volume",
- "Volume represented by the row",
- "The volume represented by the row",
- G_TYPE_VOLUME,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- properties[PROP_MOUNT] =
- g_param_spec_object ("mount",
- "Mount represented by the row",
- "The mount point represented by the row, if any",
- G_TYPE_MOUNT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- properties[PROP_FILE] =
- g_param_spec_object ("file",
- "File represented by the row",
- "The file represented by the row, if any",
- G_TYPE_FILE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- properties[PROP_IS_NETWORK] =
- g_param_spec_boolean ("is-network",
- "Whether the row represents a network location",
- "Whether the row represents a network location",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- g_object_class_install_properties (object_class, LAST_PROP, properties);
-
- gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/nautilus/gtk/ui/nautilusgtkplacesviewrow.ui");
-
- gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, available_space_label);
- gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, mount_stack);
- gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, busy_spinner);
- gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, eject_button);
- gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, eject_icon);
- gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, event_box);
- gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, icon_image);
- gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, name_label);
- gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, path_label);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = nautilus_gtk_places_view_row_finalize;
+ object_class->get_property = nautilus_gtk_places_view_row_get_property;
+ object_class->set_property = nautilus_gtk_places_view_row_set_property;
+
+ properties[PROP_ICON] =
+ g_param_spec_object ("icon",
+ "Icon of the row",
+ "The icon representing the volume",
+ G_TYPE_ICON,
+ G_PARAM_READWRITE);
+
+ properties[PROP_NAME] =
+ g_param_spec_string ("name",
+ "Name of the volume",
+ "The name of the volume",
+ "",
+ G_PARAM_READWRITE);
+
+ properties[PROP_PATH] =
+ g_param_spec_string ("path",
+ "Path of the volume",
+ "The path of the volume",
+ "",
+ G_PARAM_READWRITE);
+
+ properties[PROP_VOLUME] =
+ g_param_spec_object ("volume",
+ "Volume represented by the row",
+ "The volume represented by the row",
+ G_TYPE_VOLUME,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ properties[PROP_MOUNT] =
+ g_param_spec_object ("mount",
+ "Mount represented by the row",
+ "The mount point represented by the row, if any",
+ G_TYPE_MOUNT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ properties[PROP_FILE] =
+ g_param_spec_object ("file",
+ "File represented by the row",
+ "The file represented by the row, if any",
+ G_TYPE_FILE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ properties[PROP_IS_NETWORK] =
+ g_param_spec_boolean ("is-network",
+ "Whether the row represents a network location",
+ "Whether the row represents a network location",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ g_object_class_install_properties (object_class, LAST_PROP, properties);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/nautilus/gtk/ui/nautilusgtkplacesviewrow.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, available_space_label);
+ gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, mount_stack);
+ gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, busy_spinner);
+ gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, eject_button);
+ gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, eject_icon);
+ gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, event_box);
+ gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, icon_image);
+ gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, name_label);
+ gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesViewRow, path_label);
}
static void
nautilus_gtk_places_view_row_init (NautilusGtkPlacesViewRow *self)
{
- gtk_widget_init_template (GTK_WIDGET (self));
+ gtk_widget_init_template (GTK_WIDGET (self));
}
-GtkWidget *
+GtkWidget*
nautilus_gtk_places_view_row_new (GVolume *volume,
- GMount *mount)
+ GMount *mount)
{
- return g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW_ROW,
- "volume", volume,
- "mount", mount,
- NULL);
+ return g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW_ROW,
+ "volume", volume,
+ "mount", mount,
+ NULL);
}
-GMount *
+GMount*
nautilus_gtk_places_view_row_get_mount (NautilusGtkPlacesViewRow *row)
{
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL);
- return row->mount;
+ return row->mount;
}
-GVolume *
+GVolume*
nautilus_gtk_places_view_row_get_volume (NautilusGtkPlacesViewRow *row)
{
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL);
- return row->volume;
+ return row->volume;
}
-GFile *
+GFile*
nautilus_gtk_places_view_row_get_file (NautilusGtkPlacesViewRow *row)
{
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL);
- return row->file;
+ return row->file;
}
-GtkWidget *
+GtkWidget*
nautilus_gtk_places_view_row_get_eject_button (NautilusGtkPlacesViewRow *row)
{
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL);
- return GTK_WIDGET (row->eject_button);
+ return GTK_WIDGET (row->eject_button);
}
-GtkWidget *
+GtkWidget*
nautilus_gtk_places_view_row_get_event_box (NautilusGtkPlacesViewRow *row)
{
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL);
- return GTK_WIDGET (row->event_box);
+ return GTK_WIDGET (row->event_box);
}
void
nautilus_gtk_places_view_row_set_busy (NautilusGtkPlacesViewRow *row,
- gboolean is_busy)
+ gboolean is_busy)
{
- g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row));
+ g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row));
- if (is_busy)
+ if (is_busy)
{
- gtk_stack_set_visible_child (row->mount_stack, GTK_WIDGET (row->busy_spinner));
- gtk_widget_set_child_visible (GTK_WIDGET (row->mount_stack), TRUE);
+ gtk_stack_set_visible_child (row->mount_stack, GTK_WIDGET (row->busy_spinner));
+ gtk_widget_set_child_visible (GTK_WIDGET (row->mount_stack), TRUE);
}
- else
+ else
{
- gtk_widget_set_child_visible (GTK_WIDGET (row->mount_stack), FALSE);
+ gtk_widget_set_child_visible (GTK_WIDGET (row->mount_stack), FALSE);
}
}
gboolean
nautilus_gtk_places_view_row_get_is_network (NautilusGtkPlacesViewRow *row)
{
- g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), FALSE);
+ g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), FALSE);
- return row->is_network;
+ return row->is_network;
}
void
nautilus_gtk_places_view_row_set_is_network (NautilusGtkPlacesViewRow *row,
- gboolean is_network)
+ gboolean is_network)
{
- if (row->is_network != is_network)
+ if (row->is_network != is_network)
{
- row->is_network = is_network;
+ row->is_network = is_network;
- gtk_image_set_from_icon_name (row->eject_icon, "media-eject-symbolic", GTK_ICON_SIZE_BUTTON);
- gtk_widget_set_tooltip_text (GTK_WIDGET (row->eject_button), is_network ? _("Disconnect") : _("Unmount"));
+ gtk_image_set_from_icon_name (row->eject_icon, "media-eject-symbolic", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (row->eject_button), is_network ? _("Disconnect") : _("Unmount"));
}
}
void
nautilus_gtk_places_view_row_set_path_size_group (NautilusGtkPlacesViewRow *row,
- GtkSizeGroup *group)
+ GtkSizeGroup *group)
{
- if (group)
- {
- gtk_size_group_add_widget (group, GTK_WIDGET (row->path_label));
- }
+ if (group)
+ gtk_size_group_add_widget (group, GTK_WIDGET (row->path_label));
}
void
nautilus_gtk_places_view_row_set_space_size_group (NautilusGtkPlacesViewRow *row,
- GtkSizeGroup *group)
+ GtkSizeGroup *group)
{
- if (group)
- {
- gtk_size_group_add_widget (group, GTK_WIDGET (row->available_space_label));
- }
+ if (group)
+ gtk_size_group_add_widget (group, GTK_WIDGET (row->available_space_label));
}
diff --git a/src/gtk/nautilusgtkplacesviewrow.ui b/src/gtk/nautilusgtkplacesviewrow.ui
index 99d2dcb42..e7e425e04 100644
--- a/src/gtk/nautilusgtkplacesviewrow.ui
+++ b/src/gtk/nautilusgtkplacesviewrow.ui
@@ -66,7 +66,7 @@
<property name="vhomogeneous">1</property>
<child>
<object class="GtkButton" id="eject_button">
- <property name="visible">1</property>
+ <property name="visible">0</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Unmount</property>