diff options
author | Carlos Soriano <csoriano@gnome.org> | 2016-11-30 21:35:21 +0100 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2016-11-30 21:35:21 +0100 |
commit | 838691f27a78aa52e5dded5dc13867ebf4746a1c (patch) | |
tree | 4e3aa39176d8f00b906a077c624d554bb79614a2 | |
parent | 3050a9c6e2131aa96faf3516e86711ad0dd4c0c1 (diff) | |
download | nautilus-838691f27a78aa52e5dded5dc13867ebf4746a1c.tar.gz |
general: format code with newer Uncrustify
Some issues were fixed, and now we can rerun Uncrustify to format
correctly more part of the code.
31 files changed, 2843 insertions, 2675 deletions
diff --git a/libnautilus-extension/nautilus-extension-types.c b/libnautilus-extension/nautilus-extension-types.c index f61d5db11..37bb92633 100644 --- a/libnautilus-extension/nautilus-extension-types.c +++ b/libnautilus-extension/nautilus-extension-types.c @@ -33,20 +33,20 @@ nautilus_operation_result_get_type (void) static const GEnumValue values[] = { { - NAUTILUS_OPERATION_COMPLETE, - "NAUTILUS_OPERATION_COMPLETE", - "complete", -}, + NAUTILUS_OPERATION_COMPLETE, + "NAUTILUS_OPERATION_COMPLETE", + "complete", + }, { - NAUTILUS_OPERATION_FAILED, - "NAUTILUS_OPERATION_FAILED", - "failed", -}, + NAUTILUS_OPERATION_FAILED, + "NAUTILUS_OPERATION_FAILED", + "failed", + }, { - NAUTILUS_OPERATION_IN_PROGRESS, - "NAUTILUS_OPERATION_IN_PROGRESS", - "in_progress", -}, + NAUTILUS_OPERATION_IN_PROGRESS, + "NAUTILUS_OPERATION_IN_PROGRESS", + "in_progress", + }, { 0, NULL, NULL } }; diff --git a/src/gtk/nautilusgtkplacesview.c b/src/gtk/nautilusgtkplacesview.c index dae81ef9b..2de53fc14 100644 --- a/src/gtk/nautilusgtkplacesview.c +++ b/src/gtk/nautilusgtkplacesview.c @@ -49,339 +49,359 @@ struct _NautilusGtkPlacesViewPrivate { - GVolumeMonitor *volume_monitor; - GtkPlacesOpenFlags open_flags; - GtkPlacesOpenFlags current_open_flags; - - GFile *server_list_file; - GFileMonitor *server_list_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; + + 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-3.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-3.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); } } @@ -390,550 +410,574 @@ 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); - 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->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->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; - - priv = nautilus_gtk_places_view_get_instance_private (view); - server_list = server_list_load (view); - - if (!server_list) - return; + NautilusGtkPlacesViewPrivate *priv; + GBookmarkFile *server_list; + GList *children; + gchar **uris; + gsize num_uris; + gint i; - uris = g_bookmark_file_get_uris (server_list, &num_uris); + priv = nautilus_gtk_places_view_get_instance_private (view); + server_list = server_list_load (view); - gtk_stack_set_visible_child_name (GTK_STACK (priv->recent_servers_stack), - num_uris > 0 ? "list" : "empty"); - - if (!uris) + if (!server_list) { - g_bookmark_file_free (server_list); - return; + return; } - /* clear previous items */ - children = gtk_container_get_children (GTK_CONTAINER (priv->recent_servers_listbox)); - g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy); + uris = g_bookmark_file_get_uris (server_list, &num_uris); - gtk_list_store_clear (priv->completion_store); + gtk_stack_set_visible_child_name (GTK_STACK (priv->recent_servers_stack), + num_uris > 0 ? "list" : "empty"); - for (i = 0; i < num_uris; i++) + if (!uris) { - 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_bookmark_file_free (server_list); + return; + } - g_signal_connect_swapped (button, - "clicked", - G_CALLBACK (on_remove_server_button_clicked), - data); + /* clear previous items */ + children = gtk_container_get_children (GTK_CONTAINER (priv->recent_servers_listbox)); + g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy); - gtk_widget_show_all (row); + gtk_list_store_clear (priv->completion_store); - g_free (name); + 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); } - 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) -{ - gboolean is_network; - GMount *mount; - GFile *root; - GIcon *icon; - gchar *identifier; - gchar *name; - gchar *path; - - if (is_external_volume (volume)) - return; - - 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; - - 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); + GVolume *volume) +{ + gboolean is_network; + GMount *mount; + GFile *root; + GIcon *icon; + gchar *identifier; + gchar *name; + gchar *path; - insert_row (view, row, is_network); + if (is_external_volume (volume)) + { + return; } - g_clear_object (&root); - g_clear_object (&icon); - g_clear_object (&mount); - g_free (identifier); - g_free (name); - g_free (path); + 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; + + 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); + + 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); } 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; + NautilusGtkPlacesViewPrivate *priv; - priv = nautilus_gtk_places_view_get_instance_private (view); + priv = nautilus_gtk_places_view_get_instance_private (view); - if (priv->network_placeholder == NULL) + 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); + 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)) + 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)) + /* 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_all (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_all (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); } } 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); } } @@ -942,41 +986,43 @@ 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); - update_loading (view); + update_network_state (view); + update_loading (view); } } @@ -985,171 +1031,183 @@ 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); } } static void fetch_networks (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; - GFile *network_file; - const gchar * const *supported_uris; - gboolean found; + 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 ()); + priv = nautilus_gtk_places_view_get_instance_private (view); + supported_uris = g_vfs_get_supported_uri_schemes (g_vfs_get_default ()); - for (found = FALSE; !found && supported_uris && supported_uris[0]; supported_uris++) - if (g_strcmp0 (supported_uris[0], "network") == 0) - found = TRUE; + for (found = FALSE; !found && supported_uris && supported_uris[0]; supported_uris++) + { + if (g_strcmp0 (supported_uris[0], "network") == 0) + { + found = TRUE; + } + } - if (!found) - return; + if (!found) + { + return; + } - network_file = g_file_new_for_uri ("network:///"); + network_file = g_file_new_for_uri ("network:///"); - 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_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_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 @@ -1157,75 +1215,78 @@ 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 @@ -1233,73 +1294,75 @@ 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 @@ -1307,182 +1370,187 @@ 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 */ @@ -1490,127 +1558,136 @@ 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) + GtkWidget **view, + GFile **file) { - if (view) - *view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW); + if (view) + { + *view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW); + } - if (file) + if (file) { - GVolume *volume; - GMount *mount; + GVolume *volume; + GMount *mount; - volume = nautilus_gtk_places_view_row_get_volume (row); - mount = nautilus_gtk_places_view_row_get_mount (row); + volume = nautilus_gtk_places_view_row_get_volume (row); + mount = nautilus_gtk_places_view_row_get_mount (row); - if (mount) + if (mount) { - *file = g_mount_get_default_location (mount); + *file = g_mount_get_default_location (mount); } - else if (volume) + else if (volume) { - *file = g_volume_get_activation_root (volume); + *file = g_volume_get_activation_root (volume); } - else + else { - *file = nautilus_gtk_places_view_row_get_file (row); - if (*file) { - g_object_ref (*file); - } + *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; + GtkWidget *view; + GFile *file; - get_view_and_file (row, &view, &file); + get_view_and_file (row, &view, &file); - if (file) - emit_open_location (NAUTILUS_GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NORMAL); + if (file) + { + emit_open_location (NAUTILUS_GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NORMAL); + } - g_clear_object (&file); + g_clear_object (&file); } static void -open_in_new_tab_cb (GtkMenuItem *item, +open_in_new_tab_cb (GtkMenuItem *item, NautilusGtkPlacesViewRow *row) { - GtkWidget *view; - GFile *file; + GtkWidget *view; + GFile *file; - get_view_and_file (row, &view, &file); + get_view_and_file (row, &view, &file); - if (file) - emit_open_location (NAUTILUS_GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NEW_TAB); + if (file) + { + emit_open_location (NAUTILUS_GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NEW_TAB); + } - g_clear_object (&file); + g_clear_object (&file); } static void -open_in_new_window_cb (GtkMenuItem *item, +open_in_new_window_cb (GtkMenuItem *item, NautilusGtkPlacesViewRow *row) { - GtkWidget *view; - GFile *file; + GtkWidget *view; + GFile *file; - get_view_and_file (row, &view, &file); + get_view_and_file (row, &view, &file); - if (file) - emit_open_location (NAUTILUS_GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NEW_WINDOW); + if (file) + { + emit_open_location (NAUTILUS_GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NEW_WINDOW); + } - g_clear_object (&file); + g_clear_object (&file); } 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 */ @@ -1618,346 +1695,374 @@ 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; - - /* Separator */ - item = gtk_separator_menu_item_new (); - gtk_widget_show (item); - gtk_menu_shell_insert (GTK_MENU_SHELL (priv->popup_menu), item, -1); - - /* 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); - } - 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); + 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; + } + + /* Separator */ + item = gtk_separator_menu_item_new (); + gtk_widget_show (item); + gtk_menu_shell_insert (GTK_MENU_SHELL (priv->popup_menu), item, -1); + + /* 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); + } + 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); } } 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; + NautilusGtkPlacesViewPrivate *priv; + const gchar *uri; + GFile *file; - priv = nautilus_gtk_places_view_get_instance_private (view); - file = NULL; + 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; + /* + * 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 @@ -1965,86 +2070,88 @@ 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_widget_show_all (header); - 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); } } @@ -2053,238 +2160,244 @@ 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, - 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, + gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->listbox), + listbox_sort_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); + 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); } 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, - 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, + 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); - 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"); + 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"); } 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)); } /** @@ -2303,7 +2416,7 @@ 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); } /** @@ -2330,19 +2443,19 @@ 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]); } } @@ -2359,13 +2472,13 @@ 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; } /** @@ -2376,16 +2489,16 @@ 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; } /** @@ -2398,23 +2511,23 @@ 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); } } @@ -2429,74 +2542,74 @@ 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]); } } @@ -2514,13 +2627,13 @@ 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; } /** @@ -2534,23 +2647,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/nautilusgtkplacesviewrow.c b/src/gtk/nautilusgtkplacesviewrow.c index 121c5823b..e5d86d321 100644 --- a/src/gtk/nautilusgtkplacesviewrow.c +++ b/src/gtk/nautilusgtkplacesviewrow.c @@ -43,39 +43,40 @@ 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]; @@ -85,113 +86,115 @@ 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); } } } @@ -199,303 +202,335 @@ 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: - 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) + case PROP_ICON: { - gtk_stack_set_visible_child (self->mount_stack, GTK_WIDGET (self->eject_button)); - gtk_widget_set_child_visible (GTK_WIDGET (self->mount_stack), TRUE); + gtk_image_set_from_gicon (self->icon_image, + g_value_get_object (value), + GTK_ICON_SIZE_LARGE_TOOLBAR); } - else + break; + + case PROP_NAME: { - gtk_widget_set_child_visible (GTK_WIDGET (self->mount_stack), FALSE); + gtk_label_set_label (self->name_label, g_value_get_string (value)); } - measure_available_space (self); - break; + break; - case PROP_FILE: - g_set_object (&self->file, g_value_get_object (value)); - measure_available_space (self); - break; + case PROP_PATH: + { + gtk_label_set_label (self->path_label, g_value_get_string (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_VOLUME: + { + g_set_object (&self->volume, g_value_get_object (value)); + } + break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + 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); } } 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/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c index 1e4b67270..1d9e7f7fe 100644 --- a/src/nautilus-batch-rename-dialog.c +++ b/src/nautilus-batch-rename-dialog.c @@ -141,7 +141,7 @@ change_numbering_order (GSimpleAction *action, dialog->selection = nautilus_batch_rename_dialog_sort (dialog->selection, sorts_constants[i].sort_mode, dialog->create_date); - break; + break; } } @@ -636,9 +636,13 @@ create_arrow_row_for_label (NautilusBatchRenameDialog *dialog, g_object_set_data (G_OBJECT (row), "show-separator", GINT_TO_POINTER (show_separator)); if (gtk_widget_get_direction (row) == GTK_TEXT_DIR_RTL) + { icon = gtk_label_new ("←"); + } else + { icon = gtk_label_new ("→"); + } gtk_label_set_xalign (GTK_LABEL (icon), 1.0); gtk_widget_set_hexpand (icon, FALSE); @@ -943,7 +947,7 @@ update_listbox (NautilusBatchRenameDialog *dialog) new_name = l1->data; gtk_label_set_label (label, new_name->str); - gtk_widget_set_tooltip_text(GTK_WIDGET (label), new_name->str); + gtk_widget_set_tooltip_text (GTK_WIDGET (label), new_name->str); if (g_strcmp0 (new_name->str, "") == 0) { @@ -957,7 +961,7 @@ update_listbox (NautilusBatchRenameDialog *dialog) file = NAUTILUS_FILE (l1->data); old_name = nautilus_file_get_name (file); - gtk_widget_set_tooltip_text(GTK_WIDGET (label), old_name); + gtk_widget_set_tooltip_text (GTK_WIDGET (label), old_name); if (dialog->mode == NAUTILUS_BATCH_RENAME_DIALOG_FORMAT) { @@ -1175,9 +1179,9 @@ file_names_list_has_duplicates_finish (NautilusBatchRenameDialog *self, GAsyncResult *res, GError **error) { - g_return_val_if_fail (g_task_is_valid (res, self), FALSE); + g_return_val_if_fail (g_task_is_valid (res, self), FALSE); - return g_task_propagate_boolean (G_TASK (res), error); + return g_task_propagate_boolean (G_TASK (res), error); } static void @@ -1298,11 +1302,10 @@ file_names_list_has_duplicates_async_thread (GTask *task, } g_mutex_unlock (&task_data->wait_ready_mutex); - } - g_task_return_boolean (task, TRUE); - nautilus_directory_list_free (directories); + g_task_return_boolean (task, TRUE); + nautilus_directory_list_free (directories); } static void @@ -1340,7 +1343,7 @@ file_names_list_has_duplicates_async (NautilusBatchRenameDialog *dialog, dialog->checking_conflicts = TRUE; task = g_task_new (dialog, dialog->conflict_cancellable, callback, user_data); - task_data = g_new0(CheckConflictsData, 1); + task_data = g_new0 (CheckConflictsData, 1); g_task_set_task_data (task, task_data, destroy_conflicts_task_data); g_task_run_in_thread (task, file_names_list_has_duplicates_async_thread); } @@ -1459,7 +1462,7 @@ numbering_tag_is_some_added (NautilusBatchRenameDialog *self) tag_data = g_hash_table_lookup (self->tag_info_table, tag_text_representation); if (tag_data->set) { - return TRUE; + return TRUE; } } @@ -1493,11 +1496,11 @@ update_display_text (NautilusBatchRenameDialog *dialog) if (!numbering_tag_is_some_added (dialog)) { - gtk_revealer_set_reveal_child(GTK_REVEALER(dialog->numbering_revealer), FALSE); + gtk_revealer_set_reveal_child (GTK_REVEALER (dialog->numbering_revealer), FALSE); } else { - gtk_revealer_set_reveal_child(GTK_REVEALER(dialog->numbering_revealer), TRUE); + gtk_revealer_set_reveal_child (GTK_REVEALER (dialog->numbering_revealer), TRUE); } dialog->new_names = batch_rename_dialog_get_new_names (dialog); @@ -1801,7 +1804,7 @@ typedef enum TEXT_WAS_INSERTED } TextChangedMode; -static GList* +static GList * get_tags_intersecting_sorted (NautilusBatchRenameDialog *self, gint start_position, gint end_position, @@ -1842,7 +1845,6 @@ get_tags_intersecting_sorted (NautilusBatchRenameDialog *self, start_position < tag_end_position; selection_intersects_tag_end = FALSE; tag_is_contained_in_selection = FALSE; - } if (selection_intersects_tag_end || selection_intersects_tag_start || tag_is_contained_in_selection) { @@ -1957,7 +1959,7 @@ on_insert_text (GtkEditable *editable, g_autoptr (GList) intersecting_tags = NULL; self = NAUTILUS_BATCH_RENAME_DIALOG (user_data); - start_position = *(int *)position; + start_position = *(int *) position; end_position = start_position + g_utf8_strlen (new_text, -1); intersecting_tags = get_tags_intersecting_sorted (self, start_position, end_position, TEXT_WAS_INSERTED); @@ -1977,7 +1979,7 @@ on_insert_text (GtkEditable *editable, static void file_names_widget_entry_on_changed (NautilusBatchRenameDialog *self) { - update_display_text (self); + update_display_text (self); } static void @@ -2131,7 +2133,7 @@ nautilus_batch_rename_dialog_new (GList *selection, } } - dialog_title = g_string_new (""); + dialog_title = g_string_new (""); if (all_targets_are_folders) { g_string_append_printf (dialog_title, @@ -2148,7 +2150,7 @@ nautilus_batch_rename_dialog_new (GList *selection, g_list_length (selection)), g_list_length (selection)); } - else + else { /* To translators: %d is the total number of files and folders. * Singular case of the string is never used */ @@ -2156,7 +2158,7 @@ nautilus_batch_rename_dialog_new (GList *selection, ngettext ("Rename %d File and Folder", "Rename %d Files and Folders", g_list_length (selection)), - g_list_length (selection)); + g_list_length (selection)); } gtk_window_set_title (GTK_WINDOW (dialog), dialog_title->str); diff --git a/src/nautilus-batch-rename-utilities.c b/src/nautilus-batch-rename-utilities.c index bac61cb3f..7a2979651 100644 --- a/src/nautilus-batch-rename-utilities.c +++ b/src/nautilus-batch-rename-utilities.c @@ -83,7 +83,7 @@ conflict_data_free (gpointer mem) g_free (conflict_data); } -gchar* +gchar * batch_rename_get_tag_text_representation (TagConstants tag_constants) { return g_strdup_printf ("[%s]", gettext (tag_constants.label)); @@ -376,19 +376,22 @@ batch_rename_format (NautilusFile *file, g_string_append_printf (new_name, "%d", count); } break; + case NUMBERING_ONE_ZERO_PAD: { g_string_append_printf (new_name, "%02d", count); } break; + case NUMBERING_TWO_ZERO_PAD: { g_string_append_printf (new_name, "%03d", count); } break; + default: { - g_warn_if_reached (); + g_warn_if_reached (); } break; } @@ -434,11 +437,13 @@ batch_rename_format (NautilusFile *file, new_name = g_string_append (new_name, base_name); } break; + case TRACK_NUMBER: { g_string_append_printf (new_name, "%02d", atoi (metadata)); } break; + default: { new_name = g_string_append (new_name, metadata); @@ -759,7 +764,7 @@ remove_metadata (QueryData *query_data, query_data->has_metadata[metadata_type] = FALSE; } -static GString* +static GString * format_date_time (GDateTime *date_time) { g_autofree gchar *date = NULL; @@ -877,49 +882,58 @@ on_cursor_callback (GObject *object, current_metadata = file_name; } break; + case CREATION_DATE: { current_metadata = creation_date; } break; + case EQUIPMENT: { current_metadata = equipment; } break; + case SEASON_NUMBER: { current_metadata = season_number; } break; + case EPISODE_NUMBER: { current_metadata = episode_number; } break; + case ARTIST_NAME: { current_metadata = artist_name; } break; + case ALBUM_NAME: { current_metadata = album_name; } break; + case TITLE: { current_metadata = title; } break; + case TRACK_NUMBER: { current_metadata = track_number; } break; + default: { - g_warn_if_reached(); + g_warn_if_reached (); } break; } @@ -935,8 +949,8 @@ on_cursor_callback (GObject *object, if (metadata_type == CREATION_DATE && query_data->date_order_hash_table) { - g_hash_table_destroy (query_data->date_order_hash_table); - query_data->date_order_hash_table = NULL; + g_hash_table_destroy (query_data->date_order_hash_table); + query_data->date_order_hash_table = NULL; } } else diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c index 7a358b10e..d7a0ea092 100644 --- a/src/nautilus-bookmark-list.c +++ b/src/nautilus-bookmark-list.c @@ -40,7 +40,7 @@ struct _NautilusBookmarkList { GObject parent_instance; - GList *list; + GList *list; GFileMonitor *monitor; GQueue *pending_ops; }; @@ -642,7 +642,7 @@ nautilus_bookmark_list_can_bookmark_location (NautilusBookmarkList *list, { return FALSE; } - + bookmark = nautilus_bookmark_new (location, NULL); is_builtin = nautilus_bookmark_get_is_builtin (bookmark); g_object_unref (bookmark); diff --git a/src/nautilus-canvas-dnd.c b/src/nautilus-canvas-dnd.c index 27d6aac14..1cf87ff14 100644 --- a/src/nautilus-canvas-dnd.c +++ b/src/nautilus-canvas-dnd.c @@ -1273,42 +1273,42 @@ nautilus_canvas_container_get_drop_action (NautilusCanvasContainer *container, switch (container->details->dnd_info->drag_info.data_type) { case NAUTILUS_ICON_DND_GNOME_ICON_LIST: + { + if (container->details->dnd_info->drag_info.selection_list != NULL) { - if (container->details->dnd_info->drag_info.selection_list != NULL) - { - nautilus_drag_default_drop_action_for_icons (context, drop_target, - container->details->dnd_info->drag_info.selection_list, - 0, - action); - } + nautilus_drag_default_drop_action_for_icons (context, drop_target, + container->details->dnd_info->drag_info.selection_list, + 0, + action); } - break; + } + break; case NAUTILUS_ICON_DND_URI_LIST: - { - *action = nautilus_drag_default_drop_action_for_uri_list (context, drop_target); - } - break; + { + *action = nautilus_drag_default_drop_action_for_uri_list (context, drop_target); + } + break; case NAUTILUS_ICON_DND_NETSCAPE_URL: - { - *action = nautilus_drag_default_drop_action_for_netscape_url (context); - } - break; + { + *action = nautilus_drag_default_drop_action_for_netscape_url (context); + } + break; case NAUTILUS_ICON_DND_ROOTWINDOW_DROP: - { - *action = gdk_drag_context_get_suggested_action (context); - } - break; + { + *action = gdk_drag_context_get_suggested_action (context); + } + break; case NAUTILUS_ICON_DND_TEXT: case NAUTILUS_ICON_DND_XDNDDIRECTSAVE: case NAUTILUS_ICON_DND_RAW: - { - *action = GDK_ACTION_COPY; - } - break; + { + *action = GDK_ACTION_COPY; + } + break; } g_free (drop_target); @@ -1797,41 +1797,41 @@ drag_data_received_callback (GtkWidget *widget, switch (info) { case NAUTILUS_ICON_DND_GNOME_ICON_LIST: - { - nautilus_canvas_container_dropped_canvas_feedback (widget, data, x, y); - } - break; + { + nautilus_canvas_container_dropped_canvas_feedback (widget, data, x, y); + } + break; case NAUTILUS_ICON_DND_URI_LIST: case NAUTILUS_ICON_DND_TEXT: case NAUTILUS_ICON_DND_XDNDDIRECTSAVE: case NAUTILUS_ICON_DND_RAW: + { + /* Save the data so we can do the actual work on drop. */ + if (drag_info->selection_data != NULL) { - /* Save the data so we can do the actual work on drop. */ - if (drag_info->selection_data != NULL) - { - gtk_selection_data_free (drag_info->selection_data); - } - drag_info->selection_data = gtk_selection_data_copy (data); + gtk_selection_data_free (drag_info->selection_data); } - break; + drag_info->selection_data = gtk_selection_data_copy (data); + } + break; /* Netscape keeps sending us the data, even though we accept the first drag */ case NAUTILUS_ICON_DND_NETSCAPE_URL: + { + if (drag_info->selection_data != NULL) { - if (drag_info->selection_data != NULL) - { - gtk_selection_data_free (drag_info->selection_data); - drag_info->selection_data = gtk_selection_data_copy (data); - } + gtk_selection_data_free (drag_info->selection_data); + drag_info->selection_data = gtk_selection_data_copy (data); } - break; + } + break; case NAUTILUS_ICON_DND_ROOTWINDOW_DROP: - { - /* Do nothing, this won't even happen, since we don't want to call get_data twice */ - } - break; + { + /* Do nothing, this won't even happen, since we don't want to call get_data twice */ + } + break; } /* this is the second use case of this callback. @@ -1843,104 +1843,104 @@ drag_data_received_callback (GtkWidget *widget, switch (info) { case NAUTILUS_ICON_DND_GNOME_ICON_LIST: - { - nautilus_canvas_container_receive_dropped_icons - (NAUTILUS_CANVAS_CONTAINER (widget), - context, x, y); - } - break; + { + nautilus_canvas_container_receive_dropped_icons + (NAUTILUS_CANVAS_CONTAINER (widget), + context, x, y); + } + break; case NAUTILUS_ICON_DND_NETSCAPE_URL: - { - receive_dropped_netscape_url - (NAUTILUS_CANVAS_CONTAINER (widget), - (char *) gtk_selection_data_get_data (data), context, x, y); - success = TRUE; - } - break; + { + receive_dropped_netscape_url + (NAUTILUS_CANVAS_CONTAINER (widget), + (char *) gtk_selection_data_get_data (data), context, x, y); + success = TRUE; + } + break; case NAUTILUS_ICON_DND_URI_LIST: - { - receive_dropped_uri_list - (NAUTILUS_CANVAS_CONTAINER (widget), - (char *) gtk_selection_data_get_data (data), context, x, y); - success = TRUE; - } - break; + { + receive_dropped_uri_list + (NAUTILUS_CANVAS_CONTAINER (widget), + (char *) gtk_selection_data_get_data (data), context, x, y); + success = TRUE; + } + break; case NAUTILUS_ICON_DND_TEXT: - { - tmp = gtk_selection_data_get_text (data); - receive_dropped_text - (NAUTILUS_CANVAS_CONTAINER (widget), - (char *) tmp, context, x, y); - success = TRUE; - g_free (tmp); - } - break; + { + tmp = gtk_selection_data_get_text (data); + receive_dropped_text + (NAUTILUS_CANVAS_CONTAINER (widget), + (char *) tmp, context, x, y); + success = TRUE; + g_free (tmp); + } + break; case NAUTILUS_ICON_DND_RAW: - { - length = gtk_selection_data_get_length (data); - tmp_raw = gtk_selection_data_get_data (data); - receive_dropped_raw - (NAUTILUS_CANVAS_CONTAINER (widget), - (const gchar *) tmp_raw, length, drag_info->direct_save_uri, - context, x, y); - success = TRUE; - } - break; + { + length = gtk_selection_data_get_length (data); + tmp_raw = gtk_selection_data_get_data (data); + receive_dropped_raw + (NAUTILUS_CANVAS_CONTAINER (widget), + (const gchar *) tmp_raw, length, drag_info->direct_save_uri, + context, x, y); + success = TRUE; + } + break; case NAUTILUS_ICON_DND_ROOTWINDOW_DROP: - { - /* Do nothing, everything is done by the sender */ - } - break; + { + /* Do nothing, everything is done by the sender */ + } + break; case NAUTILUS_ICON_DND_XDNDDIRECTSAVE: + { + const guchar *selection_data; + gint selection_length; + gint selection_format; + + selection_data = gtk_selection_data_get_data (drag_info->selection_data); + selection_length = gtk_selection_data_get_length (drag_info->selection_data); + selection_format = gtk_selection_data_get_format (drag_info->selection_data); + + if (selection_format == 8 && + selection_length == 1 && + selection_data[0] == 'F') { - const guchar *selection_data; - gint selection_length; - gint selection_format; - - selection_data = gtk_selection_data_get_data (drag_info->selection_data); - selection_length = gtk_selection_data_get_length (drag_info->selection_data); - selection_format = gtk_selection_data_get_format (drag_info->selection_data); - - if (selection_format == 8 && - selection_length == 1 && - selection_data[0] == 'F') - { - gtk_drag_get_data (widget, context, - gdk_atom_intern (NAUTILUS_ICON_DND_RAW_TYPE, - FALSE), - time); - return; - } - else if (selection_format == 8 && - selection_length == 1 && - selection_data[0] == 'F' && - drag_info->direct_save_uri != NULL) - { - GdkPoint p; - GFile *location; - - location = g_file_new_for_uri (drag_info->direct_save_uri); - - nautilus_file_changes_queue_file_added (location); - p.x = x; - p.y = y; - nautilus_file_changes_queue_schedule_position_set ( - location, - p, - gdk_screen_get_number ( - gtk_widget_get_screen (widget))); - g_object_unref (location); - nautilus_file_changes_consume_changes (TRUE); - success = TRUE; - } - } /* NAUTILUS_ICON_DND_XDNDDIRECTSAVE */ - break; + gtk_drag_get_data (widget, context, + gdk_atom_intern (NAUTILUS_ICON_DND_RAW_TYPE, + FALSE), + time); + return; + } + else if (selection_format == 8 && + selection_length == 1 && + selection_data[0] == 'F' && + drag_info->direct_save_uri != NULL) + { + GdkPoint p; + GFile *location; + + location = g_file_new_for_uri (drag_info->direct_save_uri); + + nautilus_file_changes_queue_file_added (location); + p.x = x; + p.y = y; + nautilus_file_changes_queue_schedule_position_set ( + location, + p, + gdk_screen_get_number ( + gtk_widget_get_screen (widget))); + g_object_unref (location); + nautilus_file_changes_consume_changes (TRUE); + success = TRUE; + } + } /* NAUTILUS_ICON_DND_XDNDDIRECTSAVE */ + break; } gtk_drag_finish (context, success, FALSE, time); diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c index 7d7d6eb24..87d118102 100644 --- a/src/nautilus-canvas-view.c +++ b/src/nautilus-canvas-view.c @@ -116,67 +116,67 @@ struct NautilusCanvasViewDetails static const SortCriterion sort_criteria[] = { { - NAUTILUS_FILE_SORT_BY_DISPLAY_NAME, - "name", - "name", - FALSE -}, - { - NAUTILUS_FILE_SORT_BY_DISPLAY_NAME, - "name", - "name-desc", - TRUE -}, - { - NAUTILUS_FILE_SORT_BY_SIZE, - "size", - "size", - TRUE -}, - { - NAUTILUS_FILE_SORT_BY_TYPE, - "type", - "type", - FALSE -}, - { - NAUTILUS_FILE_SORT_BY_MTIME, - "modification date", - "modification-date", - FALSE -}, - { - NAUTILUS_FILE_SORT_BY_MTIME, - "modification date", - "modification-date-desc", - TRUE -}, - { - NAUTILUS_FILE_SORT_BY_ATIME, - "access date", - "access-date", - FALSE -}, - { - NAUTILUS_FILE_SORT_BY_ATIME, - "access date", - "access-date-desc", - TRUE -}, - { - NAUTILUS_FILE_SORT_BY_TRASHED_TIME, - "trashed", - "trash-time", - TRUE, - nautilus_file_is_in_trash -}, - { - NAUTILUS_FILE_SORT_BY_SEARCH_RELEVANCE, - NULL, - "search-relevance", - TRUE, - nautilus_file_is_in_search -} + NAUTILUS_FILE_SORT_BY_DISPLAY_NAME, + "name", + "name", + FALSE + }, + { + NAUTILUS_FILE_SORT_BY_DISPLAY_NAME, + "name", + "name-desc", + TRUE + }, + { + NAUTILUS_FILE_SORT_BY_SIZE, + "size", + "size", + TRUE + }, + { + NAUTILUS_FILE_SORT_BY_TYPE, + "type", + "type", + FALSE + }, + { + NAUTILUS_FILE_SORT_BY_MTIME, + "modification date", + "modification-date", + FALSE + }, + { + NAUTILUS_FILE_SORT_BY_MTIME, + "modification date", + "modification-date-desc", + TRUE + }, + { + NAUTILUS_FILE_SORT_BY_ATIME, + "access date", + "access-date", + FALSE + }, + { + NAUTILUS_FILE_SORT_BY_ATIME, + "access date", + "access-date-desc", + TRUE + }, + { + NAUTILUS_FILE_SORT_BY_TRASHED_TIME, + "trashed", + "trash-time", + TRUE, + nautilus_file_is_in_trash + }, + { + NAUTILUS_FILE_SORT_BY_SEARCH_RELEVANCE, + NULL, + "search-relevance", + TRUE, + nautilus_file_is_in_search + } }; static void nautilus_canvas_view_set_directory_sort_by (NautilusCanvasView *canvas_view, @@ -797,7 +797,6 @@ on_clipboard_contents_received (GtkClipboard *clipboard, static void update_clipboard_status (NautilusCanvasView *view) { - g_object_ref (view); /* Need to keep the object alive until we get the reply */ gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)), nautilus_clipboard_get_atom (), @@ -1894,34 +1893,34 @@ nautilus_canvas_view_set_property (GObject *object, switch (prop_id) { case PROP_SUPPORTS_AUTO_LAYOUT: - { - canvas_view->details->supports_auto_layout = g_value_get_boolean (value); - } - break; + { + canvas_view->details->supports_auto_layout = g_value_get_boolean (value); + } + break; case PROP_SUPPORTS_MANUAL_LAYOUT: - { - canvas_view->details->supports_manual_layout = g_value_get_boolean (value); - } - break; + { + canvas_view->details->supports_manual_layout = g_value_get_boolean (value); + } + break; case PROP_SUPPORTS_SCALING: - { - canvas_view->details->supports_scaling = g_value_get_boolean (value); - } - break; + { + canvas_view->details->supports_scaling = g_value_get_boolean (value); + } + break; case PROP_SUPPORTS_KEEP_ALIGNED: - { - canvas_view->details->supports_keep_aligned = g_value_get_boolean (value); - } - break; + { + canvas_view->details->supports_keep_aligned = g_value_get_boolean (value); + } + break; default: - { - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } - break; + { + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } + break; } } diff --git a/src/nautilus-clipboard.c b/src/nautilus-clipboard.c index 808ac1b8f..267d7a354 100644 --- a/src/nautilus-clipboard.c +++ b/src/nautilus-clipboard.c @@ -217,7 +217,7 @@ nautilus_clipboard_is_cut_from_selection_data (GtkSelectionData *selection_data) items = get_item_list_from_selection_data (selection_data); is_cut_from_selection_data = items != NULL && - g_strcmp0 ((gchar *)items->data, "cut") == 0; + g_strcmp0 ((gchar *) items->data, "cut") == 0; g_list_free_full (items, g_free); @@ -293,7 +293,6 @@ nautilus_clipboard_prepare_for_files (GtkClipboard *clipboard, GList *files, gboolean cut) { - GtkTargetList *target_list; GtkTargetEntry *targets; int n_targets; diff --git a/src/nautilus-file-conflict-dialog.c b/src/nautilus-file-conflict-dialog.c index 593a43f50..55e536692 100644 --- a/src/nautilus-file-conflict-dialog.c +++ b/src/nautilus-file-conflict-dialog.c @@ -328,7 +328,7 @@ nautilus_file_conflict_dialog_init (NautilusFileConflictDialog *fcd) fcd->replace_button = gtk_dialog_add_button (dialog, _("Replace"), - CONFLICT_RESPONSE_REPLACE); + CONFLICT_RESPONSE_REPLACE); gtk_widget_grab_focus (fcd->replace_button); /* Setup HIG properties */ diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c index af08b5137..7930b72ec 100644 --- a/src/nautilus-file-operations.c +++ b/src/nautilus-file-operations.c @@ -3049,40 +3049,40 @@ report_preparing_count_progress (CommonJob *job, { default: case OP_KIND_COPY: - { - s = f (ngettext ("Preparing to copy %'d file (%S)", - "Preparing to copy %'d files (%S)", - source_info->num_files), - source_info->num_files, source_info->num_bytes); - } - break; + { + s = f (ngettext ("Preparing to copy %'d file (%S)", + "Preparing to copy %'d files (%S)", + source_info->num_files), + source_info->num_files, source_info->num_bytes); + } + break; case OP_KIND_MOVE: - { - s = f (ngettext ("Preparing to move %'d file (%S)", - "Preparing to move %'d files (%S)", - source_info->num_files), - source_info->num_files, source_info->num_bytes); - } - break; + { + s = f (ngettext ("Preparing to move %'d file (%S)", + "Preparing to move %'d files (%S)", + source_info->num_files), + source_info->num_files, source_info->num_bytes); + } + break; case OP_KIND_DELETE: - { - s = f (ngettext ("Preparing to delete %'d file (%S)", - "Preparing to delete %'d files (%S)", - source_info->num_files), - source_info->num_files, source_info->num_bytes); - } - break; + { + s = f (ngettext ("Preparing to delete %'d file (%S)", + "Preparing to delete %'d files (%S)", + source_info->num_files), + source_info->num_files, source_info->num_bytes); + } + break; case OP_KIND_TRASH: - { - s = f (ngettext ("Preparing to trash %'d file", - "Preparing to trash %'d files", - source_info->num_files), - source_info->num_files); - } - break; + { + s = f (ngettext ("Preparing to trash %'d file", + "Preparing to trash %'d files", + source_info->num_files), + source_info->num_files); + } + break; case OP_KIND_COMPRESS: s = f (ngettext ("Preparing to compress %'d file", @@ -3117,24 +3117,24 @@ get_scan_primary (OpKind kind) { default: case OP_KIND_COPY: - { - return f (_("Error while copying.")); - } + { + return f (_("Error while copying.")); + } case OP_KIND_MOVE: - { - return f (_("Error while moving.")); - } + { + return f (_("Error while moving.")); + } case OP_KIND_DELETE: - { - return f (_("Error while deleting.")); - } + { + return f (_("Error while deleting.")); + } case OP_KIND_TRASH: - { - return f (_("Error while moving files to trash.")); - } + { + return f (_("Error while moving files to trash.")); + } case OP_KIND_COMPRESS: return f (_("Error while compressing files.")); @@ -3161,7 +3161,7 @@ scan_dir (GFile *dir, retry: error = NULL; enumerator = g_file_enumerate_children (dir, - G_FILE_ATTRIBUTE_ID_FILE"," + G_FILE_ATTRIBUTE_ID_FILE "," G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SIZE, @@ -3328,7 +3328,7 @@ scan_file (GFile *file, retry: error = NULL; info = g_file_query_info (file, - G_FILE_ATTRIBUTE_ID_FILE"," + G_FILE_ATTRIBUTE_ID_FILE "," G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, @@ -4574,25 +4574,25 @@ copy_move_directory (CopyMoveJob *copy_job, switch (create_dest_dir (job, src, dest, same_fs, parent_dest_fs_type)) { case CREATE_DEST_DIR_RETRY: - { - /* next time copy_move_directory() is called, - * create_dest will be FALSE if a directory already - * exists under the new name (i.e. WOULD_RECURSE) - */ - return FALSE; - } + { + /* next time copy_move_directory() is called, + * create_dest will be FALSE if a directory already + * exists under the new name (i.e. WOULD_RECURSE) + */ + return FALSE; + } case CREATE_DEST_DIR_FAILED: - { - *skipped_file = TRUE; - return TRUE; - } + { + *skipped_file = TRUE; + return TRUE; + } case CREATE_DEST_DIR_SUCCESS: default: - { - } - break; + { + } + break; } if (debuting_files) diff --git a/src/nautilus-file-undo-manager.c b/src/nautilus-file-undo-manager.c index ef6f2a1c8..4dc26c64a 100644 --- a/src/nautilus-file-undo-manager.c +++ b/src/nautilus-file-undo-manager.c @@ -56,7 +56,7 @@ struct _NautilusFileUndoManager G_DEFINE_TYPE (NautilusFileUndoManager, nautilus_file_undo_manager, G_TYPE_OBJECT) -static NautilusFileUndoManager *undo_singleton = NULL; +static NautilusFileUndoManager * undo_singleton = NULL; NautilusFileUndoManager * nautilus_file_undo_manager_new (void) diff --git a/src/nautilus-file-utilities.c b/src/nautilus-file-utilities.c index a99ddaf29..51b9c716c 100644 --- a/src/nautilus-file-utilities.c +++ b/src/nautilus-file-utilities.c @@ -595,10 +595,10 @@ nautilus_is_search_directory (GFile *dir) gboolean nautilus_is_other_locations_directory (GFile *dir) { - g_autofree gchar *uri = NULL; + g_autofree gchar *uri = NULL; - uri = g_file_get_uri (dir); - return eel_uri_is_other_locations (uri); + uri = g_file_get_uri (dir); + return eel_uri_is_other_locations (uri); } GMount * diff --git a/src/nautilus-file.c b/src/nautilus-file.c index 26a767270..8c388b84b 100644 --- a/src/nautilus-file.c +++ b/src/nautilus-file.c @@ -2375,7 +2375,9 @@ nautilus_file_rename_handle_file_gone (NautilusFile *file, error = g_error_new (G_IO_ERROR, G_IO_ERROR_NOT_FOUND, _("File not found")); if (callback) + { (*callback)(file, NULL, error, callback_data); + } g_error_free (error); return TRUE; } @@ -8207,7 +8209,7 @@ static const gchar * const remote_types[] = gboolean nautilus_file_is_remote (NautilusFile *file) { - g_autofree char* filesystem_type = NULL; + g_autofree char *filesystem_type = NULL; g_assert (NAUTILUS_IS_FILE (file)); @@ -8765,35 +8767,35 @@ nautilus_file_dump (NautilusFile *file) switch (file->details->type) { case G_FILE_TYPE_REGULAR: - { - file_kind = "regular file"; - } - break; + { + file_kind = "regular file"; + } + break; case G_FILE_TYPE_DIRECTORY: - { - file_kind = "folder"; - } - break; + { + file_kind = "folder"; + } + break; case G_FILE_TYPE_SPECIAL: - { - file_kind = "special"; - } - break; + { + file_kind = "special"; + } + break; case G_FILE_TYPE_SYMBOLIC_LINK: - { - file_kind = "symbolic link"; - } - break; + { + file_kind = "symbolic link"; + } + break; case G_FILE_TYPE_UNKNOWN: default: - { - file_kind = "unknown"; - } - break; + { + file_kind = "unknown"; + } + break; } g_print ("kind: %s \n", file_kind); if (file->details->type == G_FILE_TYPE_SYMBOLIC_LINK) @@ -9475,27 +9477,27 @@ nautilus_drag_can_accept_info (NautilusFile *drop_target_item, switch (drag_type) { case NAUTILUS_ICON_DND_GNOME_ICON_LIST: - { - return nautilus_drag_can_accept_items (drop_target_item, items); - } + { + return nautilus_drag_can_accept_items (drop_target_item, items); + } case NAUTILUS_ICON_DND_URI_LIST: case NAUTILUS_ICON_DND_NETSCAPE_URL: case NAUTILUS_ICON_DND_TEXT: - { - return nautilus_drag_can_accept_files (drop_target_item); - } + { + return nautilus_drag_can_accept_files (drop_target_item); + } case NAUTILUS_ICON_DND_XDNDDIRECTSAVE: case NAUTILUS_ICON_DND_RAW: - { - return nautilus_drag_can_accept_files (drop_target_item); /* Check if we can accept files at this location */ - } + { + return nautilus_drag_can_accept_files (drop_target_item); /* Check if we can accept files at this location */ + } case NAUTILUS_ICON_DND_ROOTWINDOW_DROP: - { - return FALSE; - } + { + return FALSE; + } default: g_assert_not_reached (); diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index dffcc643c..e93ffb32f 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -6773,9 +6773,9 @@ on_clipboard_contents_received (GtkClipboard *clipboard, static void on_clipboard_targets_received (GtkClipboard *clipboard, - GdkAtom *targets, - int n_targets, - gpointer user_data) + GdkAtom *targets, + int n_targets, + gpointer user_data) { NautilusFilesView *view; gboolean is_data_copied; @@ -7569,28 +7569,28 @@ update_selection_menu (NautilusFilesView *view) default: case G_DRIVE_START_STOP_TYPE_UNKNOWN: case G_DRIVE_START_STOP_TYPE_SHUTDOWN: - { - item_label = _("_Start"); - } - break; + { + item_label = _("_Start"); + } + break; case G_DRIVE_START_STOP_TYPE_NETWORK: - { - item_label = _("_Connect"); - } - break; + { + item_label = _("_Connect"); + } + break; case G_DRIVE_START_STOP_TYPE_MULTIDISK: - { - item_label = _("_Start Multi-disk Drive"); - } - break; + { + item_label = _("_Start Multi-disk Drive"); + } + break; case G_DRIVE_START_STOP_TYPE_PASSWORD: - { - item_label = _("U_nlock Drive"); - } - break; + { + item_label = _("U_nlock Drive"); + } + break; } menu_item = g_menu_item_new (item_label, "view.start-volume"); @@ -7607,34 +7607,34 @@ update_selection_menu (NautilusFilesView *view) { default: case G_DRIVE_START_STOP_TYPE_UNKNOWN: - { - item_label = _("Stop Drive"); - } - break; + { + item_label = _("Stop Drive"); + } + break; case G_DRIVE_START_STOP_TYPE_SHUTDOWN: - { - item_label = _("_Safely Remove Drive"); - } - break; + { + item_label = _("_Safely Remove Drive"); + } + break; case G_DRIVE_START_STOP_TYPE_NETWORK: - { - item_label = _("_Disconnect"); - } - break; + { + item_label = _("_Disconnect"); + } + break; case G_DRIVE_START_STOP_TYPE_MULTIDISK: - { - item_label = _("_Stop Multi-disk Drive"); - } - break; + { + item_label = _("_Stop Multi-disk Drive"); + } + break; case G_DRIVE_START_STOP_TYPE_PASSWORD: - { - item_label = _("_Lock Drive"); - } - break; + { + item_label = _("_Lock Drive"); + } + break; } menu_item = g_menu_item_new (item_label, "view.stop-volume"); @@ -8473,28 +8473,28 @@ nautilus_files_view_get_property (GObject *object, switch (prop_id) { case PROP_IS_LOADING: - { - g_value_set_boolean (value, nautilus_view_is_loading (NAUTILUS_VIEW (view))); - } - break; + { + g_value_set_boolean (value, nautilus_view_is_loading (NAUTILUS_VIEW (view))); + } + break; case PROP_IS_SEARCH: - { - g_value_set_boolean (value, nautilus_view_is_searching (NAUTILUS_VIEW (view))); - } - break; + { + g_value_set_boolean (value, nautilus_view_is_searching (NAUTILUS_VIEW (view))); + } + break; case PROP_LOCATION: - { - g_value_set_object (value, nautilus_view_get_location (NAUTILUS_VIEW (view))); - } - break; + { + g_value_set_object (value, nautilus_view_get_location (NAUTILUS_VIEW (view))); + } + break; case PROP_SEARCH_QUERY: - { - g_value_set_object (value, view->details->search_query); - } - break; + { + g_value_set_object (value, view->details->search_query); + } + break; default: g_assert_not_reached (); @@ -8515,44 +8515,44 @@ nautilus_files_view_set_property (GObject *object, switch (prop_id) { case PROP_WINDOW_SLOT: - { - g_assert (directory_view->details->slot == NULL); + { + g_assert (directory_view->details->slot == NULL); - slot = NAUTILUS_WINDOW_SLOT (g_value_get_object (value)); - directory_view->details->slot = slot; + slot = NAUTILUS_WINDOW_SLOT (g_value_get_object (value)); + directory_view->details->slot = slot; - g_signal_connect_object (directory_view->details->slot, - "active", G_CALLBACK (slot_active), - directory_view, 0); - g_signal_connect_object (directory_view->details->slot, - "inactive", G_CALLBACK (slot_inactive), - directory_view, 0); - } - break; + g_signal_connect_object (directory_view->details->slot, + "active", G_CALLBACK (slot_active), + directory_view, 0); + g_signal_connect_object (directory_view->details->slot, + "inactive", G_CALLBACK (slot_inactive), + directory_view, 0); + } + break; case PROP_SUPPORTS_ZOOMING: - { - directory_view->details->supports_zooming = g_value_get_boolean (value); - } - break; + { + directory_view->details->supports_zooming = g_value_get_boolean (value); + } + break; case PROP_LOCATION: - { - nautilus_view_set_location (NAUTILUS_VIEW (directory_view), g_value_get_object (value)); - } - break; + { + nautilus_view_set_location (NAUTILUS_VIEW (directory_view), g_value_get_object (value)); + } + break; case PROP_SEARCH_QUERY: - { - nautilus_view_set_search_query (NAUTILUS_VIEW (directory_view), g_value_get_object (value)); - } - break; + { + nautilus_view_set_search_query (NAUTILUS_VIEW (directory_view), g_value_get_object (value)); + } + break; default: - { - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } - break; + { + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } + break; } } @@ -8569,53 +8569,53 @@ nautilus_files_view_handle_scroll_event (NautilusFilesView *directory_view, switch (event->direction) { case GDK_SCROLL_UP: - { - /* Zoom In */ - nautilus_files_view_bump_zoom_level (directory_view, 1); - return TRUE; - } + { + /* Zoom In */ + nautilus_files_view_bump_zoom_level (directory_view, 1); + return TRUE; + } case GDK_SCROLL_DOWN: + { + /* Zoom Out */ + nautilus_files_view_bump_zoom_level (directory_view, -1); + return TRUE; + } + + case GDK_SCROLL_SMOOTH: + { + gdk_event_get_scroll_deltas ((const GdkEvent *) event, + &delta_x, &delta_y); + + /* try to emulate a normal scrolling event by summing deltas */ + total_delta_y += delta_y; + + if (total_delta_y >= 1) { - /* Zoom Out */ + total_delta_y = 0; + /* emulate scroll down */ nautilus_files_view_bump_zoom_level (directory_view, -1); return TRUE; } - - case GDK_SCROLL_SMOOTH: + else if (total_delta_y <= -1) + { + total_delta_y = 0; + /* emulate scroll up */ + nautilus_files_view_bump_zoom_level (directory_view, 1); + return TRUE; + } + else { - gdk_event_get_scroll_deltas ((const GdkEvent *) event, - &delta_x, &delta_y); - - /* try to emulate a normal scrolling event by summing deltas */ - total_delta_y += delta_y; - - if (total_delta_y >= 1) - { - total_delta_y = 0; - /* emulate scroll down */ - nautilus_files_view_bump_zoom_level (directory_view, -1); - return TRUE; - } - else if (total_delta_y <= -1) - { - total_delta_y = 0; - /* emulate scroll up */ - nautilus_files_view_bump_zoom_level (directory_view, 1); - return TRUE; - } - else - { - /* eat event */ - return TRUE; - } + /* eat event */ + return TRUE; } + } case GDK_SCROLL_LEFT: case GDK_SCROLL_RIGHT: - { - } - break; + { + } + break; default: g_assert_not_reached (); @@ -9268,23 +9268,23 @@ nautilus_files_view_new (guint id, switch (id) { case NAUTILUS_VIEW_GRID_ID: - { - view = nautilus_canvas_view_new (slot); - } - break; + { + view = nautilus_canvas_view_new (slot); + } + break; case NAUTILUS_VIEW_LIST_ID: - { - view = nautilus_list_view_new (slot); - } - break; + { + view = nautilus_list_view_new (slot); + } + break; #if ENABLE_EMPTY_VIEW case NAUTILUS_VIEW_EMPTY_ID: - { - view = nautilus_empty_view_new (slot); - } - break; + { + view = nautilus_empty_view_new (slot); + } + break; #endif } diff --git a/src/nautilus-list-model.c b/src/nautilus-list-model.c index 3bf0d917e..0d3af7e42 100644 --- a/src/nautilus-list-model.c +++ b/src/nautilus-list-model.c @@ -149,27 +149,27 @@ nautilus_list_model_get_column_type (GtkTreeModel *tree_model, switch (index) { case NAUTILUS_LIST_MODEL_FILE_COLUMN: - { - return NAUTILUS_TYPE_FILE; - } + { + return NAUTILUS_TYPE_FILE; + } case NAUTILUS_LIST_MODEL_SUBDIRECTORY_COLUMN: - { - return NAUTILUS_TYPE_DIRECTORY; - } + { + return NAUTILUS_TYPE_DIRECTORY; + } case NAUTILUS_LIST_MODEL_SMALL_ICON_COLUMN: case NAUTILUS_LIST_MODEL_STANDARD_ICON_COLUMN: case NAUTILUS_LIST_MODEL_LARGE_ICON_COLUMN: case NAUTILUS_LIST_MODEL_LARGER_ICON_COLUMN: - { - return CAIRO_GOBJECT_TYPE_SURFACE; - } + { + return CAIRO_GOBJECT_TYPE_SURFACE; + } case NAUTILUS_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN: - { - return G_TYPE_BOOLEAN; - } + { + return G_TYPE_BOOLEAN; + } default: if (index < NAUTILUS_LIST_MODEL_NUM_COLUMNS + NAUTILUS_LIST_MODEL (tree_model)->details->columns->len) @@ -291,19 +291,19 @@ nautilus_list_model_get_icon_size_for_zoom_level (NautilusListZoomLevel zoom_lev switch (zoom_level) { case NAUTILUS_LIST_ZOOM_LEVEL_SMALL: - { - return NAUTILUS_LIST_ICON_SIZE_SMALL; - } + { + return NAUTILUS_LIST_ICON_SIZE_SMALL; + } case NAUTILUS_LIST_ZOOM_LEVEL_STANDARD: - { - return NAUTILUS_LIST_ICON_SIZE_STANDARD; - } + { + return NAUTILUS_LIST_ICON_SIZE_STANDARD; + } case NAUTILUS_LIST_ZOOM_LEVEL_LARGE: - { - return NAUTILUS_LIST_ICON_SIZE_LARGE; - } + { + return NAUTILUS_LIST_ICON_SIZE_LARGE; + } case NAUTILUS_LIST_ZOOM_LEVEL_LARGER: return NAUTILUS_LIST_ICON_SIZE_LARGER; @@ -338,89 +338,89 @@ nautilus_list_model_get_value (GtkTreeModel *tree_model, switch (column) { case NAUTILUS_LIST_MODEL_FILE_COLUMN: - { - g_value_init (value, NAUTILUS_TYPE_FILE); + { + g_value_init (value, NAUTILUS_TYPE_FILE); - g_value_set_object (value, file); - } - break; + g_value_set_object (value, file); + } + break; case NAUTILUS_LIST_MODEL_SUBDIRECTORY_COLUMN: - { - g_value_init (value, NAUTILUS_TYPE_DIRECTORY); + { + g_value_init (value, NAUTILUS_TYPE_DIRECTORY); - g_value_set_object (value, file_entry->subdirectory); - } - break; + g_value_set_object (value, file_entry->subdirectory); + } + break; case NAUTILUS_LIST_MODEL_SMALL_ICON_COLUMN: case NAUTILUS_LIST_MODEL_STANDARD_ICON_COLUMN: case NAUTILUS_LIST_MODEL_LARGE_ICON_COLUMN: case NAUTILUS_LIST_MODEL_LARGER_ICON_COLUMN: + { + g_value_init (value, CAIRO_GOBJECT_TYPE_SURFACE); + + if (file != NULL) { - g_value_init (value, CAIRO_GOBJECT_TYPE_SURFACE); + zoom_level = nautilus_list_model_get_zoom_level_from_column_id (column); + icon_size = nautilus_list_model_get_icon_size_for_zoom_level (zoom_level); + icon_scale = nautilus_list_model_get_icon_scale (model); - if (file != NULL) - { - zoom_level = nautilus_list_model_get_zoom_level_from_column_id (column); - icon_size = nautilus_list_model_get_icon_size_for_zoom_level (zoom_level); - icon_scale = nautilus_list_model_get_icon_scale (model); + flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS | + NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE | + NAUTILUS_FILE_ICON_FLAGS_USE_EMBLEMS | + NAUTILUS_FILE_ICON_FLAGS_USE_ONE_EMBLEM; - flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS | - NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE | - NAUTILUS_FILE_ICON_FLAGS_USE_EMBLEMS | - NAUTILUS_FILE_ICON_FLAGS_USE_ONE_EMBLEM; + if (model->details->drag_view != NULL) + { + GtkTreePath *path_a, *path_b; - if (model->details->drag_view != NULL) + gtk_tree_view_get_drag_dest_row (model->details->drag_view, + &path_a, + NULL); + if (path_a != NULL) { - GtkTreePath *path_a, *path_b; + path_b = gtk_tree_model_get_path (tree_model, iter); - gtk_tree_view_get_drag_dest_row (model->details->drag_view, - &path_a, - NULL); - if (path_a != NULL) + if (gtk_tree_path_compare (path_a, path_b) == 0) { - path_b = gtk_tree_model_get_path (tree_model, iter); - - if (gtk_tree_path_compare (path_a, path_b) == 0) - { - flags |= NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT; - } - - gtk_tree_path_free (path_a); - gtk_tree_path_free (path_b); + flags |= NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT; } + + gtk_tree_path_free (path_a); + gtk_tree_path_free (path_b); } + } - icon = nautilus_file_get_icon_pixbuf (file, icon_size, TRUE, icon_scale, flags); + icon = nautilus_file_get_icon_pixbuf (file, icon_size, TRUE, icon_scale, flags); - if (model->details->highlight_files != NULL && - g_list_find_custom (model->details->highlight_files, - file, (GCompareFunc) nautilus_file_compare_location)) - { - rendered_icon = eel_create_spotlight_pixbuf (icon); + if (model->details->highlight_files != NULL && + g_list_find_custom (model->details->highlight_files, + file, (GCompareFunc) nautilus_file_compare_location)) + { + rendered_icon = eel_create_spotlight_pixbuf (icon); - if (rendered_icon != NULL) - { - g_object_unref (icon); - icon = rendered_icon; - } + if (rendered_icon != NULL) + { + g_object_unref (icon); + icon = rendered_icon; } - - surface = gdk_cairo_surface_create_from_pixbuf (icon, icon_scale, NULL); - g_value_take_boxed (value, surface); - g_object_unref (icon); } + + surface = gdk_cairo_surface_create_from_pixbuf (icon, icon_scale, NULL); + g_value_take_boxed (value, surface); + g_object_unref (icon); } - break; + } + break; case NAUTILUS_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN: - { - g_value_init (value, G_TYPE_BOOLEAN); + { + g_value_init (value, G_TYPE_BOOLEAN); - g_value_set_boolean (value, file != NULL && nautilus_file_can_rename (file)); - } - break; + g_value_set_boolean (value, file != NULL && nautilus_file_can_rename (file)); + } + break; default: if (column >= NAUTILUS_LIST_MODEL_NUM_COLUMNS || column < NAUTILUS_LIST_MODEL_NUM_COLUMNS + model->details->columns->len) @@ -1447,19 +1447,19 @@ nautilus_list_model_get_zoom_level_from_column_id (int column) switch (column) { case NAUTILUS_LIST_MODEL_SMALL_ICON_COLUMN: - { - return NAUTILUS_LIST_ZOOM_LEVEL_SMALL; - } + { + return NAUTILUS_LIST_ZOOM_LEVEL_SMALL; + } case NAUTILUS_LIST_MODEL_STANDARD_ICON_COLUMN: - { - return NAUTILUS_LIST_ZOOM_LEVEL_STANDARD; - } + { + return NAUTILUS_LIST_ZOOM_LEVEL_STANDARD; + } case NAUTILUS_LIST_MODEL_LARGE_ICON_COLUMN: - { - return NAUTILUS_LIST_ZOOM_LEVEL_LARGE; - } + { + return NAUTILUS_LIST_ZOOM_LEVEL_LARGE; + } case NAUTILUS_LIST_MODEL_LARGER_ICON_COLUMN: return NAUTILUS_LIST_ZOOM_LEVEL_LARGER; @@ -1474,19 +1474,19 @@ nautilus_list_model_get_column_id_from_zoom_level (NautilusListZoomLevel zoom_le switch (zoom_level) { case NAUTILUS_LIST_ZOOM_LEVEL_SMALL: - { - return NAUTILUS_LIST_MODEL_SMALL_ICON_COLUMN; - } + { + return NAUTILUS_LIST_MODEL_SMALL_ICON_COLUMN; + } case NAUTILUS_LIST_ZOOM_LEVEL_STANDARD: - { - return NAUTILUS_LIST_MODEL_STANDARD_ICON_COLUMN; - } + { + return NAUTILUS_LIST_MODEL_STANDARD_ICON_COLUMN; + } case NAUTILUS_LIST_ZOOM_LEVEL_LARGE: - { - return NAUTILUS_LIST_MODEL_LARGE_ICON_COLUMN; - } + { + return NAUTILUS_LIST_MODEL_LARGE_ICON_COLUMN; + } case NAUTILUS_LIST_ZOOM_LEVEL_LARGER: return NAUTILUS_LIST_MODEL_LARGER_ICON_COLUMN; diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index 36656c5c6..38cd3a886 100644 --- a/src/nautilus-list-view.c +++ b/src/nautilus-list-view.c @@ -3416,7 +3416,6 @@ on_clipboard_contents_received (GtkClipboard *clipboard, static void update_clipboard_status (NautilusListView *view) { - g_object_ref (view); /* Need to keep the object alive until we get the reply */ gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)), nautilus_clipboard_get_atom (), diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c index f2830ab78..b2d5a5f77 100644 --- a/src/nautilus-location-entry.c +++ b/src/nautilus-location-entry.c @@ -337,13 +337,13 @@ drag_data_get_callback (GtkWidget *widget, { case NAUTILUS_DND_URI_LIST: case NAUTILUS_DND_TEXT_PLAIN: - { - gtk_selection_data_set (selection_data, - gtk_selection_data_get_target (selection_data), - 8, (guchar *) uri, - strlen (uri)); - } - break; + { + gtk_selection_data_set (selection_data, + gtk_selection_data_get_target (selection_data), + 8, (guchar *) uri, + strlen (uri)); + } + break; default: g_assert_not_reached (); @@ -428,9 +428,9 @@ entry_would_have_inserted_characters (const GdkEventKey *event) case GDK_KEY_KP_Left: case GDK_KEY_KP_Right: case GDK_KEY_Return: - { - return FALSE; - } + { + return FALSE; + } default: if (event->keyval >= 0x20 && event->keyval <= 0xFF) @@ -609,16 +609,16 @@ nautilus_location_entry_icon_release (GtkEntry *gentry, switch (priv->secondary_action) { case NAUTILUS_LOCATION_ENTRY_ACTION_GOTO: - { - g_signal_emit_by_name (gentry, "activate", gentry); - } - break; + { + g_signal_emit_by_name (gentry, "activate", gentry); + } + break; case NAUTILUS_LOCATION_ENTRY_ACTION_CLEAR: - { - gtk_entry_set_text (gentry, ""); - } - break; + { + gtk_entry_set_text (gentry, ""); + } + break; default: g_assert_not_reached (); @@ -780,20 +780,20 @@ nautilus_location_entry_set_secondary_action (NautilusLocationEntry *entry switch (secondary_action) { case NAUTILUS_LOCATION_ENTRY_ACTION_CLEAR: - { - gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), - GTK_ENTRY_ICON_SECONDARY, - "edit-clear-symbolic"); - } - break; + { + gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), + GTK_ENTRY_ICON_SECONDARY, + "edit-clear-symbolic"); + } + break; case NAUTILUS_LOCATION_ENTRY_ACTION_GOTO: - { - gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), - GTK_ENTRY_ICON_SECONDARY, - "go-next-symbolic"); - } - break; + { + gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), + GTK_ENTRY_ICON_SECONDARY, + "go-next-symbolic"); + } + break; default: g_assert_not_reached (); diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c index 90902bfa6..036b9679d 100644 --- a/src/nautilus-mime-actions.c +++ b/src/nautilus-mime-actions.c @@ -96,20 +96,20 @@ struct } mimetype_groups[] = { { - N_("Anything"), - { NULL } -}, - { - N_("Files"), - { "application/octet-stream", - "text/plain", - NULL} -}, - { - N_("Folders"), - { "inode/directory", - NULL} -}, + N_("Anything"), + { NULL } + }, + { + N_("Files"), + { "application/octet-stream", + "text/plain", + NULL} + }, + { + N_("Folders"), + { "inode/directory", + NULL} + }, { N_("Documents"), { "application/rtf", "application/msword", @@ -620,19 +620,19 @@ get_executable_text_file_action (GtkWindow *parent_window, switch (preferences_value) { case NAUTILUS_EXECUTABLE_TEXT_LAUNCH: - { - return ACTIVATION_ACTION_LAUNCH; - } + { + return ACTIVATION_ACTION_LAUNCH; + } case NAUTILUS_EXECUTABLE_TEXT_DISPLAY: - { - return ACTIVATION_ACTION_OPEN_IN_APPLICATION; - } + { + return ACTIVATION_ACTION_OPEN_IN_APPLICATION; + } case NAUTILUS_EXECUTABLE_TEXT_ASK: - { - } - break; + { + } + break; default: /* Complain non-fatally, since preference data can't be trusted */ @@ -667,19 +667,19 @@ get_executable_text_file_action (GtkWindow *parent_window, switch (response) { case RESPONSE_RUN: - { - return ACTIVATION_ACTION_LAUNCH; - } + { + return ACTIVATION_ACTION_LAUNCH; + } case RESPONSE_RUN_IN_TERMINAL: - { - return ACTIVATION_ACTION_LAUNCH_IN_TERMINAL; - } + { + return ACTIVATION_ACTION_LAUNCH_IN_TERMINAL; + } case RESPONSE_DISPLAY: - { - return ACTIVATION_ACTION_OPEN_IN_APPLICATION; - } + { + return ACTIVATION_ACTION_OPEN_IN_APPLICATION; + } default: return ACTIVATION_ACTION_DO_NOTHING; @@ -696,14 +696,14 @@ get_default_executable_text_file_action (void) switch (preferences_value) { case NAUTILUS_EXECUTABLE_TEXT_LAUNCH: - { - return ACTIVATION_ACTION_LAUNCH; - } + { + return ACTIVATION_ACTION_LAUNCH; + } case NAUTILUS_EXECUTABLE_TEXT_DISPLAY: - { - return ACTIVATION_ACTION_OPEN_IN_APPLICATION; - } + { + return ACTIVATION_ACTION_OPEN_IN_APPLICATION; + } case NAUTILUS_EXECUTABLE_TEXT_ASK: default: @@ -1518,32 +1518,32 @@ untrusted_launcher_response_callback (GtkDialog *dialog, switch (response_id) { case RESPONSE_RUN: - { - screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window)); - uri = nautilus_file_get_uri (parameters->file); - DEBUG ("Launching untrusted launcher %s", uri); - nautilus_launch_desktop_file (screen, uri, NULL, - parameters->parent_window); - g_free (uri); - } - break; + { + screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window)); + uri = nautilus_file_get_uri (parameters->file); + DEBUG ("Launching untrusted launcher %s", uri); + nautilus_launch_desktop_file (screen, uri, NULL, + parameters->parent_window); + g_free (uri); + } + break; case RESPONSE_MARK_TRUSTED: - { - file = nautilus_file_get_location (parameters->file); - nautilus_file_mark_desktop_file_trusted (file, - parameters->parent_window, - TRUE, - NULL, NULL); - g_object_unref (file); - } - break; + { + file = nautilus_file_get_location (parameters->file); + nautilus_file_mark_desktop_file_trusted (file, + parameters->parent_window, + TRUE, + NULL, NULL); + g_object_unref (file); + } + break; default: - { - /* Just destroy dialog */ - } - break; + { + /* Just destroy dialog */ + } + break; } gtk_widget_destroy (GTK_WIDGET (dialog)); @@ -1710,8 +1710,8 @@ activate_files (ActivateParameters *parameters) case ACTIVATION_ACTION_EXTRACT: { - /* Extraction of files should be handled in the view */ - g_assert_not_reached (); + /* Extraction of files should be handled in the view */ + g_assert_not_reached (); } break; @@ -1804,10 +1804,12 @@ activate_files (ActivateParameters *parameters) } else { - /* if we want to close the window and activate a single directory, then we will need - * the NEW_WINDOW flag set */ - if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) - flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW; + /* if we want to close the window and activate a single directory, then we will need + * the NEW_WINDOW flag set */ + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) + { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW; + } } if (parameters->slot != NULL && diff --git a/src/nautilus-mime-application-chooser.c b/src/nautilus-mime-application-chooser.c index c7ceeade2..146edaa80 100644 --- a/src/nautilus-mime-application-chooser.c +++ b/src/nautilus-mime-application-chooser.c @@ -48,7 +48,7 @@ struct _NautilusMimeApplicationChooser GtkWidget *entry; GtkWidget *set_as_default_button; GtkWidget *open_with_widget; - GtkWidget *add_button; + GtkWidget *add_button; }; enum diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c index 54b344f22..35eaf30d0 100644 --- a/src/nautilus-pathbar.c +++ b/src/nautilus-pathbar.c @@ -425,14 +425,14 @@ get_dir_name (ButtonData *button_data) switch (button_data->type) { case HOME_BUTTON: - { - return _("Home"); - } + { + return _("Home"); + } case OTHER_LOCATIONS_BUTTON: - { - return _("Other Locations"); - } + { + return _("Other Locations"); + } default: return button_data->dir_name; @@ -912,22 +912,22 @@ nautilus_path_bar_scroll (GtkWidget *widget, { case GDK_SCROLL_RIGHT: case GDK_SCROLL_DOWN: - { - nautilus_path_bar_scroll_down (path_bar); - return TRUE; - } + { + nautilus_path_bar_scroll_down (path_bar); + return TRUE; + } case GDK_SCROLL_LEFT: case GDK_SCROLL_UP: - { - nautilus_path_bar_scroll_up (path_bar); - return TRUE; - } + { + nautilus_path_bar_scroll_up (path_bar); + return TRUE; + } case GDK_SCROLL_SMOOTH: - { - } - break; + { + } + break; } return FALSE; @@ -1699,19 +1699,19 @@ get_gicon (ButtonData *button_data) switch (button_data->type) { case ROOT_BUTTON: - { - return g_themed_icon_new (NAUTILUS_ICON_FILESYSTEM); - } + { + return g_themed_icon_new (NAUTILUS_ICON_FILESYSTEM); + } case HOME_BUTTON: - { - return g_themed_icon_new (NAUTILUS_ICON_HOME); - } + { + return g_themed_icon_new (NAUTILUS_ICON_HOME); + } case MOUNT_BUTTON: - { - return get_gicon_for_mount (button_data); - } + { + return get_gicon_for_mount (button_data); + } default: return NULL; @@ -2052,23 +2052,23 @@ make_button_data (NautilusPathBar *path_bar, switch (button_data->type) { case ROOT_BUTTON: - { - child = button_data->image; - button_data->label = NULL; - } - break; + { + child = button_data->image; + button_data->label = NULL; + } + break; case HOME_BUTTON: case MOUNT_BUTTON: case NORMAL_BUTTON: default: - { - button_data->label = gtk_label_new (NULL); - child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); - gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (child), button_data->label, FALSE, FALSE, 0); - } - break; + { + button_data->label = gtk_label_new (NULL); + child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); + gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (child), button_data->label, FALSE, FALSE, 0); + } + break; } if (button_data->label != NULL) diff --git a/src/nautilus-progress-info.c b/src/nautilus-progress-info.c index d8ac8d226..d642d9a4b 100644 --- a/src/nautilus-progress-info.c +++ b/src/nautilus-progress-info.c @@ -85,8 +85,8 @@ G_DEFINE_TYPE (NautilusProgressInfo, nautilus_progress_info, G_TYPE_OBJECT) static void set_details (NautilusProgressInfo *info, const char *details); -static void set_status (NautilusProgressInfo *info, - const char *status); +static void set_status (NautilusProgressInfo *info, + const char *status); static void nautilus_progress_info_finalize (GObject *object) @@ -699,7 +699,7 @@ nautilus_progress_info_set_progress (NautilusProgressInfo *info, G_LOCK (progress_info); if ((info->activity_mode || /* emit on switch from activity mode */ - fabs (current_percent - info->progress) > 0.005) && /* Emit on change of 0.5 percent */ + fabs (current_percent - info->progress) > 0.005) && /* Emit on change of 0.5 percent */ !g_cancellable_is_cancelled (info->cancellable)) { info->activity_mode = FALSE; diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c index ec80d4e2f..20cff3453 100644 --- a/src/nautilus-properties-window.c +++ b/src/nautilus-properties-window.c @@ -5363,16 +5363,16 @@ real_response (GtkDialog *dialog, case GTK_RESPONSE_NONE: case GTK_RESPONSE_CLOSE: case GTK_RESPONSE_DELETE_EVENT: - { - gtk_widget_destroy (GTK_WIDGET (dialog)); - } - break; + { + gtk_widget_destroy (GTK_WIDGET (dialog)); + } + break; default: - { - g_assert_not_reached (); - } - break; + { + g_assert_not_reached (); + } + break; } } @@ -5592,30 +5592,30 @@ custom_icon_file_chooser_response_cb (GtkDialog *dialog, switch (response) { case GTK_RESPONSE_NO: - { - reset_icon (window); - } - break; + { + reset_icon (window); + } + break; case GTK_RESPONSE_OK: + { + uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); + if (uri != NULL) { - uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); - if (uri != NULL) - { - set_icon (uri, window); - } - else - { - reset_icon (window); - } - g_free (uri); + set_icon (uri, window); } - break; - - default: + else { + reset_icon (window); } - break; + g_free (uri); + } + break; + + default: + { + } + break; } gtk_widget_hide (GTK_WIDGET (dialog)); diff --git a/src/nautilus-search-engine.c b/src/nautilus-search-engine.c index ecb380b2b..f2bc0126b 100644 --- a/src/nautilus-search-engine.c +++ b/src/nautilus-search-engine.c @@ -33,7 +33,8 @@ #include "nautilus-search-engine-tracker.h" #endif -typedef struct { +typedef struct +{ #ifdef ENABLE_TRACKER NautilusSearchEngineTracker *tracker; #endif diff --git a/src/nautilus-search-hit.c b/src/nautilus-search-hit.c index 5a12ddfa9..6ae9ae948 100644 --- a/src/nautilus-search-hit.c +++ b/src/nautilus-search-hit.c @@ -376,7 +376,6 @@ nautilus_search_hit_class_init (NautilusSearchHitClass *class) -G_MAXDOUBLE, G_MAXDOUBLE, 0, G_PARAM_READWRITE)); - } static void diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c index 215dc5a52..d5ed7e069 100644 --- a/src/nautilus-toolbar.c +++ b/src/nautilus-toolbar.c @@ -293,7 +293,7 @@ navigation_button_press_cb (GtkButton *button, NautilusToolbar *self = user_data; GdkEventButton *button_event; - button_event = (GdkEventButton *)event; + button_event = (GdkEventButton *) event; if (button_event->button == 3) { diff --git a/src/nautilus-trash-bar.c b/src/nautilus-trash-bar.c index 9f8dfc318..798a0234b 100644 --- a/src/nautilus-trash-bar.c +++ b/src/nautilus-trash-bar.c @@ -166,7 +166,7 @@ trash_bar_response_cb (GtkInfoBar *infobar, bar = NAUTILUS_TRASH_BAR (infobar); window = gtk_widget_get_toplevel (GTK_WIDGET (bar)); - + switch (response_id) { case TRASH_BAR_RESPONSE_EMPTY: diff --git a/src/nautilus-tree-view-drag-dest.c b/src/nautilus-tree-view-drag-dest.c index b3d61b630..42868e3bd 100644 --- a/src/nautilus-tree-view-drag-dest.c +++ b/src/nautilus-tree-view-drag-dest.c @@ -551,35 +551,35 @@ get_drop_action (NautilusTreeViewDragDest *dest, switch (dest->details->drag_type) { case NAUTILUS_ICON_DND_GNOME_ICON_LIST: - { - nautilus_drag_default_drop_action_for_icons - (context, - drop_target, - dest->details->drag_list, - 0, - &action); - } - break; + { + nautilus_drag_default_drop_action_for_icons + (context, + drop_target, + dest->details->drag_list, + 0, + &action); + } + break; case NAUTILUS_ICON_DND_NETSCAPE_URL: - { - action = nautilus_drag_default_drop_action_for_netscape_url (context); - } - break; + { + action = nautilus_drag_default_drop_action_for_netscape_url (context); + } + break; case NAUTILUS_ICON_DND_URI_LIST: - { - action = gdk_drag_context_get_suggested_action (context); - } - break; + { + action = gdk_drag_context_get_suggested_action (context); + } + break; case NAUTILUS_ICON_DND_TEXT: case NAUTILUS_ICON_DND_RAW: case NAUTILUS_ICON_DND_XDNDDIRECTSAVE: - { - action = GDK_ACTION_COPY; - } - break; + { + action = GDK_ACTION_COPY; + } + break; } g_free (drop_target); @@ -1001,48 +1001,48 @@ drag_data_received_callback (GtkWidget *widget, switch (info) { case NAUTILUS_ICON_DND_GNOME_ICON_LIST: - { - receive_dropped_icons (dest, context, x, y); - success = TRUE; - } - break; + { + receive_dropped_icons (dest, context, x, y); + success = TRUE; + } + break; case NAUTILUS_ICON_DND_NETSCAPE_URL: - { - receive_dropped_netscape_url (dest, context, x, y); - success = TRUE; - } - break; + { + receive_dropped_netscape_url (dest, context, x, y); + success = TRUE; + } + break; case NAUTILUS_ICON_DND_URI_LIST: - { - receive_dropped_uri_list (dest, context, x, y); - success = TRUE; - } - break; + { + receive_dropped_uri_list (dest, context, x, y); + success = TRUE; + } + break; case NAUTILUS_ICON_DND_TEXT: - { - receive_dropped_text (dest, context, x, y); - success = TRUE; - } - break; + { + receive_dropped_text (dest, context, x, y); + success = TRUE; + } + break; case NAUTILUS_ICON_DND_RAW: - { - length = gtk_selection_data_get_length (selection_data); - tmp = (const gchar *) gtk_selection_data_get_data (selection_data); - receive_dropped_raw (dest, tmp, length, context, x, y); - success = TRUE; - } - break; + { + length = gtk_selection_data_get_length (selection_data); + tmp = (const gchar *) gtk_selection_data_get_data (selection_data); + receive_dropped_raw (dest, tmp, length, context, x, y); + success = TRUE; + } + break; case NAUTILUS_ICON_DND_XDNDDIRECTSAVE: - { - finished = receive_xds (dest, widget, time, context, x, y); - success = TRUE; - } - break; + { + finished = receive_xds (dest, widget, time, context, x, y); + success = TRUE; + } + break; } if (finished) diff --git a/src/nautilus-ui-utilities.c b/src/nautilus-ui-utilities.c index 07aca02e8..cb7ab7b1e 100644 --- a/src/nautilus-ui-utilities.c +++ b/src/nautilus-ui-utilities.c @@ -181,7 +181,7 @@ nautilus_pop_up_context_menu (GtkWidget *parent, gtk_menu_popup_at_pointer (GTK_MENU (gtk_menu), button_event ? (GdkEvent *) button_event : - gtk_get_current_event ()); + gtk_get_current_event ()); g_object_ref_sink (gtk_menu); g_object_unref (gtk_menu); diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 262395c93..0f4646f95 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -1371,60 +1371,60 @@ nautilus_window_slot_display_view_selection_failure (NautilusWindow *window, switch (error->code) { case G_IO_ERROR_NOT_FOUND: - { - detail_message = g_strdup (_("Unable to find the requested file. Please check the spelling and try again.")); - } - break; + { + detail_message = g_strdup (_("Unable to find the requested file. Please check the spelling and try again.")); + } + break; case G_IO_ERROR_NOT_SUPPORTED: + { + scheme_string = g_file_get_uri_scheme (location); + if (scheme_string != NULL) { - scheme_string = g_file_get_uri_scheme (location); - if (scheme_string != NULL) - { - detail_message = g_strdup_printf (_("“%s” locations are not supported."), - scheme_string); - } - else - { - detail_message = g_strdup (_("Unable to handle this kind of location.")); - } - g_free (scheme_string); + detail_message = g_strdup_printf (_("“%s” locations are not supported."), + scheme_string); } - break; - - case G_IO_ERROR_NOT_MOUNTED: + else { - detail_message = g_strdup (_("Unable to access the requested location.")); + detail_message = g_strdup (_("Unable to handle this kind of location.")); } - break; + g_free (scheme_string); + } + break; + + case G_IO_ERROR_NOT_MOUNTED: + { + detail_message = g_strdup (_("Unable to access the requested location.")); + } + break; case G_IO_ERROR_PERMISSION_DENIED: - { - detail_message = g_strdup (_("Don’t have permission to access the requested location.")); - } - break; + { + detail_message = g_strdup (_("Don’t have permission to access the requested location.")); + } + break; case G_IO_ERROR_HOST_NOT_FOUND: - { - /* This case can be hit for user-typed strings like "foo" due to - * the code that guesses web addresses when there's no initial "/". - * But this case is also hit for legitimate web addresses when - * the proxy is set up wrong. - */ - detail_message = g_strdup (_("Unable to find the requested location. Please check the spelling or the network settings.")); - } - break; + { + /* This case can be hit for user-typed strings like "foo" due to + * the code that guesses web addresses when there's no initial "/". + * But this case is also hit for legitimate web addresses when + * the proxy is set up wrong. + */ + detail_message = g_strdup (_("Unable to find the requested location. Please check the spelling or the network settings.")); + } + break; case G_IO_ERROR_CANCELLED: case G_IO_ERROR_FAILED_HANDLED: - { - goto done; - } + { + goto done; + } default: - { - } - break; + { + } + break; } } @@ -2200,22 +2200,22 @@ update_history (NautilusWindowSlot *self, switch (type) { case NAUTILUS_LOCATION_CHANGE_STANDARD: - { - handle_go_elsewhere (self, new_location); - return; - } + { + handle_go_elsewhere (self, new_location); + return; + } case NAUTILUS_LOCATION_CHANGE_RELOAD: - { - /* for reload there is no work to do */ - return; - } + { + /* for reload there is no work to do */ + return; + } case NAUTILUS_LOCATION_CHANGE_BACK: - { - handle_go_direction (self, new_location, FALSE); - return; - } + { + handle_go_direction (self, new_location, FALSE); + return; + } case NAUTILUS_LOCATION_CHANGE_FORWARD: handle_go_direction (self, new_location, TRUE); @@ -3095,16 +3095,19 @@ nautilus_window_slot_get_icon (NautilusWindowSlot *self) return nautilus_view_get_icon (NAUTILUS_VIEW_GRID_ID); } break; + case NAUTILUS_VIEW_GRID_ID: { return nautilus_view_get_icon (NAUTILUS_VIEW_LIST_ID); } break; + case NAUTILUS_VIEW_OTHER_LOCATIONS_ID: { return nautilus_view_get_icon (NAUTILUS_VIEW_OTHER_LOCATIONS_ID); } break; + default: { return NULL; diff --git a/src/nautilus-window.c b/src/nautilus-window.c index a9c1d87d8..789b217ac 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -2281,16 +2281,16 @@ nautilus_window_set_property (GObject *object, switch (arg_id) { case PROP_DISABLE_CHROME: - { - window->priv->disable_chrome = g_value_get_boolean (value); - } - break; + { + window->priv->disable_chrome = g_value_get_boolean (value); + } + break; default: - { - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, arg_id, pspec); - } - break; + { + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, arg_id, pspec); + } + break; } } @@ -2307,10 +2307,10 @@ nautilus_window_get_property (GObject *object, switch (arg_id) { case PROP_DISABLE_CHROME: - { - g_value_set_boolean (value, window->priv->disable_chrome); - } - break; + { + g_value_set_boolean (value, window->priv->disable_chrome); + } + break; } } |