diff options
105 files changed, 4642 insertions, 6350 deletions
diff --git a/build-aux/flatpak/org.gnome.Nautilus.json b/build-aux/flatpak/org.gnome.Nautilus.json index fb6213074..f952cfeed 100644 --- a/build-aux/flatpak/org.gnome.Nautilus.json +++ b/build-aux/flatpak/org.gnome.Nautilus.json @@ -118,7 +118,7 @@ "builddir": true, "config-opts": [ "-Ddocs=false", - "-Dbackends=gtk3", + "-Dbackends=gtk4", "--libdir=/app/lib", "--buildtype=debugoptimized" ], diff --git a/build-aux/flatpak/org.gnome.Nautilus.yml b/build-aux/flatpak/org.gnome.Nautilus.yml index 555f95905..af617396f 100644 --- a/build-aux/flatpak/org.gnome.Nautilus.yml +++ b/build-aux/flatpak/org.gnome.Nautilus.yml @@ -86,7 +86,7 @@ modules: builddir: true config-opts: - "-Ddocs=false" - - "-Dbackends=gtk3" + - "-Dbackends=gtk4" - "--libdir=/app/lib" - "--buildtype=debugoptimized" sources: diff --git a/eel/check-program.c b/eel/check-program.c index 1e0f0a382..04cbc7de6 100644 --- a/eel/check-program.c +++ b/eel/check-program.c @@ -40,8 +40,7 @@ main (int argc, LIBXML_TEST_VERSION - gtk_init (&argc, - &argv); + gtk_init (); /* Run the checks for eel twice. */ diff --git a/eel/eel-stock-dialogs.c b/eel/eel-stock-dialogs.c index 9e10eb28a..9844da086 100644 --- a/eel/eel-stock-dialogs.c +++ b/eel/eel-stock-dialogs.c @@ -101,7 +101,7 @@ timed_wait_delayed_close_timeout_callback (gpointer callback_data) G_CALLBACK (timed_wait_delayed_close_destroy_dialog_callback), GUINT_TO_POINTER (handler_id)); - gtk_widget_destroy (GTK_WIDGET (callback_data)); + gtk_window_destroy (GTK_WINDOW (callback_data)); return FALSE; } @@ -151,7 +151,7 @@ timed_wait_free (TimedWait *wait) } else { - gtk_widget_destroy (GTK_WIDGET (wait->dialog)); + gtk_window_destroy (GTK_WINDOW (wait->dialog)); } } @@ -187,7 +187,7 @@ trash_dialog_response_callback (GtkDialog *dialog, int response_id, TimedWait *wait) { - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); } static gboolean @@ -334,7 +334,7 @@ eel_show_simple_dialog (GtkWidget *parent, chosen_parent = NULL; if (parent != NULL) { - top_widget = gtk_widget_get_toplevel (parent); + top_widget = GTK_WIDGET (gtk_widget_get_root (parent)); if (GTK_IS_WINDOW (top_widget)) { chosen_parent = top_widget; @@ -368,7 +368,7 @@ eel_show_simple_dialog (GtkWidget *parent, } va_end (button_title_args); - gtk_widget_show_all (dialog); + gtk_widget_show (dialog); return GTK_DIALOG (dialog); } @@ -414,7 +414,7 @@ show_message_dialog (const char *primary_text, gtk_widget_show (GTK_WIDGET (dialog)); g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), NULL); + G_CALLBACK (gtk_window_destroy), NULL); return dialog; } diff --git a/extensions/audio-video-properties/bacon-video-widget-properties.c b/extensions/audio-video-properties/bacon-video-widget-properties.c index b2b2aaf37..fca9dfd7d 100644 --- a/extensions/audio-video-properties/bacon-video-widget-properties.c +++ b/extensions/audio-video-properties/bacon-video-widget-properties.c @@ -276,7 +276,7 @@ bacon_video_widget_properties_new (void) g_object_unref (group); - gtk_widget_show_all (GTK_WIDGET (props)); + gtk_widget_show (GTK_WIDGET (props)); return GTK_WIDGET (props); } diff --git a/extensions/audio-video-properties/test-properties-page.c b/extensions/audio-video-properties/test-properties-page.c index 21be43a34..f52881625 100644 --- a/extensions/audio-video-properties/test-properties-page.c +++ b/extensions/audio-video-properties/test-properties-page.c @@ -38,7 +38,7 @@ create_props (const char *url) props = totem_properties_view_new (url, label); gtk_container_add (GTK_CONTAINER (window), props); - gtk_widget_show_all (window); + gtk_widget_show (window); } static void @@ -58,7 +58,7 @@ int main (int argc, char **argv) totem_gst_disable_display_decoders (); gst_init (&argc, &argv); - gtk_init (&argc, &argv); + gtk_init (); if (argc != 2) { g_print ("Usage: %s [URI]\n", argv[0]); diff --git a/extensions/image-properties/nautilus-image-properties-page.c b/extensions/image-properties/nautilus-image-properties-page.c index a8dd7a6d2..ea415aa69 100644 --- a/extensions/image-properties/nautilus-image-properties-page.c +++ b/extensions/image-properties/nautilus-image-properties-page.c @@ -80,7 +80,7 @@ append_item (NautilusImagesPropertiesPage *page, value_label = gtk_label_new (value); - gtk_label_set_line_wrap (GTK_LABEL (value_label), TRUE); + gtk_label_set_wrap (GTK_LABEL (value_label), TRUE); gtk_grid_attach_next_to (GTK_GRID (page->grid), value_label, name_label, GTK_POS_RIGHT, 1, 1); @@ -93,7 +93,7 @@ append_item (NautilusImagesPropertiesPage *page, static void nautilus_image_properties_page_init (NautilusImagesPropertiesPage *self) { - self->page_widget = gtk_scrolled_window_new (NULL, NULL); + self->page_widget = gtk_scrolled_window_new (); g_object_set (self->page_widget, "margin-bottom", 6, @@ -119,7 +119,7 @@ nautilus_image_properties_page_init (NautilusImagesPropertiesPage *self) self->grid); #endif - gtk_widget_show_all (GTK_WIDGET (self->page_widget)); + gtk_widget_show (GTK_WIDGET (self->page_widget)); } static void diff --git a/libnautilus-extension/meson.build b/libnautilus-extension/meson.build index ad791f60e..6ceb53a14 100644 --- a/libnautilus-extension/meson.build +++ b/libnautilus-extension/meson.build @@ -83,10 +83,10 @@ if get_option('introspection') '-DNAUTILUS_COMPILATION' ], sources: libnautilus_extension_sources, - nsversion: '3.0', + nsversion: '4.0', namespace: 'Nautilus', includes: [ - 'Gtk-3.0', + 'Gtk-4.0', 'Gio-2.0', 'GLib-2.0' ], @@ -115,7 +115,7 @@ pkgconfig.generate( requires: [ 'gio-2.0', 'glib-2.0', - 'gtk+-3.0' + 'gtk4' ], variables: [ 'exec_prefix=${prefix}', diff --git a/meson.build b/meson.build index c8f28ccb3..9d7784921 100644 --- a/meson.build +++ b/meson.build @@ -107,14 +107,14 @@ gio_unix = dependency('gio-unix-2.0', version: glib_ver) glib = dependency('glib-2.0', version: glib_ver) gmodule = dependency('gmodule-no-export-2.0', version: glib_ver) gnome_autoar = dependency('gnome-autoar-0', version: '>= 0.4.0') -gnome_desktop = dependency('gnome-desktop-3.0', version: '>= 3.0.0') -gtk = dependency('gtk+-3.0', version: '>= 3.22.27') -libhandy = dependency('libhandy-1', version: '>= 1.1.90') +gnome_desktop = dependency('gnome-desktop-4', version: '>= 1.0.0') +gtk = dependency('gtk4', version: '>= 4.6') +libadwaita = dependency('libadwaita-1', version: '>= 1.0') libportal = [] -libportal_gtk3 = [] +libportal_gtk4 = [] if get_option('libportal') libportal = dependency('libportal', version: '>= 0.5') - libportal_gtk3 = dependency('libportal-gtk3', version: '>= 0.5') + libportal_gtk4 = dependency('libportal-gtk4', version: '>= 0.5') endif selinux = [] if get_option('selinux') diff --git a/src/gtk/gtk-code-generator.sh b/src/gtk/gtk-code-generator.sh index e6f2ac0d0..4effdc33d 100755 --- a/src/gtk/gtk-code-generator.sh +++ b/src/gtk/gtk-code-generator.sh @@ -5,9 +5,9 @@ # action. # Also remove/add the neccesary bits to make it work inside nautilus -URL=https://gitlab.gnome.org/GNOME/gtk/raw/gtk-3-24/gtk/ -URLUI=https://gitlab.gnome.org/GNOME/gtk/raw/gtk-3-24/gtk/ui/ -SUFIX=?h=gtk-3-24 +URL=https://gitlab.gnome.org/GNOME/gtk/raw/master/gtk/ +URLUI=https://gitlab.gnome.org/GNOME/gtk/raw/master/gtk/ui/ +SUFIX=?h=master # Since comments are not allowed inside the sed line, this is what it will do # by order: @@ -24,27 +24,22 @@ SUFIX=?h=gtk-3-24 # use local sidebar header instead of private gtk one # in-line replace private gtkfilesystem.h helper function # ignore shadowed variable which we would treat as compile error +# use local header instead of private gtk one +# replace private macros with their expansion +# replace private enum type with our own equivalent update_file () { _source="$1" _dest="$2" curl "${_source}" | sed \ - -e 's/gtkplacesview/nautilusgtkplacesview/g' \ - -e 's/gtk_places_view/nautilus_gtk_places_view/g' \ - -e 's/GtkPlacesView/NautilusGtkPlacesView/g' \ - -e 's/GTK_PLACES_VIEW/NAUTILUS_GTK_PLACES_VIEW/g' \ - -e 's/GTK_TYPE_PLACES_VIEW/NAUTILUS_TYPE_GTK_PLACES_VIEW/g' \ - -e 's/GTK_IS_PLACES_VIEW/NAUTILUS_IS_GTK_PLACES_VIEW/g' \ + -e 's/gtkplaces/nautilusgtkplaces/g' \ + -e 's/gtk_places_/nautilus_gtk_places_/g' \ + -e 's/GtkPlaces/NautilusGtkPlaces/g' \ + -e 's/GTK_PLACES_/NAUTILUS_GTK_PLACES_/g' \ + -e 's/GTK_TYPE_PLACES_/NAUTILUS_TYPE_GTK_PLACES_/g' \ + -e 's/GTK_IS_PLACES_/NAUTILUS_IS_GTK_PLACES_/g' \ -e 's/G_DECLARE_FINAL_TYPE (NautilusGtkPlacesViewRow, nautilus_gtk_places_view_row, GTK, PLACES_VIEW_ROW, GtkListBoxRow/ G_DECLARE_FINAL_TYPE (NautilusGtkPlacesViewRow, nautilus_gtk_places_view_row, NAUTILUS, GTK_PLACES_VIEW_ROW, GtkListBoxRow/g' \ - -e 's/gtkplacessidebar/nautilusgtkplacessidebar/g' \ - -e 's/gtk_places_sidebar/nautilus_gtk_places_sidebar/g' \ - -e 's/GtkPlacesSidebar/NautilusGtkPlacesSidebar/g' \ - -e 's/GTK_PLACES_SIDEBAR/NAUTILUS_GTK_PLACES_SIDEBAR/g' \ - -e 's/GTK_TYPE_PLACES_SIDEBAR/NAUTILUS_TYPE_GTK_PLACES_SIDEBAR/g' \ - -e 's/GTK_IS_PLACES_SIDEBAR/NAUTILUS_IS_GTK_PLACES_SIDEBAR/g' \ - -e 's/GtkPlacesOpen/NautilusGtkPlacesOpen/g' \ - -e 's/GTK_PLACES_OPEN/NAUTILUS_GTK_PLACES_OPEN/g' \ -e 's/gtkbookmarksmanager/nautilusgtkbookmarksmanager/g' \ -e 's/gtk_bookmarks_manager/nautilus_gtk_bookmarks_manager/g' \ -e 's/GtkBookmarksManager/NautilusGtkBookmarksManager/g' \ @@ -75,6 +70,8 @@ update_file () { -e "s/P_(\(.*\))/\1/" \ -e "s/I_(\(.*\))/\1/" \ -e '/"config.h"/a #include <gtk\/gtk.h>' \ + -e 's/<gtk\/gtkwidget.h>/<gtk\/gtk.h>/g' \ + -e '/gtkenums.h/d' \ -e '/gtktypebuiltins.h/d' \ -e '/gtkintl.h/d' \ -e '/<gtk\/gtkbox.h>/d' \ @@ -88,7 +85,9 @@ update_file () { -e '/"gtki\(.*\).h"/d' \ -e '/"gtkl\(.*\).h"/d' \ -e '/"gtkm\(.*\).h"/d' \ + -e '/"gtkn\(.*\).h"/d' \ -e '/"gtkpo\(.*\).h"/d' \ + -e '/"gtkpr\(.*\).h"/d' \ -e '/"gtkr\(.*\).h"/d' \ -e '/"gtksc\(.*\).h"/d' \ -e '/"gtkse\(.*\).h"/d' \ @@ -99,9 +98,14 @@ update_file () { -e '/"gtkw\(.*\).h"/d' \ -e '/#error/d' \ -e 's/gtk\/libgtk/gnome\/nautilus\/gtk/g' \ - -e 's/<gtk\/nautilusgtkplacessidebar.h>/"nautilusgtkplacessidebar.h"'/g \ + -e 's/<gtk\/nautilusgtkplacessidebarprivate.h>/"nautilusgtkplacessidebarprivate.h"'/g \ -e 's/_gtk_file_info_consider_as_directory (info)/(g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY || g_file_info_get_file_type (info) == G_FILE_TYPE_MOUNTABLE || g_file_info_get_file_type (info) == G_FILE_TYPE_SHORTCUT)/g' \ -e '/#include "nautilus-trash-monitor.h"/a #pragma GCC diagnostic ignored "-Wshadow"' \ + -e 's/gtk_drag_check_threshold_double/gtk_drag_check_threshold/g' \ + -e 's/NAUTILUS_TYPE_GTK_PLACES_OPEN_FLAGS/NAUTILUS_TYPE_OPEN_FLAGS/g' \ + -e '/"config.h"/a #include "nautilus-enum-types.h"' \ + -e 's/GTK_PARAM_READABLE/G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB/g' \ + -e 's/GTK_PARAM_READWRITE/G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB/g' \ > "${_dest}" } @@ -110,9 +114,8 @@ update_file "${URL}/gtkplacesviewprivate.h${SUFIX}" "nautilusgtkplacesviewprivat update_file "${URLUI}/gtkplacesview.ui${SUFIX}" "nautilusgtkplacesview.ui" update_file "${URL}/gtkplacessidebar.c${SUFIX}" "nautilusgtkplacessidebar.c" update_file "${URL}/gtkplacessidebarprivate.h${SUFIX}" "nautilusgtkplacessidebarprivate.h" -update_file "${URL}/gtkplacessidebar.h${SUFIX}" "nautilusgtkplacessidebar.h" update_file "${URL}/gtkbookmarksmanager.c${SUFIX}" "nautilusgtkbookmarksmanager.c" -update_file "${URL}/gtkbookmarksmanager.h${SUFIX}" "nautilusgtkbookmarksmanager.h" +update_file "${URL}/gtkbookmarksmanagerprivate.h${SUFIX}" "nautilusgtkbookmarksmanagerprivate.h" update_file "${URL}/gtkplacesviewrow.c${SUFIX}" "nautilusgtkplacesviewrow.c" update_file "${URL}/gtkplacesviewrowprivate.h${SUFIX}" "nautilusgtkplacesviewrowprivate.h" update_file "${URLUI}/gtkplacesviewrow.ui${SUFIX}" "nautilusgtkplacesviewrow.ui" diff --git a/src/gtk/nautilusgtkbookmarksmanager.c b/src/gtk/nautilusgtkbookmarksmanager.c index 385d58635..3563fc2f1 100644 --- a/src/gtk/nautilusgtkbookmarksmanager.c +++ b/src/gtk/nautilusgtkbookmarksmanager.c @@ -24,12 +24,13 @@ #include "config.h" #include <glib/gi18n.h> #include <gtk/gtk.h> +#include "nautilus-enum-types.h" #include <string.h> #include <glib/gi18n-lib.h> -#include "nautilusgtkbookmarksmanager.h" +#include "nautilusgtkbookmarksmanagerprivate.h" static void _gtk_bookmark_free (gpointer data) @@ -44,7 +45,7 @@ _gtk_bookmark_free (gpointer data) static void set_error_bookmark_doesnt_exist (GFile *file, GError **error) { - gchar *uri = g_file_get_uri (file); + char *uri = g_file_get_uri (file); g_set_error (error, GTK_FILE_CHOOSER_ERROR, @@ -59,7 +60,7 @@ static GFile * get_legacy_bookmarks_file (void) { GFile *file; - gchar *filename; + char *filename; filename = g_build_filename (g_get_home_dir (), ".gtk-bookmarks", NULL); file = g_file_new_for_path (filename); @@ -72,8 +73,12 @@ static GFile * get_bookmarks_file (void) { GFile *file; - gchar *filename; + char *filename; + /* Use gtk-3.0's bookmarks file as the format didn't change. + * Add the 3.0 file format to get_legacy_bookmarks_file() when + * the format does change. + */ filename = g_build_filename (g_get_user_config_dir (), "gtk-3.0", "bookmarks", NULL); file = g_file_new_for_path (filename); g_free (filename); @@ -82,16 +87,11 @@ get_bookmarks_file (void) } static GSList * -read_bookmarks (GFile *file) +parse_bookmarks (const char *contents) { - gchar *contents; - gchar **lines, *space; + char **lines, *space; GSList *bookmarks = NULL; - gint i; - - if (!g_file_load_contents (file, NULL, &contents, - NULL, NULL, NULL)) - return NULL; + int i; lines = g_strsplit (contents, "\n", -1); @@ -119,12 +119,61 @@ read_bookmarks (GFile *file) bookmarks = g_slist_reverse (bookmarks); g_strfreev (lines); + + return bookmarks; +} + +static GSList * +read_bookmarks (GFile *file) +{ + char *contents; + GSList *bookmarks = NULL; + + if (!g_file_load_contents (file, NULL, &contents, + NULL, NULL, NULL)) + return NULL; + + bookmarks = parse_bookmarks (contents); + g_free (contents); return bookmarks; } static void +notify_changed (NautilusGtkBookmarksManager *manager) +{ + if (manager->changed_func) + manager->changed_func (manager->changed_func_data); +} + +static void +read_bookmarks_finish (GObject *source, + GAsyncResult *result, + gpointer data) +{ + GFile *file = G_FILE (source); + NautilusGtkBookmarksManager *manager = data; + char *contents = NULL; + GError *error = NULL; + + if (!g_file_load_contents_finish (file, result, &contents, NULL, NULL, &error)) + { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("Failed to load '%s': %s", g_file_peek_path (file), error->message); + g_error_free (error); + return; + } + + g_slist_free_full (manager->bookmarks, _gtk_bookmark_free); + manager->bookmarks = parse_bookmarks (contents); + + g_free (contents); + + notify_changed (manager); +} + +static void save_bookmarks (GFile *bookmarks_file, GSList *bookmarks) { @@ -138,7 +187,7 @@ save_bookmarks (GFile *bookmarks_file, for (l = bookmarks; l; l = l->next) { GtkBookmark *bookmark = l->data; - gchar *uri; + char *uri; uri = g_file_get_uri (bookmark->file); if (!uri) @@ -179,13 +228,6 @@ save_bookmarks (GFile *bookmarks_file, } static void -notify_changed (NautilusGtkBookmarksManager *manager) -{ - if (manager->changed_func) - manager->changed_func (manager->changed_func_data); -} - -static void bookmarks_file_changed (GFileMonitor *monitor, GFile *file, GFile *other_file, @@ -199,15 +241,17 @@ bookmarks_file_changed (GFileMonitor *monitor, case G_FILE_MONITOR_EVENT_CHANGED: case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: case G_FILE_MONITOR_EVENT_CREATED: - case G_FILE_MONITOR_EVENT_DELETED: - g_slist_free_full (manager->bookmarks, _gtk_bookmark_free); - manager->bookmarks = read_bookmarks (file); - - gdk_threads_enter (); - notify_changed (manager); - gdk_threads_leave (); + g_file_load_contents_async (file, manager->cancellable, read_bookmarks_finish, manager); break; + case G_FILE_MONITOR_EVENT_DELETED: + case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: + case G_FILE_MONITOR_EVENT_PRE_UNMOUNT: + case G_FILE_MONITOR_EVENT_UNMOUNTED: + case G_FILE_MONITOR_EVENT_MOVED: + case G_FILE_MONITOR_EVENT_RENAMED: + case G_FILE_MONITOR_EVENT_MOVED_IN: + case G_FILE_MONITOR_EVENT_MOVED_OUT: default: /* ignore at the moment */ break; @@ -226,9 +270,10 @@ _nautilus_gtk_bookmarks_manager_new (GtkBookmarksChangedFunc changed_func, gpoin manager->changed_func = changed_func; manager->changed_func_data = changed_func_data; + manager->cancellable = g_cancellable_new (); + bookmarks_file = get_bookmarks_file (); - manager->bookmarks = read_bookmarks (bookmarks_file); - if (!manager->bookmarks) + if (!g_file_query_exists (bookmarks_file, NULL)) { GFile *legacy_bookmarks_file; @@ -240,6 +285,8 @@ _nautilus_gtk_bookmarks_manager_new (GtkBookmarksChangedFunc changed_func, gpoin g_object_unref (legacy_bookmarks_file); } + else + g_file_load_contents_async (bookmarks_file, manager->cancellable, read_bookmarks_finish, manager); error = NULL; manager->bookmarks_monitor = g_file_monitor_file (bookmarks_file, @@ -254,6 +301,7 @@ _nautilus_gtk_bookmarks_manager_new (GtkBookmarksChangedFunc changed_func, gpoin manager->bookmarks_monitor_changed_id = g_signal_connect (manager->bookmarks_monitor, "changed", G_CALLBACK (bookmarks_file_changed), manager); + g_object_unref (bookmarks_file); return manager; @@ -264,6 +312,9 @@ _nautilus_gtk_bookmarks_manager_free (NautilusGtkBookmarksManager *manager) { g_return_if_fail (manager != NULL); + g_cancellable_cancel (manager->cancellable); + g_object_unref (manager->cancellable); + if (manager->bookmarks_monitor) { g_file_monitor_cancel (manager->bookmarks_monitor); @@ -339,7 +390,7 @@ _nautilus_gtk_bookmarks_manager_has_bookmark (NautilusGtkBookmarksManager *manag gboolean _nautilus_gtk_bookmarks_manager_insert_bookmark (NautilusGtkBookmarksManager *manager, GFile *file, - gint position, + int position, GError **error) { GSList *link; @@ -353,7 +404,7 @@ _nautilus_gtk_bookmarks_manager_insert_bookmark (NautilusGtkBookmarksManager *ma if (link) { - gchar *uri; + char *uri; bookmark = link->data; uri = g_file_get_uri (bookmark->file); @@ -423,7 +474,7 @@ _nautilus_gtk_bookmarks_manager_remove_bookmark (NautilusGtkBookmarksManager *ma gboolean _nautilus_gtk_bookmarks_manager_reorder_bookmark (NautilusGtkBookmarksManager *manager, GFile *file, - gint new_position, + int new_position, GError **error) { GSList *link; @@ -468,12 +519,12 @@ _nautilus_gtk_bookmarks_manager_reorder_bookmark (NautilusGtkBookmarksManager *m return TRUE; } -gchar * +char * _nautilus_gtk_bookmarks_manager_get_bookmark_label (NautilusGtkBookmarksManager *manager, GFile *file) { GSList *bookmarks; - gchar *label = NULL; + char *label = NULL; g_return_val_if_fail (manager != NULL, NULL); g_return_val_if_fail (file != NULL, NULL); @@ -500,7 +551,7 @@ _nautilus_gtk_bookmarks_manager_get_bookmark_label (NautilusGtkBookmarksManager gboolean _nautilus_gtk_bookmarks_manager_set_bookmark_label (NautilusGtkBookmarksManager *manager, GFile *file, - const gchar *label, + const char *label, GError **error) { GFile *bookmarks_file; @@ -532,7 +583,7 @@ _nautilus_gtk_bookmarks_manager_set_bookmark_label (NautilusGtkBookmarksManager return TRUE; } -gboolean +static gboolean _nautilus_gtk_bookmarks_manager_get_xdg_type (NautilusGtkBookmarksManager *manager, GFile *file, GUserDirectory *directory) @@ -540,7 +591,7 @@ _nautilus_gtk_bookmarks_manager_get_xdg_type (NautilusGtkBookmarksManager *manag GSList *link; gboolean match; GFile *location; - const gchar *path; + const char *path; GUserDirectory dir; GtkBookmark *bookmark; diff --git a/src/gtk/nautilusgtkbookmarksmanager.h b/src/gtk/nautilusgtkbookmarksmanagerprivate.h index 229c61370..99890a331 100644 --- a/src/gtk/nautilusgtkbookmarksmanager.h +++ b/src/gtk/nautilusgtkbookmarksmanagerprivate.h @@ -38,12 +38,14 @@ typedef struct gpointer changed_func_data; GtkBookmarksChangedFunc changed_func; + + GCancellable *cancellable; } NautilusGtkBookmarksManager; typedef struct { GFile *file; - gchar *label; + char *label; } GtkBookmark; NautilusGtkBookmarksManager *_nautilus_gtk_bookmarks_manager_new (GtkBookmarksChangedFunc changed_func, @@ -56,7 +58,7 @@ GSList *_nautilus_gtk_bookmarks_manager_list_bookmarks (NautilusGtkBookmarksMana gboolean _nautilus_gtk_bookmarks_manager_insert_bookmark (NautilusGtkBookmarksManager *manager, GFile *file, - gint position, + int position, GError **error); gboolean _nautilus_gtk_bookmarks_manager_remove_bookmark (NautilusGtkBookmarksManager *manager, @@ -65,23 +67,20 @@ gboolean _nautilus_gtk_bookmarks_manager_remove_bookmark (NautilusGtkBookmarksMa gboolean _nautilus_gtk_bookmarks_manager_reorder_bookmark (NautilusGtkBookmarksManager *manager, GFile *file, - gint new_position, + int new_position, GError **error); gboolean _nautilus_gtk_bookmarks_manager_has_bookmark (NautilusGtkBookmarksManager *manager, GFile *file); -gchar * _nautilus_gtk_bookmarks_manager_get_bookmark_label (NautilusGtkBookmarksManager *manager, +char * _nautilus_gtk_bookmarks_manager_get_bookmark_label (NautilusGtkBookmarksManager *manager, GFile *file); gboolean _nautilus_gtk_bookmarks_manager_set_bookmark_label (NautilusGtkBookmarksManager *manager, GFile *file, - const gchar *label, + const char *label, GError **error); -gboolean _nautilus_gtk_bookmarks_manager_get_xdg_type (NautilusGtkBookmarksManager *manager, - GFile *file, - GUserDirectory *directory); gboolean _nautilus_gtk_bookmarks_manager_get_is_builtin (NautilusGtkBookmarksManager *manager, GFile *file); diff --git a/src/gtk/nautilusgtkplacessidebar.c b/src/gtk/nautilusgtkplacessidebar.c index 71c320d7d..254bfe93e 100644 --- a/src/gtk/nautilusgtkplacessidebar.c +++ b/src/gtk/nautilusgtkplacessidebar.c @@ -24,31 +24,26 @@ #include "config.h" #include <glib/gi18n.h> #include <gtk/gtk.h> +#include "nautilus-enum-types.h" #include <gio/gio.h> #ifdef HAVE_CLOUDPROVIDERS -#include <cloudproviders/cloudproviderscollector.h> -#include <cloudproviders/cloudprovidersaccount.h> -#include <cloudproviders/cloudprovidersprovider.h> +#include <cloudproviders.h> #endif #include "nautilusgtkplacessidebarprivate.h" #include "nautilusgtksidebarrowprivate.h" #include "gdk/gdkkeysyms.h" -#include "nautilusgtkbookmarksmanager.h" -#include "nautilusgtkplacessidebar.h" +#include "nautilusgtkbookmarksmanagerprivate.h" #include "nautilus-trash-monitor.h" #pragma GCC diagnostic ignored "-Wshadow" -/** - * SECTION:nautilusgtkplacessidebar - * @Short_description: Sidebar that displays frequently-used places in the file system - * @Title: NautilusGtkPlacesSidebar - * @See_also: #GtkFileChooser +/*< private > + * NautilusGtkPlacesSidebar: * - * #NautilusGtkPlacesSidebar is a widget that displays a list of frequently-used places in the + * NautilusGtkPlacesSidebar is a widget that displays a list of frequently-used places in the * file system: the user’s home directory, the user’s bookmarks, and volumes and drives. - * This widget is used as a sidebar in #GtkFileChooser and may be used by file managers + * This widget is used as a sidebar in GtkFileChooser and may be used by file managers * and similar programs. * * The places sidebar displays drives and volumes, and will automatically mount @@ -64,7 +59,7 @@ * for a Clipart folder. You can do this with nautilus_gtk_places_sidebar_add_shortcut(). * * To make use of the places sidebar, an application at least needs to connect - * to the #NautilusGtkPlacesSidebar::open-location signal. This is emitted when the + * to the NautilusGtkPlacesSidebar::open-location signal. This is emitted when the * user selects in the sidebar a location to open. The application should also * call nautilus_gtk_places_sidebar_set_location() when it changes the currently-viewed * location. @@ -95,13 +90,16 @@ typedef enum { } DropState; struct _NautilusGtkPlacesSidebar { - GtkScrolledWindow parent; + GtkWidget parent; + GtkWidget *swin; GtkWidget *list_box; GtkWidget *new_bookmark_row; NautilusGtkBookmarksManager *bookmarks_manager; + GActionGroup *row_actions; + #ifdef HAVE_CLOUDPROVIDERS CloudProvidersCollector *cloud_manager; GList *unready_accounts; @@ -116,25 +114,19 @@ struct _NautilusGtkPlacesSidebar { GtkWidget *rename_entry; GtkWidget *rename_button; GtkWidget *rename_error; - gchar *rename_uri; + char *rename_uri; gulong trash_monitor_changed_id; GtkWidget *trash_row; /* DND */ - GList *drag_list; /* list of GFile */ - gint drag_data_info; gboolean dragging_over; - GtkTargetList *source_targets; GtkWidget *drag_row; - gint drag_row_height; - gint drag_row_x; - gint drag_row_y; - gint drag_root_x; - gint drag_root_y; + int drag_row_height; + int drag_row_x; + int drag_row_y; GtkWidget *row_placeholder; DropState drop_state; - GtkGesture *long_press_gesture; /* volume mounting - delayed open process */ NautilusGtkPlacesOpenFlags go_to_after_mount_open_flags; @@ -142,50 +134,37 @@ struct _NautilusGtkPlacesSidebar { GtkWidget *popover; NautilusGtkSidebarRow *context_row; - GSList *shortcuts; + GListStore *shortcuts; GDBusProxy *hostnamed_proxy; GCancellable *hostnamed_cancellable; - gchar *hostname; + char *hostname; NautilusGtkPlacesOpenFlags open_flags; - GActionGroup *action_group; - guint mounting : 1; - guint drag_data_received : 1; - guint drop_occurred : 1; guint show_recent_set : 1; guint show_recent : 1; guint show_desktop_set : 1; guint show_desktop : 1; - guint show_connect_to_server : 1; guint show_enter_location : 1; guint show_other_locations : 1; guint show_trash : 1; guint show_starred_location : 1; - guint local_only : 1; - guint populate_all : 1; }; struct _NautilusGtkPlacesSidebarClass { - GtkScrolledWindowClass parent; + GtkWidgetClass parent_class; void (* open_location) (NautilusGtkPlacesSidebar *sidebar, GFile *location, NautilusGtkPlacesOpenFlags open_flags); - void (* populate_popup) (NautilusGtkPlacesSidebar *sidebar, - GtkMenu *menu, - GFile *selected_item, - GVolume *selected_volume); void (* show_error_message) (NautilusGtkPlacesSidebar *sidebar, - const gchar *primary, - const gchar *secondary); - void (* show_connect_to_server) (NautilusGtkPlacesSidebar *sidebar); + const char *primary, + const char *secondary); GdkDragAction (* drag_action_requested) (NautilusGtkPlacesSidebar *sidebar, - GdkDragContext *context, GFile *dest_file, - GList *source_file_list); + GSList *source_file_list); GdkDragAction (* drag_action_ask) (NautilusGtkPlacesSidebar *sidebar, GdkDragAction actions); void (* drag_perform_drop) (NautilusGtkPlacesSidebar *sidebar, @@ -194,8 +173,6 @@ struct _NautilusGtkPlacesSidebarClass { GdkDragAction action); void (* show_enter_location) (NautilusGtkPlacesSidebar *sidebar); - void (* show_other_locations) (NautilusGtkPlacesSidebar *sidebar); - void (* show_other_locations_with_flags) (NautilusGtkPlacesSidebar *sidebar, NautilusGtkPlacesOpenFlags open_flags); @@ -209,14 +186,11 @@ struct _NautilusGtkPlacesSidebarClass { enum { OPEN_LOCATION, - POPULATE_POPUP, SHOW_ERROR_MESSAGE, - SHOW_CONNECT_TO_SERVER, SHOW_ENTER_LOCATION, DRAG_ACTION_REQUESTED, DRAG_ACTION_ASK, DRAG_PERFORM_DROP, - SHOW_OTHER_LOCATIONS, SHOW_OTHER_LOCATIONS_WITH_FLAGS, SHOW_STARRED_LOCATION, MOUNT, @@ -229,13 +203,10 @@ enum { PROP_OPEN_FLAGS, PROP_SHOW_RECENT, PROP_SHOW_DESKTOP, - PROP_SHOW_CONNECT_TO_SERVER, PROP_SHOW_ENTER_LOCATION, PROP_SHOW_TRASH, PROP_SHOW_STARRED_LOCATION, - PROP_LOCAL_ONLY, PROP_SHOW_OTHER_LOCATIONS, - PROP_POPULATE_ALL, NUM_PROPERTIES }; @@ -270,40 +241,32 @@ static void check_unmount_and_eject (GMount *mount, GDrive *drive, gboolean *show_unmount, gboolean *show_eject); -static gboolean on_button_press_event (GtkWidget *widget, - GdkEventButton *event, - NautilusGtkSidebarRow *sidebar); -static gboolean on_button_release_event (GtkWidget *widget, - GdkEventButton *event, - NautilusGtkSidebarRow *sidebar); +static void on_row_pressed (GtkGestureClick *gesture, + int n_press, + double x, + double y, + NautilusGtkSidebarRow *row); +static void on_row_released (GtkGestureClick *gesture, + int n_press, + double x, + double y, + NautilusGtkSidebarRow *row); +static void on_row_dragged (GtkGestureDrag *gesture, + double x, + double y, + NautilusGtkSidebarRow *row); + static void popup_menu_cb (NautilusGtkSidebarRow *row); static void long_press_cb (GtkGesture *gesture, - gdouble x, - gdouble y, + double x, + double y, NautilusGtkPlacesSidebar *sidebar); static void stop_drop_feedback (NautilusGtkPlacesSidebar *sidebar); static GMountOperation * get_mount_operation (NautilusGtkPlacesSidebar *sidebar); static GMountOperation * get_unmount_operation (NautilusGtkPlacesSidebar *sidebar); -/* Identifiers for target types */ -enum { - DND_UNKNOWN, - DND_NAUTILUS_GTK_SIDEBAR_ROW, - DND_TEXT_URI_LIST -}; - -/* Target types for dragging from the shortcuts list */ -static const GtkTargetEntry dnd_source_targets[] = { - { "DND_NAUTILUS_GTK_SIDEBAR_ROW", GTK_TARGET_SAME_WIDGET, DND_NAUTILUS_GTK_SIDEBAR_ROW } -}; - -/* Target types for dropping into the shortcuts list */ -static const GtkTargetEntry dnd_drop_targets [] = { - { "DND_NAUTILUS_GTK_SIDEBAR_ROW", GTK_TARGET_SAME_WIDGET, DND_NAUTILUS_GTK_SIDEBAR_ROW } -}; - -G_DEFINE_TYPE (NautilusGtkPlacesSidebar, nautilus_gtk_places_sidebar, GTK_TYPE_SCROLLED_WINDOW); +G_DEFINE_TYPE (NautilusGtkPlacesSidebar, nautilus_gtk_places_sidebar, GTK_TYPE_WIDGET); static void emit_open_location (NautilusGtkPlacesSidebar *sidebar, @@ -319,32 +282,20 @@ emit_open_location (NautilusGtkPlacesSidebar *sidebar, static void emit_show_error_message (NautilusGtkPlacesSidebar *sidebar, - const gchar *primary, - const gchar *secondary) + const char *primary, + const char *secondary) { g_signal_emit (sidebar, places_sidebar_signals[SHOW_ERROR_MESSAGE], 0, primary, secondary); } static void -emit_show_connect_to_server (NautilusGtkPlacesSidebar *sidebar) -{ - g_signal_emit (sidebar, places_sidebar_signals[SHOW_CONNECT_TO_SERVER], 0); -} - -static void emit_show_enter_location (NautilusGtkPlacesSidebar *sidebar) { g_signal_emit (sidebar, places_sidebar_signals[SHOW_ENTER_LOCATION], 0); } static void -emit_show_other_locations (NautilusGtkPlacesSidebar *sidebar) -{ - g_signal_emit (sidebar, places_sidebar_signals[SHOW_OTHER_LOCATIONS], 0); -} - -static void emit_show_other_locations_with_flags (NautilusGtkPlacesSidebar *sidebar, NautilusGtkPlacesOpenFlags open_flags) { @@ -377,26 +328,13 @@ emit_unmount_operation (NautilusGtkPlacesSidebar *sidebar, static GdkDragAction emit_drag_action_requested (NautilusGtkPlacesSidebar *sidebar, - GdkDragContext *context, GFile *dest_file, - GList *source_file_list) + GSList *source_file_list) { GdkDragAction ret_action = 0; g_signal_emit (sidebar, places_sidebar_signals[DRAG_ACTION_REQUESTED], 0, - context, dest_file, source_file_list, &ret_action); - - return ret_action; -} - -static GdkDragAction -emit_drag_action_ask (NautilusGtkPlacesSidebar *sidebar, - GdkDragAction actions) -{ - GdkDragAction ret_action = 0; - - g_signal_emit (sidebar, places_sidebar_signals[DRAG_ACTION_ASK], 0, - actions, &ret_action); + dest_file, source_file_list, &ret_action); return ret_action; } @@ -404,7 +342,7 @@ emit_drag_action_ask (NautilusGtkPlacesSidebar *sidebar, static void emit_drag_perform_drop (NautilusGtkPlacesSidebar *sidebar, GFile *dest_file, - GList *source_file_list, + GSList *source_file_list, GdkDragAction action) { g_signal_emit (sidebar, places_sidebar_signals[DRAG_PERFORM_DROP], 0, @@ -415,8 +353,8 @@ list_box_header_func (GtkListBoxRow *row, GtkListBoxRow *before, gpointer user_data) { - NautilusGtkPlacesSidebarSectionType row_section_type; - NautilusGtkPlacesSidebarSectionType before_section_type; + NautilusGtkPlacesSectionType row_section_type; + NautilusGtkPlacesSectionType before_section_type; GtkWidget *separator; gtk_list_box_row_set_header (row, NULL); @@ -428,27 +366,24 @@ list_box_header_func (GtkListBoxRow *row, } else { - before_section_type = SECTION_INVALID; - gtk_widget_set_margin_top (GTK_WIDGET (row), 4); + before_section_type = NAUTILUS_GTK_PLACES_SECTION_INVALID; } if (before && before_section_type != row_section_type) { separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - gtk_widget_set_margin_top (separator, 4); - gtk_widget_set_margin_bottom (separator, 4); gtk_list_box_row_set_header (row, separator); } } static GtkWidget* add_place (NautilusGtkPlacesSidebar *sidebar, - NautilusGtkPlacesSidebarPlaceType place_type, - NautilusGtkPlacesSidebarSectionType section_type, - const gchar *name, + NautilusGtkPlacesPlaceType place_type, + NautilusGtkPlacesSectionType section_type, + const char *name, GIcon *start_icon, GIcon *end_icon, - const gchar *uri, + const char *uri, GDrive *drive, GVolume *volume, GMount *mount, @@ -457,20 +392,20 @@ add_place (NautilusGtkPlacesSidebar *sidebar, #else gpointer *cloud_provider_account, #endif - const gint index, - const gchar *tooltip) + const int index, + const char *tooltip) { gboolean show_eject, show_unmount; gboolean show_eject_button; GtkWidget *row; GtkWidget *eject_button; - GtkWidget *event_box; + GtkGesture *gesture; check_unmount_and_eject (mount, volume, drive, &show_unmount, &show_eject); if (show_unmount || show_eject) - g_assert (place_type != PLACES_BOOKMARK); + g_assert (place_type != NAUTILUS_GTK_PLACES_BOOKMARK); show_eject_button = (show_unmount || show_eject); @@ -494,17 +429,24 @@ add_place (NautilusGtkPlacesSidebar *sidebar, NULL); eject_button = nautilus_gtk_sidebar_row_get_eject_button (NAUTILUS_GTK_SIDEBAR_ROW (row)); - event_box = nautilus_gtk_sidebar_row_get_event_box (NAUTILUS_GTK_SIDEBAR_ROW (row)); g_signal_connect_swapped (eject_button, "clicked", G_CALLBACK (eject_or_unmount_bookmark), row); - g_signal_connect (event_box, "button-press-event", - G_CALLBACK (on_button_press_event), row); - g_signal_connect (event_box, "button-release-event", - G_CALLBACK (on_button_release_event), row); - gtk_container_add (GTK_CONTAINER (sidebar->list_box), GTK_WIDGET (row)); - gtk_widget_show_all (row); + gesture = gtk_gesture_click_new (); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0); + g_signal_connect (gesture, "pressed", + G_CALLBACK (on_row_pressed), row); + g_signal_connect (gesture, "released", + G_CALLBACK (on_row_released), row); + gtk_widget_add_controller (row, GTK_EVENT_CONTROLLER (gesture)); + + gesture = gtk_gesture_drag_new (); + g_signal_connect (gesture, "drag-update", + G_CALLBACK (on_row_dragged), row); + gtk_widget_add_controller (row, GTK_EVENT_CONTROLLER (gesture)); + + gtk_list_box_insert (GTK_LIST_BOX (sidebar->list_box), GTK_WIDGET (row), -1); return row; } @@ -528,6 +470,7 @@ special_directory_get_gicon (GUserDirectory directory) ICON_CASE (TEMPLATES); ICON_CASE (VIDEOS); + case G_USER_N_DIRECTORIES: default: return g_themed_icon_new_with_default_fallbacks (ICON_NAME_FOLDER); } @@ -550,7 +493,7 @@ recent_files_setting_is_enabled (NautilusGtkPlacesSidebar *sidebar) static gboolean recent_scheme_is_supported (void) { - const gchar * const *supported; + const char * const *supported; supported = g_vfs_get_supported_uri_schemes (g_vfs_get_default ()); if (supported != NULL) @@ -568,11 +511,11 @@ should_show_recent (NautilusGtkPlacesSidebar *sidebar) } static gboolean -path_is_home_dir (const gchar *path) +path_is_home_dir (const char *path) { GFile *home_dir; GFile *location; - const gchar *home_path; + const char *home_path; gboolean res; home_path = g_get_home_dir (); @@ -592,7 +535,7 @@ path_is_home_dir (const gchar *path) static void open_home (NautilusGtkPlacesSidebar *sidebar) { - const gchar *home_path; + const char *home_path; GFile *home_dir; home_path = g_get_home_dir (); @@ -609,17 +552,17 @@ static void add_special_dirs (NautilusGtkPlacesSidebar *sidebar) { GList *dirs; - gint index; + int index; dirs = NULL; for (index = 0; index < G_USER_N_DIRECTORIES; index++) { - const gchar *path; + const char *path; GFile *root; GIcon *start_icon; - gchar *name; - gchar *mount_uri; - gchar *tooltip; + char *name; + char *mount_uri; + char *tooltip; if (!_nautilus_gtk_bookmarks_manager_get_is_xdg_dir_builtin (index)) continue; @@ -645,8 +588,8 @@ add_special_dirs (NautilusGtkPlacesSidebar *sidebar) mount_uri = g_file_get_uri (root); tooltip = g_file_get_parse_name (root); - add_place (sidebar, PLACES_XDG_DIR, - SECTION_COMPUTER, + add_place (sidebar, NAUTILUS_GTK_PLACES_XDG_DIR, + NAUTILUS_GTK_PLACES_SECTION_COMPUTER, name, start_icon, NULL, mount_uri, NULL, NULL, NULL, NULL, 0, tooltip); @@ -656,16 +599,16 @@ add_special_dirs (NautilusGtkPlacesSidebar *sidebar) g_free (mount_uri); g_free (tooltip); - dirs = g_list_prepend (dirs, (gchar *)path); + dirs = g_list_prepend (dirs, (char *)path); } g_list_free (dirs); } -static gchar * +static char * get_home_directory_uri (void) { - const gchar *home; + const char *home; home = g_get_home_dir (); if (!home) @@ -674,10 +617,10 @@ get_home_directory_uri (void) return g_filename_to_uri (home, NULL, NULL); } -static gchar * +static char * get_desktop_directory_uri (void) { - const gchar *name; + const char *name; name = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); @@ -691,38 +634,21 @@ get_desktop_directory_uri (void) } static gboolean -should_show_file (NautilusGtkPlacesSidebar *sidebar, - GFile *file) -{ - gchar *path; - - if (!sidebar->local_only) - return TRUE; - - path = g_file_get_path (file); - if (path) - { - g_free (path); - return TRUE; - } - - return FALSE; -} - -static gboolean file_is_shown (NautilusGtkPlacesSidebar *sidebar, GFile *file) { - gchar *uri; - GList *rows; - GList *l; + char *uri; + GtkWidget *row; gboolean found = FALSE; - rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box)); - l = rows; - while (l != NULL && !found) + for (row = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box)); + row != NULL && !found; + row = gtk_widget_get_next_sibling (row)) { - g_object_get (l->data, "uri", &uri, NULL); + if (!GTK_IS_LIST_BOX_ROW (row)) + continue; + + g_object_get (row, "uri", &uri, NULL); if (uri) { GFile *other; @@ -731,47 +657,46 @@ file_is_shown (NautilusGtkPlacesSidebar *sidebar, g_object_unref (other); g_free (uri); } - l = l->next; } - g_list_free (rows); - return found; } +typedef struct +{ + NautilusGtkPlacesSidebar *sidebar; + guint position; +} ShortcutData; + static void on_app_shortcuts_query_complete (GObject *source, GAsyncResult *result, gpointer data) { - NautilusGtkPlacesSidebar *sidebar = data; + ShortcutData *sdata = data; + NautilusGtkPlacesSidebar *sidebar = sdata->sidebar; + guint pos = sdata->position; GFile *file = G_FILE (source); GFileInfo *info; + g_free (sdata); + info = g_file_query_info_finish (file, result, NULL); if (info) { - gchar *uri; - gchar *tooltip; - const gchar *name; + char *uri; + char *tooltip; + const char *name; GIcon *start_icon; - int pos = 0; name = g_file_info_get_display_name (info); start_icon = g_file_info_get_symbolic_icon (info); uri = g_file_get_uri (file); tooltip = g_file_get_parse_name (file); - /* XXX: we could avoid this by using an ancillary closure - * with the index coming from add_application_shortcuts(), - * but in terms of algorithmic overhead, the application - * shortcuts is not going to be really big - */ - pos = g_slist_index (sidebar->shortcuts, file); - - add_place (sidebar, PLACES_BUILT_IN, - SECTION_COMPUTER, + add_place (sidebar, NAUTILUS_GTK_PLACES_BUILT_IN, + NAUTILUS_GTK_PLACES_SECTION_COMPUTER, name, start_icon, NULL, uri, NULL, NULL, NULL, NULL, pos, @@ -787,25 +712,29 @@ on_app_shortcuts_query_complete (GObject *source, static void add_application_shortcuts (NautilusGtkPlacesSidebar *sidebar) { - GSList *l; + guint i, n; - for (l = sidebar->shortcuts; l; l = l->next) + n = g_list_model_get_n_items (G_LIST_MODEL (sidebar->shortcuts)); + for (i = 0; i < n; i++) { - GFile *file = l->data; + GFile *file = g_list_model_get_item (G_LIST_MODEL (sidebar->shortcuts), i); + ShortcutData *data; - if (!should_show_file (sidebar, file)) - continue; + g_object_unref (file); if (file_is_shown (sidebar, file)) continue; + data = g_new (ShortcutData, 1); + data->sidebar = sidebar; + data->position = i; g_file_query_info_async (file, "standard::display-name,standard::symbolic-icon", G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, sidebar->cancellable, on_app_shortcuts_query_complete, - sidebar); + data); } } @@ -825,9 +754,9 @@ on_bookmark_query_info_complete (GObject *source, GFile *root = G_FILE (source); GError *error = NULL; GFileInfo *info; - gchar *bookmark_name; - gchar *mount_uri; - gchar *tooltip; + char *bookmark_name; + char *mount_uri; + char *tooltip; GIcon *start_icon; info = g_file_query_info_finish (root, result, &error); @@ -841,6 +770,9 @@ on_bookmark_query_info_complete (GObject *source, { /* Don't add non-UTF-8 bookmarks */ bookmark_name = g_file_get_basename (root); + if (bookmark_name == NULL) + goto out; + if (!g_utf8_validate (bookmark_name, -1, NULL)) { g_free (bookmark_name); @@ -856,8 +788,8 @@ on_bookmark_query_info_complete (GObject *source, mount_uri = g_file_get_uri (root); tooltip = g_file_get_parse_name (root); - add_place (sidebar, PLACES_BOOKMARK, - SECTION_BOOKMARKS, + add_place (sidebar, NAUTILUS_GTK_PLACES_BOOKMARK, + NAUTILUS_GTK_PLACES_SECTION_BOOKMARKS, bookmark_name, start_icon, NULL, mount_uri, NULL, NULL, NULL, NULL, clos->index, tooltip); @@ -878,7 +810,7 @@ is_external_volume (GVolume *volume) { gboolean is_external; GDrive *drive; - gchar *id; + char *id; drive = g_volume_get_drive (volume); id = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_CLASS); @@ -918,19 +850,20 @@ create_cloud_provider_account_row (NautilusGtkPlacesSidebar *sidebar, { GIcon *end_icon; GIcon *start_icon; - gchar *mount_uri; - gchar *name; - gchar *tooltip; + const char *mount_path; + const char *name; + char *mount_uri; + char *tooltip; guint provider_account_status; start_icon = cloud_providers_account_get_icon (account); name = cloud_providers_account_get_name (account); provider_account_status = cloud_providers_account_get_status (account); - mount_uri = cloud_providers_account_get_path (account); + mount_path = cloud_providers_account_get_path (account); if (start_icon != NULL && name != NULL && provider_account_status != CLOUD_PROVIDERS_ACCOUNT_STATUS_INVALID - && mount_uri != NULL) + && mount_path != NULL) { switch (provider_account_status) { @@ -950,17 +883,20 @@ create_cloud_provider_account_row (NautilusGtkPlacesSidebar *sidebar, return FALSE; } - mount_uri = g_strconcat ("file://", mount_uri, NULL); + mount_uri = g_strconcat ("file://", mount_path, NULL); /* translators: %s is the name of a cloud provider for files */ tooltip = g_strdup_printf (_("Open %s"), name); - add_place (sidebar, PLACES_BUILT_IN, - SECTION_CLOUD, + add_place (sidebar, NAUTILUS_GTK_PLACES_BUILT_IN, + NAUTILUS_GTK_PLACES_SECTION_CLOUD, name, start_icon, end_icon, mount_uri, NULL, NULL, NULL, account, 0, tooltip); + g_free (tooltip); + g_free (mount_uri); + g_object_unref (end_icon); return TRUE; } else @@ -997,22 +933,22 @@ update_places (NautilusGtkPlacesSidebar *sidebar) GList *volumes; GVolume *volume; GSList *bookmarks, *sl; - gint index; - gchar *original_uri, *mount_uri, *name, *identifier; + int index; + char *original_uri, *name, *identifier; GtkListBoxRow *selected; - gchar *home_uri; + char *home_uri; GIcon *start_icon; GFile *root; - gchar *tooltip; + char *tooltip; GList *network_mounts, *network_volumes; GIcon *new_bookmark_icon; + GtkWidget *child; #ifdef HAVE_CLOUDPROVIDERS GList *cloud_providers; GList *cloud_providers_accounts; CloudProvidersAccount *cloud_provider_account; CloudProvidersProvider *cloud_provider; #endif - GtkStyleContext *context; /* save original selection */ selected = gtk_list_box_get_selected_row (GTK_LIST_BOX (sidebar->list_box)); @@ -1029,20 +965,18 @@ update_places (NautilusGtkPlacesSidebar *sidebar) /* Reset drag state, just in case we update the places while dragging or * ending a drag */ stop_drop_feedback (sidebar); - gtk_container_foreach (GTK_CONTAINER (sidebar->list_box), - (GtkCallback) gtk_widget_destroy, - NULL); + while ((child = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box)))) + gtk_list_box_remove (GTK_LIST_BOX (sidebar->list_box), child); network_mounts = network_volumes = NULL; /* add built-in places */ if (should_show_recent (sidebar)) { - mount_uri = "recent:///"; start_icon = g_themed_icon_new_with_default_fallbacks ("document-open-recent-symbolic"); - add_place (sidebar, PLACES_BUILT_IN, - SECTION_COMPUTER, - _("Recent"), start_icon, NULL, mount_uri, + add_place (sidebar, NAUTILUS_GTK_PLACES_BUILT_IN, + NAUTILUS_GTK_PLACES_SECTION_COMPUTER, + _("Recent"), start_icon, NULL, "recent:///", NULL, NULL, NULL, NULL, 0, _("Recent files")); g_object_unref (start_icon); @@ -1050,22 +984,20 @@ update_places (NautilusGtkPlacesSidebar *sidebar) if (sidebar->show_starred_location) { - mount_uri = "starred:///"; start_icon = g_themed_icon_new_with_default_fallbacks ("starred-symbolic"); - add_place (sidebar, PLACES_STARRED_LOCATION, - SECTION_COMPUTER, - _("Starred"), start_icon, NULL, mount_uri, + add_place (sidebar, NAUTILUS_GTK_PLACES_STARRED_LOCATION, + NAUTILUS_GTK_PLACES_SECTION_COMPUTER, + _("Starred"), start_icon, NULL, "starred:///", NULL, NULL, NULL, NULL, 0, - /* TODO: Rename to 'Starred files' */ - _("Favorite files")); + _("Starred files")); g_object_unref (start_icon); } /* home folder */ home_uri = get_home_directory_uri (); start_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_HOME); - add_place (sidebar, PLACES_BUILT_IN, - SECTION_COMPUTER, + add_place (sidebar, NAUTILUS_GTK_PLACES_BUILT_IN, + NAUTILUS_GTK_PLACES_SECTION_COMPUTER, _("Home"), start_icon, NULL, home_uri, NULL, NULL, NULL, NULL, 0, _("Open your personal folder")); @@ -1075,12 +1007,12 @@ update_places (NautilusGtkPlacesSidebar *sidebar) /* desktop */ if (sidebar->show_desktop) { - mount_uri = get_desktop_directory_uri (); + char *mount_uri = get_desktop_directory_uri (); if (mount_uri) { start_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_DESKTOP); - add_place (sidebar, PLACES_BUILT_IN, - SECTION_COMPUTER, + add_place (sidebar, NAUTILUS_GTK_PLACES_BUILT_IN, + NAUTILUS_GTK_PLACES_SECTION_COMPUTER, _("Desktop"), start_icon, NULL, mount_uri, NULL, NULL, NULL, NULL, 0, _("Open the contents of your desktop in a folder")); @@ -1095,8 +1027,8 @@ update_places (NautilusGtkPlacesSidebar *sidebar) if (sidebar->show_enter_location) { start_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_NETWORK_SERVER); - add_place (sidebar, PLACES_ENTER_LOCATION, - SECTION_COMPUTER, + add_place (sidebar, NAUTILUS_GTK_PLACES_ENTER_LOCATION, + NAUTILUS_GTK_PLACES_SECTION_COMPUTER, _("Enter Location"), start_icon, NULL, NULL, NULL, NULL, NULL, NULL, 0, _("Manually enter a location")); @@ -1104,11 +1036,11 @@ update_places (NautilusGtkPlacesSidebar *sidebar) } /* Trash */ - if (!sidebar->local_only && sidebar->show_trash) + if (sidebar->show_trash) { start_icon = nautilus_trash_monitor_get_symbolic_icon (); - sidebar->trash_row = add_place (sidebar, PLACES_BUILT_IN, - SECTION_COMPUTER, + sidebar->trash_row = add_place (sidebar, NAUTILUS_GTK_PLACES_BUILT_IN, + NAUTILUS_GTK_PLACES_SECTION_COMPUTER, _("Trash"), start_icon, NULL, "trash:///", NULL, NULL, NULL, NULL, 0, _("Open the trash")); @@ -1190,6 +1122,8 @@ update_places (NautilusGtkPlacesSidebar *sidebar) mount = g_volume_get_mount (volume); if (mount != NULL) { + char *mount_uri; + /* Show mounted volume in the sidebar */ start_icon = g_mount_get_symbolic_icon (mount); root = g_mount_get_default_location (mount); @@ -1197,8 +1131,8 @@ update_places (NautilusGtkPlacesSidebar *sidebar) name = g_mount_get_name (mount); tooltip = g_file_get_parse_name (root); - add_place (sidebar, PLACES_MOUNTED_VOLUME, - SECTION_MOUNTS, + add_place (sidebar, NAUTILUS_GTK_PLACES_MOUNTED_VOLUME, + NAUTILUS_GTK_PLACES_SECTION_MOUNTS, name, start_icon, NULL, mount_uri, drive, volume, mount, NULL, 0, tooltip); g_object_unref (root); @@ -1222,8 +1156,8 @@ update_places (NautilusGtkPlacesSidebar *sidebar) name = g_volume_get_name (volume); tooltip = g_strdup_printf (_("Mount and open “%s”"), name); - add_place (sidebar, PLACES_MOUNTED_VOLUME, - SECTION_MOUNTS, + add_place (sidebar, NAUTILUS_GTK_PLACES_MOUNTED_VOLUME, + NAUTILUS_GTK_PLACES_SECTION_MOUNTS, name, start_icon, NULL, NULL, drive, volume, NULL, NULL, 0, tooltip); g_object_unref (start_icon); @@ -1250,8 +1184,8 @@ update_places (NautilusGtkPlacesSidebar *sidebar) name = g_drive_get_name (drive); tooltip = g_strdup_printf (_("Mount and open “%s”"), name); - add_place (sidebar, PLACES_BUILT_IN, - SECTION_MOUNTS, + add_place (sidebar, NAUTILUS_GTK_PLACES_BUILT_IN, + NAUTILUS_GTK_PLACES_SECTION_MOUNTS, name, start_icon, NULL, NULL, drive, NULL, NULL, NULL, 0, tooltip); g_object_unref (start_icon); @@ -1302,13 +1236,14 @@ update_places (NautilusGtkPlacesSidebar *sidebar) if (mount != NULL) { char *mount_uri; + start_icon = g_mount_get_symbolic_icon (mount); root = g_mount_get_default_location (mount); mount_uri = g_file_get_uri (root); tooltip = g_file_get_parse_name (root); name = g_mount_get_name (mount); - add_place (sidebar, PLACES_MOUNTED_VOLUME, - SECTION_MOUNTS, + add_place (sidebar, NAUTILUS_GTK_PLACES_MOUNTED_VOLUME, + NAUTILUS_GTK_PLACES_SECTION_MOUNTS, name, start_icon, NULL, mount_uri, NULL, volume, mount, NULL, 0, tooltip); g_object_unref (mount); @@ -1323,8 +1258,8 @@ update_places (NautilusGtkPlacesSidebar *sidebar) /* see comment above in why we add an icon for an unmounted mountable volume */ start_icon = g_volume_get_symbolic_icon (volume); name = g_volume_get_name (volume); - add_place (sidebar, PLACES_MOUNTED_VOLUME, - SECTION_MOUNTS, + add_place (sidebar, NAUTILUS_GTK_PLACES_MOUNTED_VOLUME, + NAUTILUS_GTK_PLACES_SECTION_MOUNTS, name, start_icon, NULL, NULL, NULL, volume, NULL, NULL, 0, name); g_object_unref (start_icon); @@ -1337,11 +1272,10 @@ update_places (NautilusGtkPlacesSidebar *sidebar) /* file system root */ if (!sidebar->show_other_locations) { - mount_uri = "file:///"; /* No need to strdup */ start_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_FILESYSTEM); - add_place (sidebar, PLACES_BUILT_IN, - SECTION_MOUNTS, - sidebar->hostname, start_icon, NULL, mount_uri, + add_place (sidebar, NAUTILUS_GTK_PLACES_BUILT_IN, + NAUTILUS_GTK_PLACES_SECTION_MOUNTS, + sidebar->hostname, start_icon, NULL, "file:///", NULL, NULL, NULL, NULL, 0, _("Open the contents of the file system")); g_object_unref (start_icon); @@ -1352,6 +1286,8 @@ update_places (NautilusGtkPlacesSidebar *sidebar) for (l = mounts; l != NULL; l = l->next) { + char *mount_uri; + mount = l->data; if (g_mount_is_shadowed (mount)) { @@ -1378,8 +1314,8 @@ update_places (NautilusGtkPlacesSidebar *sidebar) mount_uri = g_file_get_uri (root); name = g_mount_get_name (mount); tooltip = g_file_get_parse_name (root); - add_place (sidebar, PLACES_MOUNTED_VOLUME, - SECTION_COMPUTER, + add_place (sidebar, NAUTILUS_GTK_PLACES_MOUNTED_VOLUME, + NAUTILUS_GTK_PLACES_SECTION_COMPUTER, name, start_icon, NULL, mount_uri, NULL, NULL, mount, NULL, 0, tooltip); g_object_unref (root); @@ -1405,9 +1341,6 @@ update_places (NautilusGtkPlacesSidebar *sidebar) if (_nautilus_gtk_bookmarks_manager_get_is_builtin (sidebar->bookmarks_manager, root)) continue; - if (sidebar->local_only && !is_native) - continue; - clos = g_slice_new (BookmarkQueryClosure); clos->sidebar = sidebar; clos->index = index; @@ -1425,77 +1358,65 @@ update_places (NautilusGtkPlacesSidebar *sidebar) /* Add new bookmark row */ new_bookmark_icon = g_themed_icon_new ("bookmark-new-symbolic"); - sidebar->new_bookmark_row = add_place (sidebar, PLACES_DROP_FEEDBACK, - SECTION_BOOKMARKS, + sidebar->new_bookmark_row = add_place (sidebar, NAUTILUS_GTK_PLACES_DROP_FEEDBACK, + NAUTILUS_GTK_PLACES_SECTION_BOOKMARKS, _("New bookmark"), new_bookmark_icon, NULL, NULL, NULL, NULL, NULL, NULL, 0, _("Add a new bookmark")); - context = gtk_widget_get_style_context (sidebar->new_bookmark_row); - gtk_style_context_add_class (context, "sidebar-new-bookmark-row"); + gtk_widget_add_css_class (sidebar->new_bookmark_row, "sidebar-new-bookmark-row"); g_object_unref (new_bookmark_icon); /* network */ - if (!sidebar->local_only) + network_volumes = g_list_reverse (network_volumes); + for (l = network_volumes; l != NULL; l = l->next) { - if (sidebar->show_connect_to_server) - { - start_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_NETWORK_SERVER); - add_place (sidebar, PLACES_CONNECT_TO_SERVER, - SECTION_MOUNTS, - _("Connect to Server"), start_icon, NULL, - NULL, NULL, NULL, NULL, NULL, 0, - _("Connect to a network server address")); - g_object_unref (start_icon); - } + volume = l->data; + mount = g_volume_get_mount (volume); - network_volumes = g_list_reverse (network_volumes); - for (l = network_volumes; l != NULL; l = l->next) + if (mount != NULL) { - volume = l->data; - mount = g_volume_get_mount (volume); - - if (mount != NULL) - { - network_mounts = g_list_prepend (network_mounts, mount); - continue; - } - else - { - start_icon = g_volume_get_symbolic_icon (volume); - name = g_volume_get_name (volume); - tooltip = g_strdup_printf (_("Mount and open “%s”"), name); - - add_place (sidebar, PLACES_MOUNTED_VOLUME, - SECTION_MOUNTS, - name, start_icon, NULL, NULL, - NULL, volume, NULL, NULL, 0, tooltip); - g_object_unref (start_icon); - g_free (name); - g_free (tooltip); - } + network_mounts = g_list_prepend (network_mounts, mount); + continue; } - - network_mounts = g_list_reverse (network_mounts); - for (l = network_mounts; l != NULL; l = l->next) + else { - mount = l->data; - root = g_mount_get_default_location (mount); - start_icon = g_mount_get_symbolic_icon (mount); - mount_uri = g_file_get_uri (root); - name = g_mount_get_name (mount); - tooltip = g_file_get_parse_name (root); - add_place (sidebar, PLACES_MOUNTED_VOLUME, - SECTION_MOUNTS, - name, start_icon, NULL, mount_uri, - NULL, NULL, mount, NULL, 0, tooltip); - g_object_unref (root); + start_icon = g_volume_get_symbolic_icon (volume); + name = g_volume_get_name (volume); + tooltip = g_strdup_printf (_("Mount and open “%s”"), name); + + add_place (sidebar, NAUTILUS_GTK_PLACES_MOUNTED_VOLUME, + NAUTILUS_GTK_PLACES_SECTION_MOUNTS, + name, start_icon, NULL, NULL, + NULL, volume, NULL, NULL, 0, tooltip); g_object_unref (start_icon); g_free (name); - g_free (mount_uri); g_free (tooltip); } } + network_mounts = g_list_reverse (network_mounts); + for (l = network_mounts; l != NULL; l = l->next) + { + char *mount_uri; + + mount = l->data; + root = g_mount_get_default_location (mount); + start_icon = g_mount_get_symbolic_icon (mount); + mount_uri = g_file_get_uri (root); + name = g_mount_get_name (mount); + tooltip = g_file_get_parse_name (root); + add_place (sidebar, NAUTILUS_GTK_PLACES_MOUNTED_VOLUME, + NAUTILUS_GTK_PLACES_SECTION_MOUNTS, + name, start_icon, NULL, mount_uri, + NULL, NULL, mount, NULL, 0, tooltip); + g_object_unref (root); + g_object_unref (start_icon); + g_free (name); + g_free (mount_uri); + g_free (tooltip); + } + + g_list_free_full (network_volumes, g_object_unref); g_list_free_full (network_mounts, g_object_unref); @@ -1504,15 +1425,15 @@ update_places (NautilusGtkPlacesSidebar *sidebar) { start_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_OTHER_LOCATIONS); - add_place (sidebar, PLACES_OTHER_LOCATIONS, - SECTION_OTHER_LOCATIONS, + add_place (sidebar, NAUTILUS_GTK_PLACES_OTHER_LOCATIONS, + NAUTILUS_GTK_PLACES_SECTION_OTHER_LOCATIONS, _("Other Locations"), start_icon, NULL, "other-locations:///", NULL, NULL, NULL, NULL, 0, _("Show other locations")); g_object_unref (start_icon); } - gtk_widget_show_all (GTK_WIDGET (sidebar)); + gtk_widget_show (GTK_WIDGET (sidebar)); /* We want this hidden by default, but need to do it after the show_all call */ nautilus_gtk_sidebar_row_hide (NAUTILUS_GTK_SIDEBAR_ROW (sidebar->new_bookmark_row), TRUE); @@ -1531,14 +1452,16 @@ update_places (NautilusGtkPlacesSidebar *sidebar) static gboolean check_valid_drop_target (NautilusGtkPlacesSidebar *sidebar, NautilusGtkSidebarRow *row, - GdkDragContext *context) + const GValue *value) { - NautilusGtkPlacesSidebarPlaceType place_type; - NautilusGtkPlacesSidebarSectionType section_type; + NautilusGtkPlacesPlaceType place_type; + NautilusGtkPlacesSectionType section_type; gboolean valid = FALSE; - gchar *uri; + char *uri; GFile *dest_file; - gint drag_action; + int drag_action; + + g_return_val_if_fail (value != NULL, TRUE); if (row == NULL) return FALSE; @@ -1549,26 +1472,26 @@ check_valid_drop_target (NautilusGtkPlacesSidebar *sidebar, "uri", &uri, NULL); - if (place_type == PLACES_STARRED_LOCATION) + if (place_type == NAUTILUS_GTK_PLACES_STARRED_LOCATION) { g_free (uri); return FALSE; } - if (place_type == PLACES_CONNECT_TO_SERVER) + if (place_type == NAUTILUS_GTK_PLACES_CONNECT_TO_SERVER) { g_free (uri); return FALSE; } - if (place_type == PLACES_DROP_FEEDBACK) + if (place_type == NAUTILUS_GTK_PLACES_DROP_FEEDBACK) { g_free (uri); return TRUE; } /* Disallow drops on recent:/// */ - if (place_type == PLACES_BUILT_IN) + if (place_type == NAUTILUS_GTK_PLACES_BUILT_IN) { if (g_strcmp0 (uri, "recent:///") == 0) { @@ -1578,40 +1501,32 @@ check_valid_drop_target (NautilusGtkPlacesSidebar *sidebar, } /* Dragging a bookmark? */ - if (sidebar->drag_data_received && - sidebar->drag_data_info == DND_NAUTILUS_GTK_SIDEBAR_ROW) + if (G_VALUE_HOLDS (value, NAUTILUS_TYPE_GTK_SIDEBAR_ROW)) { /* Don't allow reordering bookmarks into non-bookmark areas */ - valid = section_type == SECTION_BOOKMARKS; + valid = section_type == NAUTILUS_GTK_PLACES_SECTION_BOOKMARKS; } - else + else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST)) { /* Dragging a file */ - if (context) + if (uri != NULL) { - if (uri != NULL) - { - dest_file = g_file_new_for_uri (uri); - drag_action = emit_drag_action_requested (sidebar, context, dest_file, sidebar->drag_list); - valid = drag_action > 0; + dest_file = g_file_new_for_uri (uri); + drag_action = emit_drag_action_requested (sidebar, dest_file, g_value_get_boxed (value)); + valid = drag_action > 0; - g_object_unref (dest_file); - } - else - { - valid = FALSE; - } + g_object_unref (dest_file); } else { - /* We cannot discern if it is valid or not because there is not drag - * context available to ask the client. - * Simply make insensitive the drop targets we know are not valid for - * files, that are the ones remaining. - */ - valid = TRUE; + valid = FALSE; } } + else + { + g_assert_not_reached (); + valid = TRUE; + } g_free (uri); return valid; @@ -1619,60 +1534,30 @@ check_valid_drop_target (NautilusGtkPlacesSidebar *sidebar, static void update_possible_drop_targets (NautilusGtkPlacesSidebar *sidebar, - gboolean dragging, - GdkDragContext *context) + const GValue *value) { - GList *rows; - GList *l; - gboolean sensitive; - - rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box)); + GtkWidget *row; - for (l = rows; l != NULL; l = l->next) + for (row = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box)); + row != NULL; + row = gtk_widget_get_next_sibling (row)) { - sensitive = !dragging || check_valid_drop_target (sidebar, NAUTILUS_GTK_SIDEBAR_ROW (l->data), context); - gtk_widget_set_sensitive (GTK_WIDGET (l->data), sensitive); - } - - g_list_free (rows); -} - -static gboolean -get_drag_data (GtkWidget *list_box, - GdkDragContext *context, - guint time) -{ - GdkAtom target; - - target = gtk_drag_dest_find_target (list_box, context, NULL); - - if (target == GDK_NONE) - return FALSE; + gboolean sensitive; - gtk_drag_get_data (list_box, context, target, time); - - return TRUE; -} - -static void -free_drag_data (NautilusGtkPlacesSidebar *sidebar) -{ - sidebar->drag_data_received = FALSE; + if (!GTK_IS_LIST_BOX_ROW (row)) + continue; - if (sidebar->drag_list) - { - g_list_free_full (sidebar->drag_list, g_object_unref); - sidebar->drag_list = NULL; + sensitive = value == NULL || + check_valid_drop_target (sidebar, NAUTILUS_GTK_SIDEBAR_ROW (row), value); + gtk_widget_set_sensitive (row, sensitive); } - } static void start_drop_feedback (NautilusGtkPlacesSidebar *sidebar, - NautilusGtkSidebarRow *row, - GdkDragContext *context) + const GValue *value) { - if (sidebar->drag_data_info != DND_NAUTILUS_GTK_SIDEBAR_ROW) + if (value && !G_VALUE_HOLDS (value, NAUTILUS_TYPE_GTK_SIDEBAR_ROW)) { nautilus_gtk_sidebar_row_reveal (NAUTILUS_GTK_SIDEBAR_ROW (sidebar->new_bookmark_row)); /* If the state is permanent, don't change it. The application controls it. */ @@ -1680,15 +1565,13 @@ start_drop_feedback (NautilusGtkPlacesSidebar *sidebar, sidebar->drop_state = DROP_STATE_NEW_BOOKMARK_ARMED; } - update_possible_drop_targets (sidebar, TRUE, context); + update_possible_drop_targets (sidebar, value); } static void stop_drop_feedback (NautilusGtkPlacesSidebar *sidebar) { - update_possible_drop_targets (sidebar, FALSE, NULL); - - free_drag_data (sidebar); + update_possible_drop_targets (sidebar, NULL); if (sidebar->drop_state != DROP_STATE_NEW_BOOKMARK_ARMED_PERMANENT && sidebar->new_bookmark_row != NULL) @@ -1705,92 +1588,33 @@ stop_drop_feedback (NautilusGtkPlacesSidebar *sidebar) if (sidebar->row_placeholder != NULL) { - gtk_widget_destroy (sidebar->row_placeholder); + if (gtk_widget_get_parent (sidebar->row_placeholder) != NULL) + gtk_list_box_remove (GTK_LIST_BOX (sidebar->list_box), sidebar->row_placeholder); sidebar->row_placeholder = NULL; } sidebar->dragging_over = FALSE; - sidebar->drag_data_info = DND_UNKNOWN; -} - -static gboolean -on_motion_notify_event (GtkWidget *widget, - GdkEventMotion *event, - gpointer user_data) -{ - NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (user_data); - - if (sidebar->drag_row == NULL || sidebar->dragging_over) - return FALSE; - - if (!(event->state & GDK_BUTTON1_MASK)) - return FALSE; - - if (gtk_drag_check_threshold (widget, - sidebar->drag_root_x, sidebar->drag_root_y, - event->x_root, event->y_root)) - { - sidebar->dragging_over = TRUE; - - gtk_drag_begin_with_coordinates (widget, sidebar->source_targets, GDK_ACTION_MOVE, - GDK_BUTTON_PRIMARY, (GdkEvent*)event, - -1, -1); - } - - return FALSE; -} - -static void -drag_begin_callback (GtkWidget *widget, - GdkDragContext *context, - gpointer user_data) -{ - NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (user_data); - GtkAllocation allocation; - GtkWidget *drag_widget; - GtkWidget *window; - - gtk_widget_get_allocation (sidebar->drag_row, &allocation); - gtk_widget_hide (sidebar->drag_row); - - drag_widget = GTK_WIDGET (nautilus_gtk_sidebar_row_clone (NAUTILUS_GTK_SIDEBAR_ROW (sidebar->drag_row))); - window = gtk_window_new (GTK_WINDOW_POPUP); - sidebar->drag_row_height = allocation.height; - gtk_widget_set_size_request (window, allocation.width, allocation.height); - - gtk_container_add (GTK_CONTAINER (window), drag_widget); - gtk_widget_show_all (window); - gtk_widget_set_opacity (window, 0.8); - - gtk_drag_set_icon_widget (context, - window, - sidebar->drag_row_x, - sidebar->drag_row_y); } static GtkWidget * create_placeholder_row (NautilusGtkPlacesSidebar *sidebar) { - return g_object_new (NAUTILUS_TYPE_GTK_SIDEBAR_ROW, - "placeholder", TRUE, - NULL); + return g_object_new (NAUTILUS_TYPE_GTK_SIDEBAR_ROW, "placeholder", TRUE, NULL); } -static gboolean -drag_motion_callback (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - gpointer user_data) -{ - gint action; +static GdkDragAction +drag_motion_callback (GtkDropTarget *target, + double x, + double y, + NautilusGtkPlacesSidebar *sidebar) +{ + GdkDragAction action; GtkListBoxRow *row; - NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (user_data); - NautilusGtkPlacesSidebarPlaceType place_type; - gchar *drop_target_uri = NULL; - gint row_index; - gint row_placeholder_index; + NautilusGtkPlacesPlaceType place_type; + char *drop_target_uri = NULL; + int row_index; + int row_placeholder_index; + const GValue *value; sidebar->dragging_over = TRUE; action = 0; @@ -1798,24 +1622,22 @@ drag_motion_callback (GtkWidget *widget, gtk_list_box_drag_unhighlight_row (GTK_LIST_BOX (sidebar->list_box)); - /* Nothing to do if no drag data */ - if (!sidebar->drag_data_received && - !get_drag_data (sidebar->list_box, context, time)) + /* Nothing to do if no value yet */ + value = gtk_drop_target_get_value (target); + if (value == NULL) goto out; /* Nothing to do if the target is not valid drop destination */ - if (!check_valid_drop_target (sidebar, NAUTILUS_GTK_SIDEBAR_ROW (row), context)) + if (!check_valid_drop_target (sidebar, NAUTILUS_GTK_SIDEBAR_ROW (row), value)) goto out; - if (sidebar->drag_data_received && - sidebar->drag_data_info == DND_NAUTILUS_GTK_SIDEBAR_ROW) + if (G_VALUE_HOLDS (value, NAUTILUS_TYPE_GTK_SIDEBAR_ROW)) { /* Dragging bookmarks always moves them to another position in the bookmarks list */ action = GDK_ACTION_MOVE; if (sidebar->row_placeholder == NULL) { sidebar->row_placeholder = create_placeholder_row (sidebar); - gtk_widget_show (sidebar->row_placeholder); g_object_ref_sink (sidebar->row_placeholder); } else if (GTK_WIDGET (row) == sidebar->row_placeholder) @@ -1824,15 +1646,10 @@ drag_motion_callback (GtkWidget *widget, } if (gtk_widget_get_parent (sidebar->row_placeholder) != NULL) - { - gtk_container_remove (GTK_CONTAINER (sidebar->list_box), - sidebar->row_placeholder); - } + gtk_list_box_remove (GTK_LIST_BOX (sidebar->list_box), sidebar->row_placeholder); if (row != NULL) { - gint dest_y, dest_x; - g_object_get (row, "order-index", &row_index, NULL); g_object_get (sidebar->row_placeholder, "order-index", &row_placeholder_index, NULL); /* We order the bookmarks sections based on the bookmark index that we @@ -1846,11 +1663,11 @@ drag_motion_callback (GtkWidget *widget, * of the row, we need to increase the order-index. */ row_placeholder_index = row_index; - gtk_widget_translate_coordinates (widget, GTK_WIDGET (row), + gtk_widget_translate_coordinates (GTK_WIDGET (sidebar), GTK_WIDGET (row), x, y, - &dest_x, &dest_y); + &x, &y); - if (dest_y > sidebar->drag_row_height / 2 && row_index > 0) + if (y > sidebar->drag_row_height / 2 && row_index > 0) row_placeholder_index++; } else @@ -1866,7 +1683,7 @@ drag_motion_callback (GtkWidget *widget, gtk_list_box_prepend (GTK_LIST_BOX (sidebar->list_box), sidebar->row_placeholder); } - else + else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST)) { gtk_list_box_drag_highlight_row (GTK_LIST_BOX (sidebar->list_box), row); @@ -1878,65 +1695,42 @@ drag_motion_callback (GtkWidget *widget, * file move/copy operation itself, or if we should only try to * create bookmarks out of the dragged URIs. */ - if (sidebar->drag_list != NULL) + if (place_type == NAUTILUS_GTK_PLACES_DROP_FEEDBACK) { - if (place_type == PLACES_DROP_FEEDBACK) - { - action = GDK_ACTION_COPY; - } - else + action = GDK_ACTION_COPY; + } + else + { + /* uri may be NULL for unmounted volumes, for example, so we don't allow drops there */ + if (drop_target_uri != NULL) { - /* uri may be NULL for unmounted volumes, for example, so we don't allow drops there */ - if (drop_target_uri != NULL) - { - GFile *dest_file = g_file_new_for_uri (drop_target_uri); + GFile *dest_file = g_file_new_for_uri (drop_target_uri); - action = emit_drag_action_requested (sidebar, context, dest_file, sidebar->drag_list); + action = emit_drag_action_requested (sidebar, dest_file, g_value_get_boxed (value)); - g_object_unref (dest_file); - } + g_object_unref (dest_file); } } g_free (drop_target_uri); } - - out: - start_drop_feedback (sidebar, NAUTILUS_GTK_SIDEBAR_ROW (row), context); - - g_signal_stop_emission_by_name (sidebar->list_box, "drag-motion"); - - gdk_drag_status (context, action, time); - - return TRUE; -} - -/* Takes an array of URIs and turns it into a list of GFile */ -static GList * -build_file_list_from_uris (const gchar **uris) -{ - GList *result; - gint i; - - result = NULL; - for (i = 0; uris && uris[i]; i++) + else { - GFile *file; - - file = g_file_new_for_uri (uris[i]); - result = g_list_prepend (result, file); + g_assert_not_reached (); } - return g_list_reverse (result); + out: + start_drop_feedback (sidebar, value); + return action; } /* Reorders the bookmark to the specified position */ static void reorder_bookmarks (NautilusGtkPlacesSidebar *sidebar, NautilusGtkSidebarRow *row, - gint new_position) + int new_position) { - gchar *uri; + char *uri; GFile *file; g_object_get (row, "uri", &uri, NULL); @@ -1950,10 +1744,10 @@ reorder_bookmarks (NautilusGtkPlacesSidebar *sidebar, /* Creates bookmarks for the specified files at the given position in the bookmarks list */ static void drop_files_as_bookmarks (NautilusGtkPlacesSidebar *sidebar, - GList *files, - gint position) + GSList *files, + int position) { - GList *l; + GSList *l; for (l = files; l; l = l->next) { @@ -1974,76 +1768,26 @@ drop_files_as_bookmarks (NautilusGtkPlacesSidebar *sidebar, } } -static void -drag_data_get_callback (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *data, - guint info, - guint time, - gpointer user_data) +static gboolean +drag_drop_callback (GtkDropTarget *target, + const GValue *value, + double x, + double y, + NautilusGtkPlacesSidebar *sidebar) { - NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (user_data); - GdkAtom target = gtk_selection_data_get_target (data); - - if (target == gdk_atom_intern_static_string ("DND_NAUTILUS_GTK_SIDEBAR_ROW")) - { - gtk_selection_data_set (data, - target, - 8, - (void*)&sidebar->drag_row, - sizeof (gpointer)); - } -} - -static void -drag_data_received_callback (GtkWidget *list_box, - GdkDragContext *context, - int x, - int y, - GtkSelectionData *selection_data, - guint info, - guint time, - gpointer user_data) -{ - gint target_order_index; - NautilusGtkPlacesSidebarPlaceType target_place_type; - NautilusGtkPlacesSidebarSectionType target_section_type; - gchar *target_uri; - gboolean success; - NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (user_data); + int target_order_index; + NautilusGtkPlacesPlaceType target_place_type; + NautilusGtkPlacesSectionType target_section_type; + char *target_uri; GtkListBoxRow *target_row; - - if (!sidebar->drag_data_received) - { - if (gtk_selection_data_get_target (selection_data) != GDK_NONE && - info == DND_TEXT_URI_LIST) - { - gchar **uris; - - uris = gtk_selection_data_get_uris (selection_data); - /* Free spurious drag data from previous drags if present */ - if (sidebar->drag_list != NULL) - g_list_free_full (sidebar->drag_list, g_object_unref); - sidebar->drag_list = build_file_list_from_uris ((const char **) uris); - g_strfreev (uris); - } - else - { - sidebar->drag_list = NULL; - } - sidebar->drag_data_received = TRUE; - sidebar->drag_data_info = info; - } - - g_signal_stop_emission_by_name (list_box, "drag-data-received"); - - if (!sidebar->drop_occurred) - return; + gboolean result; target_row = gtk_list_box_get_row_at_y (GTK_LIST_BOX (sidebar->list_box), y); - if (target_row == NULL) - return; + return FALSE; + + if (!check_valid_drop_target (sidebar, NAUTILUS_GTK_SIDEBAR_ROW (target_row), value)) + return FALSE; g_object_get (target_row, "place-type", &target_place_type, @@ -2051,79 +1795,67 @@ drag_data_received_callback (GtkWidget *list_box, "order-index", &target_order_index, "uri", &target_uri, NULL); + result = FALSE; - success = FALSE; - - if (!check_valid_drop_target (sidebar, NAUTILUS_GTK_SIDEBAR_ROW (target_row), context)) - goto out; - - if (sidebar->drag_data_info == DND_NAUTILUS_GTK_SIDEBAR_ROW) + if (G_VALUE_HOLDS (value, NAUTILUS_TYPE_GTK_SIDEBAR_ROW)) { - GtkWidget **source_row; + GtkWidget *source_row; /* A bookmark got reordered */ - if (target_section_type != SECTION_BOOKMARKS) + if (target_section_type != NAUTILUS_GTK_PLACES_SECTION_BOOKMARKS) goto out; - source_row = (void*) gtk_selection_data_get_data (selection_data); + source_row = g_value_get_object (value); if (sidebar->row_placeholder != NULL) g_object_get (sidebar->row_placeholder, "order-index", &target_order_index, NULL); - reorder_bookmarks (sidebar, NAUTILUS_GTK_SIDEBAR_ROW (*source_row), target_order_index); - success = TRUE; + reorder_bookmarks (sidebar, NAUTILUS_GTK_SIDEBAR_ROW (source_row), target_order_index); + result = TRUE; } - else + else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST)) { /* Dropping URIs! */ - GdkDragAction real_action; - gchar **uris; - GList *source_file_list; - - /* file transfer requested */ - real_action = gdk_drag_context_get_selected_action (context); - - if (real_action == GDK_ACTION_ASK) - real_action = emit_drag_action_ask (sidebar, gdk_drag_context_get_actions (context)); - - if (real_action > 0) + if (target_place_type == NAUTILUS_GTK_PLACES_DROP_FEEDBACK) { - GFile *dest_file; - - uris = gtk_selection_data_get_uris (selection_data); - source_file_list = build_file_list_from_uris ((const gchar **) uris); - - if (target_place_type == PLACES_DROP_FEEDBACK) - { - drop_files_as_bookmarks (sidebar, source_file_list, target_order_index); - } - else - { - dest_file = g_file_new_for_uri (target_uri); - - emit_drag_perform_drop (sidebar, dest_file, source_file_list, real_action); - - g_object_unref (dest_file); - } - - success = TRUE; - g_list_free_full (source_file_list, g_object_unref); - g_strfreev (uris); + drop_files_as_bookmarks (sidebar, g_value_get_boxed (value), target_order_index); + } + else + { + GFile *dest_file = g_file_new_for_uri (target_uri); + + emit_drag_perform_drop (sidebar, + dest_file, + g_value_get_boxed (value), + gdk_drop_get_actions (gtk_drop_target_get_current_drop (target))); + + g_object_unref (dest_file); } + result = TRUE; + } + else + { + g_assert_not_reached (); } out: - sidebar->drop_occurred = FALSE; - gtk_drag_finish (context, success, FALSE, time); stop_drop_feedback (sidebar); g_free (target_uri); + return result; } static void -drag_end_callback (GtkWidget *widget, - GdkDragContext *context, - gpointer user_data) +dnd_finished_cb (GdkDrag *drag, + NautilusGtkPlacesSidebar *sidebar) { - stop_drop_feedback (NAUTILUS_GTK_PLACES_SIDEBAR (user_data)); + stop_drop_feedback (sidebar); +} + +static void +dnd_cancel_cb (GdkDrag *drag, + GdkDragCancelReason reason, + NautilusGtkPlacesSidebar *sidebar) +{ + stop_drop_feedback (sidebar); } /* This functions is called every time the drag source leaves @@ -2136,50 +1868,28 @@ drag_end_callback (GtkWidget *widget, * but that's not true, because this function is called also before drag_drop, * which needs the data from the drag so we cannot free the drag data here. * So now one could think we could just do nothing here, and wait for - * drag-end or drag-failed signals and just stop_drop_feedback there. But that - * is also not true, since when the drag comes from a diferent widget than the + * drag-end or drag-cancel signals and just stop_drop_feedback there. But that + * is also not true, since when the drag comes from a different widget than the * sidebar, when the drag stops the last drag signal we receive is drag-leave. * So here what we will do is restore the state of the sidebar as if no drag - * is being done (and if the application didnt request for permanent hints with + * is being done (and if the application didn't request for permanent hints with * nautilus_gtk_places_sidebar_show_drop_hints) and we will free the drag data next time * we build new drag data in drag_data_received. */ static void -drag_leave_callback (GtkWidget *widget, - GdkDragContext *context, - guint time, - gpointer user_data) +drag_leave_callback (GtkDropTarget *dest, + gpointer user_data) { NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (user_data); if (sidebar->drop_state != DROP_STATE_NEW_BOOKMARK_ARMED_PERMANENT) { - update_possible_drop_targets (sidebar, FALSE, context); + update_possible_drop_targets (sidebar, FALSE); nautilus_gtk_sidebar_row_hide (NAUTILUS_GTK_SIDEBAR_ROW (sidebar->new_bookmark_row), FALSE); sidebar->drop_state = DROP_STATE_NORMAL; } - sidebar->drag_data_received = FALSE; sidebar->dragging_over = FALSE; - sidebar->drag_data_info = DND_UNKNOWN; -} - -static gboolean -drag_drop_callback (GtkWidget *list_box, - GdkDragContext *context, - gint x, - gint y, - guint time, - gpointer user_data) -{ - gboolean retval = FALSE; - NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (user_data); - - sidebar->drop_occurred = TRUE; - retval = get_drag_data (sidebar->list_box, context, time); - g_signal_stop_emission_by_name (sidebar->list_box, "drag-drop"); - - return retval; } static void @@ -2206,160 +1916,14 @@ check_unmount_and_eject (GMount *mount, } static void -check_visibility (GMount *mount, - GVolume *volume, - GDrive *drive, - gboolean *show_mount, - gboolean *show_unmount, - gboolean *show_eject, - gboolean *show_rescan, - gboolean *show_start, - gboolean *show_stop) -{ - *show_mount = FALSE; - *show_rescan = FALSE; - *show_start = FALSE; - *show_stop = FALSE; - - check_unmount_and_eject (mount, volume, drive, show_unmount, show_eject); - - if (drive != NULL) - { - if (g_drive_is_media_removable (drive) && - !g_drive_is_media_check_automatic (drive) && - g_drive_can_poll_for_media (drive)) - *show_rescan = TRUE; - - *show_start = g_drive_can_start (drive) || g_drive_can_start_degraded (drive); - *show_stop = g_drive_can_stop (drive); - - if (*show_stop) - *show_unmount = FALSE; - } - - if (volume != NULL) - { - if (mount == NULL) - *show_mount = g_volume_can_mount (volume); - } -} - -typedef struct { - GtkWidget *add_shortcut_item; - GtkWidget *remove_item; - GtkWidget *rename_item; - GtkWidget *separator_item; - GtkWidget *mount_item; - GtkWidget *unmount_item; - GtkWidget *eject_item; - GtkWidget *rescan_item; - GtkWidget *start_item; - GtkWidget *stop_item; -} PopoverData; - -static void -check_popover_sensitivity (NautilusGtkSidebarRow *row, - PopoverData *data) -{ - gboolean show_mount; - gboolean show_unmount; - gboolean show_eject; - gboolean show_rescan; - gboolean show_start; - gboolean show_stop; - NautilusGtkPlacesSidebarPlaceType type; - GDrive *drive; - GVolume *volume; - GMount *mount; - GtkWidget *sidebar; - GActionGroup *actions; - GAction *action; - - g_object_get (row, - "sidebar", &sidebar, - "place-type", &type, - "drive", &drive, - "volume", &volume, - "mount", &mount, - NULL); - - gtk_widget_set_visible (data->add_shortcut_item, (type == PLACES_MOUNTED_VOLUME)); - - actions = gtk_widget_get_action_group (sidebar, "row"); - action = g_action_map_lookup_action (G_ACTION_MAP (actions), "remove"); - g_simple_action_set_enabled (G_SIMPLE_ACTION (action), (type == PLACES_BOOKMARK)); - action = g_action_map_lookup_action (G_ACTION_MAP (actions), "rename"); - g_simple_action_set_enabled (G_SIMPLE_ACTION (action), (type == PLACES_BOOKMARK || - type == PLACES_XDG_DIR)); - action = g_action_map_lookup_action (G_ACTION_MAP (actions), "open"); - g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !gtk_list_box_row_is_selected (GTK_LIST_BOX_ROW (row))); - - check_visibility (mount, volume, drive, - &show_mount, &show_unmount, &show_eject, &show_rescan, &show_start, &show_stop); - - gtk_widget_set_visible (data->separator_item, show_mount || show_unmount || show_eject); - gtk_widget_set_visible (data->mount_item, show_mount); - gtk_widget_set_visible (data->unmount_item, show_unmount); - gtk_widget_set_visible (data->eject_item, show_eject); - gtk_widget_set_visible (data->rescan_item, show_rescan); - gtk_widget_set_visible (data->start_item, show_start); - gtk_widget_set_visible (data->stop_item, show_stop); - - /* Adjust start/stop items to reflect the type of the drive */ - g_object_set (data->start_item, "text", _("_Start"), NULL); - g_object_set (data->stop_item, "text", _("_Stop"), NULL); - if ((show_start || show_stop) && drive != NULL) - { - switch (g_drive_get_start_stop_type (drive)) - { - case G_DRIVE_START_STOP_TYPE_SHUTDOWN: - /* start() for type G_DRIVE_START_STOP_TYPE_SHUTDOWN is normally not used */ - g_object_set (data->start_item, "text", _("_Power On"), NULL); - g_object_set (data->stop_item, "text", _("_Safely Remove Drive"), NULL); - break; - - case G_DRIVE_START_STOP_TYPE_NETWORK: - g_object_set (data->start_item, "text", _("_Connect Drive"), NULL); - g_object_set (data->stop_item, "text", _("_Disconnect Drive"), NULL); - break; - - case G_DRIVE_START_STOP_TYPE_MULTIDISK: - g_object_set (data->start_item, "text", _("_Start Multi-disk Device"), NULL); - g_object_set (data->stop_item, "text", _("_Stop Multi-disk Device"), NULL); - break; - - case G_DRIVE_START_STOP_TYPE_PASSWORD: - /* stop() for type G_DRIVE_START_STOP_TYPE_PASSWORD is normally not used */ - g_object_set (data->start_item, "text", _("_Unlock Device"), NULL); - g_object_set (data->stop_item, "text", _("_Lock Device"), NULL); - break; - - default: - case G_DRIVE_START_STOP_TYPE_UNKNOWN: - /* uses defaults set above */ - break; - } - } - - if (drive) - g_object_unref (drive); - if (volume) - g_object_unref (volume); - if (mount) - g_object_unref (mount); - - g_object_unref (sidebar); -} - -static void drive_start_from_bookmark_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { NautilusGtkPlacesSidebar *sidebar; GError *error; - gchar *primary; - gchar *name; + char *primary; + char *name; sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (user_data); @@ -2387,8 +1951,8 @@ volume_mount_cb (GObject *source_object, NautilusGtkPlacesSidebar *sidebar; GVolume *volume; GError *error; - gchar *primary; - gchar *name; + char *primary; + char *name; GMount *mount; volume = G_VOLUME (source_object); @@ -2402,6 +1966,9 @@ volume_mount_cb (GObject *source_object, { name = g_volume_get_name (G_VOLUME (source_object)); if (g_str_has_prefix (error->message, "Error unlocking")) + /* Translators: This means that unlocking an encrypted storage + * device failed. %s is the name of the device. + */ primary = g_strdup_printf (_("Error unlocking “%s”"), name); else primary = g_strdup_printf (_("Unable to access “%s”"), name); @@ -2489,7 +2056,7 @@ open_volume (NautilusGtkSidebarRow *row, static void open_uri (NautilusGtkPlacesSidebar *sidebar, - const gchar *uri, + const char *uri, NautilusGtkPlacesOpenFlags open_flags) { GFile *location; @@ -2503,10 +2070,10 @@ static void open_row (NautilusGtkSidebarRow *row, NautilusGtkPlacesOpenFlags open_flags) { - gchar *uri; + char *uri; GDrive *drive; GVolume *volume; - NautilusGtkPlacesSidebarPlaceType place_type; + NautilusGtkPlacesPlaceType place_type; NautilusGtkPlacesSidebar *sidebar; g_object_get (row, @@ -2517,12 +2084,11 @@ open_row (NautilusGtkSidebarRow *row, "volume", &volume, NULL); - if (place_type == PLACES_OTHER_LOCATIONS) + if (place_type == NAUTILUS_GTK_PLACES_OTHER_LOCATIONS) { - emit_show_other_locations (sidebar); emit_show_other_locations_with_flags (sidebar, open_flags); } - else if (place_type == PLACES_STARRED_LOCATION) + else if (place_type == NAUTILUS_GTK_PLACES_STARRED_LOCATION) { emit_show_starred_location (sidebar, open_flags); } @@ -2530,11 +2096,7 @@ open_row (NautilusGtkSidebarRow *row, { open_uri (sidebar, uri, open_flags); } - else if (place_type == PLACES_CONNECT_TO_SERVER) - { - emit_show_connect_to_server (sidebar); - } - else if (place_type == PLACES_ENTER_LOCATION) + else if (place_type == NAUTILUS_GTK_PLACES_ENTER_LOCATION) { emit_show_enter_location (sidebar); } @@ -2575,8 +2137,8 @@ add_shortcut_cb (GSimpleAction *action, gpointer data) { NautilusGtkPlacesSidebar *sidebar = data; - gchar *uri; - gchar *name; + char *uri; + char *name; GFile *location; g_object_get (sidebar->context_row, @@ -2600,15 +2162,14 @@ static void rename_entry_changed (GtkEntry *entry, NautilusGtkPlacesSidebar *sidebar) { - NautilusGtkPlacesSidebarPlaceType type; - gchar *name; - gchar *uri; - const gchar *new_name; + NautilusGtkPlacesPlaceType type; + char *name; + char *uri; + const char *new_name; gboolean found = FALSE; - GList *rows; - GList *l; + GtkWidget *row; - new_name = gtk_entry_get_text (GTK_ENTRY (sidebar->rename_entry)); + new_name = gtk_editable_get_text (GTK_EDITABLE (sidebar->rename_entry)); if (strcmp (new_name, "") == 0) { @@ -2617,16 +2178,20 @@ rename_entry_changed (GtkEntry *entry, return; } - rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box)); - for (l = rows; l && !found; l = l->next) + for (row = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box)); + row != NULL && !found; + row = gtk_widget_get_next_sibling (row)) { - g_object_get (l->data, + if (!GTK_IS_LIST_BOX_ROW (row)) + continue; + + g_object_get (row, "place-type", &type, "uri", &uri, "label", &name, NULL); - if ((type == PLACES_XDG_DIR || type == PLACES_BOOKMARK) && + if ((type == NAUTILUS_GTK_PLACES_XDG_DIR || type == NAUTILUS_GTK_PLACES_BOOKMARK) && strcmp (uri, sidebar->rename_uri) != 0 && strcmp (new_name, name) == 0) found = TRUE; @@ -2634,7 +2199,6 @@ rename_entry_changed (GtkEntry *entry, g_free (uri); g_free (name); } - g_list_free (rows); gtk_widget_set_sensitive (sidebar->rename_button, !found); gtk_label_set_label (GTK_LABEL (sidebar->rename_error), @@ -2645,10 +2209,10 @@ static void do_rename (GtkButton *button, NautilusGtkPlacesSidebar *sidebar) { - gchar *new_text; + char *new_text; GFile *file; - new_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (sidebar->rename_entry))); + new_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (sidebar->rename_entry))); file = g_file_new_for_uri (sidebar->rename_uri); if (!_nautilus_gtk_bookmarks_manager_has_bookmark (sidebar->bookmarks_manager, file)) @@ -2687,20 +2251,24 @@ create_rename_popover (NautilusGtkPlacesSidebar *sidebar) GtkWidget *entry; GtkWidget *button; GtkWidget *error; - gchar *str; + char *str; if (sidebar->rename_popover) return; - popover = gtk_popover_new (GTK_WIDGET (sidebar)); + popover = gtk_popover_new (); + gtk_widget_set_parent (popover, GTK_WIDGET (sidebar)); /* Clean sidebar pointer when its destroyed, most of the times due to its * relative_to associated row being destroyed */ g_signal_connect (popover, "destroy", G_CALLBACK (on_rename_popover_destroy), sidebar); gtk_popover_set_position (GTK_POPOVER (popover), GTK_POS_RIGHT); grid = gtk_grid_new (); - gtk_container_add (GTK_CONTAINER (popover), grid); + gtk_popover_set_child (GTK_POPOVER (popover), grid); g_object_set (grid, - "margin", 10, + "margin-start", 10, + "margin-end", 10, + "margin-top", 10, + "margin-bottom", 10, "row-spacing", 6, "column-spacing", 6, NULL); @@ -2714,8 +2282,7 @@ create_rename_popover (NautilusGtkPlacesSidebar *sidebar) gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); g_free (str); button = gtk_button_new_with_mnemonic (_("_Rename")); - gtk_widget_set_can_default (button, TRUE); - gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action"); + gtk_widget_add_css_class (button, "suggested-action"); g_signal_connect (button, "clicked", G_CALLBACK (do_rename), sidebar); error = gtk_label_new (""); gtk_widget_set_halign (error, GTK_ALIGN_START); @@ -2723,7 +2290,6 @@ create_rename_popover (NautilusGtkPlacesSidebar *sidebar) gtk_grid_attach (GTK_GRID (grid), entry, 0, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), button,1, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), error, 0, 2, 2, 1); - gtk_widget_show_all (grid); gtk_popover_set_default_widget (GTK_POPOVER (popover), button); sidebar->rename_popover = popover; @@ -2746,30 +2312,28 @@ static void update_popover_shadowing (GtkWidget *row, gboolean shown) { - GtkStyleContext *context; - gint count; + int count; count = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "popover-count")); count = shown ? count + 1 : count - 1; g_object_set_data (G_OBJECT (row), "popover-count", GINT_TO_POINTER (count)); - context = gtk_widget_get_style_context (row); if (count > 0) - gtk_style_context_add_class (context, "has-open-popup"); + gtk_widget_add_css_class (row, "has-open-popup"); else - gtk_style_context_remove_class (context, "has-open-popup"); + gtk_widget_remove_css_class (row, "has-open-popup"); } static void set_prelight (GtkPopover *popover) { - update_popover_shadowing (gtk_popover_get_relative_to (popover), TRUE); + update_popover_shadowing (gtk_widget_get_parent (GTK_WIDGET (popover)), TRUE); } static void unset_prelight (GtkPopover *popover) { - update_popover_shadowing (gtk_popover_get_relative_to (popover), FALSE); + update_popover_shadowing (gtk_widget_get_parent (GTK_WIDGET (popover)), FALSE); } static void @@ -2782,8 +2346,8 @@ setup_popover_shadowing (GtkWidget *popover) static void show_rename_popover (NautilusGtkSidebarRow *row) { - gchar *name; - gchar *uri; + char *name; + char *uri; NautilusGtkPlacesSidebar *sidebar; g_object_get (row, @@ -2798,8 +2362,12 @@ show_rename_popover (NautilusGtkSidebarRow *row) g_free (sidebar->rename_uri); sidebar->rename_uri = g_strdup (uri); - gtk_entry_set_text (GTK_ENTRY (sidebar->rename_entry), name); - gtk_popover_set_relative_to (GTK_POPOVER (sidebar->rename_popover), GTK_WIDGET (row)); + gtk_editable_set_text (GTK_EDITABLE (sidebar->rename_entry), name); + g_object_ref (sidebar->rename_popover); + gtk_widget_unparent (sidebar->rename_popover); + gtk_widget_set_parent (sidebar->rename_popover, GTK_WIDGET (row)); + g_object_unref (sidebar->rename_popover); + setup_popover_shadowing (sidebar->rename_popover); gtk_popover_popup (GTK_POPOVER (sidebar->rename_popover)); @@ -2813,11 +2381,11 @@ show_rename_popover (NautilusGtkSidebarRow *row) static void rename_bookmark (NautilusGtkSidebarRow *row) { - NautilusGtkPlacesSidebarPlaceType type; + NautilusGtkPlacesPlaceType type; g_object_get (row, "place-type", &type, NULL); - if (type != PLACES_BOOKMARK && type != PLACES_XDG_DIR) + if (type != NAUTILUS_GTK_PLACES_BOOKMARK && type != NAUTILUS_GTK_PLACES_XDG_DIR) return; show_rename_popover (row); @@ -2836,8 +2404,8 @@ rename_shortcut_cb (GSimpleAction *action, static void remove_bookmark (NautilusGtkSidebarRow *row) { - NautilusGtkPlacesSidebarPlaceType type; - gchar *uri; + NautilusGtkPlacesPlaceType type; + char *uri; GFile *file; NautilusGtkPlacesSidebar *sidebar; @@ -2847,7 +2415,7 @@ remove_bookmark (NautilusGtkSidebarRow *row) "uri", &uri, NULL); - if (type == PLACES_BOOKMARK) + if (type == NAUTILUS_GTK_PLACES_BOOKMARK) { file = g_file_new_for_uri (uri); _nautilus_gtk_bookmarks_manager_remove_bookmark (sidebar->bookmarks_manager, file, NULL); @@ -2903,8 +2471,8 @@ unmount_mount_cb (GObject *source_object, { if (error->code != G_IO_ERROR_FAILED_HANDLED) { - gchar *name; - gchar *primary; + char *name; + char *primary; name = g_mount_get_name (mount); primary = g_strdup_printf (_("Unable to unmount “%s”"), name); @@ -2924,7 +2492,7 @@ get_mount_operation (NautilusGtkPlacesSidebar *sidebar) { GMountOperation *mount_op; - mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar)))); + mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (sidebar)))); emit_mount_operation (sidebar, mount_op); @@ -2936,7 +2504,7 @@ get_unmount_operation (NautilusGtkPlacesSidebar *sidebar) { GMountOperation *mount_op; - mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar)))); + mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (sidebar)))); emit_unmount_operation (sidebar, mount_op); @@ -3072,8 +2640,8 @@ drive_stop_cb (GObject *source_object, { NautilusGtkPlacesSidebar *sidebar; GError *error; - gchar *primary; - gchar *name; + char *primary; + char *name; sidebar = user_data; @@ -3101,8 +2669,8 @@ drive_eject_cb (GObject *source_object, { NautilusGtkPlacesSidebar *sidebar; GError *error; - gchar *primary; - gchar *name; + char *primary; + char *name; sidebar = user_data; @@ -3130,8 +2698,8 @@ volume_eject_cb (GObject *source_object, { NautilusGtkPlacesSidebar *sidebar; GError *error; - gchar *primary; - gchar *name; + char *primary; + char *name; sidebar = user_data; @@ -3159,8 +2727,8 @@ mount_eject_cb (GObject *source_object, { NautilusGtkPlacesSidebar *sidebar; GError *error; - gchar *primary; - gchar *name; + char *primary; + char *name; sidebar = user_data; @@ -3307,8 +2875,8 @@ drive_poll_for_media_cb (GObject *source_object, { NautilusGtkPlacesSidebar *sidebar; GError *error; - gchar *primary; - gchar *name; + char *primary; + char *name; sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (user_data); @@ -3355,8 +2923,8 @@ drive_start_cb (GObject *source_object, { NautilusGtkPlacesSidebar *sidebar; GError *error; - gchar *primary; - gchar *name; + char *primary; + char *name; sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (user_data); @@ -3428,64 +2996,62 @@ stop_shortcut_cb (GSimpleAction *action, } static gboolean -on_key_press_event (GtkWidget *widget, - GdkEventKey *event, - NautilusGtkPlacesSidebar *sidebar) +on_key_pressed (GtkEventControllerKey *controller, + guint keyval, + guint keycode, + GdkModifierType state, + NautilusGtkPlacesSidebar *sidebar) { guint modifiers; GtkListBoxRow *row; - if (event) + row = gtk_list_box_get_selected_row (GTK_LIST_BOX (sidebar->list_box)); + if (row) { - row = gtk_list_box_get_selected_row (GTK_LIST_BOX (sidebar->list_box)); - if (row) - { - 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) - { - NautilusGtkPlacesOpenFlags open_flags = NAUTILUS_GTK_PLACES_OPEN_NORMAL; + modifiers = gtk_accelerator_get_default_mod_mask (); - if ((event->state & modifiers) == GDK_SHIFT_MASK) - open_flags = NAUTILUS_GTK_PLACES_OPEN_NEW_TAB; - else if ((event->state & modifiers) == GDK_CONTROL_MASK) - open_flags = NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW; + if (keyval == GDK_KEY_Return || + keyval == GDK_KEY_KP_Enter || + keyval == GDK_KEY_ISO_Enter || + keyval == GDK_KEY_space) + { + NautilusGtkPlacesOpenFlags open_flags = NAUTILUS_GTK_PLACES_OPEN_NORMAL; - open_row (NAUTILUS_GTK_SIDEBAR_ROW (row), open_flags); + if ((state & modifiers) == GDK_SHIFT_MASK) + open_flags = NAUTILUS_GTK_PLACES_OPEN_NEW_TAB; + else if ((state & modifiers) == GDK_CONTROL_MASK) + open_flags = NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW; - return TRUE; - } + open_row (NAUTILUS_GTK_SIDEBAR_ROW (row), open_flags); - if (event->keyval == GDK_KEY_Down && - (event->state & modifiers) == GDK_MOD1_MASK) - return eject_or_unmount_selection (sidebar); + return TRUE; + } - if ((event->keyval == GDK_KEY_Delete || - event->keyval == GDK_KEY_KP_Delete) && - (event->state & modifiers) == 0) - { - remove_bookmark (NAUTILUS_GTK_SIDEBAR_ROW (row)); - return TRUE; - } + if (keyval == GDK_KEY_Down && + (state & modifiers) == GDK_ALT_MASK) + return eject_or_unmount_selection (sidebar); - if ((event->keyval == GDK_KEY_F2) && - (event->state & modifiers) == 0) - { - rename_bookmark (NAUTILUS_GTK_SIDEBAR_ROW (row)); - return TRUE; - } + if ((keyval == GDK_KEY_Delete || + keyval == GDK_KEY_KP_Delete) && + (state & modifiers) == 0) + { + remove_bookmark (NAUTILUS_GTK_SIDEBAR_ROW (row)); + return TRUE; + } - if ((event->keyval == GDK_KEY_Menu) || - ((event->keyval == GDK_KEY_F10) && - (event->state & modifiers) == GDK_SHIFT_MASK)) + if ((keyval == GDK_KEY_F2) && + (state & modifiers) == 0) + { + rename_bookmark (NAUTILUS_GTK_SIDEBAR_ROW (row)); + return TRUE; + } - { - popup_menu_cb (NAUTILUS_GTK_SIDEBAR_ROW (row)); - return TRUE; - } + if ((keyval == GDK_KEY_Menu) || + ((keyval == GDK_KEY_F10) && + (state & modifiers) == GDK_SHIFT_MASK)) + { + popup_menu_cb (NAUTILUS_GTK_SIDEBAR_ROW (row)); + return TRUE; } } @@ -3507,70 +3073,6 @@ static GActionEntry entries[] = { }; static void -add_actions (NautilusGtkPlacesSidebar *sidebar) -{ - GActionGroup *actions; - - actions = G_ACTION_GROUP (g_simple_action_group_new ()); - g_action_map_add_action_entries (G_ACTION_MAP (actions), - entries, G_N_ELEMENTS (entries), - sidebar); - gtk_widget_insert_action_group (GTK_WIDGET (sidebar), "row", actions); - g_object_unref (actions); -} - -static GtkWidget * -append_separator (GtkWidget *box) -{ - GtkWidget *separator; - - separator = g_object_new (GTK_TYPE_SEPARATOR, - "orientation", GTK_ORIENTATION_HORIZONTAL, - "visible", TRUE, - "margin-top", 6, - "margin-bottom", 6, - NULL); - gtk_container_add (GTK_CONTAINER (box), separator); - - return separator; -} - -static GtkWidget * -add_button (GtkWidget *box, - const gchar *label, - const gchar *action) -{ - GtkWidget *item; - - item = g_object_new (GTK_TYPE_MODEL_BUTTON, - "visible", TRUE, - "action-name", action, - "text", label, - NULL); - gtk_container_add (GTK_CONTAINER (box), item); - - return item; -} - -static GtkWidget * -add_open_button (GtkWidget *box, - const gchar *label, - NautilusGtkPlacesOpenFlags flags) -{ - GtkWidget *item; - - item = g_object_new (GTK_TYPE_MODEL_BUTTON, - "visible", TRUE, - "action-name", flags == NAUTILUS_GTK_PLACES_OPEN_NORMAL ? "row.open" : "row.open-other", - "action-target", g_variant_new_int32 (flags), - "text", label, - NULL); - gtk_container_add (GTK_CONTAINER (box), item); - - return item; -} - -static void on_row_popover_destroy (GtkWidget *row_popover, NautilusGtkPlacesSidebar *sidebar) { @@ -3598,7 +3100,8 @@ build_popup_menu_using_gmenu (NautilusGtkSidebarRow *row) GMenu *menu = g_menu_new (); GMenuItem *item; item = g_menu_item_new (_("_Open"), "row.open"); - g_menu_item_set_action_and_target_value (item, "row.open", g_variant_new_int32(NAUTILUS_GTK_PLACES_OPEN_NORMAL)); + g_menu_item_set_action_and_target_value (item, "row.open", + g_variant_new_int32 (NAUTILUS_GTK_PLACES_OPEN_NORMAL)); g_menu_append_item (menu, item); if (sidebar->open_flags & NAUTILUS_GTK_PLACES_OPEN_NEW_TAB) { @@ -3621,12 +3124,11 @@ build_popup_menu_using_gmenu (NautilusGtkSidebarRow *row) "cloudprovider", G_ACTION_GROUP (cloud_provider_action_group)); } - add_actions (sidebar); if (sidebar->popover) - gtk_widget_destroy (sidebar->popover); + gtk_widget_unparent (sidebar->popover); - sidebar->popover = gtk_popover_new_from_model (GTK_WIDGET (sidebar), - G_MENU_MODEL (menu)); + sidebar->popover = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu)); + gtk_widget_set_parent (sidebar->popover, GTK_WIDGET (sidebar)); g_signal_connect (sidebar->popover, "destroy", G_CALLBACK (on_row_popover_destroy), sidebar); g_object_unref (sidebar); @@ -3640,8 +3142,24 @@ static void create_row_popover (NautilusGtkPlacesSidebar *sidebar, NautilusGtkSidebarRow *row) { - PopoverData data; - GtkWidget *box; + NautilusGtkPlacesPlaceType type; + GMenu *menu, *section; + GMenuItem *item; + GMount *mount; + GVolume *volume; + GDrive *drive; + GAction *action; + gboolean show_unmount, show_eject; + gboolean show_stop; + + g_object_get (row, + "place-type", &type, + "drive", &drive, + "volume", &volume, + "mount", &mount, + NULL); + + check_unmount_and_eject (mount, volume, drive, &show_unmount, &show_eject); #ifdef HAVE_CLOUDPROVIDERS CloudProvidersAccount *cloud_provider_account; @@ -3651,72 +3169,139 @@ create_row_popover (NautilusGtkPlacesSidebar *sidebar, if (cloud_provider_account) { build_popup_menu_using_gmenu (row); - return; + return; } #endif - sidebar->popover = gtk_popover_new (GTK_WIDGET (sidebar)); - /* Clean sidebar pointer when its destroyed, most of the times due to its - * relative_to associated row being destroyed */ - g_signal_connect (sidebar->popover, "destroy", G_CALLBACK (on_row_popover_destroy), sidebar); - setup_popover_shadowing (sidebar->popover); - box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - g_object_set (box, "margin", 10, NULL); - gtk_widget_show (box); - gtk_container_add (GTK_CONTAINER (sidebar->popover), box); + action = g_action_map_lookup_action (G_ACTION_MAP (sidebar->row_actions), "remove"); + g_simple_action_set_enabled (G_SIMPLE_ACTION (action), (type == NAUTILUS_GTK_PLACES_BOOKMARK)); + action = g_action_map_lookup_action (G_ACTION_MAP (sidebar->row_actions), "rename"); + g_simple_action_set_enabled (G_SIMPLE_ACTION (action), (type == NAUTILUS_GTK_PLACES_BOOKMARK || + type == NAUTILUS_GTK_PLACES_XDG_DIR)); + action = g_action_map_lookup_action (G_ACTION_MAP (sidebar->row_actions), "open"); + g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !gtk_list_box_row_is_selected (GTK_LIST_BOX_ROW (row))); + + menu = g_menu_new (); + section = g_menu_new (); - add_open_button (box, _("_Open"), NAUTILUS_GTK_PLACES_OPEN_NORMAL); + item = g_menu_item_new (_("_Open"), "row.open"); + g_menu_item_set_action_and_target_value (item, "row.open", + g_variant_new_int32 (NAUTILUS_GTK_PLACES_OPEN_NORMAL)); + g_menu_append_item (section, item); + g_object_unref (item); if (sidebar->open_flags & NAUTILUS_GTK_PLACES_OPEN_NEW_TAB) - add_open_button (box, _("Open in New _Tab"), NAUTILUS_GTK_PLACES_OPEN_NEW_TAB); + { + item = g_menu_item_new (_("Open in New _Tab"), "row.open"); + g_menu_item_set_action_and_target_value (item, "row.open", + g_variant_new_int32 (NAUTILUS_GTK_PLACES_OPEN_NEW_TAB)); + g_menu_append_item (section, item); + g_object_unref (item); + } if (sidebar->open_flags & NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW) - add_open_button (box, _("Open in New _Window"), NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW); + { + item = g_menu_item_new (_("Open in New _Window"), "row.open"); + g_menu_item_set_action_and_target_value (item, "row.open", + g_variant_new_int32 (NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW)); + g_menu_append_item (section, item); + g_object_unref (item); + } + + g_menu_append_section (menu, NULL, G_MENU_MODEL (section)); + g_object_unref (section); - append_separator (box); + section = g_menu_new (); + item = g_menu_item_new (_("_Add Bookmark"), "row.add-bookmark"); + g_menu_append_item (section, item); + g_object_unref (item); - data.add_shortcut_item = add_button (box, _("_Add Bookmark"), "row.bookmark"); - data.remove_item = add_button (box, _("_Remove"), "row.remove"); - data.rename_item = add_button (box, _("Rename…"), "row.rename"); + item = g_menu_item_new (_("_Remove"), "row.remove"); + g_menu_append_item (section, item); + g_object_unref (item); - data.separator_item = append_separator (box); + item = g_menu_item_new (_("_Rename"), "row.rename"); + g_menu_append_item (section, item); + g_object_unref (item); - data.mount_item = add_button (box, _("_Mount"), "row.mount"); - data.unmount_item = add_button (box, _("_Unmount"), "row.unmount"); - data.eject_item = add_button (box, _("_Eject"), "row.eject"); - data.rescan_item = add_button (box, _("_Detect Media"), "row.rescan"); - data.start_item = add_button (box, _("_Start"), "row.start"); - data.stop_item = add_button (box, _("_Stop"), "row.stop"); + g_menu_append_section (menu, NULL, G_MENU_MODEL (section)); + g_object_unref (section); - /* Update everything! */ - check_popover_sensitivity (row, &data); + section = g_menu_new (); - if (sidebar->populate_all) + if (volume != NULL && mount == NULL && + g_volume_can_mount (volume)) { - gchar *uri; - GVolume *volume; - GFile *file; + item = g_menu_item_new (_("_Mount"), "row.mount"); + g_menu_append_item (section, item); + g_object_unref (item); + } - g_object_get (row, - "uri", &uri, - "volume", &volume, - NULL); + show_stop = (drive != NULL && g_drive_can_stop (drive)); - if (uri) - file = g_file_new_for_uri (uri); - else - file = NULL; + if (show_unmount && !show_stop) + { + item = g_menu_item_new (_("_Unmount"), "row.unmount"); + g_menu_append_item (section, item); + g_object_unref (item); + } - g_signal_emit (sidebar, places_sidebar_signals[POPULATE_POPUP], 0, - box, file, volume); + if (show_eject) + { + item = g_menu_item_new (_("_Eject"), "row.eject"); + g_menu_append_item (section, item); + g_object_unref (item); + } - if (file) - g_object_unref (file); + if (drive != NULL && + g_drive_is_media_removable (drive) && + !g_drive_is_media_check_automatic (drive) && + g_drive_can_poll_for_media (drive)) + { + item = g_menu_item_new (_("_Detect Media"), "row.rescan"); + g_menu_append_item (section, item); + g_object_unref (item); + } - g_free (uri); - if (volume) - g_object_unref (volume); + if (drive != NULL && + (g_drive_can_start (drive) || g_drive_can_start_degraded (drive))) + { + const guint ss_type = g_drive_get_start_stop_type (drive); + const char *start_label = _("_Start"); + + if (ss_type == G_DRIVE_START_STOP_TYPE_SHUTDOWN) start_label = _("_Power On"); + else if (ss_type == G_DRIVE_START_STOP_TYPE_NETWORK) start_label = _("_Connect Drive"); + else if (ss_type == G_DRIVE_START_STOP_TYPE_MULTIDISK) start_label = _("_Start Multi-disk Device"); + else if (ss_type == G_DRIVE_START_STOP_TYPE_PASSWORD) start_label = _("_Unlock Device"); + + item = g_menu_item_new (start_label, "row.start"); + g_menu_append_item (section, item); + g_object_unref (item); + } + + if (show_stop && !show_unmount) + { + const guint ss_type = g_drive_get_start_stop_type (drive); + const char *stop_label = _("_Stop"); + + if (ss_type == G_DRIVE_START_STOP_TYPE_SHUTDOWN) stop_label = _("_Safely Remove Drive"); + else if (ss_type == G_DRIVE_START_STOP_TYPE_NETWORK) stop_label = _("_Disconnect Drive"); + else if (ss_type == G_DRIVE_START_STOP_TYPE_MULTIDISK) stop_label = _("_Stop Multi-disk Device"); + else if (ss_type == G_DRIVE_START_STOP_TYPE_PASSWORD) stop_label = _("_Lock Device"); + + item = g_menu_item_new (stop_label, "row.stop"); + g_menu_append_item (section, item); + g_object_unref (item); } + + g_menu_append_section (menu, NULL, G_MENU_MODEL (section)); + g_object_unref (section); + + sidebar->popover = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu)); + g_object_unref (menu); + g_signal_connect (sidebar->popover, "destroy", G_CALLBACK (on_row_popover_destroy), sidebar); + + setup_popover_shadowing (sidebar->popover); } static void @@ -3726,12 +3311,11 @@ show_row_popover (NautilusGtkSidebarRow *row) g_object_get (row, "sidebar", &sidebar, NULL); - if (sidebar->popover) - gtk_widget_destroy (sidebar->popover); + g_clear_pointer (&sidebar->popover, gtk_widget_unparent); create_row_popover (sidebar, row); - gtk_popover_set_relative_to (GTK_POPOVER (sidebar->popover), GTK_WIDGET (row)); + gtk_widget_set_parent (sidebar->popover, GTK_WIDGET (row)); sidebar->context_row = row; gtk_popover_popup (GTK_POPOVER (sidebar->popover)); @@ -3757,84 +3341,154 @@ on_row_activated (GtkListBox *list_box, open_row (selected_row, 0); } -static gboolean -on_button_press_event (GtkWidget *widget, - GdkEventButton *event, - NautilusGtkSidebarRow *row) +static void +on_row_pressed (GtkGestureClick *gesture, + int n_press, + double x, + double y, + NautilusGtkSidebarRow *row) { NautilusGtkPlacesSidebar *sidebar; - NautilusGtkPlacesSidebarSectionType section_type; + NautilusGtkPlacesSectionType section_type; + NautilusGtkPlacesPlaceType row_type; - g_object_get (NAUTILUS_GTK_SIDEBAR_ROW (row), + g_object_get (row, "sidebar", &sidebar, "section_type", §ion_type, + "place-type", &row_type, NULL); - if (section_type == SECTION_BOOKMARKS) + if (section_type == NAUTILUS_GTK_PLACES_SECTION_BOOKMARKS) { sidebar->drag_row = GTK_WIDGET (row); - sidebar->drag_row_x = (gint)event->x; - sidebar->drag_row_y = (gint)event->y; - - sidebar->drag_root_x = event->x_root; - sidebar->drag_root_y = event->y_root; + sidebar->drag_row_x = (int)x; + sidebar->drag_row_y = (int)y; } g_object_unref (sidebar); - - return FALSE; } -static gboolean -on_button_release_event (GtkWidget *widget, - GdkEventButton *event, - NautilusGtkSidebarRow *row) +static void +on_row_released (GtkGestureClick *gesture, + int n_press, + double x, + double y, + NautilusGtkSidebarRow *row) { - gboolean ret = FALSE; - NautilusGtkPlacesSidebarPlaceType row_type; + NautilusGtkPlacesSidebar *sidebar; + NautilusGtkPlacesSectionType section_type; + NautilusGtkPlacesPlaceType row_type; + guint button, state; - if (event && row) - { - g_object_get (row, "place-type", &row_type, NULL); + g_object_get (row, + "sidebar", &sidebar, + "section_type", §ion_type, + "place-type", &row_type, + NULL); - if (event->button == 1) - ret = FALSE; - else if (event->button == 2) + button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)); + state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture)); + + if (row) + { + if (button == 2) { NautilusGtkPlacesOpenFlags open_flags = NAUTILUS_GTK_PLACES_OPEN_NORMAL; - open_flags = (event->state & GDK_CONTROL_MASK) ? - NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW : - NAUTILUS_GTK_PLACES_OPEN_NEW_TAB; + open_flags = (state & GDK_CONTROL_MASK) ? + NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW : + NAUTILUS_GTK_PLACES_OPEN_NEW_TAB; open_row (NAUTILUS_GTK_SIDEBAR_ROW (row), open_flags); - ret = TRUE; + gtk_gesture_set_state (GTK_GESTURE (gesture), + GTK_EVENT_SEQUENCE_CLAIMED); } - else if (event->button == 3) + else if (button == 3) { - if (row_type != PLACES_CONNECT_TO_SERVER) + if (row_type != NAUTILUS_GTK_PLACES_CONNECT_TO_SERVER) show_row_popover (NAUTILUS_GTK_SIDEBAR_ROW (row)); } } +} - return ret; +static void +on_row_dragged (GtkGestureDrag *gesture, + double x, + double y, + NautilusGtkSidebarRow *row) +{ + NautilusGtkPlacesSidebar *sidebar; + + g_object_get (row, "sidebar", &sidebar, NULL); + + if (sidebar->drag_row == NULL || sidebar->dragging_over) + { + g_object_unref (sidebar); + return; + } + + if (gtk_drag_check_threshold (GTK_WIDGET (row), 0, 0, x, y)) + { + double start_x, start_y; + double drag_x, drag_y; + GdkContentProvider *content; + GdkSurface *surface; + GdkDevice *device; + GtkAllocation allocation; + GtkWidget *drag_widget; + GdkDrag *drag; + + gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y); + gtk_widget_translate_coordinates (GTK_WIDGET (row), + GTK_WIDGET (sidebar), + start_x, start_y, + &drag_x, &drag_y); + + sidebar->dragging_over = TRUE; + + content = gdk_content_provider_new_typed (NAUTILUS_TYPE_GTK_SIDEBAR_ROW, sidebar->drag_row); + + surface = gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (sidebar))); + device = gtk_gesture_get_device (GTK_GESTURE (gesture)); + + drag = gdk_drag_begin (surface, device, content, GDK_ACTION_MOVE, drag_x, drag_y); + + g_object_unref (content); + + g_signal_connect (drag, "dnd-finished", G_CALLBACK (dnd_finished_cb), sidebar); + g_signal_connect (drag, "cancel", G_CALLBACK (dnd_cancel_cb), sidebar); + + gtk_widget_get_allocation (sidebar->drag_row, &allocation); + gtk_widget_hide (sidebar->drag_row); + + drag_widget = GTK_WIDGET (nautilus_gtk_sidebar_row_clone (NAUTILUS_GTK_SIDEBAR_ROW (sidebar->drag_row))); + sidebar->drag_row_height = allocation.height; + gtk_widget_set_size_request (drag_widget, allocation.width, allocation.height); + gtk_widget_set_opacity (drag_widget, 0.8); + + gtk_drag_icon_set_child (GTK_DRAG_ICON (gtk_drag_icon_get_for_drag (drag)), drag_widget); + + g_object_unref (drag); + } + + g_object_unref (sidebar); } static void popup_menu_cb (NautilusGtkSidebarRow *row) { - NautilusGtkPlacesSidebarPlaceType row_type; + NautilusGtkPlacesPlaceType row_type; g_object_get (row, "place-type", &row_type, NULL); - if (row_type != PLACES_CONNECT_TO_SERVER) + if (row_type != NAUTILUS_GTK_PLACES_CONNECT_TO_SERVER) show_row_popover (row); } static void long_press_cb (GtkGesture *gesture, - gdouble x, - gdouble y, + double x, + double y, NautilusGtkPlacesSidebar *sidebar) { GtkWidget *row; @@ -3844,16 +3498,16 @@ long_press_cb (GtkGesture *gesture, popup_menu_cb (NAUTILUS_GTK_SIDEBAR_ROW (row)); } -static gint +static int list_box_sort_func (GtkListBoxRow *row1, GtkListBoxRow *row2, gpointer user_data) { - NautilusGtkPlacesSidebarSectionType section_type_1, section_type_2; - NautilusGtkPlacesSidebarPlaceType place_type_1, place_type_2; - gchar *label_1, *label_2; - gint index_1, index_2; - gint retval = 0; + NautilusGtkPlacesSectionType section_type_1, section_type_2; + NautilusGtkPlacesPlaceType place_type_1, place_type_2; + char *label_1, *label_2; + int index_1, index_2; + int retval = 0; g_object_get (row1, "label", &label_1, @@ -3869,11 +3523,11 @@ list_box_sort_func (GtkListBoxRow *row1, NULL); /* Always last position for "connect to server" */ - if (place_type_1 == PLACES_CONNECT_TO_SERVER) + if (place_type_1 == NAUTILUS_GTK_PLACES_CONNECT_TO_SERVER) { retval = 1; } - else if (place_type_2 == PLACES_CONNECT_TO_SERVER) + else if (place_type_2 == NAUTILUS_GTK_PLACES_CONNECT_TO_SERVER) { retval = -1; } @@ -3881,20 +3535,20 @@ list_box_sort_func (GtkListBoxRow *row1, { if (section_type_1 == section_type_2) { - if ((section_type_1 == SECTION_COMPUTER && + if ((section_type_1 == NAUTILUS_GTK_PLACES_SECTION_COMPUTER && place_type_1 == place_type_2 && - place_type_1 == PLACES_XDG_DIR) || - section_type_1 == SECTION_MOUNTS) + place_type_1 == NAUTILUS_GTK_PLACES_XDG_DIR) || + section_type_1 == NAUTILUS_GTK_PLACES_SECTION_MOUNTS) { retval = g_utf8_collate (label_1, label_2); } - else if ((place_type_1 == PLACES_BOOKMARK || place_type_2 == PLACES_DROP_FEEDBACK) && - (place_type_1 == PLACES_DROP_FEEDBACK || place_type_2 == PLACES_BOOKMARK)) + else if ((place_type_1 == NAUTILUS_GTK_PLACES_BOOKMARK || place_type_2 == NAUTILUS_GTK_PLACES_DROP_FEEDBACK) && + (place_type_1 == NAUTILUS_GTK_PLACES_DROP_FEEDBACK || place_type_2 == NAUTILUS_GTK_PLACES_BOOKMARK)) { retval = index_1 - index_2; } /* We order the bookmarks sections based on the bookmark index that we - * set on the row as a order-index property, but we have to deal with + * set on the row as an order-index property, but we have to deal with * the placeholder row wanted to be between two consecutive bookmarks, * with two consecutive order-index values which is the usual case. * For that, in the list box sort func we give priority to the placeholder row, @@ -3903,14 +3557,14 @@ list_box_sort_func (GtkListBoxRow *row1, * the current row, for instance when the cursor is in the lower half * of the row, we need to increase the order-index. */ - else if (place_type_1 == PLACES_BOOKMARK_PLACEHOLDER && place_type_2 == PLACES_BOOKMARK) + else if (place_type_1 == NAUTILUS_GTK_PLACES_BOOKMARK_PLACEHOLDER && place_type_2 == NAUTILUS_GTK_PLACES_BOOKMARK) { if (index_1 == index_2) retval = index_1 - index_2 - 1; else retval = index_1 - index_2; } - else if (place_type_1 == PLACES_BOOKMARK && place_type_2 == PLACES_BOOKMARK_PLACEHOLDER) + else if (place_type_1 == NAUTILUS_GTK_PLACES_BOOKMARK && place_type_2 == NAUTILUS_GTK_PLACES_BOOKMARK_PLACEHOLDER) { if (index_1 == index_2) retval = index_1 - index_2 + 1; @@ -3937,7 +3591,7 @@ update_hostname (NautilusGtkPlacesSidebar *sidebar) { GVariant *variant; gsize len; - const gchar *hostname; + const char *hostname; if (sidebar->hostnamed_proxy == NULL) return; @@ -4046,13 +3700,19 @@ shell_shows_desktop_changed (GtkSettings *settings, static void nautilus_gtk_places_sidebar_init (NautilusGtkPlacesSidebar *sidebar) { - GtkTargetList *target_list; + GtkDropTarget *target; gboolean show_desktop; - GtkStyleContext *context; + GtkEventController *controller; + GtkGesture *gesture; sidebar->cancellable = g_cancellable_new (); sidebar->show_trash = TRUE; + sidebar->show_other_locations = TRUE; + sidebar->show_recent = TRUE; + sidebar->show_desktop = TRUE; + + sidebar->shortcuts = g_list_store_new (G_TYPE_FILE); create_volume_monitor (sidebar); @@ -4064,19 +3724,19 @@ nautilus_gtk_places_sidebar_init (NautilusGtkPlacesSidebar *sidebar) sidebar->trash_monitor_changed_id = g_signal_connect_swapped (sidebar->trash_monitor, "trash-state-changed", G_CALLBACK (update_trash_icon), sidebar); - gtk_widget_set_size_request (GTK_WIDGET (sidebar), 140, 280); + sidebar->swin = gtk_scrolled_window_new (); + gtk_widget_set_parent (sidebar->swin, GTK_WIDGET (sidebar)); + gtk_widget_set_size_request (sidebar->swin, 140, 280); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sidebar), + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sidebar->swin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sidebar), GTK_SHADOW_IN); - context = gtk_widget_get_style_context (GTK_WIDGET (sidebar)); - gtk_style_context_add_class (context, GTK_STYLE_CLASS_SIDEBAR); - gtk_style_context_set_junction_sides (context, GTK_JUNCTION_RIGHT | GTK_JUNCTION_LEFT); + gtk_widget_add_css_class (GTK_WIDGET (sidebar), "sidebar"); /* list box */ sidebar->list_box = gtk_list_box_new (); + gtk_widget_add_css_class (sidebar->list_box, "navigation-sidebar"); gtk_list_box_set_header_func (GTK_LIST_BOX (sidebar->list_box), list_box_header_func, sidebar, NULL); @@ -4087,48 +3747,33 @@ nautilus_gtk_places_sidebar_init (NautilusGtkPlacesSidebar *sidebar) g_signal_connect (sidebar->list_box, "row-activated", G_CALLBACK (on_row_activated), sidebar); - g_signal_connect (sidebar->list_box, "key-press-event", - G_CALLBACK (on_key_press_event), sidebar); - sidebar->long_press_gesture = gtk_gesture_long_press_new (GTK_WIDGET (sidebar)); - gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (sidebar->long_press_gesture), TRUE); - g_signal_connect (sidebar->long_press_gesture, "pressed", + controller = gtk_event_controller_key_new (); + g_signal_connect (controller, "key-pressed", + G_CALLBACK (on_key_pressed), sidebar); + gtk_widget_add_controller (sidebar->list_box, controller); + + gesture = gtk_gesture_long_press_new (); + gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE); + g_signal_connect (gesture, "pressed", G_CALLBACK (long_press_cb), sidebar); + gtk_widget_add_controller (GTK_WIDGET (sidebar), GTK_EVENT_CONTROLLER (gesture)); /* DND support */ - gtk_drag_dest_set (sidebar->list_box, - 0, - NULL, 0, - GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK); - target_list = gtk_target_list_new (dnd_drop_targets, G_N_ELEMENTS (dnd_drop_targets)); - gtk_target_list_add_uri_targets (target_list, DND_TEXT_URI_LIST); - gtk_drag_dest_set_target_list (sidebar->list_box, target_list); - gtk_target_list_unref (target_list); - sidebar->source_targets = gtk_target_list_new (dnd_source_targets, G_N_ELEMENTS (dnd_source_targets)); - gtk_target_list_add_text_targets (sidebar->source_targets, 0); - - g_signal_connect (sidebar->list_box, "motion-notify-event", - G_CALLBACK (on_motion_notify_event), sidebar); - g_signal_connect (sidebar->list_box, "drag-begin", - G_CALLBACK (drag_begin_callback), sidebar); - g_signal_connect (sidebar->list_box, "drag-motion", - G_CALLBACK (drag_motion_callback), sidebar); - g_signal_connect (sidebar->list_box, "drag-data-get", - G_CALLBACK (drag_data_get_callback), sidebar); - g_signal_connect (sidebar->list_box, "drag-data-received", - G_CALLBACK (drag_data_received_callback), sidebar); - g_signal_connect (sidebar->list_box, "drag-drop", - G_CALLBACK (drag_drop_callback), sidebar); - g_signal_connect (sidebar->list_box, "drag-end", - G_CALLBACK (drag_end_callback), sidebar); - g_signal_connect (sidebar->list_box, "drag-leave", - G_CALLBACK (drag_leave_callback), sidebar); + target = gtk_drop_target_new (G_TYPE_INVALID, GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK); + gtk_drop_target_set_preload (target, TRUE); + gtk_drop_target_set_gtypes (target, (GType[2]) { NAUTILUS_TYPE_GTK_SIDEBAR_ROW, GDK_TYPE_FILE_LIST }, 2); + g_signal_connect (target, "enter", G_CALLBACK (drag_motion_callback), sidebar); + g_signal_connect (target, "motion", G_CALLBACK (drag_motion_callback), sidebar); + g_signal_connect (target, "drop", G_CALLBACK (drag_drop_callback), sidebar); + g_signal_connect (target, "leave", G_CALLBACK (drag_leave_callback), sidebar); + gtk_widget_add_controller (sidebar->list_box, GTK_EVENT_CONTROLLER (target)); + sidebar->drag_row = NULL; sidebar->row_placeholder = NULL; sidebar->dragging_over = FALSE; - sidebar->drag_data_info = DND_UNKNOWN; - gtk_container_add (GTK_CONTAINER (sidebar), sidebar->list_box); + gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sidebar->swin), sidebar->list_box); sidebar->hostname = g_strdup (_("Computer")); sidebar->hostnamed_cancellable = g_cancellable_new (); @@ -4163,7 +3808,11 @@ nautilus_gtk_places_sidebar_init (NautilusGtkPlacesSidebar *sidebar) /* populate the sidebar */ update_places (sidebar); - add_actions (sidebar); + sidebar->row_actions = G_ACTION_GROUP (g_simple_action_group_new ()); + g_action_map_add_action_entries (G_ACTION_MAP (sidebar->row_actions), + entries, G_N_ELEMENTS (entries), + sidebar); + gtk_widget_insert_action_group (GTK_WIDGET (sidebar), "row", sidebar->row_actions); } static void @@ -4192,12 +3841,6 @@ nautilus_gtk_places_sidebar_set_property (GObject *obj, nautilus_gtk_places_sidebar_set_show_desktop (sidebar, g_value_get_boolean (value)); break; - case PROP_SHOW_CONNECT_TO_SERVER: -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - nautilus_gtk_places_sidebar_set_show_connect_to_server (sidebar, g_value_get_boolean (value)); -G_GNUC_END_IGNORE_DEPRECATIONS - break; - case PROP_SHOW_ENTER_LOCATION: nautilus_gtk_places_sidebar_set_show_enter_location (sidebar, g_value_get_boolean (value)); break; @@ -4214,18 +3857,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS nautilus_gtk_places_sidebar_set_show_starred_location (sidebar, g_value_get_boolean (value)); break; - case PROP_LOCAL_ONLY: - nautilus_gtk_places_sidebar_set_local_only (sidebar, g_value_get_boolean (value)); - break; - - case PROP_POPULATE_ALL: - if (sidebar->populate_all != g_value_get_boolean (value)) - { - sidebar->populate_all = g_value_get_boolean (value); - g_object_notify_by_pspec (obj, pspec); - } - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec); break; @@ -4258,12 +3889,6 @@ nautilus_gtk_places_sidebar_get_property (GObject *obj, g_value_set_boolean (value, nautilus_gtk_places_sidebar_get_show_desktop (sidebar)); break; - case PROP_SHOW_CONNECT_TO_SERVER: -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - g_value_set_boolean (value, nautilus_gtk_places_sidebar_get_show_connect_to_server (sidebar)); -G_GNUC_END_IGNORE_DEPRECATIONS - break; - case PROP_SHOW_ENTER_LOCATION: g_value_set_boolean (value, nautilus_gtk_places_sidebar_get_show_enter_location (sidebar)); break; @@ -4280,14 +3905,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS g_value_set_boolean (value, nautilus_gtk_places_sidebar_get_show_starred_location (sidebar)); break; - case PROP_LOCAL_ONLY: - g_value_set_boolean (value, nautilus_gtk_places_sidebar_get_local_only (sidebar)); - break; - - case PROP_POPULATE_ALL: - g_value_set_boolean (value, sidebar->populate_all); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec); break; @@ -4311,23 +3928,17 @@ nautilus_gtk_places_sidebar_dispose (GObject *object) sidebar->cancellable = NULL; } - free_drag_data (sidebar); - if (sidebar->bookmarks_manager != NULL) { _nautilus_gtk_bookmarks_manager_free (sidebar->bookmarks_manager); sidebar->bookmarks_manager = NULL; } - if (sidebar->popover) - { - gtk_widget_destroy (sidebar->popover); - sidebar->popover = NULL; - } + g_clear_pointer (&sidebar->popover, gtk_widget_unparent); if (sidebar->rename_popover) { - gtk_widget_destroy (sidebar->rename_popover); + gtk_widget_unparent (sidebar->rename_popover); sidebar->rename_popover = NULL; sidebar->rename_entry = NULL; sidebar->rename_button = NULL; @@ -4373,17 +3984,7 @@ nautilus_gtk_places_sidebar_dispose (GObject *object) g_clear_object (&sidebar->current_location); g_clear_pointer (&sidebar->rename_uri, g_free); - - g_clear_object (&sidebar->long_press_gesture); - - if (sidebar->source_targets) - { - gtk_target_list_unref (sidebar->source_targets); - sidebar->source_targets = NULL; - } - - g_slist_free_full (sidebar->shortcuts, g_object_unref); - sidebar->shortcuts = NULL; + g_clear_object (&sidebar->shortcuts); #ifdef HAVE_CLOUDPROVIDERS for (l = sidebar->unready_accounts; l != NULL; l = l->next) @@ -4392,7 +3993,6 @@ nautilus_gtk_places_sidebar_dispose (GObject *object) } g_list_free_full (sidebar->unready_accounts, g_object_unref); sidebar->unready_accounts = NULL; - if (sidebar->cloud_manager) { g_signal_handlers_disconnect_by_data (sidebar->cloud_manager, sidebar); @@ -4412,10 +4012,53 @@ nautilus_gtk_places_sidebar_dispose (GObject *object) static void nautilus_gtk_places_sidebar_finalize (GObject *object) { + NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (object); + + g_clear_object (&sidebar->row_actions); + + g_clear_pointer (&sidebar->swin, gtk_widget_unparent); + G_OBJECT_CLASS (nautilus_gtk_places_sidebar_parent_class)->finalize (object); } static void +nautilus_gtk_places_sidebar_measure (GtkWidget *widget, + GtkOrientation orientation, + int for_size, + int *minimum, + int *natural, + int *minimum_baseline, + int *natural_baseline) +{ + NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (widget); + + gtk_widget_measure (sidebar->swin, + orientation, + for_size, + minimum, natural, + minimum_baseline, natural_baseline); +} + +static void +nautilus_gtk_places_sidebar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) +{ + NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (widget); + + gtk_widget_size_allocate (sidebar->swin, + &(GtkAllocation) { 0, 0, width, height }, + baseline); + + if (sidebar->popover) + gtk_popover_present (GTK_POPOVER (sidebar->popover)); + + if (sidebar->rename_popover) + gtk_popover_present (GTK_POPOVER (sidebar->rename_popover)); +} + +static void nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); @@ -4427,18 +4070,19 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) gobject_class->set_property = nautilus_gtk_places_sidebar_set_property; gobject_class->get_property = nautilus_gtk_places_sidebar_get_property; - /** + widget_class->measure = nautilus_gtk_places_sidebar_measure; + widget_class->size_allocate = nautilus_gtk_places_sidebar_size_allocate; + + /* * NautilusGtkPlacesSidebar::open-location: * @sidebar: the object which received the signal. - * @location: (type Gio.File): #GFile to which the caller should switch. - * @open_flags: a single value from #NautilusGtkPlacesOpenFlags specifying how the @location should be opened. + * @location: (type Gio.File): GFile to which the caller should switch. + * @open_flags: a single value from NautilusGtkPlacesOpenFlags specifying how the @location should be opened. * * The places sidebar 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.10 */ places_sidebar_signals [OPEN_LOCATION] = g_signal_new ("open-location", @@ -4449,58 +4093,9 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) NULL, G_TYPE_NONE, 2, G_TYPE_OBJECT, - GTK_TYPE_PLACES_OPEN_FLAGS); - - /** - * NautilusGtkPlacesSidebar::populate-popup: - * @sidebar: the object which received the signal. - * @container: (type Gtk.Widget): a #GtkMenu or another #GtkContainer - * @selected_item: (type Gio.File) (nullable): #GFile with the item to which - * the popup should refer, or %NULL in the case of a @selected_volume. - * @selected_volume: (type Gio.Volume) (nullable): #GVolume if the selected - * item is a volume, or %NULL if it is a file. - * - * The places sidebar emits this signal when the user invokes a contextual - * popup on one of its items. In the signal handler, the application may - * add extra items to the menu as appropriate. For example, a file manager - * may want to add a "Properties" command to the menu. - * - * It is not necessary to store the @selected_item for each menu item; - * during their callbacks, the application can use nautilus_gtk_places_sidebar_get_location() - * to get the file to which the item refers. - * - * The @selected_item argument may be %NULL in case the selection refers to - * a volume. In this case, @selected_volume will be non-%NULL. In this case, - * the calling application will have to g_object_ref() the @selected_volume and - * keep it around to use it in the callback. - * - * The @container and all its contents are destroyed after the user - * dismisses the popup. The popup is re-created (and thus, this signal is - * emitted) every time the user activates the contextual menu. - * - * Before 3.18, the @container always was a #GtkMenu, and you were expected - * to add your items as #GtkMenuItems. Since 3.18, the popup may be implemented - * as a #GtkPopover, in which case @container will be something else, e.g. a - * #GtkBox, to which you may add #GtkModelButtons or other widgets, such as - * #GtkEntries, #GtkSpinButtons, etc. If your application can deal with this - * situation, you can set #NautilusGtkPlacesSidebar::populate-all to %TRUE to request - * that this signal is emitted for populating popovers as well. - * - * Since: 3.10 - */ - places_sidebar_signals [POPULATE_POPUP] = - g_signal_new ("populate-popup", - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NautilusGtkPlacesSidebarClass, populate_popup), - NULL, NULL, - NULL, - G_TYPE_NONE, 3, - GTK_TYPE_WIDGET, - G_TYPE_FILE, - G_TYPE_VOLUME); + NAUTILUS_TYPE_OPEN_FLAGS); - /** + /* * NautilusGtkPlacesSidebar::show-error-message: * @sidebar: the object which received the signal. * @primary: primary message with a summary of the error to show. @@ -4510,8 +4105,6 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) * 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.10 */ places_sidebar_signals [SHOW_ERROR_MESSAGE] = g_signal_new ("show-error-message", @@ -4524,38 +4117,14 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) G_TYPE_STRING, G_TYPE_STRING); - /** - * NautilusGtkPlacesSidebar::show-connect-to-server: - * @sidebar: the object which received the signal. - * - * The places sidebar emits this signal when it needs the calling - * application to present an way to connect directly to a network server. - * For example, the application may bring up a dialog box asking for - * a URL like "sftp://ftp.example.com". It is up to the application to create - * the corresponding mount by using, for example, g_file_mount_enclosing_volume(). - * - * Deprecated: 3.18: use the #NautilusGtkPlacesSidebar::show-other-locations signal - * to connect to network servers. - */ - places_sidebar_signals [SHOW_CONNECT_TO_SERVER] = - g_signal_new ("show-connect-to-server", - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NautilusGtkPlacesSidebarClass, show_connect_to_server), - NULL, NULL, - NULL, - G_TYPE_NONE, 0); - - /** + /* * NautilusGtkPlacesSidebar::show-enter-location: * @sidebar: the object which received the signal. * * The places sidebar emits this signal when it needs the calling - * application to present an way to directly enter a location. + * application to present a way to directly enter a location. * For example, the application may bring up a dialog box asking for * a URL like "http://http.example.com". - * - * Since: 3.14 */ places_sidebar_signals [SHOW_ENTER_LOCATION] = g_signal_new ("show-enter-location", @@ -4566,13 +4135,13 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) NULL, G_TYPE_NONE, 0); - /** + /* * NautilusGtkPlacesSidebar::drag-action-requested: * @sidebar: the object which received the signal. - * @context: (type Gdk.DragContext): #GdkDragContext with information about the drag operation - * @dest_file: (type Gio.File): #GFile with the tentative location that is being hovered for a drop - * @source_file_list: (type GLib.List) (element-type GFile) (transfer none): - * List of #GFile that are being dragged + * @drop: (type Gdk.Drop): GdkDrop with information about the drag operation + * @dest_file: (type Gio.File): GFile with the tentative location that is being hovered for a drop + * @source_file_list: (type GLib.SList) (element-type GFile) (transfer none): + * List of GFile that are being dragged * * When the user starts a drag-and-drop operation and the sidebar needs * to ask the application for which drag action to perform, then the @@ -4584,11 +4153,9 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) * * The drag action to use must be the return value of the signal handler. * - * Returns: The drag action to use, for example, #GDK_ACTION_COPY - * or #GDK_ACTION_MOVE, or 0 if no action is allowed here (i.e. drops + * Returns: The drag action to use, for example, GDK_ACTION_COPY + * or GDK_ACTION_MOVE, or 0 if no action is allowed here (i.e. drops * are not allowed in the specified @dest_file). - * - * Since: 3.10 */ places_sidebar_signals [DRAG_ACTION_REQUESTED] = g_signal_new ("drag-action-requested", @@ -4597,12 +4164,11 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) G_STRUCT_OFFSET (NautilusGtkPlacesSidebarClass, drag_action_requested), NULL, NULL, NULL, - G_TYPE_INT, 3, - GDK_TYPE_DRAG_CONTEXT, + GDK_TYPE_DRAG_ACTION, 2, G_TYPE_OBJECT, - G_TYPE_POINTER /* GList of GFile */ ); + GDK_TYPE_FILE_LIST); - /** + /* * NautilusGtkPlacesSidebar::drag-action-ask: * @sidebar: the object which received the signal. * @actions: Possible drag actions that need to be asked for. @@ -4612,8 +4178,6 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) * * Returns: the final drag action that the sidebar should pass to the drag side * of the drag-and-drop operation. - * - * Since: 3.10 */ places_sidebar_signals [DRAG_ACTION_ASK] = g_signal_new ("drag-action-ask", @@ -4622,15 +4186,15 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) G_STRUCT_OFFSET (NautilusGtkPlacesSidebarClass, drag_action_ask), NULL, NULL, NULL, - G_TYPE_INT, 1, - G_TYPE_INT); + GDK_TYPE_DRAG_ACTION, 1, + GDK_TYPE_DRAG_ACTION); - /** + /* * NautilusGtkPlacesSidebar::drag-perform-drop: * @sidebar: the object which received the signal. - * @dest_file: (type Gio.File): Destination #GFile. - * @source_file_list: (type GLib.List) (element-type GFile) (transfer none): - * #GList of #GFile that got dropped. + * @dest_file: (type Gio.File): Destination GFile. + * @source_file_list: (type GLib.SList) (element-type GFile) (transfer none): + * GSList of GFile that got dropped. * @action: Drop action to perform. * * The places sidebar emits this signal when the user completes a @@ -4638,8 +4202,6 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) * destination. This item is in the @dest_file, and the * @source_file_list has the list of files that are dropped into it and * which should be copied/moved/etc. based on the specified @action. - * - * Since: 3.10 */ places_sidebar_signals [DRAG_PERFORM_DROP] = g_signal_new ("drag-perform-drop", @@ -4650,46 +4212,19 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) NULL, G_TYPE_NONE, 3, G_TYPE_OBJECT, - G_TYPE_POINTER, /* GList of GFile */ - G_TYPE_INT); + GDK_TYPE_FILE_LIST, + GDK_TYPE_DRAG_ACTION); - /** - * NautilusGtkPlacesSidebar::show-other-locations: - * @sidebar: the object which received the signal. - * - * The places sidebar emits this signal when it needs the calling - * application to present a way to show other locations e.g. drives - * and network access points. - * For example, the application may bring up a page showing persistent - * volumes and discovered network addresses. - * - * Deprecated: 3.20: use the #NautilusGtkPlacesSidebar::show-other-locations-with-flags - * which includes the open flags in order to allow the user to specify to open - * in a new tab or window, in a similar way than #NautilusGtkPlacesSidebar::open-location - * - * Since: 3.18 - */ - places_sidebar_signals [SHOW_OTHER_LOCATIONS] = - g_signal_new ("show-other-locations", - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_FIRST | G_SIGNAL_DEPRECATED, - G_STRUCT_OFFSET (NautilusGtkPlacesSidebarClass, show_other_locations), - NULL, NULL, - NULL, - G_TYPE_NONE, 0); - - /** + /* * NautilusGtkPlacesSidebar::show-other-locations-with-flags: * @sidebar: the object which received the signal. - * @open_flags: a single value from #NautilusGtkPlacesOpenFlags specifying how it should be opened. + * @open_flags: a single value from NautilusGtkPlacesOpenFlags specifying how it should be opened. * * The places sidebar emits this signal when it needs the calling * application to present a way to show other locations e.g. drives * and network access points. * For example, the application may bring up a page showing persistent * volumes and discovered network addresses. - * - * Since: 3.20 */ places_sidebar_signals [SHOW_OTHER_LOCATIONS_WITH_FLAGS] = g_signal_new ("show-other-locations-with-flags", @@ -4699,19 +4234,17 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) NULL, NULL, NULL, G_TYPE_NONE, 1, - GTK_TYPE_PLACES_OPEN_FLAGS); + NAUTILUS_TYPE_OPEN_FLAGS); - /** + /* * NautilusGtkPlacesSidebar::mount: * @sidebar: the object which received the signal. - * @mount_operation: the #GMountOperation that is going to start. + * @mount_operation: the GMountOperation that is going to start. * * The places sidebar emits this signal when it starts a new operation * because the user clicked on some location that needs mounting. - * In this way the application using the #NautilusGtkPlacesSidebar can track the + * In this way the application using the NautilusGtkPlacesSidebar can track the * progress of the operation and, for example, show a notification. - * - * Since: 3.20 */ places_sidebar_signals [MOUNT] = g_signal_new ("mount", @@ -4723,17 +4256,15 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) G_TYPE_NONE, 1, G_TYPE_MOUNT_OPERATION); - /** + /* * NautilusGtkPlacesSidebar::unmount: * @sidebar: the object which received the signal. - * @mount_operation: the #GMountOperation that is going to start. + * @mount_operation: the GMountOperation that is going to start. * * The places sidebar emits this signal when it starts a new operation * because the user for example ejected some drive or unmounted a mount. - * In this way the application using the #NautilusGtkPlacesSidebar can track the + * In this way the application using the NautilusGtkPlacesSidebar can track the * progress of the operation and, for example, show a notification. - * - * Since: 3.20 */ places_sidebar_signals [UNMOUNT] = g_signal_new ("unmount", @@ -4746,18 +4277,15 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) 1, G_TYPE_MOUNT_OPERATION); - /** + /* * NautilusGtkPlacesSidebar::show-starred-location: - * @sidebar: the object which received the signal. - * @open_flags: a single value from #NautilusGtkPlacesOpenFlags specifying how the - * starred file should be opened. + * @sidebar: the object which received the signal + * @flags: the flags for the operation * * The places sidebar emits this signal when it needs the calling * application to present a way to show the starred files. In GNOME, * starred files are implemented by setting the nao:predefined-tag-favorite * tag in the tracker database. - * - * Since: 3.22.26 */ places_sidebar_signals [SHOW_STARRED_LOCATION] = g_signal_new ("show-starred-location", @@ -4767,103 +4295,73 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class) NULL, NULL, NULL, G_TYPE_NONE, 1, - GTK_TYPE_PLACES_OPEN_FLAGS); + NAUTILUS_TYPE_OPEN_FLAGS); properties[PROP_LOCATION] = g_param_spec_object ("location", "Location to Select", "The location to highlight in the sidebar", G_TYPE_FILE, - G_PARAM_READWRITE); + G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); 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, + NAUTILUS_TYPE_OPEN_FLAGS, NAUTILUS_GTK_PLACES_OPEN_NORMAL, - G_PARAM_READWRITE); + G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); properties[PROP_SHOW_RECENT] = g_param_spec_boolean ("show-recent", "Show recent files", "Whether the sidebar includes a builtin shortcut for recent files", TRUE, - G_PARAM_READWRITE); + G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); properties[PROP_SHOW_DESKTOP] = g_param_spec_boolean ("show-desktop", - "Show 'Desktop'", + "Show “Desktop”", "Whether the sidebar includes a builtin shortcut to the Desktop folder", TRUE, - G_PARAM_READWRITE); - properties[PROP_SHOW_CONNECT_TO_SERVER] = - g_param_spec_boolean ("show-connect-to-server", - "Show 'Connect to Server'", - "Whether the sidebar includes a builtin shortcut to a 'Connect to server' dialog", - FALSE, - G_PARAM_READWRITE | G_PARAM_DEPRECATED); + G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); properties[PROP_SHOW_ENTER_LOCATION] = g_param_spec_boolean ("show-enter-location", - "Show 'Enter Location'", + "Show “Enter Location”", "Whether the sidebar includes a builtin shortcut to manually enter a location", FALSE, - G_PARAM_READWRITE); - properties[PROP_LOCAL_ONLY] = - g_param_spec_boolean ("local-only", - "Local Only", - "Whether the sidebar only includes local files", - FALSE, - G_PARAM_READWRITE); + G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); properties[PROP_SHOW_TRASH] = g_param_spec_boolean ("show-trash", - "Show 'Trash'", + "Show “Trash”", "Whether the sidebar includes a builtin shortcut to the Trash location", TRUE, - G_PARAM_READWRITE); + G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); properties[PROP_SHOW_OTHER_LOCATIONS] = g_param_spec_boolean ("show-other-locations", - "Show 'Other locations'", + "Show “Other locations”", "Whether the sidebar includes an item to show external locations", - FALSE, - G_PARAM_READWRITE); + TRUE, + G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); properties[PROP_SHOW_STARRED_LOCATION] = g_param_spec_boolean ("show-starred-location", "Show “Starred Location”", "Whether the sidebar includes an item to show starred files", FALSE, - G_PARAM_READWRITE); - - - /** - * NautilusGtkPlacesSidebar:populate-all: - * - * If :populate-all is %TRUE, the #NautilusGtkPlacesSidebar::populate-popup signal - * is also emitted for popovers. - * - * Since: 3.18 - */ - properties[PROP_POPULATE_ALL] = - g_param_spec_boolean ("populate-all", - "Populate all", - "Whether to emit ::populate-popup for popups that are not menus", - FALSE, - G_PARAM_READWRITE); + G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties); gtk_widget_class_set_css_name (widget_class, "placessidebar"); } -/** +/* * nautilus_gtk_places_sidebar_new: * - * Creates a new #NautilusGtkPlacesSidebar widget. + * Creates a new NautilusGtkPlacesSidebar widget. * * The application should connect to at least the - * #NautilusGtkPlacesSidebar::open-location signal to be notified + * NautilusGtkPlacesSidebar::open-location signal to be notified * when the user makes a selection in the sidebar. * - * Returns: a newly created #NautilusGtkPlacesSidebar - * - * Since: 3.10 + * Returns: a newly created NautilusGtkPlacesSidebar */ GtkWidget * nautilus_gtk_places_sidebar_new (void) @@ -4871,9 +4369,7 @@ nautilus_gtk_places_sidebar_new (void) return GTK_WIDGET (g_object_new (nautilus_gtk_places_sidebar_get_type (), NULL)); } -/* Public methods for NautilusGtkPlacesSidebar */ - -/** +/* * nautilus_gtk_places_sidebar_set_open_flags: * @sidebar: a places sidebar * @flags: Bitmask of modes in which the calling application can open locations @@ -4887,14 +4383,12 @@ nautilus_gtk_places_sidebar_new (void) * application can open new locations, so that the sidebar can display (or not) * the “Open in new tab” and “Open in new window” menu items as appropriate. * - * When the #NautilusGtkPlacesSidebar::open-location signal is emitted, its flags + * When the NautilusGtkPlacesSidebar::open-location signal is emitted, its flags * argument will be set to one of the @flags that was passed in * nautilus_gtk_places_sidebar_set_open_flags(). * - * Passing 0 for @flags will cause #NAUTILUS_GTK_PLACES_OPEN_NORMAL to always be sent + * Passing 0 for @flags will cause NAUTILUS_GTK_PLACES_OPEN_NORMAL to always be sent * to callbacks for the “open-location” signal. - * - * Since: 3.10 */ void nautilus_gtk_places_sidebar_set_open_flags (NautilusGtkPlacesSidebar *sidebar, @@ -4909,15 +4403,13 @@ nautilus_gtk_places_sidebar_set_open_flags (NautilusGtkPlacesSidebar *sidebar, } } -/** +/* * nautilus_gtk_places_sidebar_get_open_flags: - * @sidebar: a #NautilusGtkPlacesSidebar + * @sidebar: a NautilusGtkPlacesSidebar * * Gets the open flags. * - * Returns: the #NautilusGtkPlacesOpenFlags of @sidebar - * - * Since: 3.10 + * Returns: the NautilusGtkPlacesOpenFlags of @sidebar */ NautilusGtkPlacesOpenFlags nautilus_gtk_places_sidebar_get_open_flags (NautilusGtkPlacesSidebar *sidebar) @@ -4927,7 +4419,7 @@ nautilus_gtk_places_sidebar_get_open_flags (NautilusGtkPlacesSidebar *sidebar) return sidebar->open_flags; } -/** +/* * nautilus_gtk_places_sidebar_set_location: * @sidebar: a places sidebar * @location: (nullable): location to select, or %NULL for no current path @@ -4937,17 +4429,14 @@ nautilus_gtk_places_sidebar_get_open_flags (NautilusGtkPlacesSidebar *sidebar) * @sidebar will highlight that location if it is being shown in the list of * places, or it will unhighlight everything if the @location is not among the * places in the list. - * - * Since: 3.10 */ void nautilus_gtk_places_sidebar_set_location (NautilusGtkPlacesSidebar *sidebar, GFile *location) { - GList *children; - GList *child; - gchar *row_uri; - gchar *uri; + GtkWidget *row; + char *row_uri; + char *uri; gboolean found = FALSE; g_return_if_fail (NAUTILUS_IS_GTK_PLACES_SIDEBAR (sidebar)); @@ -4965,14 +4454,18 @@ nautilus_gtk_places_sidebar_set_location (NautilusGtkPlacesSidebar *sidebar, uri = g_file_get_uri (location); - children = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box)); - for (child = children; child != NULL && !found; child = child->next) + for (row = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box)); + row != NULL && !found; + row = gtk_widget_get_next_sibling (row)) { - g_object_get (child->data, "uri", &row_uri, NULL); + if (!GTK_IS_LIST_BOX_ROW (row)) + continue; + + g_object_get (row, "uri", &row_uri, NULL); if (row_uri != NULL && g_strcmp0 (row_uri, uri) == 0) { gtk_list_box_select_row (GTK_LIST_BOX (sidebar->list_box), - GTK_LIST_BOX_ROW (child->data)); + GTK_LIST_BOX_ROW (row)); found = TRUE; } @@ -4980,13 +4473,12 @@ nautilus_gtk_places_sidebar_set_location (NautilusGtkPlacesSidebar *sidebar, } g_free (uri); - g_list_free (children); out: g_object_notify_by_pspec (G_OBJECT (sidebar), properties[PROP_LOCATION]); } -/** +/* * nautilus_gtk_places_sidebar_get_location: * @sidebar: a places sidebar * @@ -4995,15 +4487,10 @@ nautilus_gtk_places_sidebar_set_location (NautilusGtkPlacesSidebar *sidebar, * been called with a location that is not among the sidebar’s list of places to * show. * - * You can use this function to get the selection in the @sidebar. Also, if you - * connect to the #NautilusGtkPlacesSidebar::populate-popup signal, you can use this - * function to get the location that is being referred to during the callbacks - * for your menu items. + * You can use this function to get the selection in the @sidebar. * - * Returns: (nullable) (transfer full): a #GFile with the selected location, or + * Returns: (nullable) (transfer full): a GFile with the selected location, or * %NULL if nothing is visually selected. - * - * Since: 3.10 */ GFile * nautilus_gtk_places_sidebar_get_location (NautilusGtkPlacesSidebar *sidebar) @@ -5018,7 +4505,7 @@ nautilus_gtk_places_sidebar_get_location (NautilusGtkPlacesSidebar *sidebar) if (selected) { - gchar *uri; + char *uri; g_object_get (selected, "uri", &uri, NULL); file = g_file_new_for_uri (uri); @@ -5028,11 +4515,11 @@ nautilus_gtk_places_sidebar_get_location (NautilusGtkPlacesSidebar *sidebar) return file; } -gchar * +char * nautilus_gtk_places_sidebar_get_location_title (NautilusGtkPlacesSidebar *sidebar) { GtkListBoxRow *selected; - gchar *title; + char *title; g_return_val_if_fail (sidebar != NULL, NULL); @@ -5045,7 +4532,7 @@ nautilus_gtk_places_sidebar_get_location_title (NautilusGtkPlacesSidebar *sideba return title; } -/** +/* * nautilus_gtk_places_sidebar_set_show_recent: * @sidebar: a places sidebar * @show_recent: whether to show an item for recent files @@ -5054,8 +4541,6 @@ nautilus_gtk_places_sidebar_get_location_title (NautilusGtkPlacesSidebar *sideba * The default value for this option is determined by the desktop * environment, but this function can be used to override it on a * per-application basis. - * - * Since: 3.18 */ void nautilus_gtk_places_sidebar_set_show_recent (NautilusGtkPlacesSidebar *sidebar, @@ -5074,15 +4559,13 @@ nautilus_gtk_places_sidebar_set_show_recent (NautilusGtkPlacesSidebar *sidebar, } } -/** +/* * nautilus_gtk_places_sidebar_get_show_recent: * @sidebar: a places sidebar * * Returns the value previously set with nautilus_gtk_places_sidebar_set_show_recent() * * Returns: %TRUE if the sidebar will display a builtin shortcut for recent files - * - * Since: 3.18 */ gboolean nautilus_gtk_places_sidebar_get_show_recent (NautilusGtkPlacesSidebar *sidebar) @@ -5092,7 +4575,7 @@ nautilus_gtk_places_sidebar_get_show_recent (NautilusGtkPlacesSidebar *sidebar) return sidebar->show_recent; } -/** +/* * nautilus_gtk_places_sidebar_set_show_desktop: * @sidebar: a places sidebar * @show_desktop: whether to show an item for the Desktop folder @@ -5101,8 +4584,6 @@ nautilus_gtk_places_sidebar_get_show_recent (NautilusGtkPlacesSidebar *sidebar) * The default value for this option is determined by the desktop * environment and the user’s configuration, but this function can be * used to override it on a per-application basis. - * - * Since: 3.10 */ void nautilus_gtk_places_sidebar_set_show_desktop (NautilusGtkPlacesSidebar *sidebar, @@ -5125,15 +4606,13 @@ nautilus_gtk_places_sidebar_set_show_desktop (NautilusGtkPlacesSidebar *sidebar, } } -/** +/* * nautilus_gtk_places_sidebar_get_show_desktop: * @sidebar: a places sidebar * * Returns the value previously set with nautilus_gtk_places_sidebar_set_show_desktop() * * Returns: %TRUE if the sidebar will display a builtin shortcut to the desktop folder. - * - * Since: 3.10 */ gboolean nautilus_gtk_places_sidebar_get_show_desktop (NautilusGtkPlacesSidebar *sidebar) @@ -5143,58 +4622,7 @@ nautilus_gtk_places_sidebar_get_show_desktop (NautilusGtkPlacesSidebar *sidebar) return sidebar->show_desktop; } -/** - * nautilus_gtk_places_sidebar_set_show_connect_to_server: - * @sidebar: a places sidebar - * @show_connect_to_server: whether to show an item for the Connect to Server command - * - * Sets whether the @sidebar should show an item for connecting to a network server; - * this is off by default. An application may want to turn this on if it implements - * a way for the user to connect to network servers directly. - * - * If you enable this, you should connect to the - * #NautilusGtkPlacesSidebar::show-connect-to-server signal. - * - * Since: 3.10 - * - * Deprecated: 3.18: It is recommended to group this functionality with the drives - * and network location under the new 'Other Location' item - */ -void -nautilus_gtk_places_sidebar_set_show_connect_to_server (NautilusGtkPlacesSidebar *sidebar, - gboolean show_connect_to_server) -{ - g_return_if_fail (NAUTILUS_IS_GTK_PLACES_SIDEBAR (sidebar)); - - show_connect_to_server = !!show_connect_to_server; - if (sidebar->show_connect_to_server != show_connect_to_server) - { - sidebar->show_connect_to_server = show_connect_to_server; - update_places (sidebar); - g_object_notify_by_pspec (G_OBJECT (sidebar), properties[PROP_SHOW_CONNECT_TO_SERVER]); - } -} - -/** - * nautilus_gtk_places_sidebar_get_show_connect_to_server: - * @sidebar: a places sidebar - * - * Returns the value previously set with nautilus_gtk_places_sidebar_set_show_connect_to_server() - * - * Returns: %TRUE if the sidebar will display a “Connect to Server” item. - * - * Deprecated: 3.18: It is recommended to group this functionality with the drives - * and network location under the new 'Other Location' item - */ -gboolean -nautilus_gtk_places_sidebar_get_show_connect_to_server (NautilusGtkPlacesSidebar *sidebar) -{ - g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_SIDEBAR (sidebar), FALSE); - - return sidebar->show_connect_to_server; -} - -/** +/* * nautilus_gtk_places_sidebar_set_show_enter_location: * @sidebar: a places sidebar * @show_enter_location: whether to show an item to enter a location @@ -5204,9 +4632,7 @@ nautilus_gtk_places_sidebar_get_show_connect_to_server (NautilusGtkPlacesSidebar * entering URLs is an expected user action. * * If you enable this, you should connect to the - * #NautilusGtkPlacesSidebar::show-enter-location signal. - * - * Since: 3.14 + * NautilusGtkPlacesSidebar::show-enter-location signal. */ void nautilus_gtk_places_sidebar_set_show_enter_location (NautilusGtkPlacesSidebar *sidebar, @@ -5223,15 +4649,13 @@ nautilus_gtk_places_sidebar_set_show_enter_location (NautilusGtkPlacesSidebar *s } } -/** +/* * nautilus_gtk_places_sidebar_get_show_enter_location: * @sidebar: a places sidebar * * Returns the value previously set with nautilus_gtk_places_sidebar_set_show_enter_location() * * Returns: %TRUE if the sidebar will display an “Enter Location” item. - * - * Since: 3.14 */ gboolean nautilus_gtk_places_sidebar_get_show_enter_location (NautilusGtkPlacesSidebar *sidebar) @@ -5241,7 +4665,7 @@ nautilus_gtk_places_sidebar_get_show_enter_location (NautilusGtkPlacesSidebar *s return sidebar->show_enter_location; } -/** +/* * nautilus_gtk_places_sidebar_set_show_other_locations: * @sidebar: a places sidebar * @show_other_locations: whether to show an item for the Other Locations view @@ -5253,9 +4677,7 @@ nautilus_gtk_places_sidebar_get_show_enter_location (NautilusGtkPlacesSidebar *s * see and interact with drives and network servers directly. * * If you enable this, you should connect to the - * #NautilusGtkPlacesSidebar::show-other-locations signal. - * - * Since: 3.18 + * NautilusGtkPlacesSidebar::show-other-locations-with-flags signal. */ void nautilus_gtk_places_sidebar_set_show_other_locations (NautilusGtkPlacesSidebar *sidebar, @@ -5272,15 +4694,13 @@ nautilus_gtk_places_sidebar_set_show_other_locations (NautilusGtkPlacesSidebar * } } -/** +/* * nautilus_gtk_places_sidebar_get_show_other_locations: * @sidebar: a places sidebar * * Returns the value previously set with nautilus_gtk_places_sidebar_set_show_other_locations() * * Returns: %TRUE if the sidebar will display an “Other Locations” item. - * - * Since: 3.18 */ gboolean nautilus_gtk_places_sidebar_get_show_other_locations (NautilusGtkPlacesSidebar *sidebar) @@ -5290,14 +4710,12 @@ nautilus_gtk_places_sidebar_get_show_other_locations (NautilusGtkPlacesSidebar * return sidebar->show_other_locations; } -/** +/* * nautilus_gtk_places_sidebar_set_show_trash: * @sidebar: a places sidebar * @show_trash: whether to show an item for the Trash location * * Sets whether the @sidebar should show an item for the Trash location. - * - * Since: 3.18 */ void nautilus_gtk_places_sidebar_set_show_trash (NautilusGtkPlacesSidebar *sidebar, @@ -5314,15 +4732,13 @@ nautilus_gtk_places_sidebar_set_show_trash (NautilusGtkPlacesSidebar *sidebar, } } -/** +/* * nautilus_gtk_places_sidebar_get_show_trash: * @sidebar: a places sidebar * * Returns the value previously set with nautilus_gtk_places_sidebar_set_show_trash() * * Returns: %TRUE if the sidebar will display a “Trash” item. - * - * Since: 3.18 */ gboolean nautilus_gtk_places_sidebar_get_show_trash (NautilusGtkPlacesSidebar *sidebar) @@ -5332,67 +4748,7 @@ nautilus_gtk_places_sidebar_get_show_trash (NautilusGtkPlacesSidebar *sidebar) return sidebar->show_trash; } -/** - * nautilus_gtk_places_sidebar_set_local_only: - * @sidebar: a places sidebar - * @local_only: whether to show only local files - * - * Sets whether the @sidebar should only show local files. - * - * Since: 3.12 - */ -void -nautilus_gtk_places_sidebar_set_local_only (NautilusGtkPlacesSidebar *sidebar, - gboolean local_only) -{ - g_return_if_fail (NAUTILUS_IS_GTK_PLACES_SIDEBAR (sidebar)); - - local_only = !!local_only; - if (sidebar->local_only != local_only) - { - sidebar->local_only = local_only; - update_places (sidebar); - g_object_notify_by_pspec (G_OBJECT (sidebar), properties[PROP_LOCAL_ONLY]); - } -} - -/** - * nautilus_gtk_places_sidebar_get_local_only: - * @sidebar: a places sidebar - * - * Returns the value previously set with nautilus_gtk_places_sidebar_set_local_only(). - * - * Returns: %TRUE if the sidebar will only show local files. - * - * Since: 3.12 - */ -gboolean -nautilus_gtk_places_sidebar_get_local_only (NautilusGtkPlacesSidebar *sidebar) -{ - g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_SIDEBAR (sidebar), FALSE); - - return sidebar->local_only; -} - -static GSList * -find_shortcut_link (NautilusGtkPlacesSidebar *sidebar, - GFile *location) -{ - GSList *l; - - for (l = sidebar->shortcuts; l; l = l->next) - { - GFile *shortcut; - - shortcut = G_FILE (l->data); - if (g_file_equal (shortcut, location)) - return l; - } - - return NULL; -} - -/** +/* * nautilus_gtk_places_sidebar_add_shortcut: * @sidebar: a places sidebar * @location: location to add as an application-specific shortcut @@ -5407,8 +4763,6 @@ find_shortcut_link (NautilusGtkPlacesSidebar *sidebar, * across applications, and they are not persistent. If this function * is called multiple times with different locations, then they are added * to the sidebar’s list in the same order as the function is called. - * - * Since: 3.10 */ void nautilus_gtk_places_sidebar_add_shortcut (NautilusGtkPlacesSidebar *sidebar, @@ -5417,13 +4771,12 @@ nautilus_gtk_places_sidebar_add_shortcut (NautilusGtkPlacesSidebar *sidebar, g_return_if_fail (NAUTILUS_IS_GTK_PLACES_SIDEBAR (sidebar)); g_return_if_fail (G_IS_FILE (location)); - g_object_ref (location); - sidebar->shortcuts = g_slist_append (sidebar->shortcuts, location); + g_list_store_append (sidebar->shortcuts, location); update_places (sidebar); } -/** +/* * nautilus_gtk_places_sidebar_remove_shortcut: * @sidebar: a places sidebar * @location: location to remove @@ -5431,95 +4784,93 @@ nautilus_gtk_places_sidebar_add_shortcut (NautilusGtkPlacesSidebar *sidebar, * Removes an application-specific shortcut that has been previously been * inserted with nautilus_gtk_places_sidebar_add_shortcut(). If the @location is not a * shortcut in the sidebar, then nothing is done. - * - * Since: 3.10 */ void nautilus_gtk_places_sidebar_remove_shortcut (NautilusGtkPlacesSidebar *sidebar, GFile *location) { - GSList *link; - GFile *shortcut; + guint i, n; g_return_if_fail (NAUTILUS_IS_GTK_PLACES_SIDEBAR (sidebar)); g_return_if_fail (G_IS_FILE (location)); - link = find_shortcut_link (sidebar, location); - if (!link) - return; + n = g_list_model_get_n_items (G_LIST_MODEL (sidebar->shortcuts)); + for (i = 0; i < n; i++) + { + GFile *shortcut = g_list_model_get_item (G_LIST_MODEL (sidebar->shortcuts), i); - shortcut = G_FILE (link->data); - g_object_unref (shortcut); + if (shortcut == location) + { + g_list_store_remove (sidebar->shortcuts, i); + g_object_unref (shortcut); + update_places (sidebar); + return; + } - sidebar->shortcuts = g_slist_delete_link (sidebar->shortcuts, link); - update_places (sidebar); + g_object_unref (shortcut); + } } -/** +/* * nautilus_gtk_places_sidebar_list_shortcuts: * @sidebar: a places sidebar * - * Gets the list of shortcuts. + * Gets the list of shortcuts, as a list model containing GFile objects. * - * Returns: (element-type GFile) (transfer full): - * A #GSList of #GFile of the locations that have been added as - * application-specific shortcuts with nautilus_gtk_places_sidebar_add_shortcut(). - * To free this list, you can use - * |[<!-- language="C" --> - * g_slist_free_full (list, (GDestroyNotify) g_object_unref); - * ]| + * You should not modify the returned list model. Future changes to + * @sidebar may or may not affect the returned model. * - * Since: 3.10 + * Returns: (transfer full): a list model of GFiles that have been added as + * application-specific shortcuts with nautilus_gtk_places_sidebar_add_shortcut() */ -GSList * -nautilus_gtk_places_sidebar_list_shortcuts (NautilusGtkPlacesSidebar *sidebar) +GListModel * +nautilus_gtk_places_sidebar_get_shortcuts (NautilusGtkPlacesSidebar *sidebar) { g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_SIDEBAR (sidebar), NULL); - return g_slist_copy_deep (sidebar->shortcuts, (GCopyFunc) g_object_ref, NULL); + return G_LIST_MODEL (g_object_ref (sidebar->shortcuts)); } -/** +/* * nautilus_gtk_places_sidebar_get_nth_bookmark: * @sidebar: a places sidebar * @n: index of the bookmark to query * * This function queries the bookmarks added by the user to the places sidebar, - * and returns one of them. This function is used by #GtkFileChooser to implement - * the “Alt-1”, “Alt-2”, etc. shortcuts, which activate the cooresponding bookmark. + * and returns one of them. This function is used by GtkFileChooser to implement + * the “Alt-1”, “Alt-2”, etc. shortcuts, which activate the corresponding bookmark. * * Returns: (nullable) (transfer full): The bookmark specified by the index @n, or * %NULL if no such index exist. Note that the indices start at 0, even though * the file chooser starts them with the keyboard shortcut "Alt-1". - * - * Since: 3.10 */ GFile * nautilus_gtk_places_sidebar_get_nth_bookmark (NautilusGtkPlacesSidebar *sidebar, - gint n) + int n) { - GList *rows; - GList *l; + GtkWidget *row; int k; GFile *file; g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_SIDEBAR (sidebar), NULL); file = NULL; - rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box)); - l = rows; - k = 0; - while (l != NULL) + for (row = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box)); + row != NULL; + row = gtk_widget_get_next_sibling (row)) { - NautilusGtkPlacesSidebarPlaceType place_type; - gchar *uri; + NautilusGtkPlacesPlaceType place_type; + char *uri; + + if (!GTK_IS_LIST_BOX_ROW (row)) + continue; - g_object_get (l->data, + g_object_get (row, "place-type", &place_type, "uri", &uri, NULL); - if (place_type == PLACES_BOOKMARK) + if (place_type == NAUTILUS_GTK_PLACES_BOOKMARK) { if (k == n) { @@ -5530,20 +4881,15 @@ nautilus_gtk_places_sidebar_get_nth_bookmark (NautilusGtkPlacesSidebar *sidebar, k++; } g_free (uri); - l = l->next; } - g_list_free (rows); - return file; } -/** +/* * nautilus_gtk_places_sidebar_set_drop_targets_visible: * @sidebar: a places sidebar. * @visible: whether to show the valid targets or not. - * @context: drag context used to ask the source about the action that wants to - * perform, so hints are more accurate. * * Make the NautilusGtkPlacesSidebar show drop targets, so it can show the available * drop targets and a "new bookmark" row. This improves the Drag-and-Drop @@ -5554,18 +4900,17 @@ nautilus_gtk_places_sidebar_get_nth_bookmark (NautilusGtkPlacesSidebar *sidebar, * that might target the sidebar. The drop-targets-visible state will be unset * automatically if the drag finishes in the NautilusGtkPlacesSidebar. You only need * to unset the state when the drag ends on some other widget on your application. - * - * Since: 3.18 */ void nautilus_gtk_places_sidebar_set_drop_targets_visible (NautilusGtkPlacesSidebar *sidebar, - gboolean visible, - GdkDragContext *context) + gboolean visible) { + g_return_if_fail (NAUTILUS_IS_GTK_PLACES_SIDEBAR (sidebar)); + if (visible) { sidebar->drop_state = DROP_STATE_NEW_BOOKMARK_ARMED_PERMANENT; - start_drop_feedback (sidebar, NULL, context); + start_drop_feedback (sidebar, NULL); } else { @@ -5589,15 +4934,13 @@ nautilus_gtk_places_sidebar_set_drop_targets_visible (NautilusGtkPlacesSidebar * } } -/** +/* * nautilus_gtk_places_sidebar_set_show_starred_location: * @sidebar: a places sidebar * @show_starred_location: whether to show an item for Starred files * * If you enable this, you should connect to the - * #NautilusGtkPlacesSidebar::show-starred-location signal. - * - * Since: 3.22.26 + * NautilusGtkPlacesSidebar::show-starred-location signal. */ void nautilus_gtk_places_sidebar_set_show_starred_location (NautilusGtkPlacesSidebar *sidebar, @@ -5614,15 +4957,13 @@ nautilus_gtk_places_sidebar_set_show_starred_location (NautilusGtkPlacesSidebar } } -/** +/* * nautilus_gtk_places_sidebar_get_show_starred_location: * @sidebar: a places sidebar * * Returns the value previously set with nautilus_gtk_places_sidebar_set_show_starred_location() * * Returns: %TRUE if the sidebar will display a Starred item. - * - * Since: 3.22.26 */ gboolean nautilus_gtk_places_sidebar_get_show_starred_location (NautilusGtkPlacesSidebar *sidebar) diff --git a/src/gtk/nautilusgtkplacessidebar.h b/src/gtk/nautilusgtkplacessidebar.h deleted file mode 100644 index e7111ecf6..000000000 --- a/src/gtk/nautilusgtkplacessidebar.h +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* NautilusGtkPlacesSidebar - sidebar widget for places in the filesystem - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * This code comes from Nautilus, GNOME’s file manager. - * - * Authors : Mr Jamie McCracken (jamiemcc at blueyonder dot co dot uk) - * Federico Mena Quintero <federico@gnome.org> - */ - -#ifndef __NAUTILUS_GTK_PLACES_SIDEBAR_H__ -#define __NAUTILUS_GTK_PLACES_SIDEBAR_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#endif - -#include <gtk/gtkwidget.h> - -G_BEGIN_DECLS - -#define NAUTILUS_TYPE_GTK_PLACES_SIDEBAR (nautilus_gtk_places_sidebar_get_type ()) -#define NAUTILUS_GTK_PLACES_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_GTK_PLACES_SIDEBAR, NautilusGtkPlacesSidebar)) -#define NAUTILUS_GTK_PLACES_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_GTK_PLACES_SIDEBAR, NautilusGtkPlacesSidebarClass)) -#define NAUTILUS_IS_GTK_PLACES_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_GTK_PLACES_SIDEBAR)) -#define NAUTILUS_IS_GTK_PLACES_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_GTK_PLACES_SIDEBAR)) -#define NAUTILUS_GTK_PLACES_SIDEBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_GTK_PLACES_SIDEBAR, NautilusGtkPlacesSidebarClass)) - -typedef struct _NautilusGtkPlacesSidebar NautilusGtkPlacesSidebar; -typedef struct _NautilusGtkPlacesSidebarClass NautilusGtkPlacesSidebarClass; - -/** - * NautilusGtkPlacesOpenFlags: - * @NAUTILUS_GTK_PLACES_OPEN_NORMAL: This is the default mode that #NautilusGtkPlacesSidebar uses if no other flags - * are specified. It indicates that the calling application should open the selected location - * in the normal way, for example, in the folder view beside the sidebar. - * @NAUTILUS_GTK_PLACES_OPEN_NEW_TAB: When passed to nautilus_gtk_places_sidebar_set_open_flags(), this indicates - * that the application can open folders selected from the sidebar in new tabs. This value - * will be passed to the #NautilusGtkPlacesSidebar::open-location signal when the user selects - * that a location be opened in a new tab instead of in the standard fashion. - * @NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW: Similar to @NAUTILUS_GTK_PLACES_OPEN_NEW_TAB, but indicates that the application - * can open folders in new windows. - * - * These flags serve two purposes. First, the application can call nautilus_gtk_places_sidebar_set_open_flags() - * using these flags as a bitmask. This tells the sidebar that the application is able to open - * folders selected from the sidebar in various ways, for example, in new tabs or in new windows in - * addition to the normal mode. - * - * Second, when one of these values gets passed back to the application in the - * #NautilusGtkPlacesSidebar::open-location signal, it means that the application should - * open the selected location in the normal way, in a new tab, or in a new - * window. The sidebar takes care of determining the desired way to open the location, - * based on the modifier keys that the user is pressing at the time the selection is made. - * - * If the application never calls nautilus_gtk_places_sidebar_set_open_flags(), then the sidebar will only - * use #NAUTILUS_GTK_PLACES_OPEN_NORMAL in the #NautilusGtkPlacesSidebar::open-location signal. This is the - * default mode of operation. - */ -typedef enum { - NAUTILUS_GTK_PLACES_OPEN_NORMAL = 1 << 0, - NAUTILUS_GTK_PLACES_OPEN_NEW_TAB = 1 << 1, - NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW = 1 << 2 -} NautilusGtkPlacesOpenFlags; - -GDK_AVAILABLE_IN_3_10 -GType nautilus_gtk_places_sidebar_get_type (void) G_GNUC_CONST; -GDK_AVAILABLE_IN_3_10 -GtkWidget * nautilus_gtk_places_sidebar_new (void); - -GDK_AVAILABLE_IN_3_10 -NautilusGtkPlacesOpenFlags nautilus_gtk_places_sidebar_get_open_flags (NautilusGtkPlacesSidebar *sidebar); -GDK_AVAILABLE_IN_3_10 -void nautilus_gtk_places_sidebar_set_open_flags (NautilusGtkPlacesSidebar *sidebar, - NautilusGtkPlacesOpenFlags flags); - -GDK_AVAILABLE_IN_3_10 -GFile * nautilus_gtk_places_sidebar_get_location (NautilusGtkPlacesSidebar *sidebar); -GDK_AVAILABLE_IN_3_10 -void nautilus_gtk_places_sidebar_set_location (NautilusGtkPlacesSidebar *sidebar, - GFile *location); - -GDK_AVAILABLE_IN_3_18 -gboolean nautilus_gtk_places_sidebar_get_show_recent (NautilusGtkPlacesSidebar *sidebar); -GDK_AVAILABLE_IN_3_18 -void nautilus_gtk_places_sidebar_set_show_recent (NautilusGtkPlacesSidebar *sidebar, - gboolean show_recent); - -GDK_AVAILABLE_IN_3_10 -gboolean nautilus_gtk_places_sidebar_get_show_desktop (NautilusGtkPlacesSidebar *sidebar); -GDK_AVAILABLE_IN_3_10 -void nautilus_gtk_places_sidebar_set_show_desktop (NautilusGtkPlacesSidebar *sidebar, - gboolean show_desktop); - -GDK_DEPRECATED_IN_3_18 -gboolean nautilus_gtk_places_sidebar_get_show_connect_to_server (NautilusGtkPlacesSidebar *sidebar); -GDK_DEPRECATED_IN_3_18 -void nautilus_gtk_places_sidebar_set_show_connect_to_server (NautilusGtkPlacesSidebar *sidebar, - gboolean show_connect_to_server); -GDK_AVAILABLE_IN_3_14 -gboolean nautilus_gtk_places_sidebar_get_show_enter_location (NautilusGtkPlacesSidebar *sidebar); -GDK_AVAILABLE_IN_3_14 -void nautilus_gtk_places_sidebar_set_show_enter_location (NautilusGtkPlacesSidebar *sidebar, - gboolean show_enter_location); - -GDK_AVAILABLE_IN_3_12 -void nautilus_gtk_places_sidebar_set_local_only (NautilusGtkPlacesSidebar *sidebar, - gboolean local_only); -GDK_AVAILABLE_IN_3_12 -gboolean nautilus_gtk_places_sidebar_get_local_only (NautilusGtkPlacesSidebar *sidebar); - - -GDK_AVAILABLE_IN_3_10 -void nautilus_gtk_places_sidebar_add_shortcut (NautilusGtkPlacesSidebar *sidebar, - GFile *location); -GDK_AVAILABLE_IN_3_10 -void nautilus_gtk_places_sidebar_remove_shortcut (NautilusGtkPlacesSidebar *sidebar, - GFile *location); -GDK_AVAILABLE_IN_3_10 -GSList * nautilus_gtk_places_sidebar_list_shortcuts (NautilusGtkPlacesSidebar *sidebar); - -GDK_AVAILABLE_IN_3_10 -GFile * nautilus_gtk_places_sidebar_get_nth_bookmark (NautilusGtkPlacesSidebar *sidebar, - gint n); -GDK_AVAILABLE_IN_3_18 -void nautilus_gtk_places_sidebar_set_drop_targets_visible (NautilusGtkPlacesSidebar *sidebar, - gboolean visible, - GdkDragContext *context); -GDK_AVAILABLE_IN_3_18 -gboolean nautilus_gtk_places_sidebar_get_show_trash (NautilusGtkPlacesSidebar *sidebar); -GDK_AVAILABLE_IN_3_18 -void nautilus_gtk_places_sidebar_set_show_trash (NautilusGtkPlacesSidebar *sidebar, - gboolean show_trash); - -GDK_AVAILABLE_IN_3_18 -void nautilus_gtk_places_sidebar_set_show_other_locations (NautilusGtkPlacesSidebar *sidebar, - gboolean show_other_locations); -GDK_AVAILABLE_IN_3_18 -gboolean nautilus_gtk_places_sidebar_get_show_other_locations (NautilusGtkPlacesSidebar *sidebar); - -GDK_AVAILABLE_IN_3_22 -void nautilus_gtk_places_sidebar_set_show_starred_location (NautilusGtkPlacesSidebar *sidebar, - gboolean show_starred_location); -GDK_AVAILABLE_IN_3_22 -gboolean nautilus_gtk_places_sidebar_get_show_starred_location (NautilusGtkPlacesSidebar *sidebar); -G_END_DECLS - -#endif /* __NAUTILUS_GTK_PLACES_SIDEBAR_H__ */ diff --git a/src/gtk/nautilusgtkplacessidebarprivate.h b/src/gtk/nautilusgtkplacessidebarprivate.h index 6c6dd3daa..c1503ad70 100644 --- a/src/gtk/nautilusgtkplacessidebarprivate.h +++ b/src/gtk/nautilusgtkplacessidebarprivate.h @@ -22,38 +22,126 @@ #define __NAUTILUS_GTK_PLACES_SIDEBAR_PRIVATE_H__ #include <glib.h> -#include "nautilusgtkplacessidebar.h" +#include <gtk/gtk.h> G_BEGIN_DECLS +#define NAUTILUS_TYPE_GTK_PLACES_SIDEBAR (nautilus_gtk_places_sidebar_get_type ()) +#define NAUTILUS_GTK_PLACES_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_GTK_PLACES_SIDEBAR, NautilusGtkPlacesSidebar)) +#define NAUTILUS_GTK_PLACES_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_GTK_PLACES_SIDEBAR, NautilusGtkPlacesSidebarClass)) +#define NAUTILUS_IS_GTK_PLACES_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_GTK_PLACES_SIDEBAR)) +#define NAUTILUS_IS_GTK_PLACES_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_GTK_PLACES_SIDEBAR)) +#define NAUTILUS_GTK_PLACES_SIDEBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_GTK_PLACES_SIDEBAR, NautilusGtkPlacesSidebarClass)) + +typedef struct _NautilusGtkPlacesSidebar NautilusGtkPlacesSidebar; +typedef struct _NautilusGtkPlacesSidebarClass NautilusGtkPlacesSidebarClass; + +/* + * NautilusGtkPlacesOpenFlags: + * @NAUTILUS_GTK_PLACES_OPEN_NORMAL: This is the default mode that NautilusGtkPlacesSidebar uses if no other flags + * are specified. It indicates that the calling application should open the selected location + * in the normal way, for example, in the folder view beside the sidebar. + * @NAUTILUS_GTK_PLACES_OPEN_NEW_TAB: When passed to nautilus_gtk_places_sidebar_set_open_flags(), this indicates + * that the application can open folders selected from the sidebar in new tabs. This value + * will be passed to the NautilusGtkPlacesSidebar::open-location signal when the user selects + * that a location be opened in a new tab instead of in the standard fashion. + * @NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW: Similar to @NAUTILUS_GTK_PLACES_OPEN_NEW_TAB, but indicates that the application + * can open folders in new windows. + * + * These flags serve two purposes. First, the application can call nautilus_gtk_places_sidebar_set_open_flags() + * using these flags as a bitmask. This tells the sidebar that the application is able to open + * folders selected from the sidebar in various ways, for example, in new tabs or in new windows in + * addition to the normal mode. + * + * Second, when one of these values gets passed back to the application in the + * NautilusGtkPlacesSidebar::open-location signal, it means that the application should + * open the selected location in the normal way, in a new tab, or in a new + * window. The sidebar takes care of determining the desired way to open the location, + * based on the modifier keys that the user is pressing at the time the selection is made. + * + * If the application never calls nautilus_gtk_places_sidebar_set_open_flags(), then the sidebar will only + * use NAUTILUS_GTK_PLACES_OPEN_NORMAL in the NautilusGtkPlacesSidebar::open-location signal. This is the + * default mode of operation. + */ +typedef enum { + NAUTILUS_GTK_PLACES_OPEN_NORMAL = 1 << 0, + NAUTILUS_GTK_PLACES_OPEN_NEW_TAB = 1 << 1, + NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW = 1 << 2 +} NautilusGtkPlacesOpenFlags; + +GType nautilus_gtk_places_sidebar_get_type (void) G_GNUC_CONST; +GtkWidget * nautilus_gtk_places_sidebar_new (void); + +NautilusGtkPlacesOpenFlags nautilus_gtk_places_sidebar_get_open_flags (NautilusGtkPlacesSidebar *sidebar); +void nautilus_gtk_places_sidebar_set_open_flags (NautilusGtkPlacesSidebar *sidebar, + NautilusGtkPlacesOpenFlags flags); + +GFile * nautilus_gtk_places_sidebar_get_location (NautilusGtkPlacesSidebar *sidebar); +void nautilus_gtk_places_sidebar_set_location (NautilusGtkPlacesSidebar *sidebar, + GFile *location); + +gboolean nautilus_gtk_places_sidebar_get_show_recent (NautilusGtkPlacesSidebar *sidebar); +void nautilus_gtk_places_sidebar_set_show_recent (NautilusGtkPlacesSidebar *sidebar, + gboolean show_recent); + +gboolean nautilus_gtk_places_sidebar_get_show_desktop (NautilusGtkPlacesSidebar *sidebar); +void nautilus_gtk_places_sidebar_set_show_desktop (NautilusGtkPlacesSidebar *sidebar, + gboolean show_desktop); + +gboolean nautilus_gtk_places_sidebar_get_show_enter_location (NautilusGtkPlacesSidebar *sidebar); +void nautilus_gtk_places_sidebar_set_show_enter_location (NautilusGtkPlacesSidebar *sidebar, + gboolean show_enter_location); + +void nautilus_gtk_places_sidebar_add_shortcut (NautilusGtkPlacesSidebar *sidebar, + GFile *location); +void nautilus_gtk_places_sidebar_remove_shortcut (NautilusGtkPlacesSidebar *sidebar, + GFile *location); +GListModel * nautilus_gtk_places_sidebar_get_shortcuts (NautilusGtkPlacesSidebar *sidebar); + +GFile * nautilus_gtk_places_sidebar_get_nth_bookmark (NautilusGtkPlacesSidebar *sidebar, + int n); +void nautilus_gtk_places_sidebar_set_drop_targets_visible (NautilusGtkPlacesSidebar *sidebar, + gboolean visible); +gboolean nautilus_gtk_places_sidebar_get_show_trash (NautilusGtkPlacesSidebar *sidebar); +void nautilus_gtk_places_sidebar_set_show_trash (NautilusGtkPlacesSidebar *sidebar, + gboolean show_trash); + +void nautilus_gtk_places_sidebar_set_show_other_locations (NautilusGtkPlacesSidebar *sidebar, + gboolean show_other_locations); +gboolean nautilus_gtk_places_sidebar_get_show_other_locations (NautilusGtkPlacesSidebar *sidebar); + +void nautilus_gtk_places_sidebar_set_show_starred_location (NautilusGtkPlacesSidebar *sidebar, + gboolean show_starred_location); +gboolean nautilus_gtk_places_sidebar_get_show_starred_location (NautilusGtkPlacesSidebar *sidebar); + /* Keep order, since it's used for the sort functions */ typedef enum { - SECTION_INVALID, - SECTION_COMPUTER, - SECTION_MOUNTS, - SECTION_CLOUD, - SECTION_BOOKMARKS, - SECTION_OTHER_LOCATIONS, - N_SECTIONS -} NautilusGtkPlacesSidebarSectionType; + NAUTILUS_GTK_PLACES_SECTION_INVALID, + NAUTILUS_GTK_PLACES_SECTION_COMPUTER, + NAUTILUS_GTK_PLACES_SECTION_MOUNTS, + NAUTILUS_GTK_PLACES_SECTION_CLOUD, + NAUTILUS_GTK_PLACES_SECTION_BOOKMARKS, + NAUTILUS_GTK_PLACES_SECTION_OTHER_LOCATIONS, + NAUTILUS_GTK_PLACES_N_SECTIONS +} NautilusGtkPlacesSectionType; typedef enum { - PLACES_INVALID, - PLACES_BUILT_IN, - PLACES_XDG_DIR, - PLACES_MOUNTED_VOLUME, - PLACES_BOOKMARK, - PLACES_HEADING, - PLACES_CONNECT_TO_SERVER, - PLACES_ENTER_LOCATION, - PLACES_DROP_FEEDBACK, - PLACES_BOOKMARK_PLACEHOLDER, - PLACES_OTHER_LOCATIONS, - PLACES_STARRED_LOCATION, - N_PLACES -} NautilusGtkPlacesSidebarPlaceType; - -gchar *nautilus_gtk_places_sidebar_get_location_title (NautilusGtkPlacesSidebar *sidebar); + NAUTILUS_GTK_PLACES_INVALID, + NAUTILUS_GTK_PLACES_BUILT_IN, + NAUTILUS_GTK_PLACES_XDG_DIR, + NAUTILUS_GTK_PLACES_MOUNTED_VOLUME, + NAUTILUS_GTK_PLACES_BOOKMARK, + NAUTILUS_GTK_PLACES_HEADING, + NAUTILUS_GTK_PLACES_CONNECT_TO_SERVER, + NAUTILUS_GTK_PLACES_ENTER_LOCATION, + NAUTILUS_GTK_PLACES_DROP_FEEDBACK, + NAUTILUS_GTK_PLACES_BOOKMARK_PLACEHOLDER, + NAUTILUS_GTK_PLACES_OTHER_LOCATIONS, + NAUTILUS_GTK_PLACES_STARRED_LOCATION, + NAUTILUS_GTK_PLACES_N_PLACES +} NautilusGtkPlacesPlaceType; + +char *nautilus_gtk_places_sidebar_get_location_title (NautilusGtkPlacesSidebar *sidebar); G_END_DECLS diff --git a/src/gtk/nautilusgtkplacesview.c b/src/gtk/nautilusgtkplacesview.c index 62505c0e1..04fdb9fa4 100644 --- a/src/gtk/nautilusgtkplacesview.c +++ b/src/gtk/nautilusgtkplacesview.c @@ -19,6 +19,7 @@ #include "config.h" #include <glib/gi18n.h> #include <gtk/gtk.h> +#include "nautilus-enum-types.h" #include <gio/gio.h> #include <gio/gvfs.h> @@ -27,14 +28,11 @@ #include "nautilusgtkplacesviewprivate.h" #include "nautilusgtkplacesviewrowprivate.h" -/** - * SECTION:nautilusgtkplacesview - * @Short_description: Widget that displays persistent drives and manages mounted networks - * @Title: NautilusGtkPlacesView - * @See_also: #GtkFileChooser +/*< private > + * NautilusGtkPlacesView: * - * #NautilusGtkPlacesView is a stock widget that displays a list of persistent drives - * such as harddisk partitions and networks. #NautilusGtkPlacesView does not monitor + * NautilusGtkPlacesView is a widget that displays a list of persistent drives + * such as harddisk partitions and networks. NautilusGtkPlacesView does not monitor * removable devices. * * The places view displays drives and networks, and will automatically mount @@ -43,12 +41,27 @@ * shown at the network list. * * To make use of the places view, an application at least needs to connect - * to the #NautilusGtkPlacesView::open-location signal. This is emitted when the user + * to the NautilusGtkPlacesView::open-location signal. This is emitted when the user * selects a location to open in the view. */ -struct _NautilusGtkPlacesViewPrivate +struct _NautilusGtkPlacesViewClass { + GtkBoxClass parent_class; + + void (* open_location) (NautilusGtkPlacesView *view, + GFile *location, + NautilusGtkPlacesOpenFlags open_flags); + + void (* show_error_message) (NautilusGtkPlacesSidebar *sidebar, + const char *primary, + const char *secondary); +}; + +struct _NautilusGtkPlacesView +{ + GtkBox parent_instance; + GVolumeMonitor *volume_monitor; NautilusGtkPlacesOpenFlags open_flags; NautilusGtkPlacesOpenFlags current_open_flags; @@ -59,7 +72,7 @@ struct _NautilusGtkPlacesViewPrivate GCancellable *cancellable; - gchar *search_query; + char *search_query; GtkWidget *actionbar; GtkWidget *address_entry; @@ -83,7 +96,8 @@ struct _NautilusGtkPlacesViewPrivate GCancellable *networks_fetching_cancellable; - guint local_only : 1; + NautilusGtkPlacesViewRow *row_for_action; + guint should_open_location : 1; guint should_pulse_entry : 1; guint entry_pulse_timeout_id; @@ -98,13 +112,18 @@ struct _NautilusGtkPlacesViewPrivate static void mount_volume (NautilusGtkPlacesView *view, GVolume *volume); -static gboolean on_button_press_event (NautilusGtkPlacesViewRow *row, - GdkEventButton *event); - static void on_eject_button_clicked (GtkWidget *widget, NautilusGtkPlacesViewRow *row); -static gboolean on_row_popup_menu (NautilusGtkPlacesViewRow *row); +static gboolean on_row_popup_menu (GtkWidget *widget, + GVariant *args, + gpointer user_data); + +static void click_cb (GtkGesture *gesture, + int n_press, + double x, + double y, + gpointer user_data); static void populate_servers (NautilusGtkPlacesView *view); @@ -118,12 +137,11 @@ static void nautilus_gtk_places_view_set_loading (Nauti static void update_loading (NautilusGtkPlacesView *view); -G_DEFINE_TYPE_WITH_PRIVATE (NautilusGtkPlacesView, nautilus_gtk_places_view, GTK_TYPE_BOX) +G_DEFINE_TYPE (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, @@ -136,7 +154,7 @@ enum { LAST_SIGNAL }; -const gchar *unsupported_protocols [] = +const char *unsupported_protocols [] = { "file", "afc", "obex", "http", "trash", "burn", "computer", @@ -152,11 +170,7 @@ emit_open_location (NautilusGtkPlacesView *view, GFile *location, NautilusGtkPlacesOpenFlags open_flags) { - NautilusGtkPlacesViewPrivate *priv; - - priv = nautilus_gtk_places_view_get_instance_private (view); - - if ((open_flags & priv->open_flags) == 0) + if ((open_flags & view->open_flags) == 0) open_flags = NAUTILUS_GTK_PLACES_OPEN_NORMAL; g_signal_emit (view, places_view_signals[OPEN_LOCATION], 0, location, open_flags); @@ -164,8 +178,8 @@ emit_open_location (NautilusGtkPlacesView *view, static void emit_show_error_message (NautilusGtkPlacesView *view, - gchar *primary_message, - gchar *secondary_message) + char *primary_message, + char *secondary_message) { g_signal_emit (view, places_view_signals[SHOW_ERROR_MESSAGE], 0, primary_message, secondary_message); @@ -180,15 +194,13 @@ server_file_changed_cb (NautilusGtkPlacesView *view) static GBookmarkFile * server_list_load (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; GBookmarkFile *bookmarks; GError *error = NULL; - gchar *datadir; - gchar *filename; + char *datadir; + char *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); + datadir = g_build_filename (g_get_user_config_dir (), "gtk-4.0", NULL); filename = g_build_filename (datadir, "servers", NULL); g_mkdir_with_parents (datadir, 0700); @@ -207,13 +219,13 @@ server_list_load (NautilusGtkPlacesView *view) } /* Monitor the file in case it's modified outside this code */ - if (!priv->server_list_monitor) + if (!view->server_list_monitor) { - priv->server_list_file = g_file_new_for_path (filename); + view->server_list_file = g_file_new_for_path (filename); - if (priv->server_list_file) + if (view->server_list_file) { - priv->server_list_monitor = g_file_monitor_file (priv->server_list_file, + view->server_list_monitor = g_file_monitor_file (view->server_list_file, G_FILE_MONITOR_NONE, NULL, &error); @@ -225,14 +237,14 @@ server_list_load (NautilusGtkPlacesView *view) } else { - g_signal_connect_swapped (priv->server_list_monitor, + g_signal_connect_swapped (view->server_list_monitor, "changed", G_CALLBACK (server_file_changed_cb), view); } } - g_clear_object (&priv->server_list_file); + g_clear_object (&view->server_list_file); } g_free (datadir); @@ -244,9 +256,9 @@ server_list_load (NautilusGtkPlacesView *view) static void server_list_save (GBookmarkFile *bookmarks) { - gchar *filename; + char *filename; - filename = g_build_filename (g_get_user_config_dir (), "gtk-3.0", "servers", NULL); + filename = g_build_filename (g_get_user_config_dir (), "gtk-4.0", "servers", NULL); g_bookmark_file_to_file (bookmarks, filename, NULL); g_free (filename); } @@ -258,8 +270,9 @@ server_list_add_server (NautilusGtkPlacesView *view, GBookmarkFile *bookmarks; GFileInfo *info; GError *error; - gchar *title; - gchar *uri; + char *title; + char *uri; + GDateTime *now; error = NULL; bookmarks = server_list_load (view); @@ -277,7 +290,9 @@ server_list_add_server (NautilusGtkPlacesView *view, 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); + now = g_date_time_new_now_utc (); + g_bookmark_file_set_visited_date_time (bookmarks, uri, now); + g_date_time_unref (now); g_bookmark_file_add_application (bookmarks, uri, NULL, NULL); server_list_save (bookmarks); @@ -290,7 +305,7 @@ server_list_add_server (NautilusGtkPlacesView *view, static void server_list_remove_server (NautilusGtkPlacesView *view, - const gchar *uri) + const char *uri) { GBookmarkFile *bookmarks; @@ -311,11 +326,11 @@ get_toplevel (GtkWidget *widget) { GtkWidget *toplevel; - toplevel = gtk_widget_get_toplevel (widget); - if (!gtk_widget_is_toplevel (toplevel)) - return NULL; - else + toplevel = GTK_WIDGET (gtk_widget_get_root (widget)); + if (GTK_IS_WINDOW (toplevel)) return GTK_WINDOW (toplevel); + else + return NULL; } static void @@ -324,26 +339,16 @@ set_busy_cursor (NautilusGtkPlacesView *view, { 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; - display = gtk_widget_get_display (widget); - if (busy) - cursor = gdk_cursor_new_from_name (display, "progress"); + gtk_widget_set_cursor_from_name (widget, "progress"); else - cursor = NULL; - - gdk_window_set_cursor (gtk_widget_get_window (widget), cursor); - gdk_display_flush (display); - - if (cursor) - g_object_unref (cursor); + gtk_widget_set_cursor (widget, NULL); } /* Activates the given row, with the given flags as parameter */ @@ -352,12 +357,10 @@ activate_row (NautilusGtkPlacesView *view, NautilusGtkPlacesViewRow *row, NautilusGtkPlacesOpenFlags flags) { - 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); @@ -380,7 +383,7 @@ activate_row (NautilusGtkPlacesView *view, * When the row is activated, the unmounted volume shall * be mounted and opened right after. */ - priv->should_open_location = TRUE; + view->should_open_location = TRUE; nautilus_gtk_places_view_row_set_busy (row, TRUE); mount_volume (view, volume); @@ -390,47 +393,46 @@ activate_row (NautilusGtkPlacesView *view, static void update_places (NautilusGtkPlacesView *view); static void -nautilus_gtk_places_view_destroy (GtkWidget *widget) +nautilus_gtk_places_view_finalize (GObject *object) { - NautilusGtkPlacesView *self = NAUTILUS_GTK_PLACES_VIEW (widget); - NautilusGtkPlacesViewPrivate *priv = nautilus_gtk_places_view_get_instance_private (self); + NautilusGtkPlacesView *view = (NautilusGtkPlacesView *)object; - priv->destroyed = 1; + if (view->entry_pulse_timeout_id > 0) + g_source_remove (view->entry_pulse_timeout_id); - g_signal_handlers_disconnect_by_func (priv->volume_monitor, update_places, widget); + g_clear_pointer (&view->search_query, g_free); + g_clear_object (&view->server_list_file); + g_clear_object (&view->server_list_monitor); + g_clear_object (&view->volume_monitor); + g_clear_object (&view->network_monitor); + g_clear_object (&view->cancellable); + g_clear_object (&view->networks_fetching_cancellable); + g_clear_object (&view->path_size_group); + g_clear_object (&view->space_size_group); - if (priv->network_monitor) - g_signal_handlers_disconnect_by_func (priv->network_monitor, update_places, widget); - - if (priv->server_list_monitor) - g_signal_handlers_disconnect_by_func (priv->server_list_monitor, server_file_changed_cb, widget); - - g_cancellable_cancel (priv->cancellable); - g_cancellable_cancel (priv->networks_fetching_cancellable); - - GTK_WIDGET_CLASS (nautilus_gtk_places_view_parent_class)->destroy (widget); + G_OBJECT_CLASS (nautilus_gtk_places_view_parent_class)->finalize (object); } static void -nautilus_gtk_places_view_finalize (GObject *object) +nautilus_gtk_places_view_dispose (GObject *object) { - NautilusGtkPlacesView *self = (NautilusGtkPlacesView *)object; - NautilusGtkPlacesViewPrivate *priv = nautilus_gtk_places_view_get_instance_private (self); + NautilusGtkPlacesView *view = (NautilusGtkPlacesView *)object; - if (priv->entry_pulse_timeout_id > 0) - g_source_remove (priv->entry_pulse_timeout_id); + view->destroyed = 1; - g_clear_pointer (&priv->search_query, g_free); - g_clear_object (&priv->server_list_file); - g_clear_object (&priv->server_list_monitor); - g_clear_object (&priv->volume_monitor); - g_clear_object (&priv->network_monitor); - g_clear_object (&priv->cancellable); - g_clear_object (&priv->networks_fetching_cancellable); - g_clear_object (&priv->path_size_group); - g_clear_object (&priv->space_size_group); + g_signal_handlers_disconnect_by_func (view->volume_monitor, update_places, object); - G_OBJECT_CLASS (nautilus_gtk_places_view_parent_class)->finalize (object); + if (view->network_monitor) + g_signal_handlers_disconnect_by_func (view->network_monitor, update_places, object); + + if (view->server_list_monitor) + g_signal_handlers_disconnect_by_func (view->server_list_monitor, server_file_changed_cb, object); + + g_cancellable_cancel (view->cancellable); + g_cancellable_cancel (view->networks_fetching_cancellable); + g_clear_pointer (&view->popup_menu, gtk_widget_unparent); + + G_OBJECT_CLASS (nautilus_gtk_places_view_parent_class)->dispose (object); } static void @@ -443,14 +445,14 @@ nautilus_gtk_places_view_get_property (GObject *object, switch (prop_id) { - 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_OPEN_FLAGS: + g_value_set_flags (value, nautilus_gtk_places_view_get_open_flags (self)); + break; + case PROP_FETCHING_NETWORKS: g_value_set_boolean (value, nautilus_gtk_places_view_get_fetching_networks (self)); break; @@ -470,8 +472,8 @@ nautilus_gtk_places_view_set_property (GObject *object, switch (prop_id) { - case PROP_LOCAL_ONLY: - nautilus_gtk_places_view_set_local_only (self, g_value_get_boolean (value)); + case PROP_OPEN_FLAGS: + nautilus_gtk_places_view_set_open_flags (self, g_value_get_flags (value)); break; default: @@ -484,7 +486,7 @@ is_external_volume (GVolume *volume) { gboolean is_external; GDrive *drive; - gchar *id; + char *id; drive = g_volume_get_drive (volume); id = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_CLASS); @@ -505,7 +507,7 @@ is_external_volume (GVolume *volume) typedef struct { - gchar *uri; + char *uri; NautilusGtkPlacesView *view; } RemoveServerData; @@ -520,14 +522,12 @@ on_remove_server_button_clicked (RemoveServerData *data) static void populate_servers (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; GBookmarkFile *server_list; - GList *children; - gchar **uris; + GtkWidget *child; + char **uris; gsize num_uris; - gint i; + int i; - priv = nautilus_gtk_places_view_get_instance_private (view); server_list = server_list_load (view); if (!server_list) @@ -535,7 +535,7 @@ populate_servers (NautilusGtkPlacesView *view) uris = g_bookmark_file_get_uris (server_list, &num_uris); - gtk_stack_set_visible_child_name (GTK_STACK (priv->recent_servers_stack), + gtk_stack_set_visible_child_name (GTK_STACK (view->recent_servers_stack), num_uris > 0 ? "list" : "empty"); if (!uris) @@ -545,10 +545,10 @@ populate_servers (NautilusGtkPlacesView *view) } /* clear previous items */ - children = gtk_container_get_children (GTK_CONTAINER (priv->recent_servers_listbox)); - g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy); + while ((child = gtk_widget_get_first_child (GTK_WIDGET (view->recent_servers_listbox)))) + gtk_list_box_remove (GTK_LIST_BOX (view->recent_servers_listbox), child); - gtk_list_store_clear (priv->completion_store); + gtk_list_store_clear (view->completion_store); for (i = 0; i < num_uris; i++) { @@ -558,15 +558,15 @@ populate_servers (NautilusGtkPlacesView *view) GtkWidget *grid; GtkWidget *button; GtkWidget *label; - gchar *name; - gchar *dup_uri; + char *name; + char *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, + gtk_list_store_append (view->completion_store, &iter); + gtk_list_store_set (view->completion_store, &iter, 0, name, 1, uris[i], @@ -577,7 +577,6 @@ populate_servers (NautilusGtkPlacesView *view) grid = g_object_new (GTK_TYPE_GRID, "orientation", GTK_ORIENTATION_VERTICAL, - "border-width", 3, NULL); /* name of the connected uri, if any */ @@ -585,26 +584,26 @@ populate_servers (NautilusGtkPlacesView *view) 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); + gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); /* 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); + gtk_widget_add_css_class (label, "dim-label"); + gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); /* remove button */ - button = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_BUTTON); + button = gtk_button_new_from_icon_name ("window-close-symbolic"); gtk_widget_set_halign (button, GTK_ALIGN_END); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); - gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); - gtk_style_context_add_class (gtk_widget_get_style_context (button), "sidebar-button"); + gtk_button_set_has_frame (GTK_BUTTON (button), FALSE); + gtk_widget_add_css_class (button, "sidebar-button"); gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 2); - gtk_container_add (GTK_CONTAINER (row), grid); - gtk_container_add (GTK_CONTAINER (priv->recent_servers_listbox), row); + gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), grid); + gtk_list_box_insert (GTK_LIST_BOX (view->recent_servers_listbox), row, -1); /* custom data */ data = g_new0 (RemoveServerData, 1); @@ -619,8 +618,6 @@ populate_servers (NautilusGtkPlacesView *view) G_CALLBACK (on_remove_server_button_clicked), data); - gtk_widget_show_all (row); - g_free (name); } @@ -631,38 +628,33 @@ populate_servers (NautilusGtkPlacesView *view) static void update_view_mode (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; - GList *children; - GList *l; + GtkWidget *child; gboolean show_listbox; - priv = nautilus_gtk_places_view_get_instance_private (view); show_listbox = FALSE; /* drives */ - children = gtk_container_get_children (GTK_CONTAINER (priv->listbox)); - - for (l = children; l; l = l->next) + for (child = gtk_widget_get_first_child (GTK_WIDGET (view->listbox)); + child != NULL; + child = gtk_widget_get_next_sibling (child)) { /* GtkListBox filter rows by changing their GtkWidget::child-visible property */ - if (gtk_widget_get_child_visible (l->data)) + if (gtk_widget_get_child_visible (child)) { show_listbox = TRUE; break; } } - g_list_free (children); - if (!show_listbox && - priv->search_query && - priv->search_query[0] != '\0') + view->search_query && + view->search_query[0] != '\0') { - gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "empty-search"); + gtk_stack_set_visible_child_name (GTK_STACK (view->stack), "empty-search"); } else { - gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "browse"); + gtk_stack_set_visible_child_name (GTK_STACK (view->stack), "browse"); } } @@ -671,31 +663,36 @@ insert_row (NautilusGtkPlacesView *view, GtkWidget *row, gboolean is_network) { - NautilusGtkPlacesViewPrivate *priv; - - priv = nautilus_gtk_places_view_get_instance_private (view); + GtkEventController *controller; + GtkShortcutTrigger *trigger; + GtkShortcutAction *action; + GtkShortcut *shortcut; + GtkGesture *gesture; 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); + controller = gtk_shortcut_controller_new (); + trigger = gtk_alternative_trigger_new (gtk_keyval_trigger_new (GDK_KEY_F10, GDK_SHIFT_MASK), + gtk_keyval_trigger_new (GDK_KEY_Menu, 0)); + action = gtk_callback_action_new (on_row_popup_menu, row, NULL); + shortcut = gtk_shortcut_new (trigger, action); + gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut); + gtk_widget_add_controller (GTK_WIDGET (row), controller); - g_signal_connect (row, - "popup-menu", - G_CALLBACK (on_row_popup_menu), - row); + gesture = gtk_gesture_click_new (); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY); + g_signal_connect (gesture, "pressed", G_CALLBACK (click_cb), row); + gtk_widget_add_controller (row, GTK_EVENT_CONTROLLER (gesture)); 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), view->path_size_group); + nautilus_gtk_places_view_row_set_space_size_group (NAUTILUS_GTK_PLACES_VIEW_ROW (row), view->space_size_group); - gtk_container_add (GTK_CONTAINER (priv->listbox), row); + gtk_list_box_insert (GTK_LIST_BOX (view->listbox), row, -1); } static void @@ -706,9 +703,9 @@ add_volume (NautilusGtkPlacesView *view, GMount *mount; GFile *root; GIcon *icon; - gchar *identifier; - gchar *name; - gchar *path; + char *identifier; + char *name; + char *path; if (is_external_volume (volume)) return; @@ -754,10 +751,10 @@ add_mount (NautilusGtkPlacesView *view, gboolean is_network; GFile *root; GIcon *icon; - gchar *name; - gchar *path; - gchar *uri; - gchar *schema; + char *name; + char *path; + char *uri; + char *schema; icon = g_mount_get_icon (mount); name = g_mount_get_name (mount); @@ -814,8 +811,8 @@ static void add_file (NautilusGtkPlacesView *view, GFile *file, GIcon *icon, - const gchar *display_name, - const gchar *path, + const char *display_name, + const char *path, gboolean is_network) { GtkWidget *row; @@ -835,55 +832,46 @@ add_file (NautilusGtkPlacesView *view, static gboolean has_networks (NautilusGtkPlacesView *view) { - GList *l; - NautilusGtkPlacesViewPrivate *priv; - GList *children; + GtkWidget *child; gboolean has_network = FALSE; - 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) + for (child = gtk_widget_get_first_child (GTK_WIDGET (view->listbox)); + child != NULL; + child = gtk_widget_get_next_sibling (child)) { - if (GPOINTER_TO_INT (g_object_get_data (l->data, "is-network")) == TRUE && - g_object_get_data (l->data, "is-placeholder") == NULL) + if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (child), "is-network")) && + g_object_get_data (G_OBJECT (child), "is-placeholder") == NULL) { has_network = TRUE; break; } } - g_list_free (children); - return has_network; } static void update_network_state (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; - - priv = nautilus_gtk_places_view_get_instance_private (view); - - if (priv->network_placeholder == NULL) + if (view->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), + view->network_placeholder = gtk_list_box_row_new (); + view->network_placeholder_label = gtk_label_new (""); + gtk_label_set_xalign (GTK_LABEL (view->network_placeholder_label), 0.0); + gtk_widget_set_margin_start (view->network_placeholder_label, 12); + gtk_widget_set_margin_end (view->network_placeholder_label, 12); + gtk_widget_set_margin_top (view->network_placeholder_label, 6); + gtk_widget_set_margin_bottom (view->network_placeholder_label, 6); + gtk_widget_set_hexpand (view->network_placeholder_label, TRUE); + gtk_widget_set_sensitive (view->network_placeholder, FALSE); + gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (view->network_placeholder), + view->network_placeholder_label); + g_object_set_data (G_OBJECT (view->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), + g_object_set_data (G_OBJECT (view->network_placeholder), "is-placeholder", GINT_TO_POINTER (TRUE)); - gtk_container_add (GTK_CONTAINER (priv->listbox), priv->network_placeholder); + gtk_list_box_insert (GTK_LIST_BOX (view->listbox), view->network_placeholder, -1); } if (nautilus_gtk_places_view_get_fetching_networks (view)) @@ -892,38 +880,35 @@ update_network_state (NautilusGtkPlacesView *view) * 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), + gtk_widget_show (view->network_placeholder); + gtk_label_set_text (GTK_LABEL (view->network_placeholder_label), _("Searching for network locations")); } } else if (!has_networks (view)) { - gtk_widget_show_all (priv->network_placeholder); - gtk_label_set_text (GTK_LABEL (priv->network_placeholder_label), + gtk_widget_show (view->network_placeholder); + gtk_label_set_text (GTK_LABEL (view->network_placeholder_label), _("No network locations found")); } else { - gtk_widget_hide (priv->network_placeholder); + gtk_widget_hide (view->network_placeholder); } } static void -monitor_network (NautilusGtkPlacesView *self) +monitor_network (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; GFile *network_file; GError *error; - priv = nautilus_gtk_places_view_get_instance_private (self); - - if (priv->network_monitor) + if (view->network_monitor) return; error = NULL; network_file = g_file_new_for_uri ("network:///"); - priv->network_monitor = g_file_monitor (network_file, + view->network_monitor = g_file_monitor (network_file, G_FILE_MONITOR_NONE, NULL, &error); @@ -937,10 +922,10 @@ monitor_network (NautilusGtkPlacesView *self) return; } - g_signal_connect_swapped (priv->network_monitor, + g_signal_connect_swapped (view->network_monitor, "changed", G_CALLBACK (update_places), - self); + view); } static void @@ -951,10 +936,10 @@ populate_networks (NautilusGtkPlacesView *view, GList *l; GFile *file; GFile *activatable_file; - gchar *uri; + char *uri; GFileType type; GIcon *icon; - gchar *display_name; + char *display_name; for (l = detected_networks; l != NULL; l = l->next) { @@ -982,13 +967,11 @@ network_enumeration_next_files_finished (GObject *source_object, GAsyncResult *res, gpointer user_data) { - 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; detected_networks = g_file_enumerator_next_files_finish (G_FILE_ENUMERATOR (source_object), @@ -996,9 +979,14 @@ network_enumeration_next_files_finished (GObject *source_object, 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_clear_error (&error); + g_object_unref (view); + return; + } + g_warning ("Failed to fetch network locations: %s", error->message); g_clear_error (&error); } else @@ -1009,16 +997,11 @@ network_enumeration_next_files_finished (GObject *source_object, g_list_free_full (detected_networks, g_object_unref); } - g_object_unref (view); + update_network_state (view); + monitor_network (view); + update_loading (view); - /* avoid to update widgets if we are already destroyed - (and got cancelled s a result of that) */ - if (!priv->destroyed) - { - update_network_state (view); - monitor_network (view); - update_loading (view); - } + g_object_unref (view); } static void @@ -1026,7 +1009,7 @@ network_enumeration_finished (GObject *source_object, GAsyncResult *res, gpointer user_data) { - NautilusGtkPlacesViewPrivate *priv; + NautilusGtkPlacesView *view = NAUTILUS_GTK_PLACES_VIEW (user_data); GFileEnumerator *enumerator; GError *error; @@ -1040,15 +1023,14 @@ network_enumeration_finished (GObject *source_object, g_warning ("Failed to fetch network locations: %s", error->message); g_clear_error (&error); - g_object_unref (NAUTILUS_GTK_PLACES_VIEW (user_data)); + g_object_unref (view); } 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, + view->networks_fetching_cancellable, network_enumeration_next_files_finished, user_data); g_object_unref (enumerator); @@ -1058,12 +1040,10 @@ network_enumeration_finished (GObject *source_object, static void fetch_networks (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; GFile *network_file; - const gchar * const *supported_uris; + const char * 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 ()); for (found = FALSE; !found && supported_uris && supported_uris[0]; supported_uris++) @@ -1075,9 +1055,9 @@ fetch_networks (NautilusGtkPlacesView *view) 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 (); + g_cancellable_cancel (view->networks_fetching_cancellable); + g_clear_object (&view->networks_fetching_cancellable); + view->networks_fetching_cancellable = g_cancellable_new (); nautilus_gtk_places_view_set_fetching_networks (view, TRUE); update_network_state (view); @@ -1086,7 +1066,7 @@ fetch_networks (NautilusGtkPlacesView *view) "standard::type,standard::target-uri,standard::name,standard::display-name,standard::icon", G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, - priv->networks_fetching_cancellable, + view->networks_fetching_cancellable, network_enumeration_finished, view); @@ -1096,21 +1076,19 @@ fetch_networks (NautilusGtkPlacesView *view) static void update_places (NautilusGtkPlacesView *view) { - 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); + GtkWidget *child; /* 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; + while ((child = gtk_widget_get_first_child (GTK_WIDGET (view->listbox)))) + gtk_list_box_remove (GTK_LIST_BOX (view->listbox), child); + + view->network_placeholder = NULL; /* Inform clients that we started loading */ nautilus_gtk_places_view_set_loading (view, TRUE); @@ -1124,7 +1102,7 @@ update_places (NautilusGtkPlacesView *view) g_clear_object (&icon); /* Add currently connected drives */ - drives = g_volume_monitor_get_connected_drives (priv->volume_monitor); + drives = g_volume_monitor_get_connected_drives (view->volume_monitor); for (l = drives; l != NULL; l = l->next) add_drive (view, l->data); @@ -1136,7 +1114,7 @@ update_places (NautilusGtkPlacesView *view) * add_drive before, add all volumes that aren't associated with a * drive. */ - volumes = g_volume_monitor_get_volumes (priv->volume_monitor); + volumes = g_volume_monitor_get_volumes (view->volume_monitor); for (l = volumes; l != NULL; l = l->next) { @@ -1161,7 +1139,7 @@ update_places (NautilusGtkPlacesView *view) * 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); + mounts = g_volume_monitor_get_mounts (view->volume_monitor); for (l = mounts; l != NULL; l = l->next) { @@ -1198,8 +1176,7 @@ server_mount_ready_cb (GObject *source_file, GAsyncResult *res, gpointer user_data) { - NautilusGtkPlacesViewPrivate *priv; - NautilusGtkPlacesView *view; + NautilusGtkPlacesView *view = NAUTILUS_GTK_PLACES_VIEW (user_data); gboolean should_show; GError *error; GFile *location; @@ -1208,8 +1185,6 @@ server_mount_ready_cb (GObject *source_file, should_show = TRUE; error = NULL; - view = NAUTILUS_GTK_PLACES_VIEW (user_data); - g_file_mount_enclosing_volume_finish (location, res, &error); if (error) { @@ -1236,19 +1211,19 @@ server_mount_ready_cb (GObject *source_file, g_clear_error (&error); } - priv = nautilus_gtk_places_view_get_instance_private (view); - - if (priv->destroyed) { - g_object_unref (view); - return; - } + if (view->destroyed) + { + g_object_unref (view); + return; + } - priv->should_pulse_entry = FALSE; + view->should_pulse_entry = FALSE; + gtk_entry_set_progress_fraction (GTK_ENTRY (view->address_entry), 0); /* 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; + gtk_button_set_label (GTK_BUTTON (view->connect_button), _("Con_nect")); + gtk_widget_set_sensitive (view->address_entry, TRUE); + view->connecting_to_server = FALSE; if (should_show) { @@ -1259,9 +1234,9 @@ server_mount_ready_cb (GObject *source_file, * Otherwise, the user would lost the typed address even if it fails * to connect. */ - gtk_entry_set_text (GTK_ENTRY (priv->address_entry), ""); + gtk_editable_set_text (GTK_EDITABLE (view->address_entry), ""); - if (priv->should_open_location) + if (view->should_open_location) { GMount *mount; GFile *root; @@ -1271,19 +1246,19 @@ server_mount_ready_cb (GObject *source_file, * invisible, which happens e.g for smb-browse, but the location * should be opened anyway... */ - mount = g_file_find_enclosing_mount (location, priv->cancellable, NULL); + mount = g_file_find_enclosing_mount (location, view->cancellable, NULL); if (mount) { root = g_mount_get_default_location (mount); - emit_open_location (view, root, priv->open_flags); + emit_open_location (view, root, view->open_flags); g_object_unref (root); g_object_unref (mount); } else { - emit_open_location (view, location, priv->open_flags); + emit_open_location (view, location, view->open_flags); } } } @@ -1297,8 +1272,7 @@ volume_mount_ready_cb (GObject *source_volume, GAsyncResult *res, gpointer user_data) { - NautilusGtkPlacesViewPrivate *priv; - NautilusGtkPlacesView *view; + NautilusGtkPlacesView *view = NAUTILUS_GTK_PLACES_VIEW (user_data); gboolean should_show; GVolume *volume; GError *error; @@ -1335,16 +1309,13 @@ volume_mount_ready_cb (GObject *source_volume, g_clear_error (&error); } - view = NAUTILUS_GTK_PLACES_VIEW (user_data); - priv = nautilus_gtk_places_view_get_instance_private (view); - - if (priv->destroyed) + if (view->destroyed) { g_object_unref(view); return; } - priv->mounting_volume = FALSE; + view->mounting_volume = FALSE; update_loading (view); if (should_show) @@ -1355,8 +1326,8 @@ volume_mount_ready_cb (GObject *source_volume, 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 (view->should_open_location) + emit_open_location (NAUTILUS_GTK_PLACES_VIEW (user_data), root, view->open_flags); g_object_unref (mount); g_object_unref (root); @@ -1372,7 +1343,6 @@ unmount_ready_cb (GObject *source_mount, gpointer user_data) { NautilusGtkPlacesView *view; - NautilusGtkPlacesViewPrivate *priv; GMount *mount; GError *error; @@ -1395,14 +1365,12 @@ unmount_ready_cb (GObject *source_mount, g_clear_error (&error); } - priv = nautilus_gtk_places_view_get_instance_private (view); - - if (priv->destroyed) { + if (view->destroyed) { g_object_unref (view); return; } - priv->unmounting_mount = FALSE; + view->unmounting_mount = FALSE; update_loading (view); g_object_unref (view); @@ -1411,27 +1379,24 @@ unmount_ready_cb (GObject *source_mount, static gboolean pulse_entry_cb (gpointer user_data) { - NautilusGtkPlacesViewPrivate *priv; + NautilusGtkPlacesView *view = NAUTILUS_GTK_PLACES_VIEW (user_data); - priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (user_data)); - - if (priv->destroyed) + if (view->destroyed) { - priv->entry_pulse_timeout_id = 0; + view->entry_pulse_timeout_id = 0; return G_SOURCE_REMOVE; } - else if (priv->should_pulse_entry) + else if (view->should_pulse_entry) { - gtk_entry_progress_pulse (GTK_ENTRY (priv->address_entry)); + gtk_entry_progress_pulse (GTK_ENTRY (view->address_entry)); return G_SOURCE_CONTINUE; } 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); - priv->entry_pulse_timeout_id = 0; + gtk_entry_set_progress_fraction (GTK_ENTRY (view->address_entry), 0); + view->entry_pulse_timeout_id = 0; return G_SOURCE_REMOVE; } @@ -1441,18 +1406,16 @@ static void unmount_mount (NautilusGtkPlacesView *view, GMount *mount) { - NautilusGtkPlacesViewPrivate *priv; GMountOperation *operation; GtkWidget *toplevel; - priv = nautilus_gtk_places_view_get_instance_private (view); - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view)); + toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (view))); - g_cancellable_cancel (priv->cancellable); - g_clear_object (&priv->cancellable); - priv->cancellable = g_cancellable_new (); + g_cancellable_cancel (view->cancellable); + g_clear_object (&view->cancellable); + view->cancellable = g_cancellable_new (); - priv->unmounting_mount = TRUE; + view->unmounting_mount = TRUE; update_loading (view); g_object_ref (view); @@ -1461,7 +1424,7 @@ unmount_mount (NautilusGtkPlacesView *view, g_mount_unmount_with_operation (mount, 0, operation, - priv->cancellable, + view->cancellable, unmount_ready_cb, view); g_object_unref (operation); @@ -1471,32 +1434,30 @@ static void mount_server (NautilusGtkPlacesView *view, GFile *location) { - NautilusGtkPlacesViewPrivate *priv; GMountOperation *operation; GtkWidget *toplevel; - priv = nautilus_gtk_places_view_get_instance_private (view); - - g_cancellable_cancel (priv->cancellable); - g_clear_object (&priv->cancellable); + g_cancellable_cancel (view->cancellable); + g_clear_object (&view->cancellable); /* User cliked when the operation was ongoing, so wanted to cancel it */ - if (priv->connecting_to_server) + if (view->connecting_to_server) return; - priv->cancellable = g_cancellable_new (); - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view)); + view->cancellable = g_cancellable_new (); + toplevel = GTK_WIDGET (gtk_widget_get_root (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); + view->should_pulse_entry = TRUE; + gtk_entry_set_progress_pulse_step (GTK_ENTRY (view->address_entry), 0.1); + gtk_entry_set_progress_fraction (GTK_ENTRY (view->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; + gtk_button_set_label (GTK_BUTTON (view->connect_button), _("Cance_l")); + gtk_widget_set_sensitive (view->address_entry, FALSE); + view->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 (view->entry_pulse_timeout_id == 0) + view->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); @@ -1506,7 +1467,7 @@ mount_server (NautilusGtkPlacesView *view, g_file_mount_enclosing_volume (location, 0, operation, - priv->cancellable, + view->cancellable, server_mount_ready_cb, view); @@ -1518,19 +1479,17 @@ static void mount_volume (NautilusGtkPlacesView *view, GVolume *volume) { - NautilusGtkPlacesViewPrivate *priv; GMountOperation *operation; GtkWidget *toplevel; - priv = nautilus_gtk_places_view_get_instance_private (view); - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view)); + toplevel = GTK_WIDGET (gtk_widget_get_root (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 (view->cancellable); + g_clear_object (&view->cancellable); + view->cancellable = g_cancellable_new (); - priv->mounting_volume = TRUE; + view->mounting_volume = TRUE; update_loading (view); g_mount_operation_set_password_save (operation, G_PASSWORD_SAVE_FOR_SESSION); @@ -1541,7 +1500,7 @@ mount_volume (NautilusGtkPlacesView *view, g_volume_mount (volume, 0, operation, - priv->cancellable, + view->cancellable, volume_mount_ready_cb, view); @@ -1549,89 +1508,73 @@ mount_volume (NautilusGtkPlacesView *view, g_object_unref (operation); } -/* Callback used when the file list's popup menu is detached */ static void -popup_menu_detach_cb (GtkWidget *attach_widget, - GtkMenu *menu) +open_cb (GtkWidget *widget, + const char *action_name, + GVariant *parameter) { - NautilusGtkPlacesViewPrivate *priv; + NautilusGtkPlacesView *view = NAUTILUS_GTK_PLACES_VIEW (widget); + NautilusGtkPlacesOpenFlags flags = NAUTILUS_GTK_PLACES_OPEN_NORMAL; - priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (attach_widget)); - priv->popup_menu = NULL; -} - -static void -open_cb (GtkMenuItem *item, - NautilusGtkPlacesViewRow *row) -{ - NautilusGtkPlacesView *self; - - self = NAUTILUS_GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW)); - activate_row (self, row, NAUTILUS_GTK_PLACES_OPEN_NORMAL); -} - -static void -open_in_new_tab_cb (GtkMenuItem *item, - NautilusGtkPlacesViewRow *row) -{ - NautilusGtkPlacesView *self; - - self = NAUTILUS_GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW)); - activate_row (self, row, NAUTILUS_GTK_PLACES_OPEN_NEW_TAB); -} + if (view->row_for_action == NULL) + return; -static void -open_in_new_window_cb (GtkMenuItem *item, - NautilusGtkPlacesViewRow *row) -{ - NautilusGtkPlacesView *self; + if (strcmp (action_name, "location.open") == 0) + flags = NAUTILUS_GTK_PLACES_OPEN_NORMAL; + else if (strcmp (action_name, "location.open-tab") == 0) + flags = NAUTILUS_GTK_PLACES_OPEN_NEW_TAB; + else if (strcmp (action_name, "location.open-window") == 0) + flags = NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW; - self = NAUTILUS_GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW)); - activate_row (self, row, NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW); + activate_row (view, view->row_for_action, flags); } static void -mount_cb (GtkMenuItem *item, - NautilusGtkPlacesViewRow *row) +mount_cb (GtkWidget *widget, + const char *action_name, + GVariant *parameter) { - NautilusGtkPlacesViewPrivate *priv; - GtkWidget *view; + NautilusGtkPlacesView *view = NAUTILUS_GTK_PLACES_VIEW (widget); 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); + if (view->row_for_action == NULL) + return; + + volume = nautilus_gtk_places_view_row_get_volume (view->row_for_action); /* * 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; + view->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 (view->row_for_action, TRUE); + mount_volume (view, volume); } static void -unmount_cb (GtkMenuItem *item, - NautilusGtkPlacesViewRow *row) +unmount_cb (GtkWidget *widget, + const char *action_name, + GVariant *parameter) { - GtkWidget *view; + NautilusGtkPlacesView *view = NAUTILUS_GTK_PLACES_VIEW (widget); GMount *mount; - view = gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_VIEW); - mount = nautilus_gtk_places_view_row_get_mount (row); + if (view->row_for_action == NULL) + return; - nautilus_gtk_places_view_row_set_busy (row, TRUE); + mount = nautilus_gtk_places_view_row_get_mount (view->row_for_action); - unmount_mount (NAUTILUS_GTK_PLACES_VIEW (view), mount); + nautilus_gtk_places_view_row_set_busy (view->row_for_action, TRUE); + + unmount_mount (view, mount); } static void attach_protocol_row_to_grid (GtkGrid *grid, - const gchar *protocol_name, - const gchar *protocol_prefix) + const char *protocol_name, + const char *protocol_prefix) { GtkWidget *name_label; GtkWidget *prefix_label; @@ -1648,213 +1591,239 @@ attach_protocol_row_to_grid (GtkGrid *grid, static void populate_available_protocols_grid (GtkGrid *grid) { - const gchar* const *supported_protocols; + const char * const *supported_protocols; + gboolean has_any = FALSE; supported_protocols = g_vfs_get_supported_uri_schemes (g_vfs_get_default ()); if (g_strv_contains (supported_protocols, "afp")) - attach_protocol_row_to_grid (grid, _("AppleTalk"), "afp://"); + { + attach_protocol_row_to_grid (grid, _("AppleTalk"), "afp://"); + has_any = TRUE; + } if (g_strv_contains (supported_protocols, "ftp")) - /* Translators: do not translate ftp:// and ftps:// */ - attach_protocol_row_to_grid (grid, _("File Transfer Protocol"), _("ftp:// or ftps://")); + { + attach_protocol_row_to_grid (grid, _("File Transfer Protocol"), + /* Translators: do not translate ftp:// and ftps:// */ + _("ftp:// or ftps://")); + has_any = TRUE; + } if (g_strv_contains (supported_protocols, "nfs")) - attach_protocol_row_to_grid (grid, _("Network File System"), "nfs://"); + { + attach_protocol_row_to_grid (grid, _("Network File System"), "nfs://"); + has_any = TRUE; + } if (g_strv_contains (supported_protocols, "smb")) - attach_protocol_row_to_grid (grid, _("Samba"), "smb://"); + { + attach_protocol_row_to_grid (grid, _("Samba"), "smb://"); + has_any = TRUE; + } if (g_strv_contains (supported_protocols, "ssh")) - /* Translators: do not translate sftp:// and ssh:// */ - attach_protocol_row_to_grid (grid, _("SSH File Transfer Protocol"), _("sftp:// or ssh://")); + { + attach_protocol_row_to_grid (grid, _("SSH File Transfer Protocol"), + /* Translators: do not translate sftp:// and ssh:// */ + _("sftp:// or ssh://")); + has_any = TRUE; + } if (g_strv_contains (supported_protocols, "dav")) - /* Translators: do not translate dav:// and davs:// */ - attach_protocol_row_to_grid (grid, _("WebDAV"), _("dav:// or davs://")); + { + attach_protocol_row_to_grid (grid, _("WebDAV"), + /* Translators: do not translate dav:// and davs:// */ + _("dav:// or davs://")); + has_any = TRUE; + } - gtk_widget_show_all (GTK_WIDGET (grid)); + if (!has_any) + gtk_widget_hide (GTK_WIDGET (grid)); } -/* Constructs the popup menu if needed */ -static void -build_popup_menu (NautilusGtkPlacesView *view, - NautilusGtkPlacesViewRow *row) +static GMenuModel * +get_menu_model (void) +{ + GMenu *menu; + GMenu *section; + GMenuItem *item; + + menu = g_menu_new (); + section = g_menu_new (); + item = g_menu_item_new (_("_Open"), "location.open"); + g_menu_append_item (section, item); + g_object_unref (item); + + item = g_menu_item_new (_("Open in New _Tab"), "location.open-tab"); + g_menu_item_set_attribute (item, "hidden-when", "s", "action-disabled"); + g_menu_append_item (section, item); + g_object_unref (item); + + item = g_menu_item_new (_("Open in New _Window"), "location.open-window"); + g_menu_item_set_attribute (item, "hidden-when", "s", "action-disabled"); + g_menu_append_item (section, item); + g_object_unref (item); + + g_menu_append_section (menu, NULL, G_MENU_MODEL (section)); + g_object_unref (section); + + section = g_menu_new (); + item = g_menu_item_new (_("_Disconnect"), "location.disconnect"); + g_menu_item_set_attribute (item, "hidden-when", "s", "action-disabled"); + g_menu_append_item (section, item); + g_object_unref (item); + + item = g_menu_item_new (_("_Unmount"), "location.unmount"); + g_menu_item_set_attribute (item, "hidden-when", "s", "action-disabled"); + g_menu_append_item (section, item); + g_object_unref (item); + + + item = g_menu_item_new (_("_Connect"), "location.connect"); + g_menu_item_set_attribute (item, "hidden-when", "s", "action-disabled"); + g_menu_append_item (section, item); + g_object_unref (item); + + item = g_menu_item_new (_("_Mount"), "location.mount"); + g_menu_item_set_attribute (item, "hidden-when", "s", "action-disabled"); + g_menu_append_item (section, item); + g_object_unref (item); + + g_menu_append_section (menu, NULL, G_MENU_MODEL (section)); + g_object_unref (section); + + return G_MENU_MODEL (menu); +} + +static gboolean +on_row_popup_menu (GtkWidget *widget, + GVariant *args, + gpointer user_data) { - NautilusGtkPlacesViewPrivate *priv; - GtkWidget *item; + NautilusGtkPlacesViewRow *row = NAUTILUS_GTK_PLACES_VIEW_ROW (widget); + NautilusGtkPlacesView *view; GMount *mount; GFile *file; gboolean is_network; - priv = nautilus_gtk_places_view_get_instance_private (view); + view = NAUTILUS_GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), NAUTILUS_TYPE_GTK_PLACES_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); + gtk_widget_action_set_enabled (GTK_WIDGET (view), "location.disconnect", + !file && mount && is_network); + gtk_widget_action_set_enabled (GTK_WIDGET (view), "location.unmount", + !file && mount && !is_network); + gtk_widget_action_set_enabled (GTK_WIDGET (view), "location.connect", + !file && !mount && is_network); + gtk_widget_action_set_enabled (GTK_WIDGET (view), "location.mount", + !file && !mount && !is_network); - /* 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 & NAUTILUS_GTK_PLACES_OPEN_NEW_TAB) + if (!view->popup_menu) { - 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); - } + GMenuModel *model = get_menu_model (); - if (priv->open_flags & NAUTILUS_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); - } + view->popup_menu = gtk_popover_menu_new_from_model (model); + gtk_popover_set_position (GTK_POPOVER (view->popup_menu), GTK_POS_BOTTOM); - /* - * The only item that contains a file up to now is the Computer - * item, which cannot be mounted or unmounted. - */ - if (file) - return; + gtk_popover_set_has_arrow (GTK_POPOVER (view->popup_menu), FALSE); + gtk_widget_set_halign (view->popup_menu, GTK_ALIGN_CENTER); - /* 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); + g_object_unref (model); } -} - -static void -popup_menu (NautilusGtkPlacesViewRow *row, - GdkEventButton *event) -{ - 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)); + if (view->row_for_action) + g_object_set_data (G_OBJECT (view->row_for_action), "menu", NULL); - g_clear_pointer (&priv->popup_menu, gtk_widget_destroy); + g_object_ref (view->popup_menu); + gtk_widget_unparent (view->popup_menu); + gtk_widget_set_parent (view->popup_menu, GTK_WIDGET (row)); + g_object_unref (view->popup_menu); - build_popup_menu (NAUTILUS_GTK_PLACES_VIEW (view), row); + view->row_for_action = row; + if (view->row_for_action) + g_object_set_data (G_OBJECT (view->row_for_action), "menu", view->popup_menu); - gtk_menu_popup_at_pointer (GTK_MENU (priv->popup_menu), (GdkEvent *) event); -} + gtk_popover_popup (GTK_POPOVER (view->popup_menu)); -static gboolean -on_row_popup_menu (NautilusGtkPlacesViewRow *row) -{ - popup_menu (row, NULL); return TRUE; } -static gboolean -on_button_press_event (NautilusGtkPlacesViewRow *row, - GdkEventButton *event) +static void +click_cb (GtkGesture *gesture, + int n_press, + double x, + double y, + gpointer user_data) { - if (row && - gdk_event_triggers_context_menu ((GdkEvent*) event) && - event->type == GDK_BUTTON_PRESS) - { - popup_menu (row, event); - - return TRUE; - } - - return FALSE; + on_row_popup_menu (GTK_WIDGET (user_data), NULL, NULL); } static gboolean -on_key_press_event (GtkWidget *widget, - GdkEventKey *event, - NautilusGtkPlacesView *view) +on_key_press_event (GtkEventController *controller, + guint keyval, + guint keycode, + GdkModifierType state, + NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; + GdkModifierType modifiers; - priv = nautilus_gtk_places_view_get_instance_private (view); + modifiers = gtk_accelerator_get_default_mod_mask (); - if (event) + if (keyval == GDK_KEY_Return || + keyval == GDK_KEY_KP_Enter || + keyval == GDK_KEY_ISO_Enter || + keyval == GDK_KEY_space) { - guint modifiers; - - 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) - { - GtkWidget *focus_widget; - GtkWindow *toplevel; + GtkWidget *focus_widget; + GtkWindow *toplevel; - priv->current_open_flags = NAUTILUS_GTK_PLACES_OPEN_NORMAL; - toplevel = get_toplevel (GTK_WIDGET (view)); + view->current_open_flags = NAUTILUS_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_root_get_focus (GTK_ROOT (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 = NAUTILUS_GTK_PLACES_OPEN_NEW_TAB; - else if ((event->state & modifiers) == GDK_CONTROL_MASK) - priv->current_open_flags = NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW; + if ((state & modifiers) == GDK_SHIFT_MASK) + view->current_open_flags = NAUTILUS_GTK_PLACES_OPEN_NEW_TAB; + else if ((state & modifiers) == GDK_CONTROL_MASK) + view->current_open_flags = NAUTILUS_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), view->current_open_flags); - return TRUE; - } + return TRUE; } return FALSE; } static void +on_middle_click_row_event (GtkGestureClick *gesture, + guint n_press, + double x, + double y, + NautilusGtkPlacesView *view) +{ + GtkListBoxRow *row; + + if (n_press != 1) + return; + + row = gtk_list_box_get_row_at_y (GTK_LIST_BOX (view->listbox), y); + if (row != NULL && gtk_widget_is_sensitive (GTK_WIDGET (row))) + activate_row (view, NAUTILUS_GTK_PLACES_VIEW_ROW (row), NAUTILUS_GTK_PLACES_OPEN_NEW_TAB); +} + + +static void on_eject_button_clicked (GtkWidget *widget, NautilusGtkPlacesViewRow *row) { @@ -1869,11 +1838,9 @@ on_eject_button_clicked (GtkWidget *widget, static void on_connect_button_clicked (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; - const gchar *uri; + const char *uri; GFile *file; - priv = nautilus_gtk_places_view_get_instance_private (view); file = NULL; /* @@ -1881,17 +1848,17 @@ on_connect_button_clicked (NautilusGtkPlacesView *view) * 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)) + if (!gtk_widget_get_sensitive (view->connect_button)) return; - uri = gtk_entry_get_text (GTK_ENTRY (priv->address_entry)); + uri = gtk_editable_get_text (GTK_EDITABLE (view->address_entry)); if (uri != NULL && uri[0] != '\0') file = g_file_new_for_commandline_arg (uri); if (file) { - priv->should_open_location = TRUE; + view->should_open_location = TRUE; mount_server (view, file); } @@ -1904,15 +1871,13 @@ on_connect_button_clicked (NautilusGtkPlacesView *view) static void on_address_entry_text_changed (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; - const gchar* const *supported_protocols; - gchar *address, *scheme; + const char * const *supported_protocols; + char *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))); + address = g_strdup (gtk_editable_get_text (GTK_EDITABLE (view->address_entry))); scheme = g_uri_parse_scheme (address); if (!supported_protocols) @@ -1925,13 +1890,11 @@ on_address_entry_text_changed (NautilusGtkPlacesView *view) !g_strv_contains (unsupported_protocols, scheme); out: - gtk_widget_set_sensitive (priv->connect_button, supported); + gtk_widget_set_sensitive (view->connect_button, supported); if (scheme && !supported) - gtk_style_context_add_class (gtk_widget_get_style_context (priv->address_entry), - GTK_STYLE_CLASS_ERROR); + gtk_widget_add_css_class (view->address_entry, "error"); else - gtk_style_context_remove_class (gtk_widget_get_style_context (priv->address_entry), - GTK_STYLE_CLASS_ERROR); + gtk_widget_remove_css_class (view->address_entry, "error"); g_free (address); g_free (scheme); @@ -1940,21 +1903,22 @@ out: static void on_address_entry_show_help_pressed (NautilusGtkPlacesView *view, GtkEntryIconPosition icon_pos, - GdkEvent *event, GtkEntry *entry) { - NautilusGtkPlacesViewPrivate *priv; GdkRectangle rect; - - priv = nautilus_gtk_places_view_get_instance_private (view); + double x, y; /* Setup the auxiliary popover's rectangle */ - gtk_entry_get_icon_area (GTK_ENTRY (priv->address_entry), + gtk_entry_get_icon_area (GTK_ENTRY (view->address_entry), GTK_ENTRY_ICON_SECONDARY, &rect); + gtk_widget_translate_coordinates (view->address_entry, GTK_WIDGET (view), + rect.x, rect.y, &x, &y); - gtk_popover_set_pointing_to (GTK_POPOVER (priv->server_adresses_popover), &rect); - gtk_widget_set_visible (priv->server_adresses_popover, TRUE); + rect.x = x; + rect.y = y; + gtk_popover_set_pointing_to (GTK_POPOVER (view->server_adresses_popover), &rect); + gtk_widget_set_visible (view->server_adresses_popover, TRUE); } static void @@ -1962,15 +1926,13 @@ on_recent_servers_listbox_row_activated (NautilusGtkPlacesView *view, NautilusGtkPlacesViewRow *row, GtkWidget *listbox) { - NautilusGtkPlacesViewPrivate *priv; - gchar *uri; + char *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_editable_set_text (GTK_EDITABLE (view->address_entry), uri); - gtk_widget_hide (priv->recent_servers_popover); + gtk_widget_hide (view->recent_servers_popover); } static void @@ -1978,84 +1940,25 @@ on_listbox_row_activated (NautilusGtkPlacesView *view, NautilusGtkPlacesViewRow *row, GtkWidget *listbox) { - NautilusGtkPlacesViewPrivate *priv; - GdkEvent *event; - guint button; - NautilusGtkPlacesOpenFlags open_flags; - - priv = nautilus_gtk_places_view_get_instance_private (view); - - event = gtk_get_current_event (); - gdk_event_get_button (event, &button); - - if (gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE && button == GDK_BUTTON_MIDDLE) - open_flags = NAUTILUS_GTK_PLACES_OPEN_NEW_TAB; - else - open_flags = priv->current_open_flags; - - activate_row (view, row, open_flags); -} - -static gboolean -is_mount_locally_accessible (GMount *mount) -{ - GFile *base_file; - gchar *path; - - if (mount == NULL) - return FALSE; - - base_file = g_mount_get_root (mount); - - if (base_file == NULL) - return FALSE; - - path = g_file_get_path (base_file); - g_object_unref (base_file); - - if (path == NULL) - return FALSE; - - g_free (path); - return TRUE; + activate_row (view, row, view->current_open_flags); } static gboolean listbox_filter_func (GtkListBoxRow *row, gpointer user_data) { - NautilusGtkPlacesViewPrivate *priv; - gboolean is_network; + NautilusGtkPlacesView *view = NAUTILUS_GTK_PLACES_VIEW (user_data); gboolean is_placeholder; - gboolean is_local = FALSE; gboolean retval; gboolean searching; - gchar *name; - gchar *path; + char *name; + char *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'; + searching = view->search_query && view->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")); - if (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row)) - { - NautilusGtkPlacesViewRow *placesviewrow; - GMount *mount; - - placesviewrow = NAUTILUS_GTK_PLACES_VIEW_ROW (row); - g_object_get(G_OBJECT (placesviewrow), "mount", &mount, NULL); - - is_local = is_mount_locally_accessible (mount); - - g_clear_object (&mount); - } - - if (is_network && priv->local_only && !is_local) - return FALSE; - if (is_placeholder && searching) return FALSE; @@ -2068,10 +1971,22 @@ listbox_filter_func (GtkListBoxRow *row, NULL); if (name) - retval |= strstr (name, priv->search_query) != NULL; + { + char *lowercase_name = g_utf8_strdown (name, -1); + + retval |= strstr (lowercase_name, view->search_query) != NULL; + + g_free (lowercase_name); + } if (path) - retval |= strstr (path, priv->search_query) != NULL; + { + char *lowercase_path = g_utf8_strdown (path, -1); + + retval |= strstr (lowercase_path, view->search_query) != NULL; + + g_free (lowercase_path); + } g_free (name); g_free (path); @@ -2085,7 +2000,7 @@ listbox_header_func (GtkListBoxRow *row, gpointer user_data) { gboolean row_is_network; - gchar *text; + char *text; text = NULL; row_is_network = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "is-network")); @@ -2126,36 +2041,29 @@ listbox_header_func (GtkListBoxRow *row, GtkWidget *header_name; GtkWidget *network_header_spinner; - g_object_set (label, - "margin-end", 6, - NULL); + gtk_widget_set_margin_end (label, 6); 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); + gtk_widget_set_margin_end (network_header_spinner, 12); g_object_bind_property (NAUTILUS_GTK_PLACES_VIEW (user_data), "fetching-networks", network_header_spinner, - "active", + "spinning", 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); + gtk_box_append (GTK_BOX (header_name), label); + gtk_box_append (GTK_BOX (header_name), network_header_spinner); + gtk_box_append (GTK_BOX (header), header_name); } else { - g_object_set (label, - "hexpand", TRUE, - "margin-end", 12, - NULL); - gtk_container_add (GTK_CONTAINER (header), label); + gtk_widget_set_hexpand (label, TRUE); + gtk_widget_set_margin_end (label, 12); + gtk_box_append (GTK_BOX (header), label); } - gtk_container_add (GTK_CONTAINER (header), separator); - gtk_widget_show_all (header); + gtk_box_append (GTK_BOX (header), separator); gtk_list_box_row_set_header (row, header); @@ -2167,18 +2075,18 @@ listbox_header_func (GtkListBoxRow *row, } } -static gint +static int listbox_sort_func (GtkListBoxRow *row1, GtkListBoxRow *row2, gpointer user_data) { gboolean row1_is_network; gboolean row2_is_network; - gchar *path1; - gchar *path2; + char *path1; + char *path2; gboolean *is_placeholder1; gboolean *is_placeholder2; - gint retval; + int 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")); @@ -2213,49 +2121,47 @@ listbox_sort_func (GtkListBoxRow *row1, static void nautilus_gtk_places_view_constructed (GObject *object) { - NautilusGtkPlacesViewPrivate *priv; - - priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (object)); + NautilusGtkPlacesView *view = NAUTILUS_GTK_PLACES_VIEW (object); G_OBJECT_CLASS (nautilus_gtk_places_view_parent_class)->constructed (object); - gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->listbox), + gtk_list_box_set_sort_func (GTK_LIST_BOX (view->listbox), listbox_sort_func, object, NULL); - gtk_list_box_set_filter_func (GTK_LIST_BOX (priv->listbox), + gtk_list_box_set_filter_func (GTK_LIST_BOX (view->listbox), listbox_filter_func, object, NULL); - gtk_list_box_set_header_func (GTK_LIST_BOX (priv->listbox), + gtk_list_box_set_header_func (GTK_LIST_BOX (view->listbox), listbox_header_func, object, NULL); /* load drives */ - update_places (NAUTILUS_GTK_PLACES_VIEW (object)); + update_places (view); - g_signal_connect_swapped (priv->volume_monitor, + g_signal_connect_swapped (view->volume_monitor, "mount-added", G_CALLBACK (update_places), object); - g_signal_connect_swapped (priv->volume_monitor, + g_signal_connect_swapped (view->volume_monitor, "mount-changed", G_CALLBACK (update_places), object); - g_signal_connect_swapped (priv->volume_monitor, + g_signal_connect_swapped (view->volume_monitor, "mount-removed", G_CALLBACK (update_places), object); - g_signal_connect_swapped (priv->volume_monitor, + g_signal_connect_swapped (view->volume_monitor, "volume-added", G_CALLBACK (update_places), object); - g_signal_connect_swapped (priv->volume_monitor, + g_signal_connect_swapped (view->volume_monitor, "volume-changed", G_CALLBACK (update_places), object); - g_signal_connect_swapped (priv->volume_monitor, + g_signal_connect_swapped (view->volume_monitor, "volume-removed", G_CALLBACK (update_places), object); @@ -2264,11 +2170,9 @@ nautilus_gtk_places_view_constructed (GObject *object) static void nautilus_gtk_places_view_map (GtkWidget *widget) { - NautilusGtkPlacesViewPrivate *priv; - - priv = nautilus_gtk_places_view_get_instance_private (NAUTILUS_GTK_PLACES_VIEW (widget)); + NautilusGtkPlacesView *view = NAUTILUS_GTK_PLACES_VIEW (widget); - gtk_entry_set_text (GTK_ENTRY (priv->address_entry), ""); + gtk_editable_set_text (GTK_EDITABLE (view->address_entry), ""); GTK_WIDGET_CLASS (nautilus_gtk_places_view_parent_class)->map (widget); } @@ -2280,26 +2184,24 @@ nautilus_gtk_places_view_class_init (NautilusGtkPlacesViewClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); object_class->finalize = nautilus_gtk_places_view_finalize; + object_class->dispose = nautilus_gtk_places_view_dispose; 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 #NautilusGtkPlacesOpenFlags specifying how the @location + * @location: (type Gio.File): GFile to which the caller should switch. + * @open_flags: a single value from NautilusGtkPlacesOpenFlags 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", @@ -2310,9 +2212,9 @@ nautilus_gtk_places_view_class_init (NautilusGtkPlacesViewClass *klass) NULL, G_TYPE_NONE, 2, G_TYPE_OBJECT, - GTK_TYPE_PLACES_OPEN_FLAGS); + NAUTILUS_TYPE_OPEN_FLAGS); - /** + /* * NautilusGtkPlacesView::show-error-message: * @view: the object which received the signal. * @primary: primary message with a summary of the error to show. @@ -2322,8 +2224,6 @@ nautilus_gtk_places_view_class_init (NautilusGtkPlacesViewClass *klass) * 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", @@ -2336,92 +2236,147 @@ nautilus_gtk_places_view_class_init (NautilusGtkPlacesViewClass *klass) 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); + G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); properties[PROP_FETCHING_NETWORKS] = g_param_spec_boolean ("fetching-networks", "Fetching networks", "Whether the view is fetching networks", FALSE, - G_PARAM_READABLE); + G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); 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, + NAUTILUS_TYPE_OPEN_FLAGS, NAUTILUS_GTK_PLACES_OPEN_NORMAL, - G_PARAM_READWRITE); + G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); 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_child_private (widget_class, NautilusGtkPlacesView, available_protocols_grid); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, actionbar); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, address_entry); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, address_entry_completion); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, completion_store); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, connect_button); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, listbox); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, recent_servers_listbox); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, recent_servers_popover); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, recent_servers_stack); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, stack); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, server_adresses_popover); + gtk_widget_class_bind_template_child (widget_class, NautilusGtkPlacesView, available_protocols_grid); gtk_widget_class_bind_template_callback (widget_class, on_address_entry_text_changed); gtk_widget_class_bind_template_callback (widget_class, on_address_entry_show_help_pressed); 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); + /** + * NautilusGtkPlacesView|location.open: + * + * Opens the location in the current window. + */ + gtk_widget_class_install_action (widget_class, "location.open", NULL, open_cb); + + /** + * NautilusGtkPlacesView|location.open-tab: + * + * Opens the location in a new tab. + */ + gtk_widget_class_install_action (widget_class, "location.open-tab", NULL, open_cb); + + /** + * NautilusGtkPlacesView|location.open-window: + * + * Opens the location in a new window. + */ + gtk_widget_class_install_action (widget_class, "location.open-window", NULL, open_cb); + + /** + * NautilusGtkPlacesView|location.mount: + * + * Mount the location. + */ + gtk_widget_class_install_action (widget_class, "location.mount", NULL, mount_cb); + + /** + * NautilusGtkPlacesView|location.connect: + * + * Connect the location. + */ + gtk_widget_class_install_action (widget_class, "location.connect", NULL, mount_cb); + + /** + * NautilusGtkPlacesView|location.unmount: + * + * Unmount the location. + */ + gtk_widget_class_install_action (widget_class, "location.unmount", NULL, unmount_cb); + + /** + * NautilusGtkPlacesView|location.disconnect: + * + * Disconnect the location. + */ + gtk_widget_class_install_action (widget_class, "location.disconnect", NULL, unmount_cb); + gtk_widget_class_set_css_name (widget_class, "placesview"); } static void nautilus_gtk_places_view_init (NautilusGtkPlacesView *self) { - NautilusGtkPlacesViewPrivate *priv; + GtkEventController *controller; - priv = nautilus_gtk_places_view_get_instance_private (self); + self->volume_monitor = g_volume_monitor_get (); + self->open_flags = NAUTILUS_GTK_PLACES_OPEN_NORMAL; + self->path_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + self->space_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - priv->volume_monitor = g_volume_monitor_get (); - priv->open_flags = NAUTILUS_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_action_set_enabled (GTK_WIDGET (self), "location.open-tab", FALSE); + gtk_widget_action_set_enabled (GTK_WIDGET (self), "location.open-window", FALSE); gtk_widget_init_template (GTK_WIDGET (self)); - populate_available_protocols_grid (GTK_GRID (priv->available_protocols_grid)); + gtk_widget_set_parent (self->server_adresses_popover, GTK_WIDGET (self)); + controller = gtk_event_controller_key_new (); + g_signal_connect (controller, "key-pressed", G_CALLBACK (on_key_press_event), self); + gtk_widget_add_controller (GTK_WIDGET (self), controller); + + /* We need an additional controller because GtkListBox only + * activates rows for GDK_BUTTON_PRIMARY clicks + */ + controller = (GtkEventController *) gtk_gesture_click_new (); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), GDK_BUTTON_MIDDLE); + g_signal_connect (controller, "released", + G_CALLBACK (on_middle_click_row_event), self); + gtk_widget_add_controller (self->listbox, controller); + + populate_available_protocols_grid (GTK_GRID (self->available_protocols_grid)); } -/** +/* * nautilus_gtk_places_view_new: * - * Creates a new #NautilusGtkPlacesView widget. + * Creates a new NautilusGtkPlacesView widget. * * The application should connect to at least the - * #NautilusGtkPlacesView::open-location signal to be notified + * NautilusGtkPlacesView::open-location signal to be notified * when the user makes a selection in the view. * - * Returns: a newly created #NautilusGtkPlacesView - * - * Since: 3.18 + * Returns: a newly created NautilusGtkPlacesView */ GtkWidget * nautilus_gtk_places_view_new (void) @@ -2429,9 +2384,9 @@ nautilus_gtk_places_view_new (void) return g_object_new (NAUTILUS_TYPE_GTK_PLACES_VIEW, NULL); } -/** +/* * nautilus_gtk_places_view_set_open_flags: - * @view: a #NautilusGtkPlacesView + * @view: a NautilusGtkPlacesView * @flags: Bitmask of modes in which the calling application can open locations * * Sets the way in which the calling application can open new locations from @@ -2443,77 +2398,67 @@ nautilus_gtk_places_view_new (void) * application can open new locations, so that the view can display (or not) * the “Open in new tab” and “Open in new window” menu items as appropriate. * - * When the #NautilusGtkPlacesView::open-location signal is emitted, its flags + * When the NautilusGtkPlacesView::open-location signal is emitted, its flags * argument will be set to one of the @flags that was passed in * nautilus_gtk_places_view_set_open_flags(). * - * Passing 0 for @flags will cause #NAUTILUS_GTK_PLACES_OPEN_NORMAL to always be sent + * Passing 0 for @flags will cause NAUTILUS_GTK_PLACES_OPEN_NORMAL to always be sent * to callbacks for the “open-location” signal. - * - * Since: 3.18 */ void nautilus_gtk_places_view_set_open_flags (NautilusGtkPlacesView *view, NautilusGtkPlacesOpenFlags flags) { - NautilusGtkPlacesViewPrivate *priv; - g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view)); - priv = nautilus_gtk_places_view_get_instance_private (view); + if (view->open_flags == flags) + return; - if (priv->open_flags != flags) - { - priv->open_flags = flags; - g_object_notify_by_pspec (G_OBJECT (view), properties[PROP_OPEN_FLAGS]); - } + view->open_flags = flags; + + gtk_widget_action_set_enabled (GTK_WIDGET (view), "location.open-tab", + (flags & NAUTILUS_GTK_PLACES_OPEN_NEW_TAB) != 0); + gtk_widget_action_set_enabled (GTK_WIDGET (view), "location.open-window", + (flags & NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW) != 0); + + g_object_notify_by_pspec (G_OBJECT (view), properties[PROP_OPEN_FLAGS]); } -/** +/* * nautilus_gtk_places_view_get_open_flags: - * @view: a #NautilusGtkPlacesSidebar + * @view: a NautilusGtkPlacesSidebar * * Gets the open flags. * - * Returns: the #NautilusGtkPlacesOpenFlags of @view - * - * Since: 3.18 + * Returns: the NautilusGtkPlacesOpenFlags of @view */ NautilusGtkPlacesOpenFlags nautilus_gtk_places_view_get_open_flags (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; - g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), 0); - priv = nautilus_gtk_places_view_get_instance_private (view); - - return priv->open_flags; + return view->open_flags; } -/** +/* * nautilus_gtk_places_view_get_search_query: - * @view: a #NautilusGtkPlacesView + * @view: a NautilusGtkPlacesView * * Retrieves the current search query from @view. * * Returns: (transfer none): the current search query. */ -const gchar* +const char * nautilus_gtk_places_view_get_search_query (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; - g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), NULL); - priv = nautilus_gtk_places_view_get_instance_private (view); - - return priv->search_query; + return view->search_query; } -/** +/* * nautilus_gtk_places_view_set_search_query: - * @view: a #NautilusGtkPlacesView + * @view: a NautilusGtkPlacesView * @query_text: the query, or NULL. * * Sets the search query of @view. The search is immediately performed @@ -2521,57 +2466,45 @@ nautilus_gtk_places_view_get_search_query (NautilusGtkPlacesView *view) */ void nautilus_gtk_places_view_set_search_query (NautilusGtkPlacesView *view, - const gchar *query_text) + const char *query_text) { - NautilusGtkPlacesViewPrivate *priv; - g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view)); - priv = nautilus_gtk_places_view_get_instance_private (view); - - if (g_strcmp0 (priv->search_query, query_text) != 0) + if (g_strcmp0 (view->search_query, query_text) != 0) { - g_clear_pointer (&priv->search_query, g_free); - priv->search_query = g_strdup (query_text); + g_clear_pointer (&view->search_query, g_free); + view->search_query = g_utf8_strdown (query_text, -1); - 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 (view->listbox)); + gtk_list_box_invalidate_headers (GTK_LIST_BOX (view->listbox)); update_view_mode (view); } } -/** +/* * nautilus_gtk_places_view_get_loading: - * @view: a #NautilusGtkPlacesView + * @view: a NautilusGtkPlacesView * * Returns %TRUE if the view is loading locations. - * - * Since: 3.18 */ gboolean nautilus_gtk_places_view_get_loading (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; - g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), FALSE); - priv = nautilus_gtk_places_view_get_instance_private (view); - - return priv->loading; + return view->loading; } static void update_loading (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; gboolean loading; 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; + loading = view->fetching_networks || view->connecting_to_server || + view->mounting_volume || view->unmounting_mount; set_busy_cursor (view, loading); nautilus_gtk_places_view_set_loading (view, loading); @@ -2581,15 +2514,11 @@ static void nautilus_gtk_places_view_set_loading (NautilusGtkPlacesView *view, gboolean loading) { - NautilusGtkPlacesViewPrivate *priv; - g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view)); - priv = nautilus_gtk_places_view_get_instance_private (view); - - if (priv->loading != loading) + if (view->loading != loading) { - priv->loading = loading; + view->loading = loading; g_object_notify_by_pspec (G_OBJECT (view), properties [PROP_LOADING]); } } @@ -2597,83 +2526,20 @@ nautilus_gtk_places_view_set_loading (NautilusGtkPlacesView *view, static gboolean nautilus_gtk_places_view_get_fetching_networks (NautilusGtkPlacesView *view) { - NautilusGtkPlacesViewPrivate *priv; - g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), FALSE); - priv = nautilus_gtk_places_view_get_instance_private (view); - - return priv->fetching_networks; + return view->fetching_networks; } static void nautilus_gtk_places_view_set_fetching_networks (NautilusGtkPlacesView *view, gboolean fetching_networks) { - NautilusGtkPlacesViewPrivate *priv; - g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view)); - priv = nautilus_gtk_places_view_get_instance_private (view); - - if (priv->fetching_networks != fetching_networks) + if (view->fetching_networks != fetching_networks) { - priv->fetching_networks = fetching_networks; + view->fetching_networks = fetching_networks; g_object_notify_by_pspec (G_OBJECT (view), properties [PROP_FETCHING_NETWORKS]); } } - -/** - * nautilus_gtk_places_view_get_local_only: - * @view: a #NautilusGtkPlacesView - * - * Returns %TRUE if only local volumes are shown, i.e. no networks - * are displayed. - * - * Returns: %TRUE if only local volumes are shown, %FALSE otherwise. - * - * Since: 3.18 - */ -gboolean -nautilus_gtk_places_view_get_local_only (NautilusGtkPlacesView *view) -{ - NautilusGtkPlacesViewPrivate *priv; - - g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view), FALSE); - - priv = nautilus_gtk_places_view_get_instance_private (view); - - return priv->local_only; -} - -/** - * nautilus_gtk_places_view_set_local_only: - * @view: a #NautilusGtkPlacesView - * @local_only: %TRUE to hide remote locations, %FALSE to show. - * - * Sets the #NautilusGtkPlacesView::local-only property to @local_only. - * - * Since: 3.18 - */ -void -nautilus_gtk_places_view_set_local_only (NautilusGtkPlacesView *view, - gboolean local_only) -{ - NautilusGtkPlacesViewPrivate *priv; - - g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view)); - - priv = nautilus_gtk_places_view_get_instance_private (view); - - if (priv->local_only != local_only) - { - priv->local_only = local_only; - - gtk_widget_set_visible (priv->actionbar, !local_only); - update_places (view); - - update_view_mode (view); - - g_object_notify_by_pspec (G_OBJECT (view), properties [PROP_LOCAL_ONLY]); - } -} diff --git a/src/gtk/nautilusgtkplacesview.ui b/src/gtk/nautilusgtkplacesview.ui index c5e785854..a7d5bdf21 100644 --- a/src/gtk/nautilusgtkplacesview.ui +++ b/src/gtk/nautilusgtkplacesview.ui @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <requires lib="gtk+" version="3.16"/> +<interface domain="gtk40"> <object class="GtkListStore" id="completion_store"> <columns> - <!-- column-name name --> <column type="gchararray"/> - <!-- column-name uri --> <column type="gchararray"/> </columns> </object> @@ -16,20 +13,21 @@ <property name="popup-completion">0</property> </object> <object class="GtkPopover" id="server_adresses_popover"> - <property name="relative-to">address_entry</property> + <property name="position">2</property> <child> <object class="GtkBox"> - <property name="visible">1</property> - <property name="border-width">18</property> - <property name="orientation">vertical</property> + <property name="orientation">1</property> <property name="spacing">6</property> + <property name="margin-start">18</property> + <property name="margin-end">18</property> + <property name="margin-top">18</property> + <property name="margin-bottom">18</property> <child> <object class="GtkLabel"> - <property name="visible">1</property> <property name="hexpand">1</property> - <property name="label" translatable="yes">Server Addresses</property> + <property name="label" translatable="1">Server Addresses</property> <attributes> - <attribute name="weight" value="bold"/> + <attribute name="weight" value="bold"></attribute> </attributes> <style> <class name="dim-label"/> @@ -38,21 +36,16 @@ </child> <child> <object class="GtkLabel"> - <property name="visible">1</property> <property name="hexpand">1</property> - <property name="label" translatable="yes">Server addresses are made up of a protocol prefix and an address. Examples:</property> + <property name="label" translatable="1">Server addresses are made up of a protocol prefix and an address. Examples:</property> <property name="wrap">1</property> <property name="width-chars">40</property> <property name="max-width-chars">40</property> <property name="xalign">0</property> </object> - <packing> - <property name="position">1</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">1</property> <property name="hexpand">1</property> <property name="label">smb://gnome.org, ssh://192.168.0.1, ftp://[2001:db8::1]</property> <property name="wrap">1</property> @@ -60,50 +53,41 @@ <property name="max-width-chars">40</property> <property name="xalign">0</property> </object> - <packing> - <property name="position">2</property> - </packing> </child> <child> <object class="GtkGrid" id="available_protocols_grid"> - <property name="visible">1</property> <property name="margin-top">12</property> <property name="hexpand">1</property> <property name="row-spacing">6</property> <property name="column-spacing">12</property> <child> <object class="GtkLabel"> - <property name="visible">1</property> <property name="hexpand">1</property> - <property name="label" translatable="yes">Available Protocols</property> + <property name="label" translatable="1">Available Protocols</property> <property name="xalign">0</property> <attributes> - <attribute name="weight" value="bold"/> + <attribute name="weight" value="bold"></attribute> </attributes> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">1</property> - <property name="label" translatable="yes">Prefix</property> + <property name="label" translatable="1">Prefix</property> <property name="xalign">0</property> <attributes> - <attribute name="weight" value="bold"/> + <attribute name="weight" value="bold"></attribute> </attributes> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">0</property> - </packing> </child> </object> - <packing> - <property name="position">3</property> - </packing> </child> </object> </child> @@ -111,233 +95,186 @@ <object class="GtkPopover" id="recent_servers_popover"> <child> <object class="GtkStack" id="recent_servers_stack"> - <property name="visible">1</property> <child> - <object class="GtkBox"> - <property name="visible">1</property> - <property name="vexpand">1</property> - <property name="valign">center</property> - <property name="orientation">vertical</property> - <property name="spacing">18</property> - <child> - <object class="GtkImage"> - <property name="visible">1</property> - <property name="pixel-size">48</property> - <property name="icon-name">network-server-symbolic</property> - <style> - <class name="dim-label"/> - </style> - </object> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">1</property> - <property name="label" translatable="yes" comments="Translators: Server as any successfully connected network address">No recent servers found</property> - <style> - <class name="dim-label"/> - </style> + <object class="GtkStackPage"> + <property name="name">empty</property> + <property name="child"> + <object class="GtkBox"> + <property name="vexpand">1</property> + <property name="valign">3</property> + <property name="orientation">1</property> + <property name="spacing">18</property> + <child> + <object class="GtkImage"> + <property name="pixel-size">48</property> + <property name="icon-name">network-server-symbolic</property> + <style> + <class name="dim-label"/> + </style> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="label" translatable="1" comments="Translators: Server as any successfully connected network address">No recent servers found</property> + <style> + <class name="dim-label"/> + </style> + </object> + </child> </object> - <packing> - <property name="position">1</property> - </packing> - </child> + </property> </object> - <packing> - <property name="name">empty</property> - </packing> </child> <child> - <object class="GtkBox"> - <property name="visible">1</property> - <property name="border-width">12</property> - <property name="orientation">vertical</property> - <property name="spacing">12</property> - <child> - <object class="GtkLabel"> - <property name="visible">1</property> - <property name="label" translatable="yes">Recent Servers</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - <child> - <object class="GtkScrolledWindow"> - <property name="visible">1</property> - <property name="can-focus">1</property> - <property name="vexpand">1</property> - <property name="shadow-type">in</property> - <property name="min-content-width">250</property> - <property name="min-content-height">200</property> + <object class="GtkStackPage"> + <property name="name">list</property> + <property name="child"> + <object class="GtkBox"> + <property name="orientation">1</property> + <property name="spacing">12</property> + <property name="margin-start">12</property> + <property name="margin-end">12</property> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> <child> - <object class="GtkViewport"> - <property name="visible">1</property> - <property name="shadow-type">none</property> + <object class="GtkLabel"> + <property name="label" translatable="1">Recent Servers</property> + <attributes> + <attribute name="weight" value="bold"></attribute> + </attributes> + </object> + </child> + <child> + <object class="GtkScrolledWindow"> + <property name="vexpand">1</property> + <property name="has-frame">1</property> + <property name="min-content-width">250</property> + <property name="min-content-height">200</property> <child> - <object class="GtkListBox" id="recent_servers_listbox"> - <property name="visible">1</property> - <property name="can-focus">1</property> - <property name="selection-mode">none</property> - <signal name="row-activated" handler="on_recent_servers_listbox_row_activated" object="NautilusGtkPlacesView" swapped="yes"/> + <object class="GtkViewport"> + <child> + <object class="GtkListBox" id="recent_servers_listbox"> + <property name="selection-mode">0</property> + <signal name="row-activated" handler="on_recent_servers_listbox_row_activated" object="NautilusGtkPlacesView" swapped="yes"/> + </object> + </child> </object> </child> </object> </child> </object> - <packing> - <property name="position">1</property> - </packing> - </child> + </property> </object> - <packing> - <property name="name">list</property> - </packing> </child> </object> </child> </object> <template class="NautilusGtkPlacesView" parent="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="orientation">vertical</property> - <signal name="key-press-event" handler="on_key_press_event" object="NautilusGtkPlacesView" swapped="no"/> + <property name="orientation">1</property> <child> <object class="GtkStack" id="stack"> - <property name="visible">1</property> <property name="vhomogeneous">0</property> - <property name="transition-type">crossfade</property> + <property name="transition-type">1</property> <child> - <object class="GtkFrame"> - <property name="visible">1</property> - <property name="shadow-type">none</property> - <child> + <object class="GtkStackPage"> + <property name="name">browse</property> + <property name="child"> <object class="GtkScrolledWindow"> - <property name="visible">1</property> <property name="hexpand">1</property> <property name="vexpand">1</property> <child> <object class="GtkViewport"> - <property name="visible">1</property> - <property name="shadow-type">none</property> <child> <object class="GtkListBox" id="listbox"> - <property name="visible">1</property> - <property name="can-focus">1</property> - <property name="selection-mode">none</property> + <property name="selection-mode">0</property> <signal name="row-activated" handler="on_listbox_row_activated" object="NautilusGtkPlacesView" swapped="yes"/> </object> </child> </object> </child> </object> - </child> + </property> </object> - <packing> - <property name="name">browse</property> - </packing> </child> <child> - <object class="GtkBox"> - <property name="visible">1</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="hexpand">1</property> - <property name="vexpand">1</property> - <property name="orientation">vertical</property> - <property name="spacing">12</property> - <child> - <object class="GtkImage"> - <property name="visible">1</property> - <property name="pixel-size">72</property> - <property name="icon-name">edit-find-symbolic</property> - <style> - <class name="dim-label"/> - </style> - </object> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">1</property> - <property name="label" translatable="yes">No results found</property> - <attributes> - <attribute name="weight" value="bold"/> - <attribute name="scale" value="1.44"/> - </attributes> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">1</property> - <property name="label" translatable="yes">Try a different search</property> - <style> - <class name="dim-label"/> - </style> + <object class="GtkStackPage"> + <property name="name">empty-search</property> + <property name="child"> + <object class="GtkBox"> + <property name="halign">3</property> + <property name="valign">3</property> + <property name="hexpand">1</property> + <property name="vexpand">1</property> + <property name="orientation">1</property> + <property name="spacing">12</property> + <child> + <object class="GtkImage"> + <property name="pixel-size">72</property> + <property name="icon-name">edit-find-symbolic</property> + <style> + <class name="dim-label"/> + </style> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="label" translatable="1">No results found</property> + <attributes> + <attribute name="weight" value="bold"></attribute> + <attribute name="scale" value="1.44"></attribute> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="label" translatable="1">Try a different search</property> + <style> + <class name="dim-label"/> + </style> + </object> + </child> </object> - <packing> - <property name="position">2</property> - </packing> - </child> + </property> </object> - <packing> - <property name="name">empty-search</property> - </packing> </child> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> </child> <child> <object class="GtkActionBar" id="actionbar"> - <property name="visible">1</property> <property name="hexpand">1</property> <style> <class name="background"/> </style> <child> <object class="GtkLabel"> - <property name="visible">1</property> <property name="hexpand">1</property> <property name="xalign">0</property> - <property name="label" translatable="yes">Connect to _Server</property> + <property name="label" translatable="1">Connect to _Server</property> <property name="mnemonic-widget">address_entry</property> <property name="use-underline">1</property> <attributes> - <attribute name="weight" value="bold"/> + <attribute name="weight" value="bold"></attribute> </attributes> </object> </child> - <child> + <child type="end"> <object class="GtkButton" id="connect_button"> - <property name="label" translatable="yes">Con_nect</property> + <property name="label" translatable="1">Con_nect</property> <property name="use-underline">1</property> - <property name="visible">1</property> - <property name="can-focus">1</property> <property name="sensitive">0</property> <property name="receives-default">1</property> - <property name="valign">center</property> + <property name="valign">3</property> <signal name="clicked" handler="on_connect_button_clicked" object="NautilusGtkPlacesView" swapped="yes"/> </object> - <packing> - <property name="pack-type">end</property> - </packing> </child> - <child> + <child type="end"> <object class="GtkBox"> - <property name="visible">1</property> <property name="hexpand">1</property> <child> <object class="GtkEntry" id="address_entry"> - <property name="visible">1</property> - <property name="can-focus">1</property> <property name="hexpand">1</property> <property name="width-chars">20</property> - <property name="placeholder-text" translatable="yes">Enter server address…</property> + <property name="placeholder-text" translatable="1">Enter server address…</property> <property name="secondary-icon-name">dialog-question-symbolic</property> <property name="completion">address_entry_completion</property> <signal name="notify::text" handler="on_address_entry_text_changed" object="NautilusGtkPlacesView" swapped="yes"/> @@ -347,36 +284,21 @@ </child> <child> <object class="GtkMenuButton" id="server_list_button"> - <property name="visible">1</property> - <property name="can-focus">1</property> <property name="receives-default">1</property> - <property name="direction">up</property> + <property name="direction">0</property> <property name="popover">recent_servers_popover</property> + <property name="icon-name">pan-down-symbolic</property> <style> <class name="server-list-button"/> </style> - <child> - <object class="GtkImage"> - <property name="visible">1</property> - <property name="icon-name">pan-down-symbolic</property> - </object> - </child> </object> </child> <style> <class name="linked"/> </style> </object> - <packing> - <property name="pack-type">end</property> - </packing> </child> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> </child> </template> </interface> diff --git a/src/gtk/nautilusgtkplacesviewprivate.h b/src/gtk/nautilusgtkplacesviewprivate.h index b821476cf..4cf6e3e17 100644 --- a/src/gtk/nautilusgtkplacesviewprivate.h +++ b/src/gtk/nautilusgtkplacesviewprivate.h @@ -22,7 +22,7 @@ #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) #endif -#include "nautilusgtkplacessidebar.h" +#include "nautilusgtkplacessidebarprivate.h" G_BEGIN_DECLS @@ -35,30 +35,6 @@ G_BEGIN_DECLS typedef struct _NautilusGtkPlacesView NautilusGtkPlacesView; typedef struct _NautilusGtkPlacesViewClass NautilusGtkPlacesViewClass; -typedef struct _NautilusGtkPlacesViewPrivate NautilusGtkPlacesViewPrivate; - -struct _NautilusGtkPlacesViewClass -{ - GtkBoxClass parent_class; - - void (* open_location) (NautilusGtkPlacesView *view, - GFile *location, - NautilusGtkPlacesOpenFlags open_flags); - - void (* show_error_message) (NautilusGtkPlacesSidebar *sidebar, - const gchar *primary, - const gchar *secondary); - - /*< private >*/ - - /* Padding for future expansion */ - gpointer reserved[10]; -}; - -struct _NautilusGtkPlacesView -{ - GtkBox parent_instance; -}; GType nautilus_gtk_places_view_get_type (void) G_GNUC_CONST; @@ -66,14 +42,9 @@ NautilusGtkPlacesOpenFlags nautilus_gtk_places_view_get_open_flags void nautilus_gtk_places_view_set_open_flags (NautilusGtkPlacesView *view, NautilusGtkPlacesOpenFlags flags); -const gchar* nautilus_gtk_places_view_get_search_query (NautilusGtkPlacesView *view); +const char * nautilus_gtk_places_view_get_search_query (NautilusGtkPlacesView *view); void nautilus_gtk_places_view_set_search_query (NautilusGtkPlacesView *view, - const gchar *query_text); - -gboolean nautilus_gtk_places_view_get_local_only (NautilusGtkPlacesView *view); - -void nautilus_gtk_places_view_set_local_only (NautilusGtkPlacesView *view, - gboolean local_only); + const char *query_text); gboolean nautilus_gtk_places_view_get_loading (NautilusGtkPlacesView *view); diff --git a/src/gtk/nautilusgtkplacesviewrow.c b/src/gtk/nautilusgtkplacesviewrow.c index f07dd4e70..0fe87ec10 100644 --- a/src/gtk/nautilusgtkplacesviewrow.c +++ b/src/gtk/nautilusgtkplacesviewrow.c @@ -19,6 +19,7 @@ #include "config.h" #include <glib/gi18n.h> #include <gtk/gtk.h> +#include "nautilus-enum-types.h" #include <gio/gio.h> @@ -42,7 +43,6 @@ struct _NautilusGtkPlacesViewRow GtkSpinner *busy_spinner; GtkButton *eject_button; GtkImage *eject_icon; - GtkEventBox *event_box; GtkImage *icon_image; GtkLabel *name_label; GtkLabel *path_label; @@ -53,7 +53,7 @@ struct _NautilusGtkPlacesViewRow GCancellable *cancellable; - gint is_network : 1; + int is_network : 1; }; G_DEFINE_TYPE (NautilusGtkPlacesViewRow, nautilus_gtk_places_view_row, GTK_TYPE_LIST_BOX_ROW) @@ -82,9 +82,9 @@ measure_available_space_finished (GObject *object, GError *error; guint64 free_space; guint64 total_space; - gchar *formatted_free_size; - gchar *formatted_total_size; - gchar *label; + char *formatted_free_size; + char *formatted_total_size; + char *label; guint plural_form; error = NULL; @@ -210,16 +210,13 @@ nautilus_gtk_places_view_row_get_property (GObject *object, GParamSpec *pspec) { NautilusGtkPlacesViewRow *self; - GIcon *icon; self = NAUTILUS_GTK_PLACES_VIEW_ROW (object); - icon = NULL; switch (prop_id) { case PROP_ICON: - gtk_image_get_gicon (self->icon_image, &icon, NULL); - g_value_set_object (value, icon); + g_value_set_object (value, gtk_image_get_gicon (self->icon_image)); break; case PROP_NAME: @@ -262,9 +259,7 @@ nautilus_gtk_places_view_row_set_property (GObject *object, switch (prop_id) { case PROP_ICON: - gtk_image_set_from_gicon (self->icon_image, - g_value_get_object (value), - GTK_ICON_SIZE_LARGE_TOOLBAR); + gtk_image_set_from_gicon (self->icon_image, g_value_get_object (value)); break; case PROP_NAME: @@ -309,6 +304,19 @@ nautilus_gtk_places_view_row_set_property (GObject *object, } static void +nautilus_gtk_places_view_row_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) +{ + GtkWidget *menu = GTK_WIDGET (g_object_get_data (G_OBJECT (widget), "menu")); + + GTK_WIDGET_CLASS (nautilus_gtk_places_view_row_parent_class)->size_allocate (widget, width, height, baseline); + if (menu) + gtk_popover_present (GTK_POPOVER (menu)); +} + +static void nautilus_gtk_places_view_row_class_init (NautilusGtkPlacesViewRowClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -318,6 +326,8 @@ nautilus_gtk_places_view_row_class_init (NautilusGtkPlacesViewRowClass *klass) object_class->get_property = nautilus_gtk_places_view_row_get_property; object_class->set_property = nautilus_gtk_places_view_row_set_property; + widget_class->size_allocate = nautilus_gtk_places_view_row_size_allocate; + properties[PROP_ICON] = g_param_spec_object ("icon", "Icon of the row", @@ -376,7 +386,6 @@ nautilus_gtk_places_view_row_class_init (NautilusGtkPlacesViewRowClass *klass) 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); @@ -430,14 +439,6 @@ nautilus_gtk_places_view_row_get_eject_button (NautilusGtkPlacesViewRow *row) return GTK_WIDGET (row->eject_button); } -GtkWidget* -nautilus_gtk_places_view_row_get_event_box (NautilusGtkPlacesViewRow *row) -{ - g_return_val_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW_ROW (row), NULL); - - return GTK_WIDGET (row->event_box); -} - void nautilus_gtk_places_view_row_set_busy (NautilusGtkPlacesViewRow *row, gboolean is_busy) @@ -448,10 +449,12 @@ nautilus_gtk_places_view_row_set_busy (NautilusGtkPlacesViewRow *row, { 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_spinner_start (row->busy_spinner); } else { gtk_widget_set_child_visible (GTK_WIDGET (row->mount_stack), FALSE); + gtk_spinner_stop (row->busy_spinner); } } @@ -471,7 +474,7 @@ nautilus_gtk_places_view_row_set_is_network (NautilusGtkPlacesViewRow *row, { row->is_network = is_network; - gtk_image_set_from_icon_name (row->eject_icon, "media-eject-symbolic", GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name (row->eject_icon, "media-eject-symbolic"); gtk_widget_set_tooltip_text (GTK_WIDGET (row->eject_button), is_network ? _("Disconnect") : _("Unmount")); } } diff --git a/src/gtk/nautilusgtkplacesviewrow.ui b/src/gtk/nautilusgtkplacesviewrow.ui index 99d2dcb42..231d65975 100644 --- a/src/gtk/nautilusgtkplacesviewrow.ui +++ b/src/gtk/nautilusgtkplacesviewrow.ui @@ -1,80 +1,59 @@ <?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <requires lib="gtk+" version="3.16"/> +<interface domain="gtk40"> <template class="NautilusGtkPlacesViewRow" parent="GtkListBoxRow"> <property name="width-request">100</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <child> - <object class="GtkEventBox" id="event_box"> - <property name="visible">1</property> + <property name="child"> + <object class="GtkBox" id="box"> + <property name="margin-start">12</property> + <property name="margin-end">12</property> + <property name="margin-top">6</property> + <property name="margin-bottom">6</property> + <property name="spacing">18</property> <child> - <object class="GtkBox" id="box"> - <property name="visible">1</property> - <property name="margin-start">12</property> - <property name="margin-end">12</property> - <property name="margin-top">6</property> - <property name="margin-bottom">6</property> - <property name="spacing">18</property> - <child> - <object class="GtkImage" id="icon_image"> - <property name="visible">1</property> - <property name="pixel-size">32</property> - </object> - </child> - <child> - <object class="GtkLabel" id="name_label"> - <property name="visible">1</property> - <property name="hexpand">1</property> - <property name="xalign">0</property> - <property name="ellipsize">end</property> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="available_space_label"> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="path_label"> - <property name="visible">1</property> - <property name="justify">right</property> - <property name="ellipsize">middle</property> - <property name="xalign">0</property> - <property name="max-width-chars">15</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="position">3</property> - </packing> - </child> + <object class="GtkImage" id="icon_image"> + <property name="pixel-size">32</property> + </object> + </child> + <child> + <object class="GtkLabel" id="name_label"> + <property name="hexpand">1</property> + <property name="xalign">0</property> + <property name="ellipsize">3</property> + </object> + </child> + <child> + <object class="GtkLabel" id="available_space_label"> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + </object> + </child> + <child> + <object class="GtkLabel" id="path_label"> + <property name="justify">1</property> + <property name="ellipsize">2</property> + <property name="xalign">0</property> + <property name="max-width-chars">15</property> + <style> + <class name="dim-label"/> + </style> + </object> + </child> + <child> + <object class="GtkStack" id="mount_stack"> <child> - <object class="GtkStack" id="mount_stack"> - <property name="visible">1</property> - <property name="hhomogeneous">1</property> - <property name="vhomogeneous">1</property> - <child> + <object class="GtkStackPage"> + <property name="name">button</property> + <property name="child"> <object class="GtkButton" id="eject_button"> - <property name="visible">1</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="tooltip-text" translatable="yes">Unmount</property> + <property name="visible">0</property> + <property name="halign">3</property> + <property name="valign">3</property> + <property name="tooltip-text" translatable="1">Unmount</property> <child> <object class="GtkImage" id="eject_icon"> - <property name="visible">1</property> <property name="icon-name">media-eject-symbolic</property> - <property name="icon-size">1</property> </object> </child> <style> @@ -82,23 +61,23 @@ <class name="sidebar-button"/> </style> </object> - </child> - <child> + </property> + </object> + </child> + <child> + <object class="GtkStackPage"> + <property name="name">spinner</property> + <property name="child"> <object class="GtkSpinner" id="busy_spinner"> - <property name="visible">1</property> - <property name="active">1</property> - <property name="halign">center</property> - <property name="valign">center</property> + <property name="halign">3</property> + <property name="valign">3</property> </object> - </child> + </property> </object> - <packing> - <property name="position">4</property> - </packing> </child> </object> </child> </object> - </child> + </property> </template> </interface> diff --git a/src/gtk/nautilusgtkplacesviewrowprivate.h b/src/gtk/nautilusgtkplacesviewrowprivate.h index fb32e1c67..d54b918c0 100644 --- a/src/gtk/nautilusgtkplacesviewrowprivate.h +++ b/src/gtk/nautilusgtkplacesviewrowprivate.h @@ -34,8 +34,6 @@ GtkWidget* nautilus_gtk_places_view_row_new (GVolu GtkWidget* nautilus_gtk_places_view_row_get_eject_button (NautilusGtkPlacesViewRow *row); -GtkWidget* nautilus_gtk_places_view_row_get_event_box (NautilusGtkPlacesViewRow *row); - GMount* nautilus_gtk_places_view_row_get_mount (NautilusGtkPlacesViewRow *row); GVolume* nautilus_gtk_places_view_row_get_volume (NautilusGtkPlacesViewRow *row); diff --git a/src/gtk/nautilusgtksidebarrow.c b/src/gtk/nautilusgtksidebarrow.c index 7cc24b09f..0b0d6103f 100644 --- a/src/gtk/nautilusgtksidebarrow.c +++ b/src/gtk/nautilusgtksidebarrow.c @@ -19,14 +19,14 @@ #include "config.h" #include <glib/gi18n.h> #include <gtk/gtk.h> +#include "nautilus-enum-types.h" #include "nautilusgtksidebarrowprivate.h" /* For section and place type enums */ #include "nautilusgtkplacessidebarprivate.h" -#include "nautilusgtkplacessidebar.h" #ifdef HAVE_CLOUDPROVIDERS -#include <cloudproviders/cloudprovidersaccount.h> +#include <cloudproviders.h> #endif struct _NautilusGtkSidebarRow @@ -36,22 +36,21 @@ struct _NautilusGtkSidebarRow GIcon *end_icon; GtkWidget *start_icon_widget; GtkWidget *end_icon_widget; - gchar *label; - gchar *tooltip; + char *label; + char *tooltip; GtkWidget *label_widget; gboolean ejectable; GtkWidget *eject_button; - gint order_index; - NautilusGtkPlacesSidebarSectionType section_type; - NautilusGtkPlacesSidebarPlaceType place_type; - gchar *uri; + int order_index; + NautilusGtkPlacesSectionType section_type; + NautilusGtkPlacesPlaceType place_type; + char *uri; GDrive *drive; GVolume *volume; GMount *mount; GObject *cloud_provider_account; gboolean placeholder; NautilusGtkPlacesSidebar *sidebar; - GtkWidget *event_box; GtkWidget *revealer; GtkWidget *busy_spinner; }; @@ -88,7 +87,7 @@ cloud_row_update (NautilusGtkSidebarRow *self) { CloudProvidersAccount *account; GIcon *end_icon; - gint provider_status; + int provider_status; account = CLOUD_PROVIDERS_ACCOUNT (self->cloud_provider_account); provider_status = cloud_providers_account_get_status (account); @@ -165,11 +164,11 @@ nautilus_gtk_sidebar_row_get_property (GObject *object, break; case PROP_SECTION_TYPE: - g_value_set_int (value, self->section_type); + g_value_set_enum (value, self->section_type); break; case PROP_PLACE_TYPE: - g_value_set_int (value, self->place_type); + g_value_set_enum (value, self->place_type); break; case PROP_URI: @@ -208,7 +207,6 @@ nautilus_gtk_sidebar_row_set_property (GObject *object, GParamSpec *pspec) { NautilusGtkSidebarRow *self = NAUTILUS_GTK_SIDEBAR_ROW (object); - GtkStyleContext *context; switch (prop_id) { @@ -223,9 +221,7 @@ nautilus_gtk_sidebar_row_set_property (GObject *object, if (object != NULL) { self->start_icon = G_ICON (g_object_ref (object)); - gtk_image_set_from_gicon (GTK_IMAGE (self->start_icon_widget), - self->start_icon, - GTK_ICON_SIZE_MENU); + gtk_image_set_from_gicon (GTK_IMAGE (self->start_icon_widget), self->start_icon); } else { @@ -241,9 +237,7 @@ nautilus_gtk_sidebar_row_set_property (GObject *object, if (object != NULL) { self->end_icon = G_ICON (g_object_ref (object)); - gtk_image_set_from_gicon (GTK_IMAGE (self->end_icon_widget), - self->end_icon, - GTK_ICON_SIZE_MENU); + gtk_image_set_from_gicon (GTK_IMAGE (self->end_icon_widget), self->end_icon); gtk_widget_show (self->end_icon_widget); } else @@ -279,16 +273,16 @@ nautilus_gtk_sidebar_row_set_property (GObject *object, break; case PROP_SECTION_TYPE: - self->section_type = g_value_get_int (value); - if (self->section_type == SECTION_COMPUTER || - self->section_type == SECTION_OTHER_LOCATIONS) + self->section_type = g_value_get_enum (value); + if (self->section_type == NAUTILUS_GTK_PLACES_SECTION_COMPUTER || + self->section_type == NAUTILUS_GTK_PLACES_SECTION_OTHER_LOCATIONS) gtk_label_set_ellipsize (GTK_LABEL (self->label_widget), PANGO_ELLIPSIZE_NONE); else gtk_label_set_ellipsize (GTK_LABEL (self->label_widget), PANGO_ELLIPSIZE_END); break; case PROP_PLACE_TYPE: - self->place_type = g_value_get_int (value); + self->place_type = g_value_get_enum (value); break; case PROP_URI: @@ -340,8 +334,8 @@ nautilus_gtk_sidebar_row_set_property (GObject *object, self->tooltip = NULL; gtk_widget_set_tooltip_text (GTK_WIDGET (self), NULL); self->ejectable = FALSE; - self->section_type = SECTION_BOOKMARKS; - self->place_type = PLACES_BOOKMARK_PLACEHOLDER; + self->section_type = NAUTILUS_GTK_PLACES_SECTION_BOOKMARKS; + self->place_type = NAUTILUS_GTK_PLACES_BOOKMARK_PLACEHOLDER; g_free (self->uri); self->uri = NULL; g_clear_object (&self->drive); @@ -349,12 +343,9 @@ nautilus_gtk_sidebar_row_set_property (GObject *object, g_clear_object (&self->mount); g_clear_object (&self->cloud_provider_account); - gtk_container_foreach (GTK_CONTAINER (self), - (GtkCallback) gtk_widget_destroy, - NULL); + gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (self), NULL); - context = gtk_widget_get_style_context (GTK_WIDGET (self)); - gtk_style_context_add_class (context, "sidebar-placeholder-row"); + gtk_widget_add_css_class (GTK_WIDGET (self), "sidebar-placeholder-row"); } break; @@ -380,18 +371,18 @@ on_child_revealed (GObject *self, void nautilus_gtk_sidebar_row_reveal (NautilusGtkSidebarRow *self) { - gtk_widget_show_all (GTK_WIDGET (self)); + gtk_widget_show (GTK_WIDGET (self)); gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), TRUE); } void nautilus_gtk_sidebar_row_hide (NautilusGtkSidebarRow *self, - gboolean inmediate) + gboolean immediate) { guint transition_duration; transition_duration = gtk_revealer_get_transition_duration (GTK_REVEALER (self->revealer)); - if (inmediate) + if (immediate) gtk_revealer_set_transition_duration (GTK_REVEALER (self->revealer), 0); gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), FALSE); @@ -409,8 +400,7 @@ nautilus_gtk_sidebar_row_set_start_icon (NautilusGtkSidebarRow *self, { g_set_object (&self->start_icon, icon); if (self->start_icon != NULL) - gtk_image_set_from_gicon (GTK_IMAGE (self->start_icon_widget), self->start_icon, - GTK_ICON_SIZE_MENU); + gtk_image_set_from_gicon (GTK_IMAGE (self->start_icon_widget), self->start_icon); else gtk_image_clear (GTK_IMAGE (self->start_icon_widget)); @@ -428,8 +418,7 @@ nautilus_gtk_sidebar_row_set_end_icon (NautilusGtkSidebarRow *self, { g_set_object (&self->end_icon, icon); if (self->end_icon != NULL) - gtk_image_set_from_gicon (GTK_IMAGE (self->end_icon_widget), self->end_icon, - GTK_ICON_SIZE_MENU); + gtk_image_set_from_gicon (GTK_IMAGE (self->end_icon_widget), self->end_icon); else if (self->end_icon_widget != NULL) gtk_image_clear (GTK_IMAGE (self->end_icon_widget)); @@ -467,6 +456,8 @@ static void nautilus_gtk_sidebar_row_init (NautilusGtkSidebarRow *self) { gtk_widget_init_template (GTK_WIDGET (self)); + + gtk_widget_set_focus_on_click (GTK_WIDGET (self), FALSE); } static void @@ -537,22 +528,24 @@ nautilus_gtk_sidebar_row_class_init (NautilusGtkSidebarRowClass *klass) G_PARAM_STATIC_STRINGS)); properties [PROP_SECTION_TYPE] = - g_param_spec_int ("section-type", - "section type", - "The section type.", - SECTION_INVALID, N_SECTIONS, SECTION_INVALID, - (G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS | - G_PARAM_CONSTRUCT_ONLY)); + g_param_spec_enum ("section-type", + "section type", + "The section type.", + NAUTILUS_TYPE_GTK_PLACES_SECTION_TYPE, + NAUTILUS_GTK_PLACES_SECTION_INVALID, + (G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS | + G_PARAM_CONSTRUCT_ONLY)); properties [PROP_PLACE_TYPE] = - g_param_spec_int ("place-type", - "place type", - "The place type.", - PLACES_INVALID, N_PLACES, PLACES_INVALID, - (G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS | - G_PARAM_CONSTRUCT_ONLY)); + g_param_spec_enum ("place-type", + "place type", + "The place type.", + NAUTILUS_TYPE_GTK_PLACES_PLACE_TYPE, + NAUTILUS_GTK_PLACES_INVALID, + (G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS | + G_PARAM_CONSTRUCT_ONLY)); properties [PROP_URI] = g_param_spec_string ("uri", @@ -616,7 +609,6 @@ nautilus_gtk_sidebar_row_class_init (NautilusGtkSidebarRowClass *klass) gtk_widget_class_bind_template_child (widget_class, NautilusGtkSidebarRow, end_icon_widget); gtk_widget_class_bind_template_child (widget_class, NautilusGtkSidebarRow, label_widget); gtk_widget_class_bind_template_child (widget_class, NautilusGtkSidebarRow, eject_button); - gtk_widget_class_bind_template_child (widget_class, NautilusGtkSidebarRow, event_box); gtk_widget_class_bind_template_child (widget_class, NautilusGtkSidebarRow, revealer); gtk_widget_class_bind_template_child (widget_class, NautilusGtkSidebarRow, busy_spinner); @@ -651,12 +643,6 @@ nautilus_gtk_sidebar_row_get_eject_button (NautilusGtkSidebarRow *self) return self->eject_button; } -GtkWidget* -nautilus_gtk_sidebar_row_get_event_box (NautilusGtkSidebarRow *self) -{ - return self->event_box; -} - void nautilus_gtk_sidebar_row_set_busy (NautilusGtkSidebarRow *row, gboolean is_busy) diff --git a/src/gtk/nautilusgtksidebarrow.ui b/src/gtk/nautilusgtksidebarrow.ui index 26265fcb3..956ea63cb 100644 --- a/src/gtk/nautilusgtksidebarrow.ui +++ b/src/gtk/nautilusgtksidebarrow.ui @@ -1,92 +1,70 @@ <?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> +<interface domain="gtk40"> <template class="NautilusGtkSidebarRow" parent="GtkListBoxRow"> - <property name="visible">True</property> - <property name="margin-top">1</property> - <property name="margin-bottom">1</property> - <property name="focus-on-click">False</property> + <property name="focus-on-click">0</property> <style> <class name="sidebar-row"/> </style> - <child> + <property name="child"> <object class="GtkRevealer" id="revealer"> - <property name="visible">1</property> <property name="reveal-child">1</property> <signal name="notify::child-revealed" handler="on_child_revealed"/> <style> <class name="sidebar-revealer"/> </style> <child> - <object class="GtkEventBox" id="event_box"> - <property name="visible">1</property> + <object class="GtkBox"> <child> - <object class="GtkBox"> - <property name="visible">1</property> - <child> - <object class="GtkImage" id="start_icon_widget"> - <property name="visible">True</property> - <style> - <class name="sidebar-icon"/> - </style> - </object> - </child> - <child> - <object class="GtkLabel" id="label_widget"> - <property name="visible">1</property> - <property name="hexpand">1</property> - <property name="xalign">0</property> - <style> - <class name="sidebar-label"/> - </style> - </object> - </child> - <child> - <object class="GtkImage" id="end_icon_widget"> - <property name="visible">False</property> - <property name="hexpand">True</property> - <property name="halign">end</property> - <property name="valign">center</property> - <property name="no-show-all">1</property> - <style> - <class name="sidebar-icon"/> - </style> - </object> - </child> - <child> - <object class="GtkButton" id="eject_button"> - <property name="visible">1</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="margin-start">4px</property> - <property name="no-show-all">1</property> - <property name="tooltip-text" translatable="yes">Unmount</property> - <child> - <object class="GtkImage"> - <property name="visible">1</property> - <property name="icon-name">media-eject-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - <style> - <class name="image-button"/> - <class name="sidebar-button"/> - </style> - </object> - </child> - <child> - <object class="GtkSpinner" id="busy_spinner"> - <property name="active">1</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="margin-start">4px</property> - <property name="no-show-all">1</property> - </object> - </child> + <object class="GtkImage" id="start_icon_widget"> + <style> + <class name="sidebar-icon"/> + </style> + </object> + </child> + <child> + <object class="GtkLabel" id="label_widget"> + <property name="hexpand">1</property> + <property name="xalign">0</property> + <style> + <class name="sidebar-label"/> + </style> + </object> + </child> + <child> + <object class="GtkImage" id="end_icon_widget"> + <property name="visible">0</property> + <property name="hexpand">1</property> + <property name="halign">2</property> + <property name="valign">3</property> + <style> + <class name="sidebar-icon"/> + </style> + </object> + </child> + <child> + <object class="GtkButton" id="eject_button"> + <property name="halign">3</property> + <property name="valign">3</property> + <property name="margin-start">4px</property> + <property name="icon-name">media-eject-symbolic</property> + <property name="tooltip-text" translatable="1">Unmount</property> + <style> + <class name="sidebar-button"/> + </style> + </object> + </child> + <child> + <object class="GtkSpinner" id="busy_spinner"> + <property name="spinning">1</property> + <property name="halign">3</property> + <property name="valign">3</property> + <property name="margin-start">4px</property> + <property name="visible">0</property> </object> </child> </object> </child> </object> - </child> + </property> </template> </interface> diff --git a/src/gtk/nautilusgtksidebarrowprivate.h b/src/gtk/nautilusgtksidebarrowprivate.h index 437384954..0bd9355af 100644 --- a/src/gtk/nautilusgtksidebarrowprivate.h +++ b/src/gtk/nautilusgtksidebarrowprivate.h @@ -44,11 +44,10 @@ NautilusGtkSidebarRow *nautilus_gtk_sidebar_row_clone (NautilusGtkSidebarRow *s /* Use these methods instead of gtk_widget_hide/show to use an animation */ void nautilus_gtk_sidebar_row_hide (NautilusGtkSidebarRow *self, - gboolean inmediate); + gboolean immediate); void nautilus_gtk_sidebar_row_reveal (NautilusGtkSidebarRow *self); GtkWidget *nautilus_gtk_sidebar_row_get_eject_button (NautilusGtkSidebarRow *self); -GtkWidget *nautilus_gtk_sidebar_row_get_event_box (NautilusGtkSidebarRow *self); void nautilus_gtk_sidebar_row_set_start_icon (NautilusGtkSidebarRow *self, GIcon *icon); void nautilus_gtk_sidebar_row_set_end_icon (NautilusGtkSidebarRow *self, diff --git a/src/meson.build b/src/meson.build index 4a11e4ed8..4c171bd6d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -14,6 +14,7 @@ libnautilus_sources = [ c_template: 'nautilus-enum-types.c.template', h_template: 'nautilus-enum-types.h.template', sources: [ + 'gtk/nautilusgtkplacessidebarprivate.h', 'nautilus-enums.h', 'nautilus-search-popover.h', 'nautilus-special-location-bar.h', @@ -55,18 +56,15 @@ libnautilus_sources = [ namespace: 'Nautilus' ), 'gtk/nautilusgtkbookmarksmanager.c', - 'gtk/nautilusgtkbookmarksmanager.h', + 'gtk/nautilusgtkbookmarksmanagerprivate.h', 'gtk/nautilusgtkplacessidebar.c', 'gtk/nautilusgtkplacessidebarprivate.h', - 'gtk/nautilusgtkplacessidebar.h', 'gtk/nautilusgtksidebarrow.c', 'gtk/nautilusgtksidebarrowprivate.h', 'gtk/nautilusgtkplacesview.c', 'gtk/nautilusgtkplacesviewprivate.h', 'gtk/nautilusgtkplacesviewrow.c', 'gtk/nautilusgtkplacesviewrowprivate.h', - 'nautilus-gtk4-helpers.c', - 'nautilus-gtk4-helpers.h', 'nautilus-application.c', 'nautilus-application.h', 'nautilus-bookmark-list.c', @@ -265,9 +263,9 @@ nautilus_deps = [ gmodule, gnome_autoar, gnome_desktop, - libhandy, + libadwaita, libportal, - libportal_gtk3, + libportal_gtk4, nautilus_extension, selinux, tracker_sparql, diff --git a/src/nautilus-application.c b/src/nautilus-application.c index e254c6513..505001f1a 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -33,7 +33,7 @@ #include <glib/gi18n.h> #include <glib/gstdio.h> #include <gtk/gtk.h> -#include <libhandy-1/handy.h> +#include <libadwaita-1/adwaita.h> #include <nautilus-extension.h> #include <sys/stat.h> #include <sys/types.h> @@ -65,7 +65,6 @@ #include "nautilus-view.h" #include "nautilus-window-slot.h" #include "nautilus-window.h" -#include "nautilus-gtk4-helpers.h" typedef struct { @@ -635,7 +634,7 @@ static int do_perform_self_checks (void) { #ifndef NAUTILUS_OMIT_SELF_CHECK - gtk_init (NULL, NULL); + gtk_init (); nautilus_profile_start (NULL); /* Run the checks (each twice) for nautilus and libnautilus-private. */ @@ -765,8 +764,7 @@ action_help (GSimpleAction *action, GError *error = NULL; window = gtk_application_get_active_window (application); - gtk_show_uri_on_window (window, "help:gnome-help/files", - gtk_get_current_event_time (), &error); + gtk_show_uri (window, "help:gnome-help/files", GDK_CURRENT_TIME); if (error) { @@ -777,7 +775,7 @@ action_help (GSimpleAction *action, _("There was an error displaying help: \n%s"), error->message); g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (gtk_widget_destroy), + G_CALLBACK (gtk_window_destroy), NULL); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); @@ -1133,7 +1131,7 @@ theme_changed (GtkSettings *settings) { provider = gtk_css_provider_new (); file = g_file_new_for_uri ("resource:///org/gnome/nautilus/css/Adwaita.css"); - gtk_css_provider_load_from_file (provider, file, NULL); + gtk_css_provider_load_from_file (provider, file); g_object_unref (file); } @@ -1153,7 +1151,7 @@ theme_changed (GtkSettings *settings) { permanent_provider = gtk_css_provider_new (); file = g_file_new_for_uri ("resource:///org/gnome/nautilus/css/nautilus.css"); - gtk_css_provider_load_from_file (permanent_provider, file, NULL); + gtk_css_provider_load_from_file (permanent_provider, file); /* The behavior of two style providers with the same priority is * undefined and gtk happens to prefer the provider that got added last. * Use a higher priority here to avoid this problem. @@ -1273,7 +1271,7 @@ nautilus_application_startup_common (NautilusApplication *self) */ G_APPLICATION_CLASS (nautilus_application_parent_class)->startup (G_APPLICATION (self)); - hdy_init (); + adw_init (); gtk_window_set_default_icon_name (APPLICATION_ID); @@ -1306,7 +1304,7 @@ nautilus_application_startup_common (NautilusApplication *self) g_signal_connect (self, "shutdown", G_CALLBACK (on_application_shutdown), NULL); - g_signal_connect_object (gtk_icon_theme_get_default (), + g_signal_connect_object (gtk_icon_theme_get_for_display (gdk_display_get_default ()), "changed", G_CALLBACK (icon_theme_changed_callback), NULL, 0); diff --git a/src/nautilus-autorun-software.c b/src/nautilus-autorun-software.c index 0496be5b5..cf2007a61 100644 --- a/src/nautilus-autorun-software.c +++ b/src/nautilus-autorun-software.c @@ -47,7 +47,7 @@ autorun_software_dialog_destroy (AutorunSoftwareDialogData *data) G_CALLBACK (autorun_software_dialog_mount_unmounted), data); - gtk_widget_destroy (GTK_WIDGET (data->dialog)); + gtk_window_destroy (GTK_WINDOW (data->dialog)); g_object_unref (data->mount); g_free (data); } @@ -159,10 +159,10 @@ out: g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), + G_CALLBACK (gtk_window_destroy), NULL); - gtk_widget_show_all (dialog); + gtk_widget_show (dialog); } } @@ -171,7 +171,7 @@ autorun_software_dialog_response (GtkDialog *dialog, gint response_id, GMount *mount) { - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); if (response_id == GTK_RESPONSE_OK) { @@ -236,7 +236,7 @@ present_autorun_for_software_dialog (GMount *mount) G_CALLBACK (autorun_software_dialog_response), mount); - gtk_widget_show_all (dialog); + gtk_widget_show (dialog); } int @@ -252,7 +252,7 @@ main (int argc, bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); - gtk_init (&argc, &argv); + gtk_init (); if (argc != 2) { diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c index 9bb16e0c1..514be8879 100644 --- a/src/nautilus-batch-rename-dialog.c +++ b/src/nautilus-batch-rename-dialog.c @@ -63,8 +63,6 @@ struct _NautilusBatchRenameDialog GList *listbox_icons; GtkSizeGroup *size_group; - GList *motion_controllers; - GList *selection; GList *new_names; NautilusBatchRenameDialogMode mode; @@ -429,14 +427,14 @@ batch_rename_dialog_get_new_names (NautilusBatchRenameDialog *dialog) if (dialog->mode == NAUTILUS_BATCH_RENAME_DIALOG_REPLACE) { - entry_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->find_entry))); + entry_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (dialog->find_entry))); } else { - entry_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry))); + entry_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (dialog->name_entry))); } - replace_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->replace_entry))); + replace_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (dialog->replace_entry))); if (dialog->mode == NAUTILUS_BATCH_RENAME_DIALOG_REPLACE) { @@ -474,7 +472,7 @@ begin_batch_rename (NautilusBatchRenameDialog *dialog, /* do the actual rename here */ nautilus_file_batch_rename (dialog->selection, new_names, NULL, NULL); - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (dialog->window)), NULL); + gtk_widget_set_cursor (GTK_WIDGET (dialog->window), NULL); } static void @@ -584,7 +582,7 @@ create_original_name_label (NautilusBatchRenameDialog *dialog, dialog->listbox_labels_old = g_list_prepend (dialog->listbox_labels_old, label_old); - gtk_widget_show_all (label_old); + gtk_widget_show (label_old); return label_old; } @@ -603,7 +601,7 @@ create_result_label (NautilusBatchRenameDialog *dialog, dialog->listbox_labels_new = g_list_prepend (dialog->listbox_labels_new, label_new); - gtk_widget_show_all (label_new); + gtk_widget_show (label_new); return label_new; } @@ -629,7 +627,7 @@ create_arrow (NautilusBatchRenameDialog *dialog, dialog->listbox_icons = g_list_prepend (dialog->listbox_icons, icon); - gtk_widget_show_all (icon); + gtk_widget_show (icon); return icon; } @@ -637,9 +635,6 @@ create_arrow (NautilusBatchRenameDialog *dialog, static void prepare_batch_rename (NautilusBatchRenameDialog *dialog) { - GdkCursor *cursor; - GdkDisplay *display; - /* wait for checking conflicts to finish, to be sure that * the rename can actually take place */ if (dialog->directories_pending_conflict_check != NULL) @@ -653,22 +648,14 @@ prepare_batch_rename (NautilusBatchRenameDialog *dialog) return; } - display = gtk_widget_get_display (GTK_WIDGET (dialog->window)); - cursor = gdk_cursor_new_from_name (display, "progress"); - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (dialog->window)), - cursor); - g_object_unref (cursor); + gtk_widget_set_cursor_from_name (GTK_WIDGET (dialog->window), "progress"); - display = gtk_widget_get_display (GTK_WIDGET (dialog)); - cursor = gdk_cursor_new_from_name (display, "progress"); - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (dialog)), - cursor); - g_object_unref (cursor); + gtk_widget_set_cursor_from_name (GTK_WIDGET (dialog), "progress"); gtk_widget_hide (GTK_WIDGET (dialog)); begin_batch_rename (dialog, dialog->new_names); - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); } static void @@ -687,7 +674,7 @@ batch_rename_dialog_on_response (NautilusBatchRenameDialog *dialog, cancel_conflict_check (dialog); } - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); } } @@ -939,7 +926,7 @@ update_listbox (NautilusBatchRenameDialog *dialog) else { new_name = batch_rename_replace_label_text (old_name, - gtk_entry_get_text (GTK_ENTRY (dialog->find_entry))); + gtk_editable_get_text (GTK_EDITABLE (dialog->find_entry))); gtk_label_set_markup (GTK_LABEL (label), new_name->str); g_string_free (new_name, TRUE); @@ -1227,11 +1214,11 @@ have_unallowed_character (NautilusBatchRenameDialog *dialog) if (dialog->mode == NAUTILUS_BATCH_RENAME_DIALOG_FORMAT) { - entry_text = gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)); + entry_text = gtk_editable_get_text (GTK_EDITABLE (dialog->name_entry)); } else { - entry_text = gtk_entry_get_text (GTK_ENTRY (dialog->replace_entry)); + entry_text = gtk_editable_get_text (GTK_EDITABLE (dialog->replace_entry)); } if (strstr (entry_text, "/") != NULL) @@ -1386,7 +1373,7 @@ update_display_text (NautilusBatchRenameDialog *dialog) static void batch_rename_dialog_mode_changed (NautilusBatchRenameDialog *dialog) { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->format_mode_button))) + if (gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->format_mode_button))) { gtk_stack_set_visible_child_name (GTK_STACK (dialog->mode_stack), "format"); @@ -1859,7 +1846,6 @@ nautilus_batch_rename_dialog_finalize (GObject *object) nautilus_directory_list_free (dialog->distinct_parent_directories); g_object_unref (dialog->size_group); - g_clear_list (&dialog->motion_controllers, g_object_unref); g_hash_table_destroy (dialog->tag_info_table); @@ -1994,7 +1980,7 @@ nautilus_batch_rename_dialog_new (GList *selection, fill_display_listbox (dialog); - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), NULL); + gtk_widget_set_cursor (GTK_WIDGET (window), NULL); g_string_free (dialog_title, TRUE); @@ -2007,15 +1993,13 @@ connect_to_pointer_motion_events (NautilusBatchRenameDialog *self, { GtkEventController *controller; - controller = gtk_event_controller_motion_new (listbox); + controller = gtk_event_controller_motion_new (); + gtk_widget_add_controller (listbox, controller); gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); g_signal_connect (controller, "leave", G_CALLBACK (on_event_controller_motion_leave), self); g_signal_connect (controller, "motion", G_CALLBACK (on_event_controller_motion_motion), self); - - self->motion_controllers = g_list_prepend (self->motion_controllers, - controller); } static void diff --git a/src/nautilus-compress-dialog-controller.c b/src/nautilus-compress-dialog-controller.c index 687cb5558..17a5be4b7 100644 --- a/src/nautilus-compress-dialog-controller.c +++ b/src/nautilus-compress-dialog-controller.c @@ -19,7 +19,7 @@ #include <glib/gi18n.h> #include <gnome-autoar/gnome-autoar.h> -#include <libhandy-1/handy.h> +#include <libadwaita-1/adwaita.h> #include <eel/eel-vfs-extensions.h> @@ -203,7 +203,7 @@ update_selected_format (NautilusCompressDialogController *self, gtk_widget_set_visible (self->passphrase_entry, show_passphrase); if (!show_passphrase) { - gtk_entry_set_text (GTK_ENTRY (self->passphrase_entry), ""); + gtk_editable_set_text (GTK_EDITABLE (self->passphrase_entry), ""); gtk_entry_set_visibility (GTK_ENTRY (self->passphrase_entry), FALSE); gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self->passphrase_entry), GTK_ENTRY_ICON_SECONDARY, @@ -213,21 +213,11 @@ update_selected_format (NautilusCompressDialogController *self, gtk_stack_set_visible_child (GTK_STACK (self->extension_stack), active_label); - gtk_image_set_from_icon_name (GTK_IMAGE (self->zip_checkmark), - NULL, - GTK_ICON_SIZE_BUTTON); - gtk_image_set_from_icon_name (GTK_IMAGE (self->encrypted_zip_checkmark), - NULL, - GTK_ICON_SIZE_BUTTON); - gtk_image_set_from_icon_name (GTK_IMAGE (self->tar_xz_checkmark), - NULL, - GTK_ICON_SIZE_BUTTON); - gtk_image_set_from_icon_name (GTK_IMAGE (self->seven_zip_checkmark), - NULL, - GTK_ICON_SIZE_BUTTON); - gtk_image_set_from_icon_name (GTK_IMAGE (active_checkmark), - "object-select-symbolic", - GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name (GTK_IMAGE (self->zip_checkmark), NULL); + gtk_image_set_from_icon_name (GTK_IMAGE (self->encrypted_zip_checkmark), NULL); + gtk_image_set_from_icon_name (GTK_IMAGE (self->tar_xz_checkmark), NULL); + gtk_image_set_from_icon_name (GTK_IMAGE (self->seven_zip_checkmark), NULL); + gtk_image_set_from_icon_name (GTK_IMAGE (active_checkmark), "object-select-symbolic"); g_settings_set_enum (nautilus_compression_preferences, NAUTILUS_PREFERENCES_DEFAULT_COMPRESSION_FORMAT, @@ -240,7 +230,7 @@ update_selected_format (NautilusCompressDialogController *self, } static void -zip_row_on_activated (HdyActionRow *row, +zip_row_on_activated (AdwActionRow *row, gpointer user_data) { NautilusCompressDialogController *controller; @@ -253,7 +243,7 @@ zip_row_on_activated (HdyActionRow *row, } static void -encrypted_zip_row_on_activated (HdyActionRow *row, +encrypted_zip_row_on_activated (AdwActionRow *row, gpointer user_data) { NautilusCompressDialogController *controller; @@ -266,7 +256,7 @@ encrypted_zip_row_on_activated (HdyActionRow *row, } static void -tar_xz_row_on_activated (HdyActionRow *row, +tar_xz_row_on_activated (AdwActionRow *row, gpointer user_data) { NautilusCompressDialogController *controller; @@ -279,7 +269,7 @@ tar_xz_row_on_activated (HdyActionRow *row, } static void -seven_zip_row_on_activated (HdyActionRow *row, +seven_zip_row_on_activated (AdwActionRow *row, gpointer user_data) { NautilusCompressDialogController *controller; @@ -301,7 +291,7 @@ passphrase_entry_on_changed (GtkEditable *editable, self = NAUTILUS_COMPRESS_DIALOG_CONTROLLER (user_data); g_free (self->passphrase); - self->passphrase = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->passphrase_entry))); + self->passphrase = g_strdup (gtk_editable_get_text (GTK_EDITABLE (self->passphrase_entry))); /* Simulate a change of the name_entry to ensure the correct sensitivity of * the activate_button, but only if the name_entry is valid in order to @@ -508,10 +498,10 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window, if (initial_name != NULL) { - gtk_entry_set_text (GTK_ENTRY (name_entry), initial_name); + gtk_editable_set_text (GTK_EDITABLE (name_entry), initial_name); } - gtk_widget_show_all (compress_dialog); + gtk_widget_show (compress_dialog); update_selected_format (self, format); @@ -533,7 +523,7 @@ nautilus_compress_dialog_controller_finalize (GObject *object) if (self->compress_dialog != NULL) { g_clear_signal_handler (&self->response_handler_id, self->compress_dialog); - gtk_widget_destroy (self->compress_dialog); + gtk_window_destroy (GTK_WINDOW (self->compress_dialog)); self->compress_dialog = NULL; } diff --git a/src/nautilus-dnd.c b/src/nautilus-dnd.c index 4803d52fa..a1e9ff128 100644 --- a/src/nautilus-dnd.c +++ b/src/nautilus-dnd.c @@ -27,7 +27,6 @@ #include "nautilus-dnd.h" #include "nautilus-program-choosing.h" -#include "nautilus-gtk4-helpers.h" #include <eel/eel-glib-extensions.h> #include <eel/eel-string.h> #include <eel/eel-vfs-extensions.h> @@ -414,7 +413,7 @@ nautilus_drag_get_source_data (GdkDragContext *context) NautilusWindowSlot *active_slot; NautilusView *view; - window = NAUTILUS_WINDOW (gtk_widget_get_toplevel (source_widget)); + window = NAUTILUS_WINDOW (gtk_widget_get_root (source_widget)); active_slot = nautilus_window_get_active_slot (window); view = nautilus_window_slot_get_current_view (active_slot); if (NAUTILUS_IS_LIST_VIEW (view)) diff --git a/src/nautilus-file-conflict-dialog.c b/src/nautilus-file-conflict-dialog.c index 0adc39142..327c5c69b 100644 --- a/src/nautilus-file-conflict-dialog.c +++ b/src/nautilus-file-conflict-dialog.c @@ -69,11 +69,11 @@ nautilus_file_conflict_dialog_set_text (NautilusFileConflictDialog *fcd, void nautilus_file_conflict_dialog_set_images (NautilusFileConflictDialog *fcd, - GdkPixbuf *destination_pixbuf, - GdkPixbuf *source_pixbuf) + GdkPaintable *destination_paintable, + GdkPaintable *source_paintable) { - gtk_image_set_from_pixbuf (GTK_IMAGE (fcd->dest_image), destination_pixbuf); - gtk_image_set_from_pixbuf (GTK_IMAGE (fcd->src_image), source_pixbuf); + gtk_image_set_from_paintable (GTK_IMAGE (fcd->dest_image), destination_paintable); + gtk_image_set_from_paintable (GTK_IMAGE (fcd->src_image), source_paintable); } void @@ -97,7 +97,7 @@ nautilus_file_conflict_dialog_set_suggested_name (NautilusFileConflictDialog *fc gchar *suggested_name) { fcd->suggested_name = g_strdup (suggested_name); - gtk_entry_set_text (GTK_ENTRY (fcd->entry), suggested_name); + gtk_editable_set_text (GTK_EDITABLE (fcd->entry), suggested_name); } void @@ -129,8 +129,8 @@ static void entry_text_changed_cb (GtkEditable *entry, NautilusFileConflictDialog *dialog) { - if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (entry)), "") != 0 && - g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (entry)), dialog->conflict_name) != 0) + if (g_strcmp0 (gtk_editable_get_text (GTK_EDITABLE (entry)), "") != 0 && + g_strcmp0 (gtk_editable_get_text (GTK_EDITABLE (entry)), dialog->conflict_name) != 0) { gtk_widget_set_sensitive (dialog->rename_button, TRUE); } @@ -171,7 +171,7 @@ on_expanded_notify (GtkExpander *w, gtk_widget_set_sensitive (dialog->checkbox, FALSE); gtk_widget_grab_focus (dialog->entry); - if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (dialog->entry)), dialog->suggested_name) == 0) + if (g_strcmp0 (gtk_editable_get_text (GTK_EDITABLE (dialog->entry)), dialog->suggested_name) == 0) { /* The suggested name is in the form "original (1).txt", if the * the conflicting name was "original.txt". The user may want to @@ -198,10 +198,10 @@ on_expanded_notify (GtkExpander *w, } static void -checkbox_toggled_cb (GtkToggleButton *t, +checkbox_toggled_cb (GtkCheckButton *t, NautilusFileConflictDialog *dialog) { - gtk_widget_set_sensitive (dialog->expander, !gtk_toggle_button_get_active (t)); + gtk_widget_set_sensitive (dialog->expander, !gtk_check_button_get_active (t)); } static void @@ -210,7 +210,7 @@ reset_button_clicked_cb (GtkButton *w, { int start_pos, end_pos; - gtk_entry_set_text (GTK_ENTRY (dialog->entry), dialog->conflict_name); + gtk_editable_set_text (GTK_EDITABLE (dialog->entry), dialog->conflict_name); gtk_widget_grab_focus (dialog->entry); eel_filename_get_rename_region (dialog->conflict_name, &start_pos, &end_pos); gtk_editable_select_region (GTK_EDITABLE (dialog->entry), start_pos, end_pos); @@ -288,13 +288,13 @@ nautilus_file_conflict_dialog_delay_buttons_activation (NautilusFileConflictDial char * nautilus_file_conflict_dialog_get_new_name (NautilusFileConflictDialog *dialog) { - return g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->entry))); + return g_strdup (gtk_editable_get_text (GTK_EDITABLE (dialog->entry))); } gboolean nautilus_file_conflict_dialog_get_apply_to_all (NautilusFileConflictDialog *dialog) { - return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbox)); + return gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->checkbox)); } NautilusFileConflictDialog * diff --git a/src/nautilus-file-conflict-dialog.h b/src/nautilus-file-conflict-dialog.h index c62b43018..70f81d0b3 100644 --- a/src/nautilus-file-conflict-dialog.h +++ b/src/nautilus-file-conflict-dialog.h @@ -38,8 +38,8 @@ void nautilus_file_conflict_dialog_set_text (NautilusFileConflictDialog *fcd, gchar *primary_text, gchar *secondary_text); void nautilus_file_conflict_dialog_set_images (NautilusFileConflictDialog *fcd, - GdkPixbuf *source_pixbuf, - GdkPixbuf *destination_pixbuf); + GdkPaintable *source_paintable, + GdkPaintable *destination_paintable); void nautilus_file_conflict_dialog_set_file_labels (NautilusFileConflictDialog *fcd, gchar *destination_label, gchar *source_label); diff --git a/src/nautilus-file-name-widget-controller.c b/src/nautilus-file-name-widget-controller.c index 308ab51f2..db048b7f8 100644 --- a/src/nautilus-file-name-widget-controller.c +++ b/src/nautilus-file-name-widget-controller.c @@ -122,7 +122,7 @@ real_get_new_name (NautilusFileNameWidgetController *self) priv = nautilus_file_name_widget_controller_get_instance_private (self); - return g_strstrip (g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->name_entry)))); + return g_strstrip (g_strdup (gtk_editable_get_text (GTK_EDITABLE (priv->name_entry)))); } static gboolean diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c index 7af3865aa..a6ab32905 100644 --- a/src/nautilus-file-operations.c +++ b/src/nautilus-file-operations.c @@ -59,14 +59,13 @@ #include "nautilus-file-undo-operations.h" #include "nautilus-file-undo-manager.h" #include "nautilus-ui-utilities.h" -#include "nautilus-gtk4-helpers.h" #ifdef GDK_WINDOWING_X11 -#include <gdk/gdkx.h> +#include <gdk/x11/gdkx.h> #endif #ifdef GDK_WINDOWING_WAYLAND -#include <gdk/gdkwayland.h> +#include <gdk/wayland/gdkwayland.h> #endif typedef struct @@ -1243,13 +1242,13 @@ typedef struct } RunSimpleDialogData; static void -set_transient_for (GdkWindow *child_window, +set_transient_for (GdkSurface *child_surface, const char *parent_handle) { GdkDisplay *display; const char *prefix; - display = gdk_window_get_display (child_window); + display = gdk_surface_get_display (child_surface); #ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY (display)) @@ -1259,15 +1258,14 @@ set_transient_for (GdkWindow *child_window, if (g_str_has_prefix (parent_handle, prefix)) { const char *handle; - GdkWindow *window; + GdkSurface *surface; handle = parent_handle + strlen (prefix); - window = gdk_x11_window_foreign_new_for_display (display, strtol (handle, NULL, 16)); + surface = gdk_x11_surface_lookup_for_display (display, strtol (handle, NULL, 16)); - if (window != NULL) + if (surface != NULL) { - gdk_window_set_transient_for (child_window, window); - g_object_unref (window); + gdk_toplevel_set_transient_for (GDK_TOPLEVEL (child_surface), surface); } } } @@ -1284,7 +1282,7 @@ set_transient_for (GdkWindow *child_window, handle = parent_handle + strlen (prefix); - gdk_wayland_window_set_transient_for_exported (child_window, (char *) handle); + gdk_wayland_toplevel_set_transient_for_exported (GDK_TOPLEVEL (child_surface), (char *) handle); } } #endif @@ -1298,7 +1296,7 @@ dialog_realize_cb (GtkWidget *widget, const char *parent_handle; parent_handle = nautilus_file_operations_dbus_data_get_parent_handle (dbus_data); - set_transient_for (gtk_widget_get_window (widget), parent_handle); + set_transient_for (gtk_native_get_surface (gtk_widget_get_native (widget)), parent_handle); } static gboolean @@ -1327,7 +1325,7 @@ simple_dialog_cb (GtkDialog *dialog, return; } - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); data->result = response_id; data->completed = TRUE; @@ -1395,7 +1393,7 @@ do_run_simple_dialog (gpointer _data) content_area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog)); label = gtk_label_new (data->details_text); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_label_set_wrap (GTK_LABEL (label), TRUE); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_label_set_xalign (GTK_LABEL (label), 0); /* Ideally, we shouldn’t do this. @@ -1431,7 +1429,7 @@ do_run_simple_dialog (gpointer _data) /* Run it. */ g_signal_connect (dialog, "response", G_CALLBACK (simple_dialog_cb), data); - gtk_widget_show_all (dialog); + gtk_widget_show (dialog); return FALSE; } @@ -3080,7 +3078,7 @@ empty_trash_prompt_cb (GtkDialog *dialog, unmount_data_free (data); } - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); } void @@ -3116,7 +3114,7 @@ nautilus_file_operations_unmount_mount_full (GtkWindow *parent_win dialog = create_empty_trash_prompt (parent_window); g_signal_connect (dialog, "response", G_CALLBACK (empty_trash_prompt_cb), data); - gtk_widget_show_all (dialog); + gtk_widget_show (dialog); return; } diff --git a/src/nautilus-file.c b/src/nautilus-file.c index 011842bd1..36c1462e4 100644 --- a/src/nautilus-file.c +++ b/src/nautilus-file.c @@ -5378,17 +5378,30 @@ out: return icon; } -GdkPixbuf * -nautilus_file_get_icon_pixbuf (NautilusFile *file, - int size, - int scale, - NautilusFileIconFlags flags) +GdkTexture * +nautilus_file_get_icon_texture (NautilusFile *file, + int size, + int scale, + NautilusFileIconFlags flags) { g_autoptr (NautilusIconInfo) info = NULL; info = nautilus_file_get_icon (file, size, scale, flags); - return nautilus_icon_info_get_pixbuf_at_size (info, size); + return nautilus_icon_info_get_texture (info); +} + +GdkPaintable * +nautilus_file_get_icon_paintable (NautilusFile *file, + int size, + int scale, + NautilusFileIconFlags flags) +{ + g_autoptr (NautilusIconInfo) info = NULL; + + info = nautilus_file_get_icon (file, size, scale, flags); + + return nautilus_icon_info_get_paintable (info); } gboolean diff --git a/src/nautilus-file.h b/src/nautilus-file.h index a50d27df0..e2af19e94 100644 --- a/src/nautilus-file.h +++ b/src/nautilus-file.h @@ -473,7 +473,11 @@ NautilusIconInfo * nautilus_file_get_icon (Nautilu int size, int scale, NautilusFileIconFlags flags); -GdkPixbuf * nautilus_file_get_icon_pixbuf (NautilusFile *file, +GdkTexture * nautilus_file_get_icon_texture (NautilusFile *file, + int size, + int scale, + NautilusFileIconFlags flags); +GdkPaintable * nautilus_file_get_icon_paintable (NautilusFile *file, int size, int scale, NautilusFileIconFlags flags); diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index ac2c0525b..c815e8c74 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -87,11 +87,10 @@ #include "nautilus-view-icon-controller.h" #include "nautilus-window.h" #include "nautilus-tracker-utilities.h" -#include "nautilus-gtk4-helpers.h" #ifdef HAVE_LIBPORTAL #include <libportal/portal.h> -#include <libportal-gtk3/portal-gtk3.h> +#include <libportal-gtk4/portal-gtk4.h> #endif /* Minimum starting update inverval */ @@ -521,8 +520,7 @@ remove_floating_bar_passthrough (gpointer data) NautilusFilesViewPrivate *priv; priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (data)); - gtk_overlay_set_overlay_pass_through (GTK_OVERLAY (priv->overlay), - priv->floating_bar, FALSE); + gtk_widget_set_can_target (priv->floating_bar, TRUE); priv->floating_bar_set_passthrough_timeout_id = 0; return G_SOURCE_REMOVE; @@ -546,7 +544,7 @@ set_floating_bar_status (NautilusFilesView *view, priv->floating_bar_set_status_timeout_id = 0; } - settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (view))); + settings = gtk_settings_get_for_display (gtk_widget_get_display (GTK_WIDGET (view))); g_object_get (settings, "gtk-double-click-time", &double_click_time, NULL); @@ -563,8 +561,7 @@ set_floating_bar_status (NautilusFilesView *view, } /* Activate passthrough on the floating bar just long enough for a * potential double click to happen, so to not interfere with it */ - gtk_overlay_set_overlay_pass_through (GTK_OVERLAY (priv->overlay), - priv->floating_bar, TRUE); + gtk_widget_set_can_target (priv->floating_bar, FALSE); priv->floating_bar_set_passthrough_timeout_id = g_timeout_add ((guint) double_click_time, remove_floating_bar_passthrough, view); @@ -1436,7 +1433,7 @@ app_chooser_dialog_response_cb (GtkDialog *dialog, g_object_unref (info); out: - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); } static void @@ -1691,7 +1688,7 @@ pattern_select_response_cb (GtkWidget *dialog, entry = g_object_get_data (G_OBJECT (dialog), "entry"); directory = nautilus_files_view_get_model (view); selection = nautilus_directory_match_pattern (directory, - gtk_entry_get_text (GTK_ENTRY (entry))); + gtk_editable_get_text (GTK_EDITABLE (entry))); nautilus_files_view_call_set_selection (view, selection); nautilus_files_view_reveal_selection (view); @@ -1707,7 +1704,7 @@ pattern_select_response_cb (GtkWidget *dialog, case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_CANCEL: { - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); } break; @@ -3123,7 +3120,7 @@ slot_active_changed (NautilusWindowSlot *slot, } } -static void +static gboolean nautilus_files_view_grab_focus (GtkWidget *widget) { /* focus the child of the scrolled window if it exists */ @@ -3135,12 +3132,12 @@ nautilus_files_view_grab_focus (GtkWidget *widget) priv = nautilus_files_view_get_instance_private (view); child = gtk_scrolled_window_get_child (GTK_SCROLLED_WINDOW (priv->scrolled_window)); - GTK_WIDGET_CLASS (nautilus_files_view_parent_class)->grab_focus (widget); - - if (child) + if (child != NULL) { - gtk_widget_grab_focus (GTK_WIDGET (child)); + return gtk_widget_grab_focus (GTK_WIDGET (child)); } + + return GTK_WIDGET_CLASS (nautilus_files_view_parent_class)->grab_focus (widget); } static void @@ -3191,6 +3188,9 @@ nautilus_files_view_dispose (GObject *object) priv->in_destruction = TRUE; nautilus_files_view_stop_loading (view); + g_clear_pointer (&priv->selection_menu, gtk_widget_unparent); + g_clear_pointer (&priv->background_menu, gtk_widget_unparent); + if (priv->model) { nautilus_directory_unref (priv->model); @@ -4872,13 +4872,13 @@ nautilus_files_view_get_directory_as_file (NautilusFilesView *view) return priv->directory_as_file; } -static GdkPixbuf * +static GdkTexture * get_menu_icon_for_file (NautilusFile *file, GtkWidget *widget) { int scale = gtk_widget_get_scale_factor (widget); - return nautilus_file_get_icon_pixbuf (file, 16, scale, 0); + return nautilus_file_get_icon_texture (file, 16, scale, 0); } static GList * @@ -5284,7 +5284,7 @@ add_script_to_scripts_menus (NautilusFilesView *view, gchar *name; g_autofree gchar *uri = NULL; g_autofree gchar *escaped_uri = NULL; - GdkPixbuf *mimetype_icon; + GdkTexture *mimetype_icon; gchar *action_name, *detailed_action_name; ScriptLaunchParameters *launch_parameters; GAction *action; @@ -5529,7 +5529,7 @@ add_template_to_templates_menus (NautilusFilesView *view, NautilusFilesViewPrivate *priv; char *tmp, *uri, *name; g_autofree gchar *escaped_uri = NULL; - GdkPixbuf *mimetype_icon; + GdkTexture *mimetype_icon; char *action_name, *detailed_action_name; CreateTemplateParameters *parameters; GAction *action; @@ -5862,7 +5862,7 @@ on_destination_dialog_response (GtkDialog *dialog, } copy_data_free (copy_data); - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); } static void @@ -5896,7 +5896,6 @@ copy_or_move_selection (NautilusFilesView *view, _("_Cancel"), GTK_RESPONSE_CANCEL, _("_Select"), GTK_RESPONSE_OK, NULL); - gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); @@ -5923,12 +5922,12 @@ copy_or_move_selection (NautilusFilesView *view, location = nautilus_directory_get_location (priv->model); } - gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), location, NULL); + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), location, NULL); g_signal_connect (dialog, "response", G_CALLBACK (on_destination_dialog_response), copy_data); - gtk_widget_show_all (dialog); + gtk_widget_show (dialog); } static void @@ -6115,18 +6114,14 @@ real_action_rename (NautilusFilesView *view) /* If there is more than one file selected, invoke a batch renamer */ if (selection->next != NULL) { - GdkCursor *cursor; - GdkDisplay *display; + NautilusWindow *window; - display = gtk_widget_get_display (GTK_WIDGET (nautilus_files_view_get_window (view))); - cursor = gdk_cursor_new_from_name (display, "progress"); - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (nautilus_files_view_get_window (view))), - cursor); - g_object_unref (cursor); + window = nautilus_files_view_get_window (view); + gtk_widget_set_cursor_from_name (GTK_WIDGET (window), "progress"); dialog = nautilus_batch_rename_dialog_new (selection, nautilus_files_view_get_model (view), - nautilus_files_view_get_window (view)); + window); gtk_widget_show (GTK_WIDGET (dialog)); } @@ -6319,7 +6314,7 @@ on_extract_destination_dialog_response (GtkDialog *dialog, extract_files (data->view, data->files, destination_directory); } - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); nautilus_file_list_free (data->files); g_free (data); } @@ -6348,7 +6343,6 @@ extract_files_to_chosen_location (NautilusFilesView *view, _("_Cancel"), GTK_RESPONSE_CANCEL, _("_Select"), GTK_RESPONSE_OK, NULL); - gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); @@ -6374,7 +6368,7 @@ extract_files_to_chosen_location (NautilusFilesView *view, location = nautilus_directory_get_location (priv->model); } - gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), location, NULL); + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), location, NULL); data->view = view; data->files = nautilus_file_list_copy (files); @@ -6383,7 +6377,7 @@ extract_files_to_chosen_location (NautilusFilesView *view, G_CALLBACK (on_extract_destination_dialog_response), data); - gtk_widget_show_all (dialog); + gtk_widget_show (dialog); } static void @@ -8269,12 +8263,13 @@ nautilus_files_view_pop_up_selection_context_menu (NautilusFilesView *view, if (NULL == priv->selection_menu) { - priv->selection_menu = gtk_popover_new (GTK_WIDGET (view)); + priv->selection_menu = gtk_popover_menu_new_from_model (NULL); + gtk_widget_set_parent (priv->selection_menu, GTK_WIDGET (view)); + g_signal_connect (priv->selection_menu, "destroy", G_CALLBACK (gtk_widget_unparent), NULL); } - gtk_popover_bind_model (GTK_POPOVER (priv->selection_menu), - G_MENU_MODEL (priv->selection_menu_model), - NULL); + gtk_popover_menu_set_menu_model (GTK_POPOVER_MENU (priv->selection_menu), + G_MENU_MODEL (priv->selection_menu_model)); if (x == -1 && y == -1) { /* If triggered from the keyboard, popup at selection, not pointer */ @@ -8316,13 +8311,16 @@ nautilus_files_view_pop_up_background_context_menu (NautilusFilesView *view, */ update_context_menus_if_pending (view); + if (NULL == priv->background_menu) { - priv->background_menu = gtk_popover_new (GTK_WIDGET (view)); + priv->background_menu = gtk_popover_menu_new_from_model (NULL); + gtk_widget_set_parent (priv->background_menu, GTK_WIDGET (view)); + g_signal_connect (priv->background_menu, "destroy", G_CALLBACK (gtk_widget_unparent), NULL); } - gtk_popover_bind_model (GTK_POPOVER (priv->background_menu), - G_MENU_MODEL (priv->background_menu_model), - NULL); + gtk_popover_menu_set_menu_model (GTK_POPOVER_MENU (priv->background_menu), + G_MENU_MODEL (priv->background_menu_model)); + gtk_popover_set_pointing_to (GTK_POPOVER (priv->background_menu), &(GdkRectangle){x, y, 0, 0}); gtk_popover_popup (GTK_POPOVER (priv->background_menu)); @@ -9118,42 +9116,26 @@ nautilus_files_view_set_property (GObject *object, /* handle Ctrl+Scroll, which will cause a zoom-in/out */ static gboolean -on_event (GtkWidget *widget, - GdkEvent *event, - gpointer user_data) +on_scroll (GtkEventControllerScroll *scroll, + gdouble dx, + gdouble dy, + gpointer user_data) { NautilusFilesView *directory_view; - static gdouble total_delta_y = 0; GdkModifierType state; - GdkScrollDirection direction; - gdouble delta_x, delta_y; - directory_view = NAUTILUS_FILES_VIEW (widget); + directory_view = NAUTILUS_FILES_VIEW (user_data); - if (gdk_event_get_event_type (event) != GDK_SCROLL) + state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (scroll)); + if (state & GDK_CONTROL_MASK) { - return GDK_EVENT_PROPAGATE; - } - - if (!gdk_event_get_state (event, &state)) - { - return GDK_EVENT_PROPAGATE; - } - - if (!(state & GDK_CONTROL_MASK)) - { - return GDK_EVENT_PROPAGATE; - } - - if (gdk_event_get_scroll_direction (event, &direction)) - { - if (direction == GDK_SCROLL_UP) + if (dy <= -1) { /* Zoom In */ nautilus_files_view_bump_zoom_level (directory_view, 1); return GDK_EVENT_STOP; } - else if (direction == GDK_SCROLL_DOWN) + else if (dy >= 1) { /* Zoom Out */ nautilus_files_view_bump_zoom_level (directory_view, -1); @@ -9161,32 +9143,6 @@ on_event (GtkWidget *widget, } } - if (gdk_event_get_scroll_deltas (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 GDK_EVENT_STOP; - } - else if (total_delta_y <= -1) - { - total_delta_y = 0; - /* emulate scroll up */ - nautilus_files_view_bump_zoom_level (directory_view, 1); - return GDK_EVENT_STOP; - } - else - { - /* eat event */ - return GDK_EVENT_STOP; - } - } - return GDK_EVENT_PROPAGATE; } @@ -9508,6 +9464,7 @@ nautilus_files_view_init (NautilusFilesView *view) #endif NautilusDirectory *scripts_directory; NautilusDirectory *templates_directory; + GtkEventController *controller; gchar *templates_uri; #if 0 && NAUTILUS_CLIPBOARD_NEEDS_GTK4_REIMPLEMENTATION GtkClipboard *clipboard; @@ -9594,24 +9551,18 @@ nautilus_files_view_init (NautilusFilesView *view) gtk_grid_attach_next_to (GTK_GRID (view), priv->overlay, NULL, GTK_POS_BOTTOM, 1, 1); gtk_widget_show (priv->overlay); - /* NautilusFloatingBar listen to its parent's 'event' signal - * and GtkOverlay doesn't have it enabled by default, so we have to add them - * here. - */ - gtk_widget_add_events (GTK_WIDGET (priv->overlay), - GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - /* Scrolled Window */ - priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL); + priv->scrolled_window = gtk_scrolled_window_new (); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_show (priv->scrolled_window); - g_signal_connect_swapped (priv->scrolled_window, - "event", - G_CALLBACK (on_event), - view); + controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL | + GTK_EVENT_CONTROLLER_SCROLL_DISCRETE); + gtk_widget_add_controller (priv->scrolled_window, controller); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); + g_signal_connect (controller, "scroll", G_CALLBACK (on_scroll), view); gtk_overlay_set_child (GTK_OVERLAY (priv->overlay), priv->scrolled_window); @@ -9619,33 +9570,25 @@ nautilus_files_view_init (NautilusFilesView *view) builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-no-search-results.ui"); priv->no_search_results_widget = GTK_WIDGET (gtk_builder_get_object (builder, "no_search_results")); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->no_search_results_widget); - gtk_overlay_set_overlay_pass_through (GTK_OVERLAY (priv->overlay), - priv->no_search_results_widget, - TRUE); + gtk_widget_set_can_target (priv->no_search_results_widget, FALSE); g_object_unref (builder); builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-folder-is-empty.ui"); priv->folder_is_empty_widget = GTK_WIDGET (gtk_builder_get_object (builder, "folder_is_empty")); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->folder_is_empty_widget); - gtk_overlay_set_overlay_pass_through (GTK_OVERLAY (priv->overlay), - priv->folder_is_empty_widget, - TRUE); + gtk_widget_set_can_target (priv->folder_is_empty_widget, FALSE); g_object_unref (builder); builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-starred-is-empty.ui"); priv->starred_is_empty_widget = GTK_WIDGET (gtk_builder_get_object (builder, "starred_is_empty")); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->starred_is_empty_widget); - gtk_overlay_set_overlay_pass_through (GTK_OVERLAY (priv->overlay), - priv->starred_is_empty_widget, - TRUE); + gtk_widget_set_can_target (priv->starred_is_empty_widget, FALSE); g_object_unref (builder); builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-trash-is-empty.ui"); priv->trash_is_empty_widget = GTK_WIDGET (gtk_builder_get_object (builder, "trash_is_empty")); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->trash_is_empty_widget); - gtk_overlay_set_overlay_pass_through (GTK_OVERLAY (priv->overlay), - priv->trash_is_empty_widget, - TRUE); + gtk_widget_set_can_target (priv->trash_is_empty_widget, FALSE); g_object_unref (builder); /* Floating bar */ diff --git a/src/nautilus-floating-bar.c b/src/nautilus-floating-bar.c index 095e7288b..ef545e6f3 100644 --- a/src/nautilus-floating-bar.c +++ b/src/nautilus-floating-bar.c @@ -24,7 +24,6 @@ #include <string.h> #include "nautilus-floating-bar.h" -#include "nautilus-gtk4-helpers.h" #define HOVER_HIDE_TIMEOUT_INTERVAL 100 @@ -246,7 +245,7 @@ on_event_controller_motion_enter (GtkEventControllerMotion *controller, NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (user_data); GtkWidget *parent; CheckPointerData *data; - gint y_pos; + gdouble y_pos; self->pointer_y_in_parent_coordinates = y; @@ -310,11 +309,25 @@ on_parent_changed (GObject *object, parent = gtk_widget_get_parent (GTK_WIDGET (object)); - g_clear_object (&self->motion_controller); + if (self->motion_controller != NULL) + { + GtkWidget *old_parent; + + old_parent = gtk_event_controller_get_widget (self->motion_controller); + g_warn_if_fail (old_parent != NULL); + if (old_parent != NULL) + { + gtk_widget_remove_controller (old_parent, self->motion_controller); + } + + g_object_unref (self->motion_controller); + self->motion_controller = NULL; + } if (parent != NULL) { - self->motion_controller = gtk_event_controller_motion_new (parent); + self->motion_controller = g_object_ref (gtk_event_controller_motion_new ()); + gtk_widget_add_controller (parent, self->motion_controller); gtk_event_controller_set_propagation_phase (self->motion_controller, GTK_PHASE_CAPTURE); @@ -345,7 +358,7 @@ nautilus_floating_bar_constructed (GObject *obj) * ensure the spinner animates if and only if it's visible, to reduce CPU * usage. */ g_object_bind_property (obj, "show-spinner", - w, "active", + w, "spinning", G_BINDING_SYNC_CREATE); self->spinner = w; @@ -376,7 +389,7 @@ nautilus_floating_bar_constructed (GObject *obj) self->details_label_widget = w; gtk_widget_show (w); - w = gtk_button_new_from_icon_name ("process-stop-symbolic", GTK_ICON_SIZE_MENU); + w = gtk_button_new_from_icon_name ("process-stop-symbolic"); context = gtk_widget_get_style_context (w); gtk_style_context_add_class (context, "circular"); gtk_style_context_add_class (context, "flat"); @@ -384,7 +397,6 @@ nautilus_floating_bar_constructed (GObject *obj) gtk_box_append (GTK_BOX (self), w); self->stop_button = w; gtk_widget_set_visible (w, FALSE); - gtk_widget_set_no_show_all (w, TRUE); g_signal_connect (self->stop_button, "clicked", G_CALLBACK (stop_button_clicked_cb), self); diff --git a/src/nautilus-gtk4-helpers.c b/src/nautilus-gtk4-helpers.c deleted file mode 100644 index 8f9c7bd35..000000000 --- a/src/nautilus-gtk4-helpers.c +++ /dev/null @@ -1,218 +0,0 @@ -#include "nautilus-gtk4-helpers.h" - -void -adw_bin_set_child (AdwBin *bin, - GtkWidget *child) -{ - g_assert (GTK_IS_BIN (bin)); - - gtk_container_add (GTK_CONTAINER (bin), child); -} - -void -gtk_button_set_child (GtkButton *button, - GtkWidget *child) -{ - g_assert (GTK_IS_BUTTON (button)); - - gtk_container_add (GTK_CONTAINER (button), child); -} - -void -gtk_menu_button_set_child (GtkMenuButton *menu_button, - GtkWidget *child) -{ - g_assert (GTK_IS_MENU_BUTTON (menu_button)); - - gtk_container_add (GTK_CONTAINER (menu_button), child); -} - -void -gtk_box_append (GtkBox *box, - GtkWidget *child) -{ - g_assert (GTK_IS_BOX (box)); - - gtk_container_add (GTK_CONTAINER (box), child); -} - -void -gtk_box_remove (GtkBox *box, - GtkWidget *child) -{ - g_assert (GTK_IS_BOX (box)); - - gtk_container_remove (GTK_CONTAINER (box), child); -} - -void -gtk_overlay_set_child (GtkOverlay *overlay, - GtkWidget *child) -{ - g_assert (GTK_IS_OVERLAY (overlay)); - - gtk_container_add (GTK_CONTAINER (overlay), child); -} - -void -gtk_scrolled_window_set_child (GtkScrolledWindow *scrolled_window, - GtkWidget *child) -{ - g_assert (GTK_IS_SCROLLED_WINDOW (scrolled_window)); - - gtk_container_add (GTK_CONTAINER (scrolled_window), child); -} - -void -gtk_list_box_row_set_child (GtkListBoxRow *row, - GtkWidget *child) -{ - g_assert (GTK_IS_LIST_BOX_ROW (row)); - - gtk_container_add (GTK_CONTAINER (row), child); -} - -void -gtk_info_bar_add_child (GtkInfoBar *info_bar, - GtkWidget *widget) -{ - g_assert (GTK_IS_INFO_BAR (info_bar)); - - gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (info_bar)), - widget); -} - -void -gtk_revealer_set_child (GtkRevealer *revealer, - GtkWidget *child) -{ - g_assert (GTK_IS_REVEALER (revealer)); - - gtk_container_add (GTK_CONTAINER (revealer), child); -} - -void -gtk_popover_set_child (GtkPopover *popover, - GtkWidget *child) -{ - g_assert (GTK_IS_POPOVER (popover)); - - gtk_container_add (GTK_CONTAINER (popover), child); -} - -void -gtk_check_button_set_active (GtkCheckButton *button, - gboolean setting) -{ - g_assert (GTK_IS_CHECK_BUTTON (button)); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), setting); -} - - -void -gtk_center_box_set_start_widget (GtkCenterBox *center_box, - GtkWidget *widget) -{ - g_assert (GTK_IS_BOX (center_box)); - - gtk_box_pack_start (GTK_BOX (center_box), widget, FALSE, TRUE, 0); -} - -void -gtk_center_box_set_center_widget (GtkCenterBox *center_box, - GtkWidget *widget) -{ - g_assert (GTK_IS_BOX (center_box)); - - gtk_box_set_center_widget (GTK_BOX (center_box), widget); -} -void -gtk_center_box_set_end_widget (GtkCenterBox *center_box, - GtkWidget *widget) -{ - g_assert (GTK_IS_BOX (center_box)); - - gtk_box_pack_end (GTK_BOX (center_box), widget, FALSE, TRUE, 0); -} - -GtkWidget * -gtk_center_box_new (void) -{ - return gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); -} - -gboolean -gtk_check_button_get_active (GtkCheckButton *button) -{ - g_assert (GTK_IS_CHECK_BUTTON (button)); - - return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); -} - -GtkWidget * -gtk_widget_get_first_child (GtkWidget *widget) -{ - g_autoptr (GList) children = NULL; - - g_assert (GTK_IS_CONTAINER (widget)); - - children = gtk_container_get_children (GTK_CONTAINER (widget)); - if (children != NULL) - { - return GTK_WIDGET (children->data); - } - - return NULL; -} - -GtkWidget * -gtk_widget_get_focus_child (GtkWidget *widget) -{ - g_assert (GTK_IS_CONTAINER (widget)); - - return gtk_container_get_focus_child (GTK_CONTAINER (widget)); -} - -GtkWidget * -gtk_scrolled_window_get_child (GtkScrolledWindow *scrolled) -{ - g_assert (GTK_IS_SCROLLED_WINDOW (scrolled)); - - return gtk_bin_get_child (GTK_BIN (scrolled)); -} - -GdkDisplay * -gtk_root_get_display (GtkRoot *root) -{ - g_assert (GTK_IS_WINDOW (root)); - - return gdk_screen_get_display (gtk_window_get_screen (GTK_WINDOW (root))); -} - -void -gtk_window_set_display (GtkWindow *window, - GdkDisplay *display) -{ - g_assert (GTK_IS_WINDOW (window)); - - gtk_window_set_screen (window, gdk_display_get_default_screen (display)); -} - -void -gtk_style_context_add_provider_for_display (GdkDisplay *display, - GtkStyleProvider *provider, - guint priority) -{ - gtk_style_context_add_provider_for_screen (gdk_display_get_default_screen (display), - provider, - priority); -} - -void -gtk_style_context_remove_provider_for_display (GdkDisplay *display, - GtkStyleProvider *provider) -{ - gtk_style_context_remove_provider_for_screen (gdk_display_get_default_screen (display), - provider); -} diff --git a/src/nautilus-gtk4-helpers.h b/src/nautilus-gtk4-helpers.h deleted file mode 100644 index 77bf8089d..000000000 --- a/src/nautilus-gtk4-helpers.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include <glib.h> -#include <gio/gio.h> -#include <gtk/gtk.h> - -G_BEGIN_DECLS -#if GTK_MAJOR_VERSION < 4 - -#define AdwBin GtkBin -#define ADW_BIN GTK_BIN -#define GtkCenterBox GtkBox -#define GTK_CENTER_BOX GTK_BOX - -void adw_bin_set_child (AdwBin *bin, - GtkWidget *child); -void gtk_button_set_child (GtkButton *button, - GtkWidget *child); -void gtk_menu_button_set_child (GtkMenuButton *menu_button, - GtkWidget *child); -void gtk_box_append (GtkBox *box, - GtkWidget *child); -void gtk_box_remove (GtkBox *box, - GtkWidget *child); -void gtk_overlay_set_child (GtkOverlay *overlay, - GtkWidget *child); -void gtk_scrolled_window_set_child (GtkScrolledWindow *scrolled_window, - GtkWidget *child); -void gtk_list_box_row_set_child (GtkListBoxRow *row, - GtkWidget *child); -void gtk_info_bar_add_child (GtkInfoBar *info_bar, - GtkWidget *widget); -void gtk_revealer_set_child (GtkRevealer *revealer, - GtkWidget *child); -void gtk_popover_set_child (GtkPopover *popover, - GtkWidget *child); -void gtk_check_button_set_active (GtkCheckButton *button, - gboolean setting); -void gtk_center_box_set_start_widget (GtkCenterBox *center_box, - GtkWidget *widget); -void gtk_center_box_set_center_widget (GtkCenterBox *center_box, - GtkWidget *widget); -void gtk_center_box_set_end_widget (GtkCenterBox *center_box, - GtkWidget *widget); - -GtkWidget *gtk_center_box_new (void); - -gboolean gtk_check_button_get_active (GtkCheckButton *button); -GtkWidget *gtk_widget_get_first_child (GtkWidget *widget); -GtkWidget *gtk_widget_get_focus_child (GtkWidget *widget); -GtkWidget *gtk_scrolled_window_get_child (GtkScrolledWindow *scrolled); - -void gtk_style_context_add_provider_for_display (GdkDisplay *display, - GtkStyleProvider *provider, - guint priority); -void gtk_style_context_remove_provider_for_display (GdkDisplay *display, - GtkStyleProvider *provider); - -#define GTK_ROOT(root) ((GtkRoot *) GTK_WINDOW (root)) -typedef GtkWindow GtkRoot; -GdkDisplay *gtk_root_get_display (GtkRoot *root); -void gtk_window_set_display (GtkWindow *window, - GdkDisplay *display); - -#endif -G_END_DECLS diff --git a/src/nautilus-icon-info.c b/src/nautilus-icon-info.c index fee560806..0831ae168 100644 --- a/src/nautilus-icon-info.c +++ b/src/nautilus-icon-info.c @@ -25,7 +25,7 @@ struct _NautilusIconInfo gboolean sole_owner; gint64 last_use_time; - GdkPixbuf *pixbuf; + GdkPaintable *paintable; char *icon_name; @@ -48,13 +48,13 @@ nautilus_icon_info_init (NautilusIconInfo *icon) gboolean nautilus_icon_info_is_fallback (NautilusIconInfo *icon) { - return icon->pixbuf == NULL; + return icon->paintable == NULL; } static void -pixbuf_toggle_notify (gpointer info, - GObject *object, - gboolean is_last_ref) +paintable_toggle_notify (gpointer info, + GObject *object, + gboolean is_last_ref) { NautilusIconInfo *icon = info; @@ -62,7 +62,7 @@ pixbuf_toggle_notify (gpointer info, { icon->sole_owner = TRUE; g_object_remove_toggle_ref (object, - pixbuf_toggle_notify, + paintable_toggle_notify, info); icon->last_use_time = g_get_monotonic_time (); schedule_reap_cache (); @@ -76,16 +76,16 @@ nautilus_icon_info_finalize (GObject *object) icon = NAUTILUS_ICON_INFO (object); - if (!icon->sole_owner && icon->pixbuf) + if (!icon->sole_owner && icon->paintable) { - g_object_remove_toggle_ref (G_OBJECT (icon->pixbuf), - pixbuf_toggle_notify, + g_object_remove_toggle_ref (G_OBJECT (icon->paintable), + paintable_toggle_notify, icon); } - if (icon->pixbuf) + if (icon->paintable) { - g_object_unref (icon->pixbuf); + g_object_unref (icon->paintable); } g_free (icon->icon_name); @@ -112,7 +112,7 @@ nautilus_icon_info_new_for_pixbuf (GdkPixbuf *pixbuf, if (pixbuf) { - icon->pixbuf = g_object_ref (pixbuf); + icon->paintable = GDK_PAINTABLE (gdk_texture_new_for_pixbuf (pixbuf)); } icon->orig_scale = scale; @@ -121,21 +121,21 @@ nautilus_icon_info_new_for_pixbuf (GdkPixbuf *pixbuf, } static NautilusIconInfo * -nautilus_icon_info_new_for_icon_info (GtkIconInfo *icon_info, - gint scale) +nautilus_icon_info_new_for_icon_paintable (GtkIconPaintable *icon_paintable, + gint scale) { NautilusIconInfo *icon; - const char *filename; + g_autoptr (GFile) file = NULL; char *basename, *p; icon = g_object_new (NAUTILUS_TYPE_ICON_INFO, NULL); - icon->pixbuf = gtk_icon_info_load_icon (icon_info, NULL); + icon->paintable = GDK_PAINTABLE (g_object_ref (icon_paintable)); - filename = gtk_icon_info_get_filename (icon_info); - if (filename != NULL) + file = gtk_icon_paintable_get_file (icon_paintable); + if (file != NULL) { - basename = g_path_get_basename (filename); + basename = g_file_get_basename (file); p = strrchr (basename, '.'); if (p) { @@ -143,6 +143,10 @@ nautilus_icon_info_new_for_icon_info (GtkIconInfo *icon_info, } icon->icon_name = basename; } + else + { + icon->icon_name = g_strdup (gtk_icon_paintable_get_icon_name (icon_paintable)); + } icon->orig_scale = scale; @@ -159,7 +163,7 @@ typedef struct typedef struct { - char *filename; + char *icon_name; int scale; int size; } ThemedIconKey; @@ -296,7 +300,7 @@ loadable_icon_key_free (LoadableIconKey *key) static guint themed_icon_key_hash (ThemedIconKey *key) { - return g_str_hash (key->filename) ^ key->size; + return g_str_hash (key->icon_name) ^ key->size; } static gboolean @@ -305,18 +309,18 @@ themed_icon_key_equal (const ThemedIconKey *a, { return a->size == b->size && a->scale == b->scale && - g_str_equal (a->filename, b->filename); + g_str_equal (a->icon_name, b->icon_name); } static ThemedIconKey * -themed_icon_key_new (const char *filename, +themed_icon_key_new (const char *icon_name, int scale, int size) { ThemedIconKey *key; key = g_slice_new (ThemedIconKey); - key->filename = g_strdup (filename); + key->icon_name = g_strdup (icon_name); key->scale = scale; key->size = size; @@ -326,7 +330,7 @@ themed_icon_key_new (const char *filename, static void themed_icon_key_free (ThemedIconKey *key) { - g_free (key->filename); + g_free (key->icon_name); g_slice_free (ThemedIconKey, key); } @@ -336,7 +340,7 @@ nautilus_icon_info_lookup (GIcon *icon, int scale) { NautilusIconInfo *icon_info; - g_autoptr (GtkIconInfo) gtkicon_info = NULL; + g_autoptr (GtkIconPaintable) icon_paintable = NULL; if (G_IS_LOADABLE_ICON (icon)) { @@ -386,9 +390,9 @@ nautilus_icon_info_lookup (GIcon *icon, return g_object_ref (icon_info); } - gtkicon_info = gtk_icon_theme_lookup_by_gicon_for_scale (gtk_icon_theme_get_default (), - icon, size, scale, 0); - if (gtkicon_info == NULL) + icon_paintable = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_for_display (gdk_display_get_default ()), + icon, size, scale, GTK_TEXT_DIR_NONE, 0); + if (icon_paintable == NULL) { return nautilus_icon_info_new_for_pixbuf (NULL, scale); } @@ -397,7 +401,7 @@ nautilus_icon_info_lookup (GIcon *icon, { ThemedIconKey lookup_key; ThemedIconKey *key; - const char *filename; + const char *icon_name; if (themed_icon_cache == NULL) { @@ -408,23 +412,18 @@ nautilus_icon_info_lookup (GIcon *icon, (GDestroyNotify) g_object_unref); } - filename = gtk_icon_info_get_filename (gtkicon_info); - if (filename == NULL) - { - g_object_unref (gtkicon_info); - return nautilus_icon_info_new_for_pixbuf (NULL, scale); - } + icon_name = gtk_icon_paintable_get_icon_name (icon_paintable); - lookup_key.filename = (char *) filename; + lookup_key.icon_name = (char *) icon_name; lookup_key.scale = scale; lookup_key.size = size; icon_info = g_hash_table_lookup (themed_icon_cache, &lookup_key); if (!icon_info) { - icon_info = nautilus_icon_info_new_for_icon_info (gtkicon_info, scale); + icon_info = nautilus_icon_info_new_for_icon_paintable (icon_paintable, scale); - key = themed_icon_key_new (filename, scale, size); + key = themed_icon_key_new (icon_name, scale, size); g_hash_table_insert (themed_icon_cache, key, icon_info); } @@ -432,31 +431,28 @@ nautilus_icon_info_lookup (GIcon *icon, } else { - g_autoptr (GdkPixbuf) pixbuf = NULL; - - pixbuf = gtk_icon_info_load_icon (gtkicon_info, NULL); - return nautilus_icon_info_new_for_pixbuf (pixbuf, scale); + return nautilus_icon_info_new_for_icon_paintable (icon_paintable, scale); } } -static GdkPixbuf * -nautilus_icon_info_get_pixbuf_nodefault (NautilusIconInfo *icon) +static GdkPaintable * +nautilus_icon_info_get_paintable_nodefault (NautilusIconInfo *icon) { - GdkPixbuf *res; + GdkPaintable *res; - if (icon->pixbuf == NULL) + if (icon->paintable == NULL) { res = NULL; } else { - res = g_object_ref (icon->pixbuf); + res = g_object_ref (icon->paintable); if (icon->sole_owner) { icon->sole_owner = FALSE; g_object_add_toggle_ref (G_OBJECT (res), - pixbuf_toggle_notify, + paintable_toggle_notify, icon); } } @@ -464,51 +460,37 @@ nautilus_icon_info_get_pixbuf_nodefault (NautilusIconInfo *icon) return res; } - -GdkPixbuf * -nautilus_icon_info_get_pixbuf (NautilusIconInfo *icon) +GdkPaintable * +nautilus_icon_info_get_paintable (NautilusIconInfo *icon) { - GdkPixbuf *res; + GdkPaintable *res; - res = nautilus_icon_info_get_pixbuf_nodefault (icon); + res = nautilus_icon_info_get_paintable_nodefault (icon); if (res == NULL) { - res = gdk_pixbuf_new_from_resource ("/org/gnome/nautilus/text-x-preview.png", - NULL); + res = GDK_PAINTABLE (gdk_texture_new_from_resource ("/org/gnome/nautilus/text-x-preview.png")); } return res; } -GdkPixbuf * -nautilus_icon_info_get_pixbuf_at_size (NautilusIconInfo *icon, - gsize forced_size) +GdkTexture * +nautilus_icon_info_get_texture (NautilusIconInfo *icon) { - GdkPixbuf *pixbuf, *scaled_pixbuf; - int w, h, s; - double scale; + g_autoptr (GdkPaintable) paintable = NULL; + GdkTexture *res; - pixbuf = nautilus_icon_info_get_pixbuf (icon); - - w = gdk_pixbuf_get_width (pixbuf) / icon->orig_scale; - h = gdk_pixbuf_get_height (pixbuf) / icon->orig_scale; - s = MAX (w, h); - if (s == forced_size) + paintable = nautilus_icon_info_get_paintable_nodefault (icon); + if (GDK_IS_TEXTURE (paintable)) { - return pixbuf; + res = GDK_TEXTURE (g_steal_pointer (&paintable)); + } + else + { + res = gdk_texture_new_from_resource ("/org/gnome/nautilus/text-x-preview.png"); } - scale = (double) forced_size / s; - - /* Neither of these can be 0. */ - w = MAX (w * scale, 1); - h = MAX (h * scale, 1); - - scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, - w, h, - GDK_INTERP_BILINEAR); - g_object_unref (pixbuf); - return scaled_pixbuf; + return res; } const char * diff --git a/src/nautilus-icon-info.h b/src/nautilus-icon-info.h index 518db76a9..e5fab7a6b 100644 --- a/src/nautilus-icon-info.h +++ b/src/nautilus-icon-info.h @@ -23,9 +23,8 @@ NautilusIconInfo * nautilus_icon_info_lookup (GIcon int size, int scale); gboolean nautilus_icon_info_is_fallback (NautilusIconInfo *icon); -GdkPixbuf * nautilus_icon_info_get_pixbuf (NautilusIconInfo *icon); -GdkPixbuf * nautilus_icon_info_get_pixbuf_at_size (NautilusIconInfo *icon, - gsize forced_size); +GdkPaintable * nautilus_icon_info_get_paintable (NautilusIconInfo *icon); +GdkTexture * nautilus_icon_info_get_texture (NautilusIconInfo *icon); const char * nautilus_icon_info_get_used_name (NautilusIconInfo *icon); void nautilus_icon_info_clear_caches (void); diff --git a/src/nautilus-list-model.c b/src/nautilus-list-model.c index 701fc3eaf..dba6b99e4 100644 --- a/src/nautilus-list-model.c +++ b/src/nautilus-list-model.c @@ -176,7 +176,7 @@ nautilus_list_model_get_column_type (GtkTreeModel *tree_model, case NAUTILUS_LIST_MODEL_LARGE_ICON_COLUMN: case NAUTILUS_LIST_MODEL_LARGER_ICON_COLUMN: { - return GDK_TYPE_PIXBUF; + return GDK_TYPE_TEXTURE; } case NAUTILUS_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN: @@ -302,7 +302,7 @@ nautilus_list_model_get_icon_scale (NautilusListModel *model) if (retval == -1) { - retval = gdk_monitor_get_scale_factor (gdk_display_get_monitor (gdk_display_get_default (), 0)); + retval = gdk_monitor_get_scale_factor (g_list_model_get_item (gdk_display_get_monitors (gdk_display_get_default ()), 0)); } /* FIXME: Temporary regression: HiDPI icons not supported, ignore scale. */ @@ -350,7 +350,7 @@ nautilus_list_model_get_value (GtkTreeModel *tree_model, FileEntry *file_entry; NautilusFile *file; char *str; - GdkPixbuf *icon, *rendered_icon; + GdkTexture *icon; int icon_size, icon_scale; NautilusListZoomLevel zoom_level; NautilusFileIconFlags flags; @@ -387,7 +387,7 @@ nautilus_list_model_get_value (GtkTreeModel *tree_model, case NAUTILUS_LIST_MODEL_LARGE_ICON_COLUMN: case NAUTILUS_LIST_MODEL_LARGER_ICON_COLUMN: { - g_value_init (value, GDK_TYPE_PIXBUF); + g_value_init (value, GDK_TYPE_TEXTURE); if (file != NULL) { @@ -421,8 +421,9 @@ nautilus_list_model_get_value (GtkTreeModel *tree_model, } } - icon = nautilus_file_get_icon_pixbuf (file, icon_size, icon_scale, flags); + icon = nautilus_file_get_icon_texture (file, icon_size, icon_scale, flags); +#if 0 && NAUTILUS_CLIPBOARD_NEEDS_GTK4_REIMPLEMENTATION if (priv->highlight_files != NULL && g_list_find_custom (priv->highlight_files, file, (GCompareFunc) nautilus_file_compare_location)) @@ -435,6 +436,7 @@ nautilus_list_model_get_value (GtkTreeModel *tree_model, icon = rendered_icon; } } +#endif g_value_set_object (value, icon); g_object_unref (icon); diff --git a/src/nautilus-list-view-dnd.c b/src/nautilus-list-view-dnd.c index 9941642bd..cef6192c5 100644 --- a/src/nautilus-list-view-dnd.c +++ b/src/nautilus-list-view-dnd.c @@ -273,7 +273,7 @@ void nautilus_list_view_dnd_drag_begin (NautilusListView *list_view, gdouble offset_x, gdouble offset_y, - const GdkEvent *event) + GdkEvent *event) { if (list_view->details->drag_button == 0) { diff --git a/src/nautilus-list-view-dnd.h b/src/nautilus-list-view-dnd.h index 97a7d2112..88ade6770 100644 --- a/src/nautilus-list-view-dnd.h +++ b/src/nautilus-list-view-dnd.h @@ -29,7 +29,7 @@ void nautilus_list_view_dnd_init (NautilusListView *list_view); void nautilus_list_view_dnd_drag_begin (NautilusListView *list_view, gdouble offset_x, gdouble offset_y, - const GdkEvent *event); + GdkEvent *event); NautilusDragInfo * nautilus_list_view_dnd_get_drag_source_data (NautilusListView *list_view, GdkDragContext *context); diff --git a/src/nautilus-list-view-private.h b/src/nautilus-list-view-private.h index de9fa5635..2c83860cc 100644 --- a/src/nautilus-list-view-private.h +++ b/src/nautilus-list-view-private.h @@ -77,11 +77,5 @@ struct NautilusListViewDetails { NautilusTagManager *tag_manager; GCancellable *starred_cancellable; - - GtkGesture *tree_view_drag_gesture; - GtkGesture *tree_view_multi_press_gesture; - GtkEventController *motion_controller; - GtkEventController *key_controller; - GtkGesture *long_press_gesture; }; diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index 74c8e6f4d..5c6d66771 100644 --- a/src/nautilus-list-view.c +++ b/src/nautilus-list-view.c @@ -54,7 +54,6 @@ #include "nautilus-ui-utilities.h" #include "nautilus-view.h" #include "nautilus-tracker-utilities.h" -#include "nautilus-gtk4-helpers.h" struct SelectionForeachData { @@ -230,11 +229,11 @@ activate_selected_items_alternate (NautilusListView *view, } static gboolean -button_event_modifies_selection (const GdkEvent *event) +button_event_modifies_selection (GdkEvent *event) { GdkModifierType state; - gdk_event_get_state (event, &state); + state = gdk_event_get_modifier_state (event); return (state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0; } @@ -279,11 +278,11 @@ on_event_controller_motion_motion (GtkEventControllerMotion *controller, { if (view->details->hover_path != NULL) { - gdk_window_set_cursor (gtk_widget_get_window (widget), hand_cursor); + gtk_widget_set_cursor (widget, hand_cursor); } else { - gdk_window_set_cursor (gtk_widget_get_window (widget), NULL); + gtk_widget_set_cursor (widget, NULL); } } @@ -344,7 +343,7 @@ on_event_controller_motion_enter (GtkEventControllerMotion *controller, if (view->details->hover_path != NULL) { - gdk_window_set_cursor (gtk_widget_get_window (widget), hand_cursor); + gtk_widget_set_cursor (widget, hand_cursor); } } @@ -449,11 +448,11 @@ on_star_cell_renderer_clicked (GtkTreePath *path, } static void -on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture, - gint n_press, - gdouble x, - gdouble y, - gpointer callback_data) +on_tree_view_click_gesture_pressed (GtkGestureClick *gesture, + gint n_press, + gdouble x, + gdouble y, + gpointer callback_data) { NautilusListView *view; GtkWidget *widget; @@ -465,7 +464,7 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture, gint bin_x; gint bin_y; GdkEventSequence *sequence; - const GdkEvent *event; + GdkEvent *event; gboolean on_expander, show_expanders; gboolean is_simple_click, path_selected; NautilusFile *file; @@ -620,7 +619,7 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture, g_autoptr (GtkTreePath) cursor = NULL; GList *selected_rows = NULL; - gdk_event_get_state (event, &state); + state = gdk_event_get_modifier_state (event); /* We cannot easily match the expected behavior of Shift+click, so we * must fall back to GtkTreeView's default event handling. @@ -714,16 +713,16 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture, } static void -on_tree_view_multi_press_gesture_released (GtkGestureMultiPress *gesture, - gint n_press, - gdouble x, - gdouble y, - gpointer callback_data) +on_tree_view_click_gesture_released (GtkGestureClick *gesture, + gint n_press, + gdouble x, + gdouble y, + gpointer callback_data) { NautilusListView *view; guint button; GdkEventSequence *sequence; - const GdkEvent *event; + GdkEvent *event; GtkTreeView *tree_view; GtkTreeSelection *selection; gint x_in_bin; @@ -771,7 +770,7 @@ on_tree_view_multi_press_gesture_released (GtkGestureMultiPress *gesture, return; } - gdk_event_get_state (event, &state); + state = gdk_event_get_modifier_state (event); if ((button == GDK_BUTTON_PRIMARY || button == GDK_BUTTON_MIDDLE) && ((state & GDK_CONTROL_MASK) != 0 || @@ -1468,7 +1467,7 @@ popup_column_header_menu (NautilusListView *list_view, G_CALLBACK (column_header_menu_use_default), list_view); - gtk_widget_show_all (menu); + gtk_widget_show (menu); gtk_popover_set_pointing_to (popover, &(GdkRectangle){x, y, 0, 0}); gtk_popover_popup (popover); @@ -1956,7 +1955,7 @@ on_tree_view_drag_gesture_drag_update (GtkGestureDrag *gesture, { #if 0 && NAUTILUS_DND_NEEDS_GTK4_REIMPLEMENTATION GdkEventSequence *sequence; - const GdkEvent *event; + GdkEvent *event; NautilusListView *list_view; sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)); @@ -1990,7 +1989,6 @@ create_and_set_up_tree_view (NautilusListView *view) GList *l; gchar **default_column_order, **default_visible_columns; GtkWidget *content_widget; - GtkGesture *gesture; GtkEventController *controller; content_widget = nautilus_files_view_get_content_widget (NAUTILUS_FILES_VIEW (view)); @@ -2040,33 +2038,29 @@ create_and_set_up_tree_view (NautilusListView *view) "changed", G_CALLBACK (list_selection_changed_callback), view, 0); - gesture = gtk_gesture_drag_new (GTK_WIDGET (view->details->tree_view)); - view->details->tree_view_drag_gesture = gesture; - - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), - GTK_PHASE_CAPTURE); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0); + controller = GTK_EVENT_CONTROLLER (gtk_gesture_drag_new ()); + gtk_widget_add_controller (GTK_WIDGET (view->details->tree_view), controller); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0); - g_signal_connect (gesture, "drag-begin", + g_signal_connect (controller, "drag-begin", G_CALLBACK (on_tree_view_drag_gesture_drag_begin), view); - g_signal_connect (gesture, "drag-update", + g_signal_connect (controller, "drag-update", G_CALLBACK (on_tree_view_drag_gesture_drag_update), view); - gesture = gtk_gesture_multi_press_new (GTK_WIDGET (view->details->tree_view)); - view->details->tree_view_multi_press_gesture = gesture; + controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ()); + gtk_widget_add_controller (GTK_WIDGET (view->details->tree_view), controller); - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), - GTK_PHASE_CAPTURE); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0); - - g_signal_connect (gesture, "pressed", - G_CALLBACK (on_tree_view_multi_press_gesture_pressed), view); - g_signal_connect (gesture, "released", - G_CALLBACK (on_tree_view_multi_press_gesture_released), view); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0); - controller = gtk_event_controller_motion_new (GTK_WIDGET (view->details->tree_view)); - view->details->motion_controller = controller; + g_signal_connect (controller, "pressed", + G_CALLBACK (on_tree_view_click_gesture_pressed), view); + g_signal_connect (controller, "released", + G_CALLBACK (on_tree_view_click_gesture_released), view); + controller = gtk_event_controller_motion_new (); + gtk_widget_add_controller (GTK_WIDGET (view->details->tree_view), controller); gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); g_signal_connect (controller, "enter", @@ -2076,8 +2070,8 @@ create_and_set_up_tree_view (NautilusListView *view) g_signal_connect (controller, "motion", G_CALLBACK (on_event_controller_motion_motion), view); - controller = gtk_event_controller_key_new (GTK_WIDGET (view->details->tree_view)); - view->details->key_controller = controller; + controller = gtk_event_controller_key_new (); + gtk_widget_add_controller (GTK_WIDGET (view->details->tree_view), controller); gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE); @@ -2114,16 +2108,12 @@ create_and_set_up_tree_view (NautilusListView *view) g_signal_connect_object (view->details->model, "get-icon-scale", G_CALLBACK (get_icon_scale_callback), view, 0); - gesture = gtk_gesture_long_press_new (GTK_WIDGET (content_widget)); - view->details->long_press_gesture = gesture; - - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), - GTK_PHASE_CAPTURE); - gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE); - g_signal_connect (gesture, - "pressed", - (GCallback) on_longpress_gesture_pressed_event, - view); + controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ()); + gtk_widget_add_controller (GTK_WIDGET (content_widget), controller); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); + gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (controller), TRUE); + g_signal_connect (controller, "pressed", + (GCallback) on_longpress_gesture_pressed_event, view); gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view->details->tree_view), GTK_SELECTION_MULTIPLE); @@ -2191,7 +2181,7 @@ create_and_set_up_tree_view (NautilusListView *view) gtk_tree_view_column_pack_start (view->details->file_name_column, cell, FALSE); gtk_tree_view_column_set_attributes (view->details->file_name_column, cell, - "pixbuf", nautilus_list_model_get_column_id_from_zoom_level (view->details->zoom_level), + "texture", nautilus_list_model_get_column_id_from_zoom_level (view->details->zoom_level), NULL); cell = gtk_cell_renderer_text_new (); @@ -3286,7 +3276,7 @@ create_column_editor (NautilusListView *view) window = GTK_WIDGET (gtk_builder_get_object (builder, "window")); gtk_window_set_transient_for (GTK_WINDOW (window), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)))); + GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (view)))); file = nautilus_files_view_get_directory_as_file (NAUTILUS_FILES_VIEW (view)); name = nautilus_file_get_display_name (file); @@ -3364,7 +3354,7 @@ nautilus_list_view_set_zoom_level (NautilusListView *view, column = nautilus_list_model_get_column_id_from_zoom_level (new_level); gtk_tree_view_column_set_attributes (view->details->file_name_column, GTK_CELL_RENDERER (view->details->pixbuf_cell), - "pixbuf", column, + "texture", column, NULL); set_up_pixbuf_size (view); } @@ -3439,7 +3429,6 @@ nautilus_list_view_is_zoom_level_default (NautilusFilesView *view) static void nautilus_list_view_click_policy_changed (NautilusFilesView *directory_view) { - GdkWindow *win; GdkDisplay *display; NautilusListView *view; GtkTreeIter iter; @@ -3467,8 +3456,7 @@ nautilus_list_view_click_policy_changed (NautilusFilesView *directory_view) tree = view->details->tree_view; if (gtk_widget_get_realized (GTK_WIDGET (tree))) { - win = gtk_widget_get_window (GTK_WIDGET (tree)); - gdk_window_set_cursor (win, NULL); + gtk_widget_set_cursor (GTK_WIDGET (tree), NULL); if (display != NULL) { @@ -3482,7 +3470,7 @@ nautilus_list_view_click_policy_changed (NautilusFilesView *directory_view) { if (hand_cursor == NULL) { - hand_cursor = gdk_cursor_new_from_name (display, "pointer"); + hand_cursor = gdk_cursor_new_from_name ("pointer", NULL); } } } @@ -3577,11 +3565,7 @@ nautilus_list_view_dispose (GObject *object) default_column_order_changed_callback, list_view); - g_clear_object (&list_view->details->tree_view_drag_gesture); - g_clear_object (&list_view->details->tree_view_multi_press_gesture); - g_clear_object (&list_view->details->motion_controller); - g_clear_object (&list_view->details->key_controller); - g_clear_object (&list_view->details->long_press_gesture); + g_clear_pointer (&list_view->details->columns_popover, gtk_widget_unparent); G_OBJECT_CLASS (nautilus_list_view_parent_class)->dispose (object); } @@ -3615,7 +3599,7 @@ nautilus_list_view_finalize (GObject *object) if (list_view->details->column_editor != NULL) { - gtk_widget_destroy (list_view->details->column_editor); + gtk_window_destroy (GTK_WINDOW (list_view->details->column_editor)); } g_regex_unref (list_view->details->regex); @@ -4008,7 +3992,11 @@ nautilus_list_view_init (NautilusListView *list_view) gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (list_view)), "nautilus-list-view"); - list_view->details->columns_popover = gtk_popover_new (GTK_WIDGET (list_view)); + list_view->details->columns_popover = gtk_popover_new (); + gtk_widget_set_parent (list_view->details->columns_popover, + GTK_WIDGET (list_view)); + g_signal_connect (list_view->details->columns_popover, "destroy", G_CALLBACK (gtk_widget_unparent), NULL); + list_view->details->columns_popover_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_widget_set_margin_top (list_view->details->columns_popover_box, 6); gtk_widget_set_margin_bottom (list_view->details->columns_popover_box, 6); diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c index 5d3e3643c..73fda840f 100644 --- a/src/nautilus-location-entry.c +++ b/src/nautilus-location-entry.c @@ -134,7 +134,7 @@ nautilus_location_entry_update_action (NautilusLocationEntry *entry) return; } - current_text = gtk_entry_get_text (GTK_ENTRY (entry)); + current_text = gtk_editable_get_text (GTK_EDITABLE (entry)); location = g_file_parse_name (current_text); if (g_file_equal (priv->last_location, location)) @@ -184,7 +184,7 @@ nautilus_location_entry_update_current_uri (NautilusLocationEntry *entry, g_free (priv->current_directory); priv->current_directory = g_strdup (uri); - gtk_entry_set_text (GTK_ENTRY (entry), uri); + gtk_editable_set_text (GTK_EDITABLE (entry), uri); set_position_and_selection_to_end (GTK_EDITABLE (entry)); } @@ -284,7 +284,7 @@ confirm_multiple_windows_cb (GtkDialog *dialog, open_multiple = (response_id == GTK_RESPONSE_OK); - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); do_open_windows (data, open_multiple); gtk_drag_finish (data->context, open_multiple, FALSE, data->time); } @@ -301,7 +301,7 @@ drag_data_received_callback (GtkWidget *widget, { char **names; int name_count; - GtkWidget *window; + GtkRoot *window; char *prompt; char *detail; GtkDialog *dialog; @@ -320,7 +320,7 @@ drag_data_received_callback (GtkWidget *widget, return; } - window = gtk_widget_get_toplevel (widget); + window = gtk_widget_get_root (widget); op_data = g_new0 (OpenWindowsOnDragData, 1); op_data->self = g_object_ref (self); @@ -578,8 +578,6 @@ finalize (GObject *object) g_clear_object (&priv->completions_store); g_free (priv->current_directory); - g_clear_object (&priv->controller); - G_OBJECT_CLASS (nautilus_location_entry_parent_class)->finalize (object); } @@ -622,7 +620,7 @@ on_has_focus_changed (GObject *object, if (priv->has_special_text) { priv->setting_special_text = TRUE; - gtk_entry_set_text (GTK_ENTRY (entry), ""); + gtk_editable_set_text (GTK_EDITABLE (entry), ""); priv->setting_special_text = FALSE; } } @@ -665,7 +663,7 @@ nautilus_location_entry_icon_release (GtkEntry *gentry, case NAUTILUS_LOCATION_ENTRY_ACTION_CLEAR: { - gtk_entry_set_text (gentry, ""); + gtk_editable_set_text (GTK_EDITABLE (gentry), ""); } break; @@ -709,7 +707,7 @@ nautilus_location_entry_key_pressed (GtkEventControllerKey *controller, { int position; - position = strlen (gtk_entry_get_text (GTK_ENTRY (editable))); + position = strlen (gtk_editable_get_text (GTK_EDITABLE (editable))); gtk_editable_select_region (editable, position, position); } else @@ -782,7 +780,7 @@ nautilus_location_entry_activate (GtkEntry *entry) loc_entry = NAUTILUS_LOCATION_ENTRY (entry); priv = nautilus_location_entry_get_instance_private (loc_entry); - entry_text = gtk_entry_get_text (entry); + entry_text = gtk_editable_get_text (GTK_EDITABLE (entry)); path = g_strdup (entry_text); path = g_strchug (path); path = g_strchomp (path); @@ -795,7 +793,7 @@ nautilus_location_entry_activate (GtkEntry *entry) { /* Fix non absolute paths */ full_path = g_build_filename (priv->current_directory, path, NULL); - gtk_entry_set_text (entry, full_path); + gtk_editable_set_text (GTK_EDITABLE (entry), full_path); g_free (full_path); } @@ -820,8 +818,7 @@ nautilus_location_entry_class_init (NautilusLocationEntryClass *class) { GObjectClass *gobject_class; GtkEntryClass *entry_class; - GtkBindingSet *binding_set; - + g_autoptr (GtkShortcut) shortcut = NULL; gobject_class = G_OBJECT_CLASS (class); gobject_class->dispose = nautilus_location_entry_dispose; @@ -850,8 +847,9 @@ nautilus_location_entry_class_init (NautilusLocationEntryClass *class) g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_OBJECT); - binding_set = gtk_binding_set_by_class (class); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0); + shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_Escape, 0), + gtk_signal_action_new ("cancel")); + gtk_widget_class_add_shortcut (GTK_WIDGET_CLASS (class), shortcut); } void @@ -901,14 +899,14 @@ editable_activate_callback (GtkEntry *entry, const char *entry_text; g_autofree gchar *path = NULL; - entry_text = gtk_entry_get_text (entry); + entry_text = gtk_editable_get_text (GTK_EDITABLE (entry)); path = g_strdup (entry_text); path = g_strchug (path); path = g_strchomp (path); if (path != NULL && *path != '\0') { - gtk_entry_set_text (entry, path); + gtk_editable_set_text (GTK_EDITABLE (entry), path); emit_location_changed (self); } } @@ -924,6 +922,7 @@ static void nautilus_location_entry_init (NautilusLocationEntry *entry) { NautilusLocationEntryPrivate *priv; + GtkEventController *controller; priv = nautilus_location_entry_get_instance_private (entry); @@ -964,15 +963,15 @@ nautilus_location_entry_init (NautilusLocationEntry *entry) g_signal_connect_object (entry, "changed", G_CALLBACK (editable_changed_callback), entry, 0); - priv->controller = gtk_event_controller_key_new (GTK_WIDGET (entry)); + controller = gtk_event_controller_key_new (); + gtk_widget_add_controller (GTK_WIDGET (entry), controller); /* In GTK3, the Tab key binding (for focus change) happens in the bubble * phase, and we want to stop that from happening. After porting to GTK4 * we need to check whether this is still correct. */ - gtk_event_controller_set_propagation_phase (priv->controller, GTK_PHASE_BUBBLE); - g_signal_connect (priv->controller, - "key-pressed", - G_CALLBACK (nautilus_location_entry_key_pressed), - NULL); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE); + g_signal_connect (controller, "key-pressed", + G_CALLBACK (nautilus_location_entry_key_pressed), NULL); + g_signal_connect_after (entry, "insert-text", G_CALLBACK (on_after_insert_text), @@ -1026,6 +1025,6 @@ nautilus_location_entry_set_special_text (NautilusLocationEntry *entry, priv->special_text = g_strdup (special_text); priv->setting_special_text = TRUE; - gtk_entry_set_text (GTK_ENTRY (entry), special_text); + gtk_editable_set_text (GTK_EDITABLE (entry), special_text); priv->setting_special_text = FALSE; } diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c index 255055b7d..9adebffc3 100644 --- a/src/nautilus-mime-actions.c +++ b/src/nautilus-mime-actions.c @@ -563,7 +563,7 @@ trash_symbolic_link_cb (GtkDialog *dialog, GList file_as_list; data = user_data; - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); if (response_id == GTK_RESPONSE_YES) { @@ -1023,7 +1023,7 @@ on_confirm_multiple_windows_response (GtkDialog *dialog, int response_id, ActivateParameters *parameters) { - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); if (response_id == GTK_RESPONSE_YES) { @@ -1109,7 +1109,7 @@ open_with_response_cb (GtkDialog *dialog, if (response_id != GTK_RESPONSE_OK) { - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); return; } @@ -1117,7 +1117,7 @@ open_with_response_cb (GtkDialog *dialog, file = g_object_get_data (G_OBJECT (dialog), "mime-action:file"); info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog)); - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); g_signal_emit_by_name (nautilus_signaller_get_current (), "mime-data-changed"); @@ -1143,7 +1143,7 @@ choose_program (GtkDialog *message_dialog, if (response != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy (GTK_WIDGET (message_dialog)); + gtk_window_destroy (GTK_WINDOW (message_dialog)); activate_parameters_install_free (parameters); return; } @@ -1156,7 +1156,7 @@ choose_program (GtkDialog *message_dialog, nautilus_file_ref (file); /* Destroy the message dialog after ref:ing the file */ - gtk_widget_destroy (GTK_WIDGET (message_dialog)); + gtk_window_destroy (GTK_WINDOW (message_dialog)); dialog = gtk_app_chooser_dialog_new (parameters->parent_window, GTK_DIALOG_MODAL, @@ -1280,7 +1280,7 @@ search_for_application_mime_type (ActivateParametersInstall *parameters_install, g_assert (parameters_install->proxy != NULL); - desktop_startup_id = g_strdup_printf ("_TIME%i", gtk_get_current_event_time ()); + desktop_startup_id = g_strdup_printf ("_TIME%i", (guint32) GDK_CURRENT_TIME); g_dbus_proxy_call (parameters_install->proxy, "InstallMimeTypes", @@ -1306,7 +1306,7 @@ application_unhandled_file_install (GtkDialog *dialog, { char *mime_type; - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); parameters_install->dialog = NULL; if (response_id == GTK_RESPONSE_YES) @@ -1377,7 +1377,7 @@ pk_proxy_appeared_cb (GObject *source, g_signal_connect (dialog, "response", G_CALLBACK (application_unhandled_file_install), parameters_install); - gtk_widget_show_all (dialog); + gtk_widget_show (dialog); g_free (mime_type); } diff --git a/src/nautilus-new-folder-dialog-controller.c b/src/nautilus-new-folder-dialog-controller.c index 17406a016..9638c8787 100644 --- a/src/nautilus-new-folder-dialog-controller.c +++ b/src/nautilus-new-folder-dialog-controller.c @@ -139,14 +139,14 @@ nautilus_new_folder_dialog_controller_new (GtkWindow *parent_window, if (initial_name != NULL) { - gtk_entry_set_text (GTK_ENTRY (name_entry), initial_name); + gtk_editable_set_text (GTK_EDITABLE (name_entry), initial_name); } gtk_button_set_label (GTK_BUTTON (activate_button), _("Create")); gtk_label_set_text (GTK_LABEL (name_label), _("Folder name")); gtk_window_set_title (GTK_WINDOW (new_folder_dialog), _("New Folder")); - gtk_widget_show_all (new_folder_dialog); + gtk_widget_show (new_folder_dialog); return self; } @@ -172,7 +172,7 @@ nautilus_new_folder_dialog_controller_finalize (GObject *object) if (self->new_folder_dialog != NULL) { g_clear_signal_handler (&self->response_handler_id, self->new_folder_dialog); - gtk_widget_destroy (self->new_folder_dialog); + gtk_window_destroy (GTK_WINDOW (self->new_folder_dialog)); self->new_folder_dialog = NULL; } diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c index f36c722ee..96a8ca97b 100644 --- a/src/nautilus-notebook.c +++ b/src/nautilus-notebook.c @@ -29,7 +29,6 @@ #include "nautilus-window.h" #include "nautilus-window-slot.h" #include "nautilus-window-slot-dnd.h" -#include "nautilus-gtk4-helpers.h" #include <eel/eel-vfs-extensions.h> #include <glib/gi18n.h> @@ -169,7 +168,7 @@ nautilus_notebook_sync_loading (GtkNotebook *notebook, g_return_if_fail (spinner != NULL && icon != NULL); active = FALSE; - g_object_get (spinner, "active", &active, NULL); + g_object_get (spinner, "spinning", &active, NULL); allow_stop = nautilus_window_slot_get_allow_stop (slot); if (active == allow_stop) @@ -270,7 +269,7 @@ build_tab_label (GtkNotebook *notebook, gtk_widget_show (label); /* Tab close button */ - close_button = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU); + close_button = gtk_button_new_from_icon_name ("window-close-symbolic"); gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (close_button)), "flat"); /* don't allow focus on the close button */ @@ -315,11 +314,11 @@ nautilus_notebook_add_tab (GtkNotebook *notebook, tab_label, position); - gtk_container_child_set (GTK_CONTAINER (notebook), - GTK_WIDGET (slot), - "tab-expand", TRUE, - "detachable", FALSE, - NULL); + g_object_set (gtk_notebook_get_page (GTK_NOTEBOOK (notebook), + GTK_WIDGET (slot)), + "tab-expand", TRUE, + "detachable", FALSE, + NULL); nautilus_notebook_sync_tab_label (notebook, slot); nautilus_notebook_sync_loading (notebook, slot); diff --git a/src/nautilus-operations-ui-manager.c b/src/nautilus-operations-ui-manager.c index 7d4225785..2371339a5 100644 --- a/src/nautilus-operations-ui-manager.c +++ b/src/nautilus-operations-ui-manager.c @@ -223,25 +223,25 @@ set_copy_move_dialog_text (FileConflictDialogData *data) static void set_images (FileConflictDialogData *data) { - GdkPixbuf *source_pixbuf; - GdkPixbuf *destination_pixbuf; + GdkPaintable *source_paintable; + GdkPaintable *destination_paintable; - destination_pixbuf = nautilus_file_get_icon_pixbuf (data->destination, - NAUTILUS_GRID_ICON_SIZE_SMALL, - 1, - NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); + destination_paintable = nautilus_file_get_icon_paintable (data->destination, + NAUTILUS_GRID_ICON_SIZE_SMALL, + 1, + NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); - source_pixbuf = nautilus_file_get_icon_pixbuf (data->source, - NAUTILUS_GRID_ICON_SIZE_SMALL, - 1, - NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); + source_paintable = nautilus_file_get_icon_paintable (data->source, + NAUTILUS_GRID_ICON_SIZE_SMALL, + 1, + NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); nautilus_file_conflict_dialog_set_images (data->dialog, - destination_pixbuf, - source_pixbuf); + destination_paintable, + source_paintable); - g_object_unref (destination_pixbuf); - g_object_unref (source_pixbuf); + g_object_unref (destination_paintable); + g_object_unref (source_paintable); } static void @@ -463,7 +463,7 @@ on_conflict_dialog_response (GtkDialog *dialog, data->response->id = response_id; - gtk_widget_destroy (GTK_WIDGET (data->dialog)); + gtk_window_destroy (GTK_WINDOW (data->dialog)); nautilus_file_unref (data->source); nautilus_file_unref (data->destination); @@ -561,7 +561,7 @@ on_app_chooser_response (GtkDialog *dialog, application = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog)); } - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); if (application != NULL) { @@ -638,10 +638,10 @@ on_request_passphrase_cb (GtkDialog *dialog, if (response_id != GTK_RESPONSE_CANCEL && response_id != GTK_RESPONSE_DELETE_EVENT) { - data->passphrase = g_strdup (gtk_entry_get_text (data->passphrase_entry)); + data->passphrase = g_strdup (gtk_editable_get_text (GTK_EDITABLE (data->passphrase_entry))); } - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); invoke_main_context_completed (data); } diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c index dbe30162e..644fc9d0e 100644 --- a/src/nautilus-pathbar.c +++ b/src/nautilus-pathbar.c @@ -33,7 +33,6 @@ #include "nautilus-icon-names.h" #include "nautilus-trash-monitor.h" #include "nautilus-ui-utilities.h" -#include "nautilus-gtk4-helpers.h" #include "nautilus-window-slot-dnd.h" @@ -78,8 +77,6 @@ typedef struct NautilusPathBar *path_bar; - GtkGesture *multi_press_gesture; - guint ignore_changes : 1; guint is_root : 1; } ButtonData; @@ -99,7 +96,7 @@ struct _NautilusPathBar GActionGroup *action_group; NautilusFile *context_menu_file; - GtkPopover *current_view_menu_popover; + GtkPopoverMenu *current_view_menu_popover; GtkWidget *current_view_menu_button; GtkWidget *button_menu_popover; GMenu *current_view_menu; @@ -214,9 +211,8 @@ on_adjustment_changed (GtkAdjustment *adjustment) static gboolean bind_current_view_menu_model_to_popover (NautilusPathBar *self) { - gtk_popover_bind_model (self->current_view_menu_popover, - G_MENU_MODEL (self->current_view_menu), - NULL); + gtk_popover_menu_set_menu_model (self->current_view_menu_popover, + G_MENU_MODEL (self->current_view_menu)); return G_SOURCE_REMOVE; } @@ -227,7 +223,7 @@ nautilus_path_bar_init (NautilusPathBar *self) GtkBuilder *builder; g_autoptr (GError) error = NULL; - self->scrolled = gtk_scrolled_window_new (NULL, NULL); + self->scrolled = gtk_scrolled_window_new (); /* Scroll horizontally only and don't use internal scrollbar. */ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (self->scrolled), /* hscrollbar-policy */ GTK_POLICY_EXTERNAL, @@ -243,8 +239,7 @@ nautilus_path_bar_init (NautilusPathBar *self) self->current_view_menu_button = gtk_menu_button_new (); gtk_menu_button_set_child (GTK_MENU_BUTTON (self->current_view_menu_button), - gtk_image_new_from_icon_name ("view-more-symbolic", - GTK_ICON_SIZE_MENU)); + gtk_image_new_from_icon_name ("view-more-symbolic")); gtk_box_append (GTK_BOX (self), self->current_view_menu_button); builder = gtk_builder_new (); @@ -258,8 +253,8 @@ nautilus_path_bar_init (NautilusPathBar *self) g_error ("Failed to add pathbar-context-menu.ui: %s", error->message); } self->button_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder, "button-menu"))); - self->button_menu_popover = g_object_ref_sink (gtk_popover_new_from_model (NULL, - G_MENU_MODEL (self->button_menu))); + self->button_menu_popover = gtk_popover_menu_new_from_model (G_MENU_MODEL (self->button_menu)); + gtk_widget_set_parent (self->button_menu_popover, GTK_WIDGET (self)); /* Add current location menu, which matches the view's background context menu */ gtk_builder_add_from_resource (builder, @@ -272,7 +267,7 @@ nautilus_path_bar_init (NautilusPathBar *self) self->current_view_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder, "background-menu"))); self->extensions_section = g_object_ref (G_MENU (gtk_builder_get_object (builder, "background-extensions-section"))); self->templates_submenu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "templates-submenu"))); - self->current_view_menu_popover = g_object_ref_sink (GTK_POPOVER (gtk_popover_new (NULL))); + self->current_view_menu_popover = g_object_ref_sink (GTK_POPOVER_MENU (gtk_popover_menu_new_from_model (NULL))); g_object_unref (builder); @@ -310,7 +305,7 @@ nautilus_path_bar_finalize (GObject *object) g_clear_object (&self->extensions_section); g_clear_object (&self->templates_submenu); g_clear_object (&self->button_menu); - g_clear_object (&self->button_menu_popover); + g_clear_pointer (&self->button_menu_popover, gtk_widget_unparent); g_clear_object (&self->current_view_menu_popover); unschedule_pop_up_context_menu (NAUTILUS_PATH_BAR (object)); @@ -378,8 +373,6 @@ button_data_free (ButtonData *button_data) nautilus_file_unref (button_data->file); } - g_clear_object (&button_data->multi_press_gesture); - g_free (button_data); } @@ -425,7 +418,7 @@ nautilus_path_bar_set_templates_menu (NautilusPathBar *self, * templates menu is set. Unbinding the model is the only way to clear * all children. After that's done, on idle, we rebind it. * See https://gitlab.gnome.org/GNOME/nautilus/-/issues/1705 */ - gtk_popover_bind_model (self->current_view_menu_popover, NULL, NULL); + gtk_popover_menu_set_menu_model (self->current_view_menu_popover, NULL); } nautilus_gmenu_set_from_model (self->templates_submenu, menu); @@ -560,11 +553,11 @@ pop_up_pathbar_context_menu (NautilusPathBar *self, static void -on_multi_press_gesture_pressed (GtkGestureMultiPress *gesture, - gint n_press, - gdouble x, - gdouble y, - gpointer user_data) +on_click_gesture_pressed (GtkGestureClick *gesture, + gint n_press, + gdouble x, + gdouble y, + gpointer user_data) { ButtonData *button_data; NautilusPathBar *self; @@ -579,7 +572,7 @@ on_multi_press_gesture_pressed (GtkGestureMultiPress *gesture, button_data = BUTTON_DATA (user_data); self = button_data->path_bar; current_button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)); - gtk_get_current_event_state (&state); + state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture)); switch (current_button) { @@ -602,8 +595,15 @@ on_multi_press_gesture_pressed (GtkGestureMultiPress *gesture, } else { - gtk_popover_set_relative_to (GTK_POPOVER (self->button_menu_popover), - button_data->button); + /* Hold a reference to keep the popover from destroying itself + * when unparented. */ + g_object_ref (self->button_menu_popover); + gtk_widget_unparent (self->button_menu_popover); + gtk_widget_set_parent (self->button_menu_popover, + button_data->button); + gtk_popover_present (GTK_POPOVER (self->button_menu_popover)); + g_object_unref (self->button_menu_popover); + pop_up_pathbar_context_menu (self, button_data->file); } } @@ -755,7 +755,7 @@ nautilus_path_bar_update_button_appearance (ButtonData *button_data, icon = get_gicon (button_data); if (icon != NULL) { - gtk_image_set_from_gicon (GTK_IMAGE (button_data->image), icon, GTK_ICON_SIZE_MENU); + gtk_image_set_from_gicon (GTK_IMAGE (button_data->image), icon); gtk_widget_show (GTK_WIDGET (button_data->image)); g_object_unref (icon); } @@ -976,6 +976,7 @@ make_button_data (NautilusPathBar *self, { GFile *path; GtkWidget *child = NULL; + GtkEventController *controller; ButtonData *button_data; path = nautilus_file_get_location (file); @@ -1077,7 +1078,7 @@ make_button_data (NautilusPathBar *self, } gtk_button_set_child (GTK_BUTTON (button_data->button), child); - gtk_widget_show_all (button_data->container); + gtk_widget_show (button_data->container); nautilus_path_bar_update_button_state (button_data, current_dir); @@ -1088,12 +1089,11 @@ make_button_data (NautilusPathBar *self, /* A gesture is needed here, because GtkButton doesn’t react to middle- or * secondary-clicking. */ - button_data->multi_press_gesture = gtk_gesture_multi_press_new (button_data->button); - - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (button_data->multi_press_gesture), 0); - - g_signal_connect (button_data->multi_press_gesture, "pressed", - G_CALLBACK (on_multi_press_gesture_pressed), button_data); + controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ()); + gtk_widget_add_controller (button_data->button, controller); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0); + g_signal_connect (controller, "pressed", + G_CALLBACK (on_click_gesture_pressed), button_data); #if 0 && NAUTILUS_DND_NEEDS_GTK4_REIMPLEMENTATION nautilus_drag_slot_proxy_init (button_data->button, button_data->file, NULL); diff --git a/src/nautilus-places-view.c b/src/nautilus-places-view.c index a2edbfc85..a704c4e33 100644 --- a/src/nautilus-places-view.c +++ b/src/nautilus-places-view.c @@ -26,7 +26,6 @@ #include "nautilus-toolbar-menu-sections.h" #include "nautilus-view.h" #include "nautilus-window-slot.h" -#include "nautilus-gtk4-helpers.h" typedef struct { @@ -72,20 +71,20 @@ open_location_cb (NautilusPlacesView *view, switch (open_flags) { - case GTK_PLACES_OPEN_NEW_TAB: + case NAUTILUS_OPEN_FLAG_NEW_TAB: { flags = NAUTILUS_OPEN_FLAG_NEW_TAB | NAUTILUS_OPEN_FLAG_DONT_MAKE_ACTIVE; } break; - case GTK_PLACES_OPEN_NEW_WINDOW: + case NAUTILUS_OPEN_FLAG_NEW_WINDOW: { flags = NAUTILUS_OPEN_FLAG_NEW_WINDOW; } break; - case GTK_PLACES_OPEN_NORMAL: /* fall-through */ + case NAUTILUS_OPEN_FLAG_NORMAL: /* fall-through */ default: { flags = 0; @@ -96,12 +95,12 @@ open_location_cb (NautilusPlacesView *view, if (slot) { NautilusFile *file; - GtkWidget *window; + GtkRoot *window; char *path; path = "other-locations:///"; file = nautilus_file_get (location); - window = gtk_widget_get_toplevel (GTK_WIDGET (view)); + window = gtk_widget_get_root (GTK_WIDGET (view)); nautilus_mime_activate_file (GTK_WINDOW (window), NAUTILUS_WINDOW_SLOT (slot), @@ -124,9 +123,9 @@ show_error_message_cb (NautilusGtkPlacesView *view, const gchar *secondary) { GtkWidget *dialog; - GtkWidget *window; + GtkRoot *window; - window = gtk_widget_get_toplevel (GTK_WIDGET (view)); + window = gtk_widget_get_root (GTK_WIDGET (view)); dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, @@ -136,8 +135,8 @@ show_error_message_cb (NautilusGtkPlacesView *view, gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", secondary); - g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); - gtk_widget_show_all (dialog); + g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL); + gtk_widget_show (dialog); } static void @@ -386,7 +385,7 @@ nautilus_places_view_init (NautilusPlacesView *self) /* Places view */ priv->places_view = nautilus_gtk_places_view_new (); nautilus_gtk_places_view_set_open_flags (NAUTILUS_GTK_PLACES_VIEW (priv->places_view), - GTK_PLACES_OPEN_NEW_TAB | GTK_PLACES_OPEN_NEW_WINDOW | GTK_PLACES_OPEN_NORMAL); + NAUTILUS_OPEN_FLAG_NEW_TAB | NAUTILUS_OPEN_FLAG_NEW_WINDOW | NAUTILUS_OPEN_FLAG_NORMAL); gtk_widget_set_hexpand (priv->places_view, TRUE); gtk_widget_set_vexpand (priv->places_view, TRUE); gtk_widget_show (priv->places_view); diff --git a/src/nautilus-preferences-window.c b/src/nautilus-preferences-window.c index 996ba559a..b3a701927 100644 --- a/src/nautilus-preferences-window.c +++ b/src/nautilus-preferences-window.c @@ -27,7 +27,7 @@ #include <gtk/gtk.h> #include <gio/gio.h> -#include <libhandy-1/handy.h> +#include <libadwaita-1/adwaita.h> #include <glib/gi18n.h> @@ -74,7 +74,7 @@ static GtkWidget *preferences_window = NULL; static void list_store_append_string (GListStore *list_store, const gchar *string) { - g_autoptr (HdyValueObject) obj = hdy_value_object_new_string (string); + g_autoptr (GtkStringObject) obj = gtk_string_object_new (string); g_list_store_append (list_store, obj); } @@ -84,10 +84,10 @@ static void free_column_names_array(GPtrArray *column_names) g_ptr_array_free (column_names, TRUE); } -static void create_icon_caption_combo_row_items(HdyComboRow *combo_row, +static void create_icon_caption_combo_row_items(AdwComboRow *combo_row, GList *columns) { - GListStore *list_store = g_list_store_new (HDY_TYPE_VALUE_OBJECT); + GListStore *list_store = g_list_store_new (GTK_TYPE_STRING_OBJECT); GList *l; GPtrArray *column_names; @@ -120,14 +120,12 @@ static void create_icon_caption_combo_row_items(HdyComboRow *combo_row, g_free (label); } - hdy_combo_row_bind_name_model (combo_row, G_LIST_MODEL (list_store), - (HdyComboRowGetNameFunc) hdy_value_object_dup_string, - NULL, NULL); + adw_combo_row_set_model (combo_row, G_LIST_MODEL (list_store)); g_object_set_data_full (G_OBJECT (combo_row), "column_names", column_names, (GDestroyNotify) free_column_names_array); } -static void icon_captions_changed_callback(HdyComboRow *widget, +static void icon_captions_changed_callback(AdwComboRow *widget, GParamSpec *pspec, gpointer user_data) { @@ -148,7 +146,7 @@ static void icon_captions_changed_callback(HdyComboRow *widget, combo_row = GTK_WIDGET ( gtk_builder_get_object (builder, icon_captions_components[i])); - selected_index = hdy_combo_row_get_selected_index (HDY_COMBO_ROW (combo_row)); + selected_index = adw_combo_row_get_selected (ADW_COMBO_ROW (combo_row)); column_names = g_object_get_data (G_OBJECT (combo_row), "column_names"); @@ -182,7 +180,7 @@ static void update_caption_combo_row(GtkBuilder *builder, { if (!strcmp (name, g_ptr_array_index (column_names, i))) { - hdy_combo_row_set_selected_index (HDY_COMBO_ROW (combo_row), i); + adw_combo_row_set_selected (ADW_COMBO_ROW (combo_row), i); break; } } @@ -242,11 +240,11 @@ nautilus_preferences_window_setup_icon_caption_page (GtkBuilder *builder) combo_row = GTK_WIDGET ( gtk_builder_get_object (builder, icon_captions_components[i])); - create_icon_caption_combo_row_items (HDY_COMBO_ROW (combo_row), columns); + create_icon_caption_combo_row_items (ADW_COMBO_ROW (combo_row), columns); gtk_widget_set_sensitive (combo_row, writable); g_signal_connect_data ( - combo_row, "notify::selected-index", G_CALLBACK (icon_captions_changed_callback), + combo_row, "notify::selected", G_CALLBACK (icon_captions_changed_callback), g_object_ref (builder), (GClosureNotify) g_object_unref, 0); } @@ -302,7 +300,7 @@ static void bind_builder_combo_row(GtkBuilder *builder, const char **values) { g_settings_bind_with_mapping (settings, prefs, gtk_builder_get_object (builder, widget_name), - "selected-index", G_SETTINGS_BIND_DEFAULT, + "selected", G_SETTINGS_BIND_DEFAULT, combo_row_mapping_get, combo_row_mapping_set, (gpointer) values, NULL); } @@ -311,20 +309,20 @@ static void setup_combo (GtkBuilder *builder, const char *widget_name, const char **strings) { - HdyComboRow *combo_row; + AdwComboRow *combo_row; GListStore *list_store; - combo_row = (HdyComboRow *) gtk_builder_get_object (builder, widget_name); - g_assert (HDY_IS_COMBO_ROW (combo_row)); + combo_row = (AdwComboRow *) gtk_builder_get_object (builder, widget_name); + g_assert (ADW_IS_COMBO_ROW (combo_row)); - list_store = g_list_store_new (HDY_TYPE_VALUE_OBJECT); + list_store = g_list_store_new (GTK_TYPE_STRING_OBJECT); for (gsize i = 0; strings[i]; i++) { list_store_append_string (list_store, strings[i]); } - hdy_combo_row_bind_name_model (combo_row, G_LIST_MODEL (list_store), (HdyComboRowGetNameFunc) hdy_value_object_dup_string, NULL, NULL); + adw_combo_row_set_model (combo_row, G_LIST_MODEL (list_store)); } static void nautilus_preferences_window_setup(GtkBuilder *builder, diff --git a/src/nautilus-progress-info-widget.c b/src/nautilus-progress-info-widget.c index fd70d9781..d2b4a3ff4 100644 --- a/src/nautilus-progress-info-widget.c +++ b/src/nautilus-progress-info-widget.c @@ -49,9 +49,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (NautilusProgressInfoWidget, nautilus_progress_info_w static void info_finished (NautilusProgressInfoWidget *self) { - gtk_image_set_from_icon_name (GTK_IMAGE (self->priv->image), - "object-select-symbolic", - GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name (GTK_IMAGE (self->priv->image), "object-select-symbolic"); gtk_widget_set_sensitive (self->priv->button, FALSE); } @@ -127,9 +125,7 @@ nautilus_progress_info_widget_constructed (GObject *obj) if (nautilus_progress_info_get_is_finished (self->priv->info)) { - gtk_image_set_from_icon_name (GTK_IMAGE (self->priv->image), - "object-select-symbolic", - GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name (GTK_IMAGE (self->priv->image), "object-select-symbolic"); } gtk_widget_set_sensitive (self->priv->button, diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c index c01c471ce..a359a2101 100644 --- a/src/nautilus-properties-window.c +++ b/src/nautilus-properties-window.c @@ -47,7 +47,6 @@ #include "nautilus-signaller.h" #include "nautilus-ui-utilities.h" #include "nautilus-signaller.h" -#include "nautilus-gtk4-helpers.h" static GHashTable *windows; static GHashTable *pending_lists; @@ -72,7 +71,7 @@ typedef struct struct _NautilusPropertiesWindow { - HdyWindow parent_instance; + AdwWindow parent_instance; GList *original_files; GList *target_files; @@ -288,7 +287,7 @@ static void schedule_directory_contents_update (NautilusPropertiesWindow *self); static void directory_contents_value_field_update (NautilusPropertiesWindow *self); static void file_changed_callback (NautilusFile *file, gpointer user_data); -static void permission_button_update (GtkToggleButton *button, +static void permission_button_update (GtkCheckButton *button, NautilusPropertiesWindow *self); static void permission_combo_update (GtkComboBox *combo, NautilusPropertiesWindow *self); @@ -316,7 +315,7 @@ static void name_field_activate (GtkWidget *name_field, gpointer user_data); static void setup_pie_widget (NautilusPropertiesWindow *self); -G_DEFINE_TYPE (NautilusPropertiesWindow, nautilus_properties_window, HDY_TYPE_WINDOW); +G_DEFINE_TYPE (NautilusPropertiesWindow, nautilus_properties_window, ADW_TYPE_WINDOW); static gboolean is_multi_file_window (NautilusPropertiesWindow *self) @@ -396,7 +395,7 @@ get_target_file (NautilusPropertiesWindow *self) static void get_image_for_properties_window (NautilusPropertiesWindow *self, char **icon_name, - GdkPixbuf **icon_pixbuf) + GdkPaintable **icon_paintable) { g_autoptr (NautilusIconInfo) icon = NULL; GList *l; @@ -445,9 +444,9 @@ get_image_for_properties_window (NautilusPropertiesWindow *self, *icon_name = g_strdup (nautilus_icon_info_get_used_name (icon)); } - if (icon_pixbuf != NULL) + if (icon_paintable != NULL) { - *icon_pixbuf = nautilus_icon_info_get_pixbuf_at_size (icon, NAUTILUS_GRID_ICON_SIZE_STANDARD); + *icon_paintable = nautilus_icon_info_get_paintable (icon); } } @@ -455,18 +454,18 @@ get_image_for_properties_window (NautilusPropertiesWindow *self, static void update_properties_window_icon (NautilusPropertiesWindow *self) { - g_autoptr (GdkPixbuf) pixbuf = NULL; + g_autoptr (GdkPaintable) paintable = NULL; g_autofree char *name = NULL; - get_image_for_properties_window (self, &name, &pixbuf); + get_image_for_properties_window (self, &name, &paintable); if (name != NULL) { gtk_window_set_icon_name (GTK_WINDOW (self), name); } - gtk_image_set_from_pixbuf (GTK_IMAGE (self->icon_image), pixbuf); - gtk_image_set_from_pixbuf (GTK_IMAGE (self->icon_button_image), pixbuf); + gtk_image_set_from_paintable (GTK_IMAGE (self->icon_image), paintable); + gtk_image_set_from_paintable (GTK_IMAGE (self->icon_button_image), paintable); } #if 0 && NAUTILUS_DND_NEEDS_GTK4_REIMPLEMENTATION @@ -527,7 +526,7 @@ nautilus_properties_window_drag_data_received (GtkWidget *widget, GtkWindow *window; image = GTK_IMAGE (widget); - window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (image))); + window = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (image))); uris = g_strsplit ((const gchar *) gtk_selection_data_get_data (selection_data), "\r\n", 0); exactly_one = uris[0] != NULL && (uris[1] == NULL || uris[1][0] == '\0'); @@ -634,7 +633,7 @@ set_name_field (NautilusPropertiesWindow *self, g_autofree gchar *displayed_name = gtk_editable_get_chars (GTK_EDITABLE (self->name_field), 0, -1); if (strcmp (displayed_name, name) != 0) { - gtk_entry_set_text (GTK_ENTRY (self->name_field), name); + gtk_editable_set_text (GTK_EDITABLE (self->name_field), name); } } } @@ -743,7 +742,7 @@ name_field_restore_original_name (GtkWidget *name_field) if (strcmp (original_name, displayed_name) != 0) { - gtk_entry_set_text (GTK_ENTRY (name_field), original_name); + gtk_editable_set_text (GTK_EDITABLE (name_field), original_name); } gtk_editable_select_region (GTK_EDITABLE (name_field), 0, -1); } @@ -1186,7 +1185,7 @@ update_files_callback (gpointer data) if (self->original_files == NULL) { /* Close the window if no files are left */ - gtk_widget_destroy (GTK_WIDGET (self)); + gtk_window_destroy (GTK_WINDOW (self)); } else { @@ -2401,10 +2400,13 @@ should_show_volume_usage (NautilusPropertiesWindow *self) } static void -paint_legend (GtkWidget *widget, - cairo_t *cr, - gpointer data) +paint_legend (GtkDrawingArea *drawing_area, + cairo_t *cr, + int width, + int height, + gpointer data) { + GtkWidget *widget = GTK_WIDGET (drawing_area); GtkStyleContext *context; GtkAllocation allocation; @@ -2428,7 +2430,6 @@ paint_slice (GtkWidget *widget, double offset = G_PI / 2.0; GdkRGBA fill; GdkRGBA stroke; - GtkStateFlags state; GtkBorder border; GtkStyleContext *context; double x, y, radius; @@ -2440,14 +2441,13 @@ paint_slice (GtkWidget *widget, } context = gtk_widget_get_style_context (widget); - state = gtk_style_context_get_state (context); - gtk_style_context_get_border (context, state, &border); + gtk_style_context_get_border (context, &border); gtk_style_context_save (context); gtk_style_context_add_class (context, style_class); - gtk_style_context_get_color (context, state, &fill); + gtk_style_context_get_color (context, &fill); gtk_style_context_add_class (context, "border"); - gtk_style_context_get_color (context, state, &stroke); + gtk_style_context_get_color (context, &stroke); gtk_style_context_restore (context); width = gtk_widget_get_allocated_width (widget); @@ -2489,11 +2489,14 @@ paint_slice (GtkWidget *widget, } static void -paint_pie_chart (GtkWidget *widget, - cairo_t *cr, - gpointer data) +paint_pie_chart (GtkDrawingArea *drawing_area, + cairo_t *cr, + int width, + int height, + gpointer data) { NautilusPropertiesWindow *self; + GtkWidget *widget = GTK_WIDGET (drawing_area); double free, used, reserved; self = NAUTILUS_PROPERTIES_WINDOW (data); @@ -2553,12 +2556,12 @@ setup_pie_widget (NautilusPropertiesWindow *self) } } - g_signal_connect (self->pie_chart, "draw", - G_CALLBACK (paint_pie_chart), self); - g_signal_connect (self->used_color, "draw", - G_CALLBACK (paint_legend), self); - g_signal_connect (self->free_color, "draw", - G_CALLBACK (paint_legend), self); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->pie_chart), + paint_pie_chart, self, NULL); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->used_color), + paint_legend, self, NULL); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->free_color), + paint_legend, self, NULL); } static void @@ -2872,12 +2875,7 @@ start_long_operation (NautilusPropertiesWindow *self) if (self->long_operation_underway == 0) { /* start long operation */ - GdkDisplay *display; - g_autoptr (GdkCursor) cursor = NULL; - - display = gtk_widget_get_display (GTK_WIDGET (self)); - cursor = gdk_cursor_new_from_name (display, "wait"); - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self)), cursor); + gtk_widget_set_cursor_from_name (GTK_WIDGET (self), "wait"); } self->long_operation_underway++; } @@ -2885,11 +2883,11 @@ start_long_operation (NautilusPropertiesWindow *self) static void end_long_operation (NautilusPropertiesWindow *self) { - if (gtk_widget_get_window (GTK_WIDGET (self)) != NULL && + if (gtk_native_get_surface (GTK_NATIVE (self)) != NULL && self->long_operation_underway == 1) { /* finished !! */ - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self)), NULL); + gtk_widget_set_cursor (GTK_WIDGET (self), NULL); } self->long_operation_underway--; } @@ -3013,7 +3011,7 @@ initial_permission_state_consistent (NautilusPropertiesWindow *self, } static void -permission_button_toggled (GtkToggleButton *button, +permission_button_toggled (GtkCheckButton *button, NautilusPropertiesWindow *self) { gboolean is_folder, is_special; @@ -3028,8 +3026,8 @@ permission_button_toggled (GtkToggleButton *button, is_special = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "is-special")); - if (gtk_toggle_button_get_active (button) - && !gtk_toggle_button_get_inconsistent (button)) + if (gtk_check_button_get_active (button) + && !gtk_check_button_get_inconsistent (button)) { /* Go to the initial state unless the initial state was * consistent, or we support recursive apply */ @@ -3042,8 +3040,8 @@ permission_button_toggled (GtkToggleButton *button, on = TRUE; } } - else if (gtk_toggle_button_get_inconsistent (button) - && !gtk_toggle_button_get_active (button)) + else if (gtk_check_button_get_inconsistent (button) + && !gtk_check_button_get_active (button)) { inconsistent = FALSE; on = TRUE; @@ -3058,8 +3056,8 @@ permission_button_toggled (GtkToggleButton *button, G_CALLBACK (permission_button_toggled), self); - gtk_toggle_button_set_active (button, on); - gtk_toggle_button_set_inconsistent (button, inconsistent); + gtk_check_button_set_active (button, on); + gtk_check_button_set_inconsistent (button, inconsistent); g_signal_handlers_unblock_by_func (G_OBJECT (button), G_CALLBACK (permission_button_toggled), @@ -3074,7 +3072,7 @@ permission_button_toggled (GtkToggleButton *button, } static void -permission_button_update (GtkToggleButton *button, +permission_button_update (GtkCheckButton *button, NautilusPropertiesWindow *self) { GList *l; @@ -3146,12 +3144,12 @@ permission_button_update (GtkToggleButton *button, G_CALLBACK (permission_button_toggled), self); - gtk_toggle_button_set_active (button, !all_unset); + gtk_check_button_set_active (button, !all_unset); /* if actually inconsistent, or default value for file buttons * if no files are selected. (useful for recursive apply) */ - gtk_toggle_button_set_inconsistent (button, - (!all_unset && !all_set) || - (!is_folder && no_match)); + gtk_check_button_set_inconsistent (button, + (!all_unset && !all_set) || + (!is_folder && no_match)); gtk_widget_set_sensitive (GTK_WIDGET (button), sensitive); g_signal_handlers_unblock_by_func (G_OBJECT (button), @@ -3900,7 +3898,7 @@ on_change_permissions_response (GtkDialog *dialog, if (response != GTK_RESPONSE_OK) { g_clear_pointer (&self->change_permission_combos, g_list_free); - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); return; } @@ -3978,7 +3976,7 @@ on_change_permissions_response (GtkDialog *dialog, } } g_clear_pointer (&self->change_permission_combos, g_list_free); - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); } static void @@ -4133,7 +4131,7 @@ on_change_permissions_clicked (GtkWidget *button, set_active_from_umask (combo, PERMISSION_OTHER, TRUE); g_signal_connect (dialog, "response", G_CALLBACK (on_change_permissions_response), self); - gtk_widget_show_all (dialog); + gtk_widget_show (dialog); } static void @@ -4173,7 +4171,7 @@ setup_permissions_page (NautilusPropertiesWindow *self) if (self->has_recursive_apply) { - gtk_widget_show_all (self->change_permissions_button_box); + gtk_widget_show (self->change_permissions_button_box); g_signal_connect (self->change_permissions_button, "clicked", G_CALLBACK (on_change_permissions_clicked), self); @@ -4234,10 +4232,10 @@ append_extension_pages (NautilusPropertiesWindow *self) gtk_notebook_append_page (self->notebook, page_widget, label); - gtk_container_child_set (GTK_CONTAINER (self->notebook), - page_widget, - "tab-expand", TRUE, - NULL); + g_object_set (gtk_notebook_get_page (GTK_NOTEBOOK (self->notebook), + GTK_WIDGET (page_widget)), + "tab-expand", TRUE, + NULL); g_object_set_data (G_OBJECT (page_widget), "is-extension-page", @@ -4441,7 +4439,7 @@ add_clicked_cb (GtkButton *button, g_app_info_get_display_name (info), error->message); show_dialog (_("Could not add application"), message, - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))), + GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))), GTK_MESSAGE_ERROR); } else @@ -4469,7 +4467,7 @@ forget_clicked_cb (GtkButton *button, { show_dialog (_("Could not forget association"), error->message, - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))), + GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))), GTK_MESSAGE_ERROR); } @@ -4514,7 +4512,7 @@ set_as_default_clicked_cb (GtkButton *button, g_app_info_get_display_name (info), error->message); show_dialog (_("Could not set as default"), message, - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))), + GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))), GTK_MESSAGE_ERROR); } @@ -4702,8 +4700,8 @@ create_properties_window (StartupData *startup_data) if (startup_data->parent_widget) { - gtk_window_set_screen (GTK_WINDOW (window), - gtk_widget_get_screen (startup_data->parent_widget)); + gtk_window_set_display (GTK_WINDOW (window), + gtk_widget_get_display (startup_data->parent_widget)); } if (startup_data->parent_window) @@ -4997,8 +4995,8 @@ nautilus_properties_window_present (GList *original_f { if (parent_widget) { - gtk_window_set_screen (GTK_WINDOW (existing_window), - gtk_widget_get_screen (parent_widget)); + gtk_window_set_display (GTK_WINDOW (existing_window), + gtk_widget_get_display (parent_widget)); } else if (startup_id) { @@ -5238,14 +5236,16 @@ select_image_button_callback (GtkWidget *widget, if (dialog == NULL) { + g_autoptr (GFile) pictures_location = NULL; dialog = gtk_file_chooser_dialog_new (_("Select Custom Icon"), GTK_WINDOW (self), GTK_FILE_CHOOSER_ACTION_OPEN, _("_Revert"), GTK_RESPONSE_NO, _("_Cancel"), GTK_RESPONSE_CANCEL, _("_Open"), GTK_RESPONSE_OK, NULL); + pictures_location = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES)); gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), - g_get_user_special_dir (G_USER_DIRECTORY_PICTURES), + pictures_location, NULL); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); @@ -5273,9 +5273,9 @@ select_image_button_callback (GtkWidget *widget, if (image_location != NULL) { - gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), - image_location, - NULL); + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), + image_location, + NULL); } } } @@ -5304,7 +5304,6 @@ select_image_button_callback (GtkWidget *widget, static void nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass) { - GtkBindingSet *binding_set; GtkWidgetClass *widget_class; GObjectClass *oclass; @@ -5313,15 +5312,9 @@ nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass) oclass->dispose = real_dispose; oclass->finalize = real_finalize; - binding_set = gtk_binding_set_by_class (klass); - g_signal_new ("close", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, - "close", 0); + gtk_widget_class_add_binding (widget_class, + GDK_KEY_Escape, 0, + (GtkShortcutFunc) gtk_window_close, NULL); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/nautilus/ui/nautilus-properties-window.ui"); @@ -5414,5 +5407,4 @@ static void nautilus_properties_window_init (NautilusPropertiesWindow *self) { gtk_widget_init_template (GTK_WIDGET (self)); - g_signal_connect (self, "close", G_CALLBACK (gtk_window_close), NULL); } diff --git a/src/nautilus-properties-window.h b/src/nautilus-properties-window.h index 84f8166a9..4b769bd1a 100644 --- a/src/nautilus-properties-window.h +++ b/src/nautilus-properties-window.h @@ -24,13 +24,13 @@ #pragma once #include <gtk/gtk.h> -#include <libhandy-1/handy.h> +#include <libadwaita-1/adwaita.h> #define NAUTILUS_TYPE_PROPERTIES_WINDOW (nautilus_properties_window_get_type ()) G_DECLARE_FINAL_TYPE (NautilusPropertiesWindow, nautilus_properties_window, NAUTILUS, PROPERTIES_WINDOW, - HdyWindow) + AdwWindow) typedef void (* NautilusPropertiesWindowCallback) (gpointer callback_data); diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c index c88010920..15bcd1f57 100644 --- a/src/nautilus-query-editor.c +++ b/src/nautilus-query-editor.c @@ -35,7 +35,6 @@ #include "nautilus-search-popover.h" #include "nautilus-mime-actions.h" #include "nautilus-ui-utilities.h" -#include "nautilus-gtk4-helpers.h" struct _NautilusQueryEditor { @@ -146,7 +145,7 @@ nautilus_query_editor_dispose (GObject *object) G_OBJECT_CLASS (nautilus_query_editor_parent_class)->dispose (object); } -static void +static gboolean nautilus_query_editor_grab_focus (GtkWidget *widget) { NautilusQueryEditor *editor; @@ -156,9 +155,10 @@ nautilus_query_editor_grab_focus (GtkWidget *widget) if (gtk_widget_get_visible (widget) && !gtk_widget_is_focus (editor->entry)) { /* avoid selecting the entry text */ - gtk_widget_grab_focus (editor->entry); - gtk_editable_set_position (GTK_EDITABLE (editor->entry), -1); + return gtk_entry_grab_focus_without_selecting (GTK_ENTRY (editor->entry)); } + + return FALSE; } static void @@ -243,6 +243,7 @@ nautilus_query_editor_class_init (NautilusQueryEditorClass *class) { GObjectClass *gobject_class; GtkWidgetClass *widget_class; + g_autoptr (GtkShortcut) shortcut = NULL; gobject_class = G_OBJECT_CLASS (class); gobject_class->finalize = nautilus_query_editor_finalize; @@ -289,11 +290,9 @@ nautilus_query_editor_class_init (NautilusQueryEditorClass *class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - gtk_binding_entry_add_signal (gtk_binding_set_by_class (class), - GDK_KEY_Down, - 0, - "focus-view", - 0); + shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_Down, 0), + gtk_signal_action_new ("focus-view")); + gtk_widget_class_add_shortcut (widget_class, shortcut); /** * NautilusQueryEditor::location: @@ -352,7 +351,7 @@ create_query (NautilusQueryEditor *editor) nautilus_query_set_search_content (query, fts_enabled); - nautilus_query_set_text (query, gtk_entry_get_text (GTK_ENTRY (editor->entry))); + nautilus_query_set_text (query, gtk_editable_get_text (GTK_EDITABLE (editor->entry))); nautilus_query_set_location (query, editor->location); /* We only set the query using the global setting for recursivity here, @@ -387,7 +386,7 @@ entry_changed_cb (GtkWidget *entry, { g_autofree gchar *text = NULL; - text = g_strdup (gtk_entry_get_text (GTK_ENTRY (editor->entry))); + text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (editor->entry))); text = g_strstrip (text); nautilus_query_set_text (editor->query, text); @@ -637,7 +636,7 @@ setup_widgets (NautilusQueryEditor *editor) G_CALLBACK (search_popover_fts_changed_cb), editor); /* show everything */ - gtk_widget_show_all (vbox); + gtk_widget_show (vbox); } static void @@ -740,11 +739,11 @@ nautilus_query_editor_set_query (NautilusQueryEditor *self, self->change_frozen = TRUE; - current_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->entry))); + current_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (self->entry))); current_text = g_strstrip (current_text); if (!g_str_equal (current_text, text)) { - gtk_entry_set_text (GTK_ENTRY (self->entry), text); + gtk_editable_set_text (GTK_EDITABLE (self->entry), text); } if (g_set_object (&self->query, query)) @@ -763,7 +762,7 @@ nautilus_query_editor_set_text (NautilusQueryEditor *self, g_return_if_fail (text != NULL); /* The handler of the entry will take care of everything */ - gtk_entry_set_text (GTK_ENTRY (self->entry), text); + gtk_editable_set_text (GTK_EDITABLE (self->entry), text); } static gboolean @@ -779,7 +778,7 @@ nautilus_gtk_search_entry_is_keynav_event (guint keyval, keyval == GDK_KEY_End || keyval == GDK_KEY_KP_End || keyval == GDK_KEY_Page_Up || keyval == GDK_KEY_KP_Page_Up || keyval == GDK_KEY_Page_Down || keyval == GDK_KEY_KP_Page_Down || - ((state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) != 0)) + ((state & (GDK_CONTROL_MASK | GDK_ALT_MASK)) != 0)) { return TRUE; } diff --git a/src/nautilus-rename-file-popover-controller.c b/src/nautilus-rename-file-popover-controller.c index b2491404b..b5fdbc48c 100644 --- a/src/nautilus-rename-file-popover-controller.c +++ b/src/nautilus-rename-file-popover-controller.c @@ -44,8 +44,6 @@ struct _NautilusRenameFilePopoverController gulong closed_handler_id; gulong file_changed_handler_id; gulong key_press_event_handler_id; - - GtkEventController *key_controller; }; G_DEFINE_TYPE (NautilusRenameFilePopoverController, nautilus_rename_file_popover_controller, NAUTILUS_TYPE_FILE_NAME_WIDGET_CONTROLLER) @@ -208,7 +206,7 @@ name_entry_on_f2_pressed (GtkWidget *widget, gint end_offset; /* Select the name part without the file extension */ - eel_filename_get_rename_region (gtk_entry_get_text (GTK_ENTRY (widget)), + eel_filename_get_rename_region (gtk_editable_get_text (GTK_EDITABLE (widget)), &start_offset, &end_offset); gtk_editable_select_region (GTK_EDITABLE (widget), start_offset, end_offset); @@ -225,7 +223,7 @@ name_entry_on_undo (GtkWidget *widget, edit_name = nautilus_file_get_edit_name (self->target_file); - gtk_entry_set_text (GTK_ENTRY (widget), edit_name); + gtk_editable_set_text (GTK_EDITABLE (widget), edit_name); gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1); @@ -324,6 +322,7 @@ nautilus_rename_file_popover_controller_show_for_file (NautilusRenameFilePopov GtkWidget *relative_to) { g_autoptr (NautilusDirectory) containing_directory = NULL; + GtkEventController *controller; g_autofree gchar *edit_name = NULL; gint n_chars; @@ -361,11 +360,10 @@ nautilus_rename_file_popover_controller_show_for_file (NautilusRenameFilePopov G_CALLBACK (target_file_on_changed), self); - self->key_controller = gtk_event_controller_key_new (self->name_entry); - g_signal_connect (self->key_controller, - "key-pressed", - G_CALLBACK (on_event_controller_key_key_pressed), - self); + controller = gtk_event_controller_key_new (); + gtk_widget_add_controller (self->name_entry, controller); + g_signal_connect (controller, "key-pressed", + G_CALLBACK (on_event_controller_key_key_pressed), self); gtk_label_set_text (GTK_LABEL (self->title_label), self->target_is_folder ? _("Rename Folder") : @@ -373,10 +371,10 @@ nautilus_rename_file_popover_controller_show_for_file (NautilusRenameFilePopov edit_name = nautilus_file_get_edit_name (self->target_file); - gtk_entry_set_text (GTK_ENTRY (self->name_entry), edit_name); + gtk_editable_set_text (GTK_EDITABLE (self->name_entry), edit_name); gtk_popover_set_pointing_to (GTK_POPOVER (self->rename_file_popover), pointing_to); - gtk_popover_set_relative_to (GTK_POPOVER (self->rename_file_popover), relative_to); + gtk_widget_set_parent (self->rename_file_popover, relative_to); gtk_popover_popup (GTK_POPOVER (self->rename_file_popover)); @@ -393,9 +391,9 @@ nautilus_rename_file_popover_controller_show_for_file (NautilusRenameFilePopov } n_chars = g_utf8_strlen (edit_name, -1); - gtk_entry_set_width_chars (GTK_ENTRY (self->name_entry), - MIN (MAX (n_chars, RENAME_ENTRY_MIN_CHARS), - RENAME_ENTRY_MAX_CHARS)); + gtk_editable_set_width_chars (GTK_EDITABLE (self->name_entry), + MIN (MAX (n_chars, RENAME_ENTRY_MIN_CHARS), + RENAME_ENTRY_MAX_CHARS)); } static void @@ -423,10 +421,7 @@ nautilus_rename_file_popover_controller_finalize (GObject *object) reset_state (self); - gtk_widget_destroy (self->rename_file_popover); - g_clear_object (&self->rename_file_popover); - - g_clear_object (&self->key_controller); + g_clear_pointer (&self->rename_file_popover, gtk_widget_unparent); G_OBJECT_CLASS (nautilus_rename_file_popover_controller_parent_class)->finalize (object); } diff --git a/src/nautilus-search-engine-recent.c b/src/nautilus-search-engine-recent.c index 6082e4a1a..d2204d163 100644 --- a/src/nautilus-search-engine-recent.c +++ b/src/nautilus-search-engine-recent.c @@ -232,9 +232,8 @@ recent_thread_func (gpointer user_data) if (rank > 0) { NautilusSearchHit *hit; - time_t modified, visited; - g_autoptr (GDateTime) gmodified = NULL; - g_autoptr (GDateTime) gvisited = NULL; + GDateTime *modified; + GDateTime *visited; if (gtk_recent_info_is_local (info)) { @@ -281,9 +280,6 @@ recent_thread_func (gpointer user_data) modified = gtk_recent_info_get_modified (info); visited = gtk_recent_info_get_visited (info); - gmodified = g_date_time_new_from_unix_local (modified); - gvisited = g_date_time_new_from_unix_local (visited); - if (date_range != NULL) { NautilusQuerySearchType type; @@ -297,11 +293,11 @@ recent_thread_func (gpointer user_data) if (type == NAUTILUS_QUERY_SEARCH_TYPE_LAST_ACCESS) { - target_time = visited; + target_time = g_date_time_to_unix (visited); } else if (type == NAUTILUS_QUERY_SEARCH_TYPE_LAST_MODIFIED) { - target_time = modified; + target_time = g_date_time_to_unix (modified); } if (!nautilus_file_date_in_between (target_time, @@ -313,8 +309,8 @@ recent_thread_func (gpointer user_data) hit = nautilus_search_hit_new (uri); nautilus_search_hit_set_fts_rank (hit, rank); - nautilus_search_hit_set_modification_time (hit, gmodified); - nautilus_search_hit_set_access_time (hit, gvisited); + nautilus_search_hit_set_modification_time (hit, modified); + nautilus_search_hit_set_access_time (hit, visited); hits = g_list_prepend (hits, hit); } diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c index 20fde2753..20559fa9e 100644 --- a/src/nautilus-search-popover.c +++ b/src/nautilus-search-popover.c @@ -24,7 +24,6 @@ #include "nautilus-file.h" #include "nautilus-ui-utilities.h" #include "nautilus-global-preferences.h" -#include "nautilus-gtk4-helpers.h" #define SEARCH_FILTER_MAX_YEARS 5 @@ -92,12 +91,9 @@ calendar_day_selected (GtkCalendar *calendar, NautilusSearchPopover *popover) { GDateTime *date; - guint year, month, day; GPtrArray *date_range; - gtk_calendar_get_date (calendar, &year, &month, &day); - - date = g_date_time_new_local (year, month + 1, day, 0, 0, 0); + date = gtk_calendar_get_date (calendar); date_range = g_ptr_array_new_full (2, (GDestroyNotify) g_date_time_unref); g_ptr_array_add (date_range, g_date_time_ref (date)); @@ -127,12 +123,7 @@ setup_date (NautilusSearchPopover *popover, g_signal_handlers_block_by_func (popover->calendar, calendar_day_selected, popover); - gtk_calendar_select_month (GTK_CALENDAR (popover->calendar), - g_date_time_get_month (date_initial) - 1, - g_date_time_get_year (date_initial)); - - gtk_calendar_select_day (GTK_CALENDAR (popover->calendar), - g_date_time_get_day_of_month (date_initial)); + gtk_calendar_select_day (GTK_CALENDAR (popover->calendar), date_initial); update_date_label (popover, date_range); @@ -166,7 +157,7 @@ date_entry_activate (GtkEntry *entry, GDate *date; date = g_date_new (); - g_date_set_parse (date, gtk_entry_get_text (entry)); + g_date_set_parse (date, gtk_editable_get_text (GTK_EDITABLE (entry))); /* Invalid date silently does nothing */ if (!g_date_valid (date)) @@ -343,16 +334,16 @@ types_listbox_row_activated (GtkListBox *listbox, } static void -search_time_type_changed (GtkToggleButton *button, +search_time_type_changed (GtkCheckButton *button, NautilusSearchPopover *popover) { NautilusQuerySearchType type = -1; - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (popover->last_modified_button))) + if (gtk_check_button_get_active (GTK_CHECK_BUTTON (popover->last_modified_button))) { type = NAUTILUS_QUERY_SEARCH_TYPE_LAST_MODIFIED; } - else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (popover->last_used_button))) + else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (popover->last_used_button))) { type = NAUTILUS_QUERY_SEARCH_TYPE_LAST_ACCESS; } @@ -407,7 +398,7 @@ create_row_for_label (const gchar *text, NULL); gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), label); - gtk_widget_show_all (row); + gtk_widget_show (row); return row; } @@ -575,7 +566,7 @@ on_other_types_dialog_response (GtkDialog *dialog, } g_clear_object (&popover->treeview); - gtk_widget_destroy (GTK_WIDGET (dialog)); + gtk_window_destroy (GTK_WINDOW (dialog)); } static void @@ -587,7 +578,7 @@ show_other_types_dialog (NautilusSearchPopover *popover) GtkListStore *store; GtkTreeViewColumn *column; GtkCellRenderer *renderer; - GtkWidget *toplevel; + GtkRoot *toplevel; GtkTreeSelection *selection; mime_infos = g_content_types_get_registered (); @@ -616,7 +607,7 @@ show_other_types_dialog (NautilusSearchPopover *popover) } g_list_free (mime_infos); - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (popover)); + toplevel = gtk_widget_get_root (GTK_WIDGET (popover)); dialog = gtk_dialog_new_with_buttons (_("Select type"), GTK_WINDOW (toplevel), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR, @@ -625,7 +616,7 @@ show_other_types_dialog (NautilusSearchPopover *popover) NULL); gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 600); - scrolled = gtk_scrolled_window_new (NULL, NULL); + scrolled = gtk_scrolled_window_new (); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); @@ -655,7 +646,7 @@ show_other_types_dialog (NautilusSearchPopover *popover) popover->treeview = GTK_TREE_VIEW (g_object_ref (treeview)); g_signal_connect (dialog, "response", G_CALLBACK (on_other_types_dialog_response), popover); - gtk_widget_show_all (dialog); + gtk_widget_show (dialog); } static void @@ -677,7 +668,7 @@ update_date_label (NautilusSearchPopover *popover, label = get_text_for_date_range (date_range, TRUE); - gtk_entry_set_text (GTK_ENTRY (popover->date_entry), days < 1 ? label : ""); + gtk_editable_set_text (GTK_EDITABLE (popover->date_entry), days < 1 ? label : ""); gtk_widget_show (popover->clear_date_button); gtk_label_set_label (GTK_LABEL (popover->select_date_button_label), label); @@ -689,7 +680,7 @@ update_date_label (NautilusSearchPopover *popover, { gtk_label_set_label (GTK_LABEL (popover->select_date_button_label), _("Select Dates…")); - gtk_entry_set_text (GTK_ENTRY (popover->date_entry), ""); + gtk_editable_set_text (GTK_EDITABLE (popover->date_entry), ""); gtk_widget_hide (popover->clear_date_button); } } @@ -725,12 +716,7 @@ nautilus_search_popover_closed (GtkPopover *popover) /* Reselect today at the calendar */ g_signal_handlers_block_by_func (self->calendar, calendar_day_selected, self); - gtk_calendar_select_month (GTK_CALENDAR (self->calendar), - g_date_time_get_month (now) - 1, - g_date_time_get_year (now)); - - gtk_calendar_select_day (GTK_CALENDAR (self->calendar), - g_date_time_get_day_of_month (now)); + gtk_calendar_select_day (GTK_CALENDAR (self->calendar), now); g_signal_handlers_unblock_by_func (self->calendar, calendar_day_selected, self); } @@ -926,21 +912,21 @@ nautilus_search_popover_init (NautilusSearchPopover *self) filter_time_type = g_settings_get_enum (nautilus_preferences, "search-filter-time-type"); if (filter_time_type == NAUTILUS_QUERY_SEARCH_TYPE_LAST_MODIFIED) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_modified_button), TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_used_button), FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->created_button), FALSE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->last_modified_button), TRUE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->last_used_button), FALSE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->created_button), FALSE); } else if (filter_time_type == NAUTILUS_QUERY_SEARCH_TYPE_LAST_ACCESS) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_modified_button), FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_used_button), TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->created_button), FALSE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->last_modified_button), FALSE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->last_used_button), TRUE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->created_button), FALSE); } else { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_modified_button), FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_used_button), FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->created_button), TRUE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->last_modified_button), FALSE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->last_used_button), FALSE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->created_button), TRUE); } self->fts_enabled = g_settings_get_boolean (nautilus_preferences, diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c index 82850dafc..55e9e1aff 100644 --- a/src/nautilus-shell-search-provider.c +++ b/src/nautilus-shell-search-provider.c @@ -619,7 +619,7 @@ result_list_attributes_ready_cb (GList *file_list, GVariant *meta_variant; gint icon_scale; - icon_scale = gdk_monitor_get_scale_factor (gdk_display_get_monitor (gdk_display_get_default (), 0)); + icon_scale = gdk_monitor_get_scale_factor (g_list_model_get_item (gdk_display_get_monitors (gdk_display_get_default ()), 0)); for (l = file_list; l != NULL; l = l->next) { @@ -658,9 +658,9 @@ result_list_attributes_ready_cb (GList *file_list, if (gicon == NULL) { - gicon = G_ICON (nautilus_file_get_icon_pixbuf (file, 128, - icon_scale, - NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS)); + gicon = G_ICON (nautilus_file_get_icon_texture (file, 128, + icon_scale, + NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS)); } g_variant_builder_add (&meta, "{sv}", @@ -739,12 +739,13 @@ typedef struct } ShowURIData; static void -show_uri_callback (gboolean res, - gpointer user_data) +show_uri_callback (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { ShowURIData *data = user_data; - if (!res) + if (!gtk_show_uri_full_finish (NULL, result, NULL)) { g_application_open (g_application_get_default (), &data->file, 1, ""); } @@ -764,16 +765,13 @@ handle_activate_result (NautilusShellSearchProvider2 *skeleton, gpointer user_data) { ShowURIData *data; - gboolean res; data = g_new (ShowURIData, 1); data->file = g_file_new_for_uri (result); data->skeleton = skeleton; data->invocation = invocation; - res = gtk_show_uri_on_window (NULL, result, timestamp, NULL); - - show_uri_callback (res, data); + gtk_show_uri_full (NULL, result, timestamp, NULL, show_uri_callback, data); return TRUE; } diff --git a/src/nautilus-special-location-bar.c b/src/nautilus-special-location-bar.c index d2a559726..4e81ff3b5 100644 --- a/src/nautilus-special-location-bar.c +++ b/src/nautilus-special-location-bar.c @@ -24,11 +24,10 @@ #include "nautilus-special-location-bar.h" #include "nautilus-enum-types.h" -#include "nautilus-gtk4-helpers.h" struct _NautilusSpecialLocationBar { - GtkBin parent_instance; + AdwBin parent_instance; GtkWidget *label; GtkWidget *learn_more_label; @@ -41,7 +40,7 @@ enum PROP_SPECIAL_LOCATION, }; -G_DEFINE_TYPE (NautilusSpecialLocationBar, nautilus_special_location_bar, GTK_TYPE_BIN) +G_DEFINE_TYPE (NautilusSpecialLocationBar, nautilus_special_location_bar, ADW_TYPE_BIN) static void set_special_location (NautilusSpecialLocationBar *bar, diff --git a/src/nautilus-special-location-bar.h b/src/nautilus-special-location-bar.h index 3d07c7171..58928d9f8 100644 --- a/src/nautilus-special-location-bar.h +++ b/src/nautilus-special-location-bar.h @@ -20,11 +20,12 @@ #include <gtk/gtk.h> #include <gio/gio.h> +#include <libadwaita-1/adwaita.h> G_BEGIN_DECLS #define NAUTILUS_TYPE_SPECIAL_LOCATION_BAR (nautilus_special_location_bar_get_type ()) -G_DECLARE_FINAL_TYPE (NautilusSpecialLocationBar, nautilus_special_location_bar, NAUTILUS, SPECIAL_LOCATION_BAR, GtkBin) +G_DECLARE_FINAL_TYPE (NautilusSpecialLocationBar, nautilus_special_location_bar, NAUTILUS, SPECIAL_LOCATION_BAR, AdwBin) typedef enum { NAUTILUS_SPECIAL_LOCATION_TEMPLATES, diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c index c6f03517c..670508933 100644 --- a/src/nautilus-toolbar.c +++ b/src/nautilus-toolbar.c @@ -37,7 +37,6 @@ #include "nautilus-toolbar-menu-sections.h" #include "nautilus-ui-utilities.h" #include "nautilus-window.h" -#include "nautilus-gtk4-helpers.h" #define OPERATION_MINIMUM_TIME 2 /*s */ #define NEEDS_ATTENTION_ANIMATION_TIMEOUT 2000 /*ms */ @@ -54,7 +53,7 @@ typedef enum struct _NautilusToolbar { - GtkBin parent_instance; + AdwBin parent_instance; NautilusWindow *window; @@ -89,13 +88,9 @@ struct _NautilusToolbar GtkWidget *forward_button; GtkWidget *forward_menu; - GtkGesture *forward_button_longpress_gesture; - GtkGesture *forward_button_multi_press_gesture; GtkWidget *back_button; GtkWidget *back_menu; - GtkGesture *back_button_longpress_gesture; - GtkGesture *back_button_multi_press_gesture; GtkWidget *search_button; @@ -121,7 +116,7 @@ enum static GParamSpec *properties[NUM_PROPERTIES] = { NULL, }; -G_DEFINE_TYPE (NautilusToolbar, nautilus_toolbar, GTK_TYPE_BIN); +G_DEFINE_TYPE (NautilusToolbar, nautilus_toolbar, ADW_TYPE_BIN); static void nautilus_toolbar_set_window_slot_real (NautilusToolbar *self, NautilusWindowSlot *slot); @@ -186,7 +181,7 @@ show_menu (NautilusToolbar *self, { g_autoptr (GMenu) menu = NULL; NautilusNavigationDirection direction; - GtkPopover *popover; + GtkPopoverMenu *popover; menu = g_menu_new (); @@ -198,14 +193,14 @@ show_menu (NautilusToolbar *self, case NAUTILUS_NAVIGATION_DIRECTION_FORWARD: { fill_menu (self, menu, FALSE); - popover = GTK_POPOVER (self->forward_menu); + popover = GTK_POPOVER_MENU (self->forward_menu); } break; case NAUTILUS_NAVIGATION_DIRECTION_BACK: { fill_menu (self, menu, TRUE); - popover = GTK_POPOVER (self->back_menu); + popover = GTK_POPOVER_MENU (self->back_menu); } break; @@ -216,16 +211,16 @@ show_menu (NautilusToolbar *self, break; } - gtk_popover_bind_model (popover, G_MENU_MODEL (menu), NULL); - gtk_popover_popup (popover); + gtk_popover_menu_set_menu_model (popover, G_MENU_MODEL (menu)); + gtk_popover_popup (GTK_POPOVER (popover)); } static void -navigation_button_press_cb (GtkGestureMultiPress *gesture, - gint n_press, - gdouble x, - gdouble y, - gpointer user_data) +navigation_button_press_cb (GtkGestureClick *gesture, + gint n_press, + gdouble x, + gdouble y, + gpointer user_data) { NautilusToolbar *self; GtkWidget *widget; @@ -575,25 +570,26 @@ on_new_progress_info (NautilusProgressInfoManager *manager, } static void -on_operations_icon_draw (GtkWidget *widget, +on_operations_icon_draw (GtkDrawingArea *drawing_area, cairo_t *cr, + int width, + int height, NautilusToolbar *self) { + GtkWidget *widget = GTK_WIDGET (drawing_area); gfloat elapsed_progress = 0; gint remaining_progress = 0; gint total_progress; gdouble ratio; GList *progress_infos; GList *l; - guint width; - guint height; gboolean all_cancelled; GdkRGBA background; GdkRGBA foreground; GtkStyleContext *style_context; style_context = gtk_widget_get_style_context (widget); - gtk_style_context_get_color (style_context, gtk_style_context_get_state (style_context), &foreground); + gtk_style_context_get_color (style_context, &foreground); background = foreground; background.alpha *= 0.3; @@ -788,7 +784,7 @@ operations_list_create_widget (GObject *item, GtkWidget *widget; widget = nautilus_progress_info_widget_new (info); - gtk_widget_show_all (widget); + gtk_widget_show (widget); return widget; } @@ -797,6 +793,7 @@ static void nautilus_toolbar_constructed (GObject *object) { NautilusToolbar *self = NAUTILUS_TOOLBAR (object); + GtkEventController *controller; self->path_bar = GTK_WIDGET (g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL)); gtk_box_append (GTK_BOX (self->path_bar_container), @@ -805,8 +802,7 @@ nautilus_toolbar_constructed (GObject *object) self->location_entry = nautilus_location_entry_new (); gtk_box_append (GTK_BOX (self->location_entry_container), self->location_entry); - self->location_entry_close_button = gtk_button_new_from_icon_name ("window-close-symbolic", - GTK_ICON_SIZE_BUTTON); + self->location_entry_close_button = gtk_button_new_from_icon_name ("window-close-symbolic"); gtk_box_append (GTK_BOX (self->location_entry_container), self->location_entry_close_button); g_signal_connect (self->location_entry_close_button, "clicked", @@ -826,12 +822,14 @@ nautilus_toolbar_constructed (GObject *object) NULL); update_operations (self); - self->back_button_longpress_gesture = gtk_gesture_long_press_new (self->back_button); - g_signal_connect (self->back_button_longpress_gesture, "pressed", + controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ()); + gtk_widget_add_controller (self->back_button, controller); + g_signal_connect (controller, "pressed", G_CALLBACK (back_button_longpress_cb), self); - self->forward_button_longpress_gesture = gtk_gesture_long_press_new (self->forward_button); - g_signal_connect (self->forward_button_longpress_gesture, "pressed", + controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ()); + gtk_widget_add_controller (self->forward_button, controller); + g_signal_connect (controller, "pressed", G_CALLBACK (forward_button_longpress_cb), self); g_object_set_data (G_OBJECT (self->back_button), "nav-direction", @@ -839,17 +837,16 @@ nautilus_toolbar_constructed (GObject *object) g_object_set_data (G_OBJECT (self->forward_button), "nav-direction", GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_FORWARD)); - - self->back_button_multi_press_gesture = gtk_gesture_multi_press_new (self->back_button); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->back_button_multi_press_gesture), - GDK_BUTTON_SECONDARY); - g_signal_connect (self->back_button_multi_press_gesture, "pressed", + controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ()); + gtk_widget_add_controller (self->back_button, controller); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), GDK_BUTTON_SECONDARY); + g_signal_connect (controller, "pressed", G_CALLBACK (navigation_button_press_cb), self); - self->forward_button_multi_press_gesture = gtk_gesture_multi_press_new (self->forward_button); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->forward_button_multi_press_gesture), - GDK_BUTTON_SECONDARY); - g_signal_connect (self->forward_button_multi_press_gesture, "pressed", + controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ()); + gtk_widget_add_controller (self->forward_button, controller); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), GDK_BUTTON_SECONDARY); + g_signal_connect (controller, "pressed", G_CALLBACK (navigation_button_press_cb), self); g_signal_connect (self->operations_popover, "show", @@ -861,9 +858,9 @@ nautilus_toolbar_constructed (GObject *object) /* Setting a max width on one entry to effectively set a max expansion for * the whole title widget. */ - gtk_entry_set_max_width_chars (GTK_ENTRY (self->location_entry), 88); + gtk_editable_set_max_width_chars (GTK_EDITABLE (self->location_entry), 88); - gtk_widget_show_all (GTK_WIDGET (self)); + gtk_widget_show (GTK_WIDGET (self)); toolbar_update_appearance (self); } @@ -871,6 +868,16 @@ static void nautilus_toolbar_init (NautilusToolbar *self) { gtk_widget_init_template (GTK_WIDGET (self)); + + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->operations_icon), + (GtkDrawingAreaDrawFunc) on_operations_icon_draw, + self, + NULL); + + gtk_widget_set_parent (self->back_menu, self->back_button); + g_signal_connect (self->back_menu, "destroy", G_CALLBACK (gtk_widget_unparent), NULL); + gtk_widget_set_parent (self->forward_menu, self->forward_button); + g_signal_connect (self->forward_menu, "destroy", G_CALLBACK (gtk_widget_unparent), NULL); } void @@ -1031,10 +1038,10 @@ nautilus_toolbar_dispose (GObject *object) self = NAUTILUS_TOOLBAR (object); - g_clear_object (&self->forward_button_multi_press_gesture); - g_clear_object (&self->back_button_multi_press_gesture); g_clear_pointer (&self->icon_binding, g_binding_unbind); g_clear_pointer (&self->search_binding, g_binding_unbind); + g_clear_pointer (&self->back_menu, gtk_widget_unparent); + g_clear_pointer (&self->forward_menu, gtk_widget_unparent); G_OBJECT_CLASS (nautilus_toolbar_parent_class)->dispose (object); } @@ -1066,9 +1073,6 @@ nautilus_toolbar_finalize (GObject *obj) g_signal_handlers_disconnect_by_func (self->window, on_window_focus_changed, self); - g_clear_object (&self->back_button_longpress_gesture); - g_clear_object (&self->forward_button_longpress_gesture); - G_OBJECT_CLASS (nautilus_toolbar_parent_class)->finalize (obj); } @@ -1142,7 +1146,6 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass) gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, search_button); - gtk_widget_class_bind_template_callback (widget_class, on_operations_icon_draw); gtk_widget_class_bind_template_callback (widget_class, on_operations_popover_notify_visible); } diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h index 6f49acee1..e67aeedba 100644 --- a/src/nautilus-toolbar.h +++ b/src/nautilus-toolbar.h @@ -24,7 +24,7 @@ #pragma once #include <gtk/gtk.h> -#include <libhandy-1/handy.h> +#include <libadwaita-1/adwaita.h> #include "nautilus-window-slot.h" @@ -32,7 +32,7 @@ G_BEGIN_DECLS #define NAUTILUS_TYPE_TOOLBAR nautilus_toolbar_get_type() -G_DECLARE_FINAL_TYPE (NautilusToolbar, nautilus_toolbar, NAUTILUS, TOOLBAR, GtkBin) +G_DECLARE_FINAL_TYPE (NautilusToolbar, nautilus_toolbar, NAUTILUS, TOOLBAR, AdwBin) GtkWidget *nautilus_toolbar_new (void); diff --git a/src/nautilus-trash-bar.c b/src/nautilus-trash-bar.c index af87dbdf1..08631f571 100644 --- a/src/nautilus-trash-bar.c +++ b/src/nautilus-trash-bar.c @@ -32,7 +32,6 @@ #include "nautilus-file.h" #include "nautilus-trash-monitor.h" #include "nautilus-ui-utilities.h" -#include "nautilus-gtk4-helpers.h" enum { @@ -49,13 +48,13 @@ enum struct _NautilusTrashBar { - GtkBin parent_instance; + AdwBin parent_instance; NautilusFilesView *view; gulong selection_handler_id; }; -G_DEFINE_TYPE (NautilusTrashBar, nautilus_trash_bar, GTK_TYPE_BIN) +G_DEFINE_TYPE (NautilusTrashBar, nautilus_trash_bar, ADW_TYPE_BIN) static void selection_changed_cb (NautilusFilesView *view, @@ -68,7 +67,7 @@ selection_changed_cb (NautilusFilesView *view, selection = nautilus_view_get_selection (NAUTILUS_VIEW (view)); count = g_list_length (selection); - info_bar = gtk_bin_get_child (GTK_BIN (bar)); + info_bar = adw_bin_get_child (ADW_BIN (bar)); gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (info_bar), TRASH_BAR_RESPONSE_RESTORE, (count > 0)); @@ -130,7 +129,7 @@ nautilus_trash_bar_trash_state_changed (NautilusTrashMonitor *trash_monitor, bar = NAUTILUS_TRASH_BAR (data); - info_bar = gtk_bin_get_child (GTK_BIN (bar)); + info_bar = adw_bin_get_child (ADW_BIN (bar)); gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (info_bar), TRASH_BAR_RESPONSE_EMPTY, !nautilus_trash_monitor_is_empty ()); @@ -163,10 +162,10 @@ trash_bar_response_cb (GtkInfoBar *infobar, gpointer user_data) { NautilusTrashBar *bar; - GtkWidget *window; + GtkRoot *window; bar = NAUTILUS_TRASH_BAR (user_data); - window = gtk_widget_get_toplevel (GTK_WIDGET (bar)); + window = gtk_widget_get_root (GTK_WIDGET (bar)); switch (response_id) { @@ -194,7 +193,7 @@ trash_bar_response_cb (GtkInfoBar *infobar, case TRASH_BAR_RESPONSE_EMPTY: { - nautilus_file_operations_empty_trash (window, TRUE, NULL); + nautilus_file_operations_empty_trash (GTK_WIDGET (window), TRUE, NULL); } break; diff --git a/src/nautilus-trash-bar.h b/src/nautilus-trash-bar.h index 9fc4ffa50..4f03f2edc 100644 --- a/src/nautilus-trash-bar.h +++ b/src/nautilus-trash-bar.h @@ -23,12 +23,13 @@ #include "nautilus-files-view.h" #include <gtk/gtk.h> +#include <libadwaita-1/adwaita.h> G_BEGIN_DECLS #define NAUTILUS_TYPE_TRASH_BAR (nautilus_trash_bar_get_type ()) -G_DECLARE_FINAL_TYPE (NautilusTrashBar, nautilus_trash_bar, NAUTILUS, TRASH_BAR, GtkBin) +G_DECLARE_FINAL_TYPE (NautilusTrashBar, nautilus_trash_bar, NAUTILUS, TRASH_BAR, AdwBin) GtkWidget *nautilus_trash_bar_new (NautilusFilesView *view); diff --git a/src/nautilus-ui-utilities.c b/src/nautilus-ui-utilities.c index 60d667a57..6153d3f1f 100644 --- a/src/nautilus-ui-utilities.c +++ b/src/nautilus-ui-utilities.c @@ -333,7 +333,7 @@ show_dialog (const gchar *primary_text, gtk_widget_show (dialog); g_signal_connect (GTK_DIALOG (dialog), "response", - G_CALLBACK (gtk_widget_destroy), NULL); + G_CALLBACK (gtk_window_destroy), NULL); return GTK_DIALOG (dialog); } diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c index f56797771..ffd12e432 100644 --- a/src/nautilus-view-icon-controller.c +++ b/src/nautilus-view-icon-controller.c @@ -9,7 +9,6 @@ #include "nautilus-directory.h" #include "nautilus-global-preferences.h" #include "nautilus-thumbnails.h" -#include "nautilus-gtk4-helpers.h" struct _NautilusViewIconController { @@ -25,7 +24,6 @@ struct _NautilusViewIconController gboolean single_click_mode; gboolean activate_on_release; - GtkGesture *multi_press_gesture; guint scroll_to_file_handle_id; guint prioritize_thumbnailing_handle_id; @@ -429,8 +427,8 @@ static void reveal_item_ui (NautilusViewIconController *self, GtkWidget *item_ui) { - int item_y; - int item_height; + gdouble item_y; + gdouble item_height; gtk_widget_translate_coordinates (item_ui, GTK_WIDGET (self->view_ui), 0, 0, @@ -769,17 +767,17 @@ activate_selection_on_click (NautilusViewIconController *self, } static void -on_button_press_event (GtkGestureMultiPress *gesture, - gint n_press, - gdouble x, - gdouble y, - gpointer user_data) +on_button_press_event (GtkGestureClick *gesture, + gint n_press, + gdouble x, + gdouble y, + gpointer user_data) { NautilusViewIconController *self; guint button; GdkModifierType modifiers = 0; - gint view_x; - gint view_y; + gdouble view_x; + gdouble view_y; GtkFlowBoxChild *child_at_pos; self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data); @@ -856,11 +854,11 @@ on_button_press_event (GtkGestureMultiPress *gesture, } static void -on_click_released (GtkGestureMultiPress *gesture, - gint n_press, - gdouble x, - gdouble y, - gpointer user_data) +on_click_released (GtkGestureClick *gesture, + gint n_press, + gdouble x, + gdouble y, + gpointer user_data) { NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data); @@ -873,8 +871,8 @@ on_click_released (GtkGestureMultiPress *gesture, } static void -on_click_stopped (GtkGestureMultiPress *gesture, - gpointer user_data) +on_click_stopped (GtkGestureClick *gesture, + gpointer user_data) { NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data); @@ -889,8 +887,8 @@ on_longpress_gesture_pressed_callback (GtkGestureLongPress *gesture, { NautilusViewIconController *self; GtkFlowBoxChild *child_at_pos; - gint view_x; - gint view_y; + gdouble view_x; + gdouble view_y; self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data); @@ -944,9 +942,9 @@ static GtkFlowBoxChild * get_first_visible_item_ui (NautilusViewIconController *self) { GtkFlowBoxChild *child_at_0; - gint x0; - gint y0; - gint scrolled_y; + gdouble x0; + gdouble y0; + gdouble scrolled_y; child_at_0 = gtk_flow_box_get_child_at_index (self->view_ui, 0); if (child_at_0 == NULL) @@ -1001,7 +999,7 @@ scroll_to_file_on_idle (ScrollToFileData *data) g_autoptr (NautilusFile) file = NULL; NautilusViewItemModel *item; GtkWidget *item_ui; - int item_y; + gdouble item_y; file = nautilus_file_get_existing_by_uri (data->uri); item = nautilus_view_model_get_item_from_file (self->model, file); @@ -1191,7 +1189,6 @@ dispose (GObject *object) self = NAUTILUS_VIEW_ICON_CONTROLLER (object); - g_clear_object (&self->multi_press_gesture); g_clear_handle_id (&self->scroll_to_file_handle_id, g_source_remove); g_clear_handle_id (&self->prioritize_thumbnailing_handle_id, g_source_remove); @@ -1214,7 +1211,7 @@ prioritize_thumbnailing_on_idle (NautilusViewIconController *self) GtkFlowBoxChild *next_child; gint first_index; gint next_index; - gint y; + gdouble y; gint last_index; gpointer item; NautilusFile *file; @@ -1308,7 +1305,7 @@ setup_item_ui (GtkWidget **child, nautilus_view_item_ui_set_caption_attributes (item_ui, self->caption_attributes); *child = GTK_WIDGET (item_ui); - gtk_widget_show_all (*child); + gtk_widget_show (*child); } static GtkWidget * @@ -1331,7 +1328,7 @@ create_view_ui (NautilusViewIconController *self) GtkFlowBox *flowbox; widget = gtk_flow_box_new (); - gtk_widget_set_can_focus (widget, TRUE); + gtk_widget_set_focusable (widget, TRUE); gtk_widget_set_valign (widget, GTK_ALIGN_START); flowbox = GTK_FLOW_BOX (widget); @@ -1365,7 +1362,7 @@ constructed (GObject *object) GtkAdjustment *hadjustment; GtkAdjustment *vadjustment; GActionGroup *view_action_group; - GtkGesture *longpress_gesture; + GtkEventController *controller; content_widget = nautilus_files_view_get_content_widget (NAUTILUS_FILES_VIEW (self)); hadjustment = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (content_widget)); @@ -1391,26 +1388,23 @@ constructed (GObject *object) self->view_icon = g_themed_icon_new ("view-grid-symbolic"); /* Compensating for the lack of event boxen to allow clicks outside the flow box. */ - self->multi_press_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (content_widget)); - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (self->multi_press_gesture), - GTK_PHASE_CAPTURE); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->multi_press_gesture), - 0); - g_signal_connect (self->multi_press_gesture, "pressed", + controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ()); + gtk_widget_add_controller (GTK_WIDGET (content_widget), controller); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0); + g_signal_connect (controller, "pressed", G_CALLBACK (on_button_press_event), self); - g_signal_connect (self->multi_press_gesture, "stopped", + g_signal_connect (controller, "stopped", G_CALLBACK (on_click_stopped), self); - g_signal_connect (self->multi_press_gesture, "released", + g_signal_connect (controller, "released", G_CALLBACK (on_click_released), self); - longpress_gesture = gtk_gesture_long_press_new (GTK_WIDGET (self->view_ui)); - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (longpress_gesture), - GTK_PHASE_CAPTURE); - gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (longpress_gesture), - TRUE); - g_signal_connect (longpress_gesture, "pressed", - (GCallback) on_longpress_gesture_pressed_callback, - self); + controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ()); + gtk_widget_add_controller (GTK_WIDGET (self->view_ui), controller); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); + gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (controller), TRUE); + g_signal_connect (controller, "pressed", + (GCallback) on_longpress_gesture_pressed_callback, self); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (content_widget), GTK_WIDGET (self->view_ui)); @@ -1421,7 +1415,7 @@ constructed (GObject *object) G_N_ELEMENTS (view_icon_actions), self); - gtk_widget_show_all (GTK_WIDGET (self)); + gtk_widget_show (GTK_WIDGET (self)); view_action_group = nautilus_files_view_get_action_group (NAUTILUS_FILES_VIEW (self)); g_action_map_add_action_entries (G_ACTION_MAP (view_action_group), diff --git a/src/nautilus-view-icon-item-ui.c b/src/nautilus-view-icon-item-ui.c index 29a4a1bd2..344e0fc2a 100644 --- a/src/nautilus-view-icon-item-ui.c +++ b/src/nautilus-view-icon-item-ui.c @@ -33,7 +33,7 @@ static void update_icon (NautilusViewIconItemUi *self) { NautilusFileIconFlags flags; - g_autoptr (GdkPixbuf) icon_pixbuf = NULL; + g_autoptr (GdkPaintable) icon_paintable = NULL; GtkStyleContext *style_context; NautilusFile *file; guint icon_size; @@ -46,8 +46,8 @@ update_icon (NautilusViewIconItemUi *self) NAUTILUS_FILE_ICON_FLAGS_USE_EMBLEMS | NAUTILUS_FILE_ICON_FLAGS_USE_ONE_EMBLEM; - icon_pixbuf = nautilus_file_get_icon_pixbuf (file, icon_size, 1, flags); - gtk_image_set_from_pixbuf (GTK_IMAGE (self->icon), icon_pixbuf); + icon_paintable = nautilus_file_get_icon_paintable (file, icon_size, 1, flags); + gtk_image_set_from_paintable (GTK_IMAGE (self->icon), icon_paintable); gtk_widget_set_size_request (self->fixed_height_box, icon_size, icon_size); if (icon_size < NAUTILUS_GRID_ICON_SIZE_LARGEST) diff --git a/src/nautilus-window-slot-dnd.c b/src/nautilus-window-slot-dnd.c index 254084cb1..ccec73b60 100644 --- a/src/nautilus-window-slot-dnd.c +++ b/src/nautilus-window-slot-dnd.c @@ -83,14 +83,14 @@ static void switch_location (NautilusDragSlotProxyInfo *drag_info) { GFile *location; - GtkWidget *window; + GtkRoot *window; if (drag_info->target_file == NULL) { return; } - window = gtk_widget_get_toplevel (drag_info->widget); + window = gtk_widget_get_root (drag_info->widget); g_assert (NAUTILUS_IS_WINDOW (window)); location = nautilus_file_get_location (drag_info->target_file); @@ -153,7 +153,7 @@ slot_proxy_drag_motion (GtkWidget *widget, { NautilusDragSlotProxyInfo *drag_info; NautilusWindowSlot *target_slot; - GtkWidget *window; + GtkRoot *window; GdkAtom target; int action; char *target_uri; @@ -172,7 +172,7 @@ slot_proxy_drag_motion (GtkWidget *widget, goto out; } - window = gtk_widget_get_toplevel (widget); + window = gtk_widget_get_root (widget); g_assert (NAUTILUS_IS_WINDOW (window)); if (!drag_info->have_data) @@ -360,7 +360,7 @@ slot_proxy_handle_drop (GtkWidget *widget, unsigned int time, NautilusDragSlotProxyInfo *drag_info) { - GtkWidget *window; + GtkRoot *window; NautilusWindowSlot *target_slot; NautilusFilesView *target_view; char *target_uri; @@ -375,7 +375,7 @@ slot_proxy_handle_drop (GtkWidget *widget, return; } - window = gtk_widget_get_toplevel (widget); + window = gtk_widget_get_root (widget); g_assert (NAUTILUS_IS_WINDOW (window)); if (drag_info->target_slot != NULL) diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 16ae23a4a..7e94ffcab 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -48,7 +48,6 @@ #include <nautilus-extension.h> #include "nautilus-ui-utilities.h" #include <eel/eel-vfs-extensions.h> -#include "nautilus-gtk4-helpers.h" enum { @@ -1863,13 +1862,13 @@ got_file_info_for_view_selection_callback (NautilusFile *file, } else { - gtk_widget_destroy (GTK_WIDGET (window)); + gtk_window_destroy (GTK_WINDOW (window)); } } else { /* Since this is a window, destroying it will also unref it. */ - gtk_widget_destroy (GTK_WIDGET (window)); + gtk_window_destroy (GTK_WINDOW (window)); } } else @@ -2945,25 +2944,26 @@ nautilus_window_slot_finalize (GObject *object) G_OBJECT_CLASS (nautilus_window_slot_parent_class)->finalize (object); } -static void +static gboolean nautilus_window_slot_grab_focus (GtkWidget *widget) { NautilusWindowSlot *self; self = NAUTILUS_WINDOW_SLOT (widget); - GTK_WIDGET_CLASS (nautilus_window_slot_parent_class)->grab_focus (widget); if (nautilus_window_slot_get_search_visible (self)) { - gtk_widget_grab_focus (GTK_WIDGET (self->query_editor)); + return gtk_widget_grab_focus (GTK_WIDGET (self->query_editor)); } - else if (self->content_view) + else if (self->content_view != NULL) { - gtk_widget_grab_focus (GTK_WIDGET (self->content_view)); + return gtk_widget_grab_focus (GTK_WIDGET (self->content_view)); } - else if (self->new_content_view) + else if (self->new_content_view != NULL) { - gtk_widget_grab_focus (GTK_WIDGET (self->new_content_view)); + return gtk_widget_grab_focus (GTK_WIDGET (self->new_content_view)); } + + return GTK_WIDGET_CLASS (nautilus_window_slot_parent_class)->grab_focus (widget); } static void diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 8134fcb4e..244adbf2a 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -36,17 +36,17 @@ #include <sys/time.h> #ifdef GDK_WINDOWING_WAYLAND -#include <gdk/gdkwayland.h> +#include <gdk/wayland/gdkwayland.h> #endif #ifdef GDK_WINDOWING_X11 -#include <gdk/gdkx.h> +#include <gdk/x11/gdkx.h> #endif #define DEBUG_FLAG NAUTILUS_DEBUG_WINDOW #include "nautilus-debug.h" -#include "gtk/nautilusgtkplacessidebar.h" +#include "gtk/nautilusgtkplacessidebarprivate.h" #include "nautilus-application.h" #include "nautilus-bookmark-list.h" @@ -70,7 +70,6 @@ #include "nautilus-trash-monitor.h" #include "nautilus-ui-utilities.h" #include "nautilus-window-slot.h" -#include "nautilus-gtk4-helpers.h" /* Forward and back buttons on the mouse */ static gboolean mouse_extra_buttons = TRUE; @@ -99,7 +98,7 @@ static void nautilus_window_back_or_forward (NautilusWindow *window, struct _NautilusWindow { - HdyApplicationWindow parent_instance; + AdwApplicationWindow parent_instance; GtkWidget *notebook; @@ -151,13 +150,6 @@ struct _NautilusWindow GMenuModel *tab_menu_model; GQueue *tab_data_queue; - - GtkPadController *pad_controller; - - GtkGesture *multi_press_gesture; - GtkGesture *notebook_multi_press_gesture; - GtkEventController *key_capture_controller; - GtkEventController *key_bubble_controller; }; enum @@ -169,7 +161,7 @@ enum static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (NautilusWindow, nautilus_window, HDY_TYPE_APPLICATION_WINDOW); +G_DEFINE_TYPE (NautilusWindow, nautilus_window, ADW_TYPE_APPLICATION_WINDOW); static const GtkPadActionEntry pad_actions[] = { @@ -640,19 +632,19 @@ remember_focus_widget (NautilusWindow *window) } } -static void +static gboolean nautilus_window_grab_focus (GtkWidget *widget) { NautilusWindowSlot *slot; slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (widget)); - GTK_WIDGET_CLASS (nautilus_window_parent_class)->grab_focus (widget); - - if (slot) + if (slot != NULL) { - gtk_widget_grab_focus (GTK_WIDGET (slot)); + return gtk_widget_grab_focus (GTK_WIDGET (slot)); } + + return GTK_WIDGET_CLASS (nautilus_window_parent_class)->grab_focus (widget); } static void @@ -756,16 +748,11 @@ update_cursor (NautilusWindow *window) if (slot != NULL && nautilus_window_slot_get_allow_stop (slot)) { - GdkDisplay *display; - g_autoptr (GdkCursor) cursor = NULL; - - display = gtk_widget_get_display (GTK_WIDGET (window)); - cursor = gdk_cursor_new_from_name (display, "progress"); - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), cursor); + gtk_widget_set_cursor_from_name (GTK_WIDGET (window), "progress"); } else { - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), NULL); + gtk_widget_set_cursor (GTK_WIDGET (window), NULL); } } @@ -1201,8 +1188,8 @@ get_window_xid (NautilusWindow *window) #ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window)))) { - GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); - return (guint) gdk_x11_window_get_xid (gdk_window); + GdkSurface *gdk_surface = gtk_native_get_surface (GTK_NATIVE (window)); + return (guint) gdk_x11_surface_get_xid (gdk_surface); } #endif return 0; @@ -1246,6 +1233,7 @@ add_menu_separator (GtkWidget *menu) gtk_widget_show (separator); } +#if 0 && SIDEBAR_MENU_ITEMS_NEEDS_GTK4_REIMPLEMENTATION static void places_sidebar_populate_popup_cb (NautilusGtkPlacesSidebar *sidebar, GtkWidget *menu, @@ -1318,6 +1306,7 @@ places_sidebar_populate_popup_cb (NautilusGtkPlacesSidebar *sidebar, } } } +#endif static void nautilus_window_set_up_sidebar (NautilusWindow *window) @@ -1345,8 +1334,10 @@ nautilus_window_set_up_sidebar (NautilusWindow *window) g_signal_connect (window->places_sidebar, "drag-perform-drop", G_CALLBACK (places_sidebar_drag_perform_drop_cb), window); #endif +#if 0 && SIDEBAR_MENU_ITEMS_NEEDS_GTK4_REIMPLEMENTATION g_signal_connect (window->places_sidebar, "populate-popup", G_CALLBACK (places_sidebar_populate_popup_cb), window); +#endif g_signal_connect (window->places_sidebar, "unmount", G_CALLBACK (places_sidebar_unmount_operation_cb), window); } @@ -1775,18 +1766,18 @@ notebook_popup_menu_show (NautilusWindow *window, } static void -notebook_button_press_cb (GtkGestureMultiPress *gesture, - gint n_press, - gdouble x, - gdouble y, - gpointer user_data) +notebook_button_press_cb (GtkGestureClick *gesture, + gint n_press, + gdouble x, + gdouble y, + gpointer user_data) { NautilusWindow *window; GtkNotebook *notebook; gint tab_clicked; guint button; GdkEventSequence *sequence; - const GdkEvent *event; + GdkEvent *event; GdkModifierType state; if (n_press != 1) @@ -1805,7 +1796,7 @@ notebook_button_press_cb (GtkGestureMultiPress *gesture, button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)); sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)); event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence); - gdk_event_get_state (event, &state); + state = gdk_event_get_modifier_state (event); if (button == GDK_BUTTON_SECONDARY && (state & gtk_accelerator_get_default_mod_mask ()) == 0) @@ -1940,6 +1931,8 @@ notebook_create_window_cb (GtkNotebook *notebook, static void setup_notebook (NautilusWindow *window) { + GtkEventController *controller; + g_signal_connect (window->notebook, "switch-page", G_CALLBACK (notebook_switch_page_cb), window); @@ -1953,9 +1946,12 @@ setup_notebook (NautilusWindow *window) G_CALLBACK (notebook_page_removed_cb), window); - g_signal_connect (window->notebook_multi_press_gesture, "pressed", - G_CALLBACK (notebook_button_press_cb), - window); + controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ()); + gtk_widget_add_controller (GTK_WIDGET (window->notebook), controller); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0); + g_signal_connect (controller, "pressed", + G_CALLBACK (notebook_button_press_cb), window); } const GActionEntry win_entries[] = @@ -2140,6 +2136,8 @@ nautilus_window_dispose (GObject *object) DEBUG ("Destroying window"); + g_clear_pointer (&window->tab_menu, gtk_widget_unparent); + /* close all slots safely */ slots_copy = g_list_copy (window->slots); if (window->active_slot != NULL) @@ -2166,11 +2164,6 @@ nautilus_window_dispose (GObject *object) nautilus_window_unexport_handle (window); - g_clear_object (&window->notebook_multi_press_gesture); - - g_clear_object (&window->key_capture_controller); - g_clear_object (&window->key_bubble_controller); - G_OBJECT_CLASS (nautilus_window_parent_class)->dispose (object); } @@ -2208,8 +2201,6 @@ nautilus_window_finalize (GObject *object) g_queue_free_full (window->tab_data_queue, free_navigation_state); - g_object_unref (window->pad_controller); - /* nautilus_window_close() should have run */ g_assert (window->slots == NULL); @@ -2219,29 +2210,11 @@ nautilus_window_finalize (GObject *object) static void nautilus_window_save_geometry (NautilusWindow *window) { - GdkWindow *gdk_window; - GdkWindowState window_state; gint width; gint height; GVariant *initial_size; - g_assert (NAUTILUS_IS_WINDOW (window)); - - gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); - if (!gdk_window) - { - return; - } - window_state = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (window))); - if (window_state & (GDK_WINDOW_STATE_TILED | GDK_WINDOW_STATE_MAXIMIZED)) - { - /* Don't save the window state for tiled or maximized windows. In GTK - * gtk_window_get_default_size() is going to do this for us. - */ - return; - } - - gtk_window_get_size (GTK_WINDOW (window), &width, &height); + gtk_window_get_default_size (GTK_WINDOW (window), &width, &height); initial_size = g_variant_new_parsed ("(%i, %i)", width, height); g_settings_set_value (nautilus_window_state, @@ -2257,7 +2230,7 @@ nautilus_window_close (NautilusWindow *window) nautilus_window_save_geometry (window); nautilus_window_set_active_slot (window, NULL); - gtk_widget_destroy (GTK_WIDGET (window)); + gtk_window_destroy (GTK_WINDOW (window)); } void @@ -2382,9 +2355,9 @@ typedef struct } WaylandWindowHandleExportedData; static void -wayland_window_handle_exported (GdkWindow *window, - const char *wayland_handle_str, - gpointer user_data) +wayland_window_handle_exported (GdkToplevel *toplevel, + const char *wayland_handle_str, + gpointer user_data) { WaylandWindowHandleExportedData *data = user_data; @@ -2418,7 +2391,7 @@ nautilus_window_export_handle (NautilusWindow *window, #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window)))) { - GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); + GdkSurface *gdk_surface = gtk_native_get_surface (GTK_NATIVE (window)); WaylandWindowHandleExportedData *data; data = g_new0 (WaylandWindowHandleExportedData, 1); @@ -2426,10 +2399,10 @@ nautilus_window_export_handle (NautilusWindow *window, data->callback = callback; data->user_data = user_data; - if (!gdk_wayland_window_export_handle (gdk_window, - wayland_window_handle_exported, - data, - g_free)) + if (!gdk_wayland_toplevel_export_handle (GDK_WAYLAND_TOPLEVEL (gdk_surface), + wayland_window_handle_exported, + data, + g_free)) { g_free (data); return FALSE; @@ -2457,10 +2430,10 @@ nautilus_window_unexport_handle (NautilusWindow *window) #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window)))) { - GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); - if (gdk_window != NULL) + GdkSurface *gdk_surface = gtk_native_get_surface (GTK_NATIVE (window)); + if (GDK_IS_WAYLAND_TOPLEVEL (gdk_surface)) { - gdk_wayland_window_unexport_handle (gdk_window); + gdk_wayland_toplevel_unexport_handle (GDK_WAYLAND_TOPLEVEL (gdk_surface)); } } #endif @@ -2511,10 +2484,9 @@ on_is_maximized_changed (GObject *object, } static gboolean -nautilus_window_delete_event (GtkWidget *widget, - GdkEventAny *event) +nautilus_window_close_request (GtkWindow *window) { - nautilus_window_close (NAUTILUS_WINDOW (widget)); + nautilus_window_close (NAUTILUS_WINDOW (window)); return FALSE; } @@ -2534,11 +2506,11 @@ nautilus_window_back_or_forward (NautilusWindow *window, } static void -on_multi_press_gesture_pressed (GtkGestureMultiPress *gesture, - gint n_press, - gdouble x, - gdouble y, - gpointer user_data) +on_click_gesture_pressed (GtkGestureClick *gesture, + gint n_press, + gdouble x, + gdouble y, + gpointer user_data) { GtkWidget *widget; NautilusWindow *window; @@ -2600,6 +2572,8 @@ static void nautilus_window_init (NautilusWindow *window) { GtkWindowGroup *window_group; + GtkPadController *pad_controller; + GtkEventController *controller; g_type_ensure (NAUTILUS_TYPE_TOOLBAR); gtk_widget_init_template (GTK_WIDGET (window)); @@ -2609,7 +2583,6 @@ nautilus_window_init (NautilusWindow *window) g_object_set (window->places_sidebar, "vexpand", TRUE, "visible", TRUE, - "populate-all", TRUE, "show-other-locations", TRUE, "show-starred-location", TRUE, NULL); @@ -2626,9 +2599,9 @@ nautilus_window_init (NautilusWindow *window) window, G_CONNECT_SWAPPED); - gtk_popover_bind_model (GTK_POPOVER (window->tab_menu), - window->tab_menu_model, - NULL); + gtk_widget_set_parent (window->tab_menu, GTK_WIDGET (window)); + gtk_popover_menu_set_menu_model (GTK_POPOVER_MENU (window->tab_menu), + G_MENU_MODEL (window->tab_menu_model)); g_signal_connect (window, "notify::is-maximized", G_CALLBACK (on_is_maximized_changed), NULL); @@ -2650,41 +2623,30 @@ nautilus_window_init (NautilusWindow *window) window->tab_data_queue = g_queue_new (); - window->pad_controller = gtk_pad_controller_new (GTK_WINDOW (window), - G_ACTION_GROUP (window), - NULL); - gtk_pad_controller_set_action_entries (window->pad_controller, + pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (window), NULL); + gtk_pad_controller_set_action_entries (pad_controller, pad_actions, G_N_ELEMENTS (pad_actions)); + gtk_widget_add_controller (GTK_WIDGET (window), + GTK_EVENT_CONTROLLER (pad_controller)); - window->multi_press_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (window)); - - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (window->multi_press_gesture), - GTK_PHASE_CAPTURE); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (window->multi_press_gesture), 0); + controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ()); + gtk_widget_add_controller (GTK_WIDGET (window), controller); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0); + g_signal_connect (controller, "pressed", + G_CALLBACK (on_click_gesture_pressed), NULL); - g_signal_connect (window->multi_press_gesture, "pressed", - G_CALLBACK (on_multi_press_gesture_pressed), NULL); + controller = gtk_event_controller_key_new (); + gtk_widget_add_controller (GTK_WIDGET (window), controller); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); + g_signal_connect (controller, "key-pressed", + G_CALLBACK (nautilus_window_key_capture), NULL); - window->notebook_multi_press_gesture = gtk_gesture_multi_press_new (window->notebook); - - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (window->notebook_multi_press_gesture), - GTK_PHASE_CAPTURE); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (window->notebook_multi_press_gesture), - 0); - - window->key_capture_controller = gtk_event_controller_key_new (GTK_WIDGET (window)); - gtk_event_controller_set_propagation_phase (window->key_capture_controller, - GTK_PHASE_CAPTURE); - g_signal_connect (window->key_capture_controller, - "key-pressed", G_CALLBACK (nautilus_window_key_capture), - NULL); - - window->key_bubble_controller = gtk_event_controller_key_new (GTK_WIDGET (window)); - gtk_event_controller_set_propagation_phase (window->key_bubble_controller, - GTK_PHASE_BUBBLE); - g_signal_connect (window->key_bubble_controller, - "key-pressed", G_CALLBACK (nautilus_window_key_bubble), - NULL); + controller = gtk_event_controller_key_new (); + gtk_widget_add_controller (GTK_WIDGET (window), controller); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE); + g_signal_connect (controller, "key-pressed", + G_CALLBACK (nautilus_window_key_bubble), NULL); } static void @@ -2692,6 +2654,7 @@ nautilus_window_class_init (NautilusWindowClass *class) { GObjectClass *oclass = G_OBJECT_CLASS (class); GtkWidgetClass *wclass = GTK_WIDGET_CLASS (class); + GtkWindowClass *winclass = GTK_WINDOW_CLASS (class); oclass->dispose = nautilus_window_dispose; oclass->finalize = nautilus_window_finalize; @@ -2699,9 +2662,10 @@ nautilus_window_class_init (NautilusWindowClass *class) wclass->show = nautilus_window_show; wclass->realize = nautilus_window_realize; - wclass->delete_event = nautilus_window_delete_event; wclass->grab_focus = nautilus_window_grab_focus; + winclass->close_request = nautilus_window_close_request; + gtk_widget_class_set_template_from_resource (wclass, "/org/gnome/nautilus/ui/nautilus-window.ui"); gtk_widget_class_bind_template_child (wclass, NautilusWindow, toolbar); diff --git a/src/nautilus-window.h b/src/nautilus-window.h index af38441f1..72fc5d987 100644 --- a/src/nautilus-window.h +++ b/src/nautilus-window.h @@ -27,14 +27,14 @@ #pragma once #include <gtk/gtk.h> -#include <libhandy-1/handy.h> +#include <libadwaita-1/adwaita.h> #include "nautilus-types.h" G_BEGIN_DECLS #define NAUTILUS_TYPE_WINDOW (nautilus_window_get_type ()) -G_DECLARE_FINAL_TYPE (NautilusWindow, nautilus_window, NAUTILUS, WINDOW, HdyApplicationWindow); +G_DECLARE_FINAL_TYPE (NautilusWindow, nautilus_window, NAUTILUS, WINDOW, AdwApplicationWindow); typedef gboolean (* NautilusWindowGoToCallback) (NautilusWindow *window, GFile *location, diff --git a/src/nautilus-x-content-bar.c b/src/nautilus-x-content-bar.c index 03fa0cade..fe4b61578 100644 --- a/src/nautilus-x-content-bar.c +++ b/src/nautilus-x-content-bar.c @@ -30,11 +30,10 @@ #include "nautilus-icon-info.h" #include "nautilus-file-utilities.h" #include "nautilus-program-choosing.h" -#include "nautilus-gtk4-helpers.h" struct _NautilusXContentBar { - GtkBin parent_instance; + AdwBin parent_instance; GtkWidget *label; char **x_content_types; @@ -79,7 +78,7 @@ content_bar_response_cb (GtkInfoBar *infobar, if (default_app != NULL) { nautilus_launch_application_for_mount (default_app, bar->mount, - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (bar)))); + GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (bar)))); g_object_unref (default_app); } } @@ -182,7 +181,7 @@ nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar, icon = g_app_info_get_icon (default_app); if (icon != NULL) { - image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_BUTTON); + image = gtk_image_new_from_gicon (icon); } else { @@ -190,7 +189,7 @@ nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar, } name = g_app_info_get_name (default_app); - info_bar = gtk_bin_get_child (GTK_BIN (bar)); + info_bar = adw_bin_get_child (ADW_BIN (bar)); button = gtk_info_bar_add_button (GTK_INFO_BAR (info_bar), name, n); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); diff --git a/src/nautilus-x-content-bar.h b/src/nautilus-x-content-bar.h index af7bcaefe..11f05ec91 100644 --- a/src/nautilus-x-content-bar.h +++ b/src/nautilus-x-content-bar.h @@ -24,12 +24,13 @@ #include <gtk/gtk.h> #include <gio/gio.h> +#include <libadwaita-1/adwaita.h> G_BEGIN_DECLS #define NAUTILUS_TYPE_X_CONTENT_BAR (nautilus_x_content_bar_get_type ()) -G_DECLARE_FINAL_TYPE (NautilusXContentBar, nautilus_x_content_bar, NAUTILUS, X_CONTENT_BAR, GtkBin) +G_DECLARE_FINAL_TYPE (NautilusXContentBar, nautilus_x_content_bar, NAUTILUS, X_CONTENT_BAR, AdwBin) GtkWidget *nautilus_x_content_bar_new (GMount *mount, const char * const *x_content_types); diff --git a/src/resources/ui/nautilus-batch-rename-dialog.ui b/src/resources/ui/nautilus-batch-rename-dialog.ui index b10248128..fd373c676 100644 --- a/src/resources/ui/nautilus-batch-rename-dialog.ui +++ b/src/resources/ui/nautilus-batch-rename-dialog.ui @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> + <requires lib="gtk" version="4.0"/> <menu id="add_tag_menu"> <section> <attribute name="label" translatable="yes">Automatic Numbers</attribute> @@ -91,26 +92,21 @@ </section> </menu> <template class="NautilusBatchRenameDialog" parent="GtkDialog"> - <property name="resizable">True</property> <property name="modal">True</property> <property name="height-request">563</property> - <property name="window_position">center-on-parent</property> <property name="destroy_with_parent">True</property> <signal name="response" handler="batch_rename_dialog_on_response"/> <child type="action"> <object class="GtkButton" id="cancel_button"> <property name="label" translatable="yes">_Cancel</property> - <property name="visible">True</property> - <property name="can_focus">True</property> <property name="use_underline">True</property> + <property name="focusable">True</property> </object> </child> <child type="action"> <object class="GtkButton" id="rename_button"> <property name="label" translatable="yes">_Rename</property> - <property name="visible">True</property> <property name="use_underline">True</property> - <property name="can_default">True</property> <style> <class name="suggested-action"/> </style> @@ -120,19 +116,16 @@ <action-widget response="ok" default="true">rename_button</action-widget> <action-widget response="cancel">cancel_button</action-widget> </action-widgets> - <child internal-child="vbox"> - <object class="GtkBox" id="vbox"> + <child internal-child="content_area"> + <object class="GtkBox" id="content_area"> <child> <object class="GtkGrid" id="grid"> - <property name="visible">True</property> <property name="row-spacing">6</property> <property name="column-spacing">6</property> <property name="hexpand">True</property> <child> <object class="GtkBox"> - <property name="orientation">horizontal</property> <property name="spacing">15</property> - <property name="visible">True</property> <property name="hexpand">True</property> <property name="halign">center</property> <property name="margin-top">20</property> @@ -140,304 +133,263 @@ <property name="margin-start">20</property> <property name="margin-end">20</property> <child> - <object class="GtkRadioButton" id="format_mode_button"> + <object class="GtkCheckButton" id="format_mode_button"> <property name="label" translatable="yes">Rename _using a template</property> - <property name="visible">True</property> - <property name="can_focus">True</property> <property name="use_underline">True</property> <property name="active">True</property> <signal name="toggled" handler="batch_rename_dialog_mode_changed" swapped="yes" /> </object> </child> <child> - <object class="GtkRadioButton" id="replace_mode_button"> + <object class="GtkCheckButton" id="replace_mode_button"> <property name="label" translatable="yes">Find and replace _text</property> - <property name="visible">True</property> - <property name="can_focus">True</property> <property name="use_underline">True</property> - <property name="active">True</property> <property name="group">format_mode_button</property> - <signal name="toggled" handler="batch_rename_dialog_mode_changed" swapped="yes" /> + <signal name="toggled" handler="batch_rename_dialog_mode_changed" swapped="yes"/> </object> </child> + <layout> + <property name="column">3</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left-attach">3</property> - <property name="top-attach">0</property> - </packing> </child> <child> <object class="GtkStack" id="mode_stack"> - <property name="visible">True</property> <property name="vhomogeneous">False</property> <property name="hhomogeneous">True</property> <property name="transition_type">crossfade</property> <property name="transition_duration">100</property> <child> - <object class="GtkGrid" id="format_stack_child"> - <property name="visible">True</property> - <property name="margin-start">40</property> - <property name="margin-end">40</property> - <property name="margin-top">0</property> - <property name="margin-bottom">10</property> - <property name="row-spacing">15</property> - <property name="column-spacing">6</property> - <child> - <object class="GtkBox"> - <property name="orientation">horizontal</property> - <property name="visible">True</property> - <property name="halign">center</property> - <child> - <object class="GtkEntry" id="name_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="width_request">400</property> - <property name="hexpand">True</property> - <property name="activates-default">True</property> - <signal name="activate" handler="file_names_widget_on_activate" swapped="yes" /> - <signal name="insert-text" handler="on_insert_text" swapped="no" /> - <signal name="delete-text" handler="on_delete_text" swapped="no" /> - </object> - </child> - <child> - <object class="GtkMenuButton"> - <property name="visible">True</property> - <property name="menu_model">add_tag_menu</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-name">list-add-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Add</property> - </object> - </child> - </object> - </child> - </object> - </child> - <style> - <class name="linked"/> - </style> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - <property name="width">5</property> - </packing> - </child> - <child> - <object class="GtkRevealer" id="numbering_revealer"> - <property name="visible">True</property> - <property name="halign">center</property> + <object class="GtkStackPage"> + <property name="name">format</property> + <property name="title" translatable="yes" comments="Translators: This is a noun, not a verb">Format</property> + <property name="child"> + <object class="GtkGrid" id="format_stack_child"> + <property name="margin-start">40</property> + <property name="margin-end">40</property> + <property name="margin-bottom">10</property> + <property name="row-spacing">15</property> + <property name="column-spacing">6</property> <child> - <object class="GtkBox" id="numbering_box"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="spacing">10</property> + <object class="GtkBox"> + <property name="halign">center</property> <child> - <object class="GtkLabel" id="numbering_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Automatic Numbering Order</property> + <object class="GtkEntry" id="name_entry"> + <property name="focusable">True</property> + <property name="width_request">400</property> + <property name="hexpand">True</property> + <property name="activates-default">True</property> + <signal name="activate" handler="file_names_widget_on_activate" swapped="yes"/> + <signal name="insert-text" handler="on_insert_text" swapped="no"/> + <signal name="delete-text" handler="on_delete_text" swapped="no"/> </object> </child> <child> <object class="GtkMenuButton"> - <property name="visible">True</property> - <property name="menu-model">numbering_order_menu</property> + <property name="menu_model">add_tag_menu</property> <child> <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="spacing">15</property> <child> - <object class="GtkLabel" id="numbering_order_label"> - <property name="visible">True</property> - <property name="width-request">180</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Original Name (Ascending)</property> + <object class="GtkImage"> + <property name="icon-name">list-add-symbolic</property> + <property name="icon-size">1</property> </object> </child> <child> - <object class="GtkImage" id="action_icon"> - <property name="visible">True</property> - <property name="icon-name">pan-down-symbolic</property> - <property name="icon-size">1</property> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">Add</property> </object> </child> </object> </child> </object> </child> + <style> + <class name="linked"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">0</property> + <property name="column-span">5</property> + </layout> + </object> + </child> + <child> + <object class="GtkRevealer" id="numbering_revealer"> + <property name="halign">center</property> + <property name="child"> + <object class="GtkBox" id="numbering_box"> + <property name="spacing">10</property> + <child> + <object class="GtkLabel" id="numbering_label"> + <property name="label" translatable="yes">Automatic Numbering Order</property> + </object> + </child> + <child> + <object class="GtkMenuButton"> + <property name="menu-model">numbering_order_menu</property> + <child> + <object class="GtkBox"> + <property name="spacing">15</property> + <child> + <object class="GtkLabel" id="numbering_order_label"> + <property name="width-request">180</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Original Name (Ascending)</property> + </object> + </child> + <child> + <object class="GtkImage" id="action_icon"> + <property name="icon-name">pan-down-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + <property name="column-span">5</property> + </layout> </object> </child> </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</property> - <property name="width">5</property> - </packing> - </child> + </property> </object> - <packing> - <property name="name">format</property> - <property name="title" translatable="yes" comments="Translators: This is a noun, not a verb">Format</property> - </packing> </child> <child> - <object class="GtkGrid" id="replace_stack_child"> - <property name="visible">True</property> - <property name="margin-start">40</property> - <property name="margin-end">40</property> - <property name="margin-top">0</property> - <property name="margin-bottom">10</property> - <property name="hexpand">True</property> - <property name="halign">center</property> - <property name="row-spacing">15</property> - <property name="column-spacing">6</property> - <child> - <object class="GtkLabel" id="existing_text_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Existing Text</property> - <property name="sensitive">False</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="find_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="width_request">375</property> - <property name="activates-default">True</property> - <signal name="changed" handler="file_names_widget_entry_on_changed" swapped="yes" /> - <signal name="activate" handler="file_names_widget_on_activate" swapped="yes" /> - </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">0</property> - <property name="width">3</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="replace_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Replace With</property> - <property name="sensitive">False</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="replace_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="width_request">375</property> - <signal name="changed" handler="file_names_widget_entry_on_changed" swapped="yes" /> - <signal name="activate" handler="file_names_widget_on_activate" swapped="yes" /> - </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">1</property> - <property name="width">3</property> - </packing> - </child> - </object> - <packing> + <object class="GtkStackPage"> <property name="name">replace</property> <property name="title" translatable="yes" context="title">Replace</property> - </packing> + <property name="child"> + <object class="GtkGrid" id="replace_stack_child"> + <property name="margin-start">40</property> + <property name="margin-end">40</property> + <property name="margin-bottom">10</property> + <property name="hexpand">True</property> + <property name="halign">center</property> + <property name="row-spacing">15</property> + <property name="column-spacing">6</property> + <child> + <object class="GtkLabel" id="existing_text_label"> + <property name="label" translatable="yes">Existing Text</property> + <property name="sensitive">False</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> + </object> + </child> + <child> + <object class="GtkEntry" id="find_entry"> + <property name="focusable">True</property> + <property name="width_request">375</property> + <property name="activates-default">True</property> + <signal name="changed" handler="file_names_widget_entry_on_changed" swapped="yes"/> + <signal name="activate" handler="file_names_widget_on_activate" swapped="yes"/> + <layout> + <property name="column">1</property> + <property name="row">0</property> + <property name="column-span">3</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="replace_label"> + <property name="label" translatable="yes">Replace With</property> + <property name="sensitive">False</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + </object> + </child> + <child> + <object class="GtkEntry" id="replace_entry"> + <property name="focusable">True</property> + <property name="width_request">375</property> + <signal name="changed" handler="file_names_widget_entry_on_changed" swapped="yes"/> + <signal name="activate" handler="file_names_widget_on_activate" swapped="yes"/> + <layout> + <property name="column">1</property> + <property name="row">1</property> + <property name="column-span">3</property> + </layout> + </object> + </child> + </object> + </property> + </object> </child> + <layout> + <property name="column">0</property> + <property name="row">1</property> + <property name="column-span">8</property> + </layout> </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</property> - <property name="width">8</property> - </packing> </child> <child> <object class="GtkScrolledWindow" id="scrolled_window"> - <property name="visible">True</property> <property name="hexpand">False</property> <property name="vexpand">True</property> - <property name="shadow_type">in</property> <property name="max-content-height">250</property> <property name="min-content-height">250</property> <property name="max-content-width">600</property> <property name="min-content-width">600</property> - <child> + <property name="child"> <object class="GtkViewport"> - <property name="visible">True</property> - <child> + <property name="child"> <object class="GtkBox" id="a_box"> - <property name="visible">True</property> <child> <object class="GtkListBox" id="original_name_listbox"> - <property name="visible">True</property> <property name="selection_mode">GTK_SELECTION_NONE</property> </object> </child> <child> <object class="GtkListBox" id="arrow_listbox"> - <property name="visible">True</property> <property name="selection_mode">GTK_SELECTION_NONE</property> </object> </child> <child> <object class="GtkListBox" id="result_listbox"> - <property name="visible">True</property> <property name="selection_mode">GTK_SELECTION_NONE</property> </object> </child> </object> - </child> + </property> </object> - </child> + </property> + <layout> + <property name="column">0</property> + <property name="row">2</property> + <property name="column-span">8</property> + </layout> </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">2</property> - <property name="width">8</property> - </packing> </child> <child> <object class="GtkBox" id="conflict_box"> - <property name="orientation">horizontal</property> <property name="spacing">6</property> <property name="visible">False</property> <property name="margin-start">6</property> <child> <object class="GtkLabel" id="conflict_label"> - <property name="visible">True</property> <property name="hexpand">True</property> <property name="xalign">0</property> </object> </child> <child> <object class="GtkBox"> - <property name="orientation">horizontal</property> - <property name="visible">True</property> <child> <object class="GtkButton" id="conflict_down"> - <property name="visible">True</property> - <signal name="clicked" handler="select_next_conflict_down" swapped="yes" /> + <signal name="clicked" handler="select_next_conflict_down" swapped="yes"/> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="icon-name">go-down-symbolic</property> <property name="icon-size">1</property> </object> @@ -449,11 +401,9 @@ </child> <child> <object class="GtkButton" id="conflict_up"> - <property name="visible">True</property> - <signal name="clicked" handler="select_next_conflict_up" swapped="yes" /> + <signal name="clicked" handler="select_next_conflict_up" swapped="yes"/> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="icon-name">go-up-symbolic</property> <property name="icon-size">1</property> </object> @@ -464,16 +414,13 @@ </object> </child> </object> - <packing> - <property name="pack-type">end</property> - </packing> </child> + <layout> + <property name="column">0</property> + <property name="row">3</property> + <property name="column-span">8</property> + </layout> </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">3</property> - <property name="width">8</property> - </packing> </child> </object> </child> @@ -481,7 +428,6 @@ </child> </template> <object class="GtkImage" id="done_image"> - <property name="visible">True</property> <property name="icon_name">object-select-symbolic</property> </object> </interface> diff --git a/src/resources/ui/nautilus-column-chooser.ui b/src/resources/ui/nautilus-column-chooser.ui index 82eb3c22e..da545224d 100644 --- a/src/resources/ui/nautilus-column-chooser.ui +++ b/src/resources/ui/nautilus-column-chooser.ui @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.38.2 --> <interface> - <requires lib="gtk+" version="3.20"/> + <requires lib="gtk" version="4.0"/> <object class="GtkListStore" id="store"> <columns> <!-- column-name COLUMN_VISIBLE --> @@ -15,16 +14,12 @@ </columns> </object> <template class="NautilusColumnChooser" parent="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> <object class="GtkScrolledWindow"> - <property name="visible">True</property> - <child> + <property name="child"> <object class="GtkTreeView" id="view"> - <property name="visible">True</property> - <property name="can-focus">True</property> + <property name="focusable">True</property> <property name="vexpand">True</property> <property name="model">store</property> <property name="headers-visible">False</property> @@ -60,7 +55,7 @@ </object> </child> </object> - </child> + </property> <style> <class name="frame"/> </style> @@ -68,19 +63,15 @@ </child> <child> <object class="GtkBox"> - <property name="visible">True</property> <child> <object class="GtkBox"> - <property name="visible">True</property> <child> <object class="GtkButton" id="move_up_button"> - <property name="visible">True</property> <property name="sensitive">False</property> - <property name="can-focus">True</property> + <property name="focusable">True</property> <signal name="clicked" handler="move_up_clicked_callback" swapped="no"/> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="icon-name">go-up-symbolic</property> </object> </child> @@ -88,13 +79,11 @@ </child> <child> <object class="GtkButton" id="move_down_button"> - <property name="visible">True</property> <property name="sensitive">False</property> - <property name="can-focus">True</property> + <property name="focusable">True</property> <signal name="clicked" handler="move_down_clicked_callback" swapped="no"/> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="icon-name">go-down-symbolic</property> </object> </child> @@ -107,12 +96,10 @@ </child> <child> <object class="GtkBox"> - <property name="visible">True</property> <child> <object class="GtkButton" id="use_default_button"> <property name="label" translatable="yes">Reset to De_fault</property> - <property name="visible">True</property> - <property name="can-focus">True</property> + <property name="focusable">True</property> <property name="tooltip-text" translatable="yes">Replace the current List Columns settings with the default settings</property> <property name="use-underline">True</property> <signal name="clicked" handler="use_default_clicked_callback" swapped="no"/> diff --git a/src/resources/ui/nautilus-compress-dialog.ui b/src/resources/ui/nautilus-compress-dialog.ui index 050a1360c..ce2e6760c 100644 --- a/src/resources/ui/nautilus-compress-dialog.ui +++ b/src/resources/ui/nautilus-compress-dialog.ui @@ -1,25 +1,22 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.14"/> + <requires lib="gtk" version="4.0"/> <object class="GtkPopover" id="extension_popover"> - <property name="position">bottom</property> - <property name="constrain-to">none</property> <child> - <object class="HdyPreferencesGroup"> + <object class="AdwPreferencesGroup"> <property name="visible">True</property> <property name="margin-top">12</property> <property name="margin-bottom">12</property> <property name="margin-start">12</property> <property name="margin-end">12</property> <child> - <object class="HdyActionRow" id="zip_row"> + <object class="AdwActionRow" id="zip_row"> <property name="visible">True</property> <property name="activatable">True</property> <property name="title" translatable="no">.zip</property> <property name="subtitle" translatable="yes">Compatible with all operating systems.</property> <child> <object class="GtkImage" id="zip_checkmark"> - <property name="visible">True</property> <property name="width-request">16</property> <property name="margin-start">12</property> <property name="margin-end">12</property> @@ -28,7 +25,7 @@ </object> </child> <child> - <object class="HdyActionRow" id="encrypted_zip_row"> + <object class="AdwActionRow" id="encrypted_zip_row"> <property name="visible">True</property> <property name="activatable">True</property> <property name="title" translatable="no">.zip</property> @@ -38,7 +35,6 @@ </style> <child> <object class="GtkImage" id="encrypted_zip_checkmark"> - <property name="visible">True</property> <property name="width-request">16</property> <property name="margin-start">12</property> <property name="margin-end">12</property> @@ -47,14 +43,13 @@ </object> </child> <child> - <object class="HdyActionRow" id="tar_xz_row"> + <object class="AdwActionRow" id="tar_xz_row"> <property name="visible">True</property> <property name="activatable">True</property> <property name="title" translatable="no">.tar.xz</property> <property name="subtitle" translatable="yes">Smaller archives but Linux and Mac only.</property> <child> <object class="GtkImage" id="tar_xz_checkmark"> - <property name="visible">True</property> <property name="width-request">16</property> <property name="margin-start">12</property> <property name="margin-end">12</property> @@ -63,14 +58,13 @@ </object> </child> <child> - <object class="HdyActionRow" id="seven_zip_row"> + <object class="AdwActionRow" id="seven_zip_row"> <property name="visible">True</property> <property name="activatable">True</property> <property name="title" translatable="no">.7z</property> <property name="subtitle" translatable="yes">Smaller archives but must be installed on Windows and Mac.</property> <child> <object class="GtkImage" id="seven_zip_checkmark"> - <property name="visible">True</property> <property name="width-request">16</property> <property name="margin-start">12</property> <property name="margin-end">12</property> @@ -85,14 +79,12 @@ <property name="title" translatable="yes">Create Archive</property> <property name="resizable">False</property> <property name="modal">True</property> - <property name="window_position">center-on-parent</property> <property name="destroy_with_parent">True</property> - <property name="type_hint">dialog</property> <property name="use-header-bar">1</property> <property name="default-width">500</property> <property name="default-height">210</property> - <child internal-child="vbox"> - <object class="GtkBox" id="vbox"> + <child internal-child="content_area"> + <object class="GtkBox" id="content_area"> <property name="orientation">vertical</property> <property name="margin-top">30</property> <property name="margin-bottom">30</property> @@ -104,21 +96,18 @@ <child> <object class="GtkLabel" id="name_label"> <property name="label" translatable="yes">Archive name</property> - <property name="visible">True</property> <property name="xalign">0</property> <attributes> - <attribute name="weight" value="bold"/> + <attribute name="weight" value="bold"></attribute> </attributes> </object> </child> <child> <object class="GtkBox"> - <property name="orientation">horizontal</property> <property name="spacing">12</property> <child> <object class="GtkEntry" id="name_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="hexpand">True</property> <property name="width-chars">30</property> </object> @@ -128,7 +117,6 @@ <property name="popover">extension_popover</property> <child> <object class="GtkBox"> - <property name="orientation">horizontal</property> <property name="spacing">6</property> <child> <object class="GtkStack" id="extension_stack"> @@ -175,18 +163,18 @@ </child> <child> <object class="GtkRevealer" id="error_revealer"> - <child> + <property name="child"> <object class="GtkLabel" id="error_label"> <property name="margin_top">4</property> <property name="margin_bottom">4</property> - <property name="visible">True</property> <property name="xalign">0</property> </object> - </child> + </property> </object> </child> <child> <object class="GtkLabel" id="passphrase_label"> + <property name="visible">False</property> <property name="label" translatable="yes">Password</property> <property name="margin-top">6</property> <property name="xalign">0</property> @@ -194,6 +182,7 @@ </child> <child> <object class="GtkEntry" id="passphrase_entry"> + <property name="visible">False</property> <property name="placeholder-text" translatable="yes">Enter a password here.</property> <property name="input-purpose">password</property> <property name="visibility">False</property> @@ -205,17 +194,14 @@ <child type="action"> <object class="GtkButton" id="cancel_button"> <property name="label" translatable="yes">Cancel</property> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="receives_default">True</property> </object> </child> <child type="action"> <object class="GtkButton" id="activate_button"> <property name="label" translatable="yes">Create</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> + <property name="focusable">True</property> <property name="receives_default">True</property> <property name="sensitive">False</property> </object> diff --git a/src/resources/ui/nautilus-create-folder-dialog.ui b/src/resources/ui/nautilus-create-folder-dialog.ui index 1f53b7c5c..91f27683c 100644 --- a/src/resources/ui/nautilus-create-folder-dialog.ui +++ b/src/resources/ui/nautilus-create-folder-dialog.ui @@ -1,16 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.14"/> + <requires lib="gtk" version="4.0"/> <object class="GtkDialog" id="create_folder_dialog"> <property name="resizable">False</property> <property name="modal">True</property> - <property name="window_position">center-on-parent</property> <property name="destroy_with_parent">True</property> - <property name="type_hint">dialog</property> <property name="use-header-bar">1</property> <property name="width_request">450</property> - <child internal-child="vbox"> - <object class="GtkBox" id="vbox"> + <child internal-child="content_area"> + <object class="GtkBox" id="content_area"> <property name="orientation">vertical</property> <property name="margin_top">18</property> <property name="margin_bottom">12</property> @@ -19,26 +17,23 @@ <property name="spacing">6</property> <child> <object class="GtkLabel" id="name_label"> - <property name="visible">True</property> <property name="xalign">0</property> </object> </child> <child> <object class="GtkEntry" id="name_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> </object> </child> <child> <object class="GtkRevealer" id="error_revealer"> - <child> + <property name="child"> <object class="GtkLabel" id="error_label"> <property name="margin_top">4</property> <property name="margin_bottom">4</property> - <property name="visible">True</property> <property name="xalign">0</property> </object> - </child> + </property> </object> </child> </object> @@ -46,16 +41,13 @@ <child type="action"> <object class="GtkButton" id="cancel_button"> <property name="label" translatable="yes">Cancel</property> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="receives_default">True</property> </object> </child> <child type="action"> <object class="GtkButton" id="ok_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> + <property name="focusable">True</property> <property name="receives_default">True</property> <property name="sensitive">False</property> </object> diff --git a/src/resources/ui/nautilus-file-conflict-dialog.ui b/src/resources/ui/nautilus-file-conflict-dialog.ui index ded27ec72..cfbafb481 100644 --- a/src/resources/ui/nautilus-file-conflict-dialog.ui +++ b/src/resources/ui/nautilus-file-conflict-dialog.ui @@ -1,12 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.20"/> + <requires lib="gtk" version="4.0"/> <template class="NautilusFileConflictDialog" parent="GtkDialog"> <property name="modal">True</property> <property name="resizable">False</property> - <child internal-child="vbox"> + <child internal-child="content_area"> <object class="GtkBox"> - <property name="visible">True</property> <property name="margin-top">18</property> <property name="margin-bottom">18</property> <property name="margin-start">18</property> @@ -14,12 +13,10 @@ <property name="spacing">12</property> <child> <object class="GtkBox"> - <property name="visible">True</property> <property name="orientation">vertical</property> <property name="spacing">12</property> <child> <object class="GtkLabel" id="primary_label"> - <property name="visible">True</property> <property name="justify">center</property> <property name="halign">center</property> <property name="max-width-chars">50</property> @@ -32,7 +29,6 @@ </child> <child> <object class="GtkLabel" id="secondary_label"> - <property name="visible">True</property> <property name="justify">center</property> <property name="halign">center</property> <property name="max-width-chars">50</property> @@ -42,58 +38,44 @@ </child> <child> <object class="GtkBox"> - <property name="visible">True</property> <property name="halign">start</property> <property name="orientation">vertical</property> <property name="spacing">12</property> <child> <object class="GtkBox"> - <property name="visible">True</property> <property name="spacing">12</property> <child> - <object class="GtkImage" id="dest_image"> - <property name="visible">True</property> - </object> + <object class="GtkImage" id="dest_image"/> </child> <child> - <object class="GtkLabel" id="dest_label"> - <property name="visible">True</property> - </object> + <object class="GtkLabel" id="dest_label"/> </child> </object> </child> <child> <object class="GtkBox"> - <property name="visible">True</property> <property name="spacing">12</property> <child> - <object class="GtkImage" id="src_image"> - <property name="visible">True</property> - </object> + <object class="GtkImage" id="src_image"/> </child> <child> - <object class="GtkLabel" id="src_label"> - <property name="visible">True</property> - </object> + <object class="GtkLabel" id="src_label"/> </child> </object> </child> <child> <object class="GtkExpander" id="expander"> - <property name="visible">True</property> <property name="label" translatable="yes">_Select a new name for the destination</property> <property name="use-underline">True</property> <signal name="notify::expanded" handler="on_expanded_notify"/> <child> <object class="GtkBox"> - <property name="visible">True</property> <property name="margin-top">6</property> <style> <class name="linked"/> </style> <child> <object class="GtkEntry" id="entry"> - <property name="visible">True</property> <property name="activates-default">True</property> <property name="hexpand">True</property> <signal name="changed" handler="entry_text_changed_cb"/> @@ -101,7 +83,6 @@ </child> <child> <object class="GtkButton"> - <property name="visible">True</property> <property name="label" translatable="yes">_Reset</property> <property name="use-underline">True</property> <signal name="clicked" handler="reset_button_clicked_cb"/> @@ -115,11 +96,9 @@ </child> <child> <object class="GtkCheckButton" id="checkbox"> - <property name="visible">True</property> <signal name="toggled" handler="checkbox_toggled_cb"/> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">Apply this action to all files and folders</property> <property name="use-underline">True</property> </object> @@ -132,7 +111,6 @@ </child> <child type="action"> <object class="GtkButton" id="cancel_button"> - <property name="visible">True</property> <property name="label" translatable="yes">_Cancel</property> <property name="use-underline">True</property> </object> @@ -140,22 +118,18 @@ <child type="action"> <object class="GtkButton" id="rename_button"> <property name="visible">False</property> - <property name="can-default">True</property> <property name="label" translatable="yes">Re_name</property> <property name="use-underline">True</property> </object> </child> <child type="action"> <object class="GtkButton" id="replace_button"> - <property name="visible">True</property> - <property name="can-default">True</property> <property name="label" translatable="yes">Re_place</property> <property name="use-underline">True</property> </object> </child> <child type="action"> <object class="GtkButton" id="skip_button"> - <property name="visible">True</property> <property name="label" translatable="yes">_Skip</property> <property name="use-underline">True</property> </object> diff --git a/src/resources/ui/nautilus-file-properties-change-permissions.ui b/src/resources/ui/nautilus-file-properties-change-permissions.ui index fe9c21c29..623b7db4a 100644 --- a/src/resources/ui/nautilus-file-properties-change-permissions.ui +++ b/src/resources/ui/nautilus-file-properties-change-permissions.ui @@ -1,27 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.22"/> + <requires lib="gtk" version="4.0"/> <object class="GtkDialog" id="change_permissions_dialog"> <property name="title" translatable="yes">Change Permissions for Enclosed Files</property> <property name="modal">True</property> <property name="destroy_with_parent">True</property> - <property name="type_hint">dialog</property> <property name="use-header-bar">1</property> <child type="action"> <object class="GtkButton" id="cancel"> - <property name="visible">True</property> <property name="label" translatable="yes">_Cancel</property> <property name="use_underline">True</property> </object> </child> <child type="action"> <object class="GtkButton" id="change"> - <property name="visible">True</property> <property name="label" translatable="yes">C_hange</property> <property name="use_underline">True</property> </object> </child> - <child internal-child="vbox"> + <child internal-child="content_area"> <object class="GtkBox"> <property name="orientation">vertical</property> <style> @@ -29,7 +26,6 @@ </style> <child> <object class="GtkGrid" id="change_permissions_grid"> - <property name="visible">True</property> <property name="halign">center</property> <property name="margin-top">6</property> <property name="margin-bottom">6</property> @@ -40,125 +36,114 @@ <property name="column_spacing">12</property> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">Files</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">Folders</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">2</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">0</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">Owner</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> </child> <child> <object class="GtkComboBox" id="file_owner_combo"> - <property name="visible">True</property> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> </child> <child> <object class="GtkComboBox" id="folder_owner_combo"> - <property name="visible">True</property> + <layout> + <property name="column">2</property> + <property name="row">1</property> + </layout> </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">1</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">Group</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> </child> <child> <object class="GtkComboBox" id="file_group_combo"> - <property name="visible">True</property> + <layout> + <property name="column">1</property> + <property name="row">2</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> </child> <child> <object class="GtkComboBox" id="folder_group_combo"> - <property name="visible">True</property> + <layout> + <property name="column">2</property> + <property name="row">2</property> + </layout> </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">2</property> - </packing> </child> <child> <object class="GtkComboBox" id="file_other_combo"> - <property name="visible">True</property> + <layout> + <property name="column">1</property> + <property name="row">3</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> </child> <child> <object class="GtkComboBox" id="folder_other_combo"> - <property name="visible">True</property> + <layout> + <property name="column">2</property> + <property name="row">3</property> + </layout> </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">3</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">Others</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">3</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - </packing> </child> </object> </child> diff --git a/src/resources/ui/nautilus-files-view-context-menus.ui b/src/resources/ui/nautilus-files-view-context-menus.ui index a951549ab..299fd8f95 100644 --- a/src/resources/ui/nautilus-files-view-context-menus.ui +++ b/src/resources/ui/nautilus-files-view-context-menus.ui @@ -1,5 +1,6 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> <interface> + <requires lib="gtk" version="4.0"/> <menu id="background-menu"> <item> <attribute name="label" translatable="yes">New _Folder</attribute> @@ -31,8 +32,7 @@ <attribute name="action">view.select-all</attribute> </item> </section> - <section id="background-extensions-section"> - </section> + <section id="background-extensions-section"/> <section> <item> <attribute name="label" translatable="yes">P_roperties</attribute> @@ -42,8 +42,7 @@ </section> </menu> <menu id="selection-menu"> - <section id="new-folder-with-selection-section"> - </section> + <section id="new-folder-with-selection-section"/> <section id="open-with-application-section"> <item> <attribute name="label" translatable="yes">Open With Other _Application</attribute> @@ -55,7 +54,7 @@ <attribute name="label" translatable="yes">_Scripts</attribute> <attribute name="action">view.scripts</attribute> <attribute name="hidden-when">action-disabled</attribute> - <section id="scripts-submenu-section" /> + <section id="scripts-submenu-section"/> <section> <item> <attribute name="label" translatable="yes">_Open Scripts Folder</attribute> @@ -217,8 +216,7 @@ <attribute name="hidden-when">action-disabled</attribute> </item> </section> - <section id="selection-extensions-section"> - </section> + <section id="selection-extensions-section"/> <section> <item> <attribute name="label" translatable="yes">Tags</attribute> diff --git a/src/resources/ui/nautilus-files-view-select-items.ui b/src/resources/ui/nautilus-files-view-select-items.ui index 1d195b609..c376cfdca 100644 --- a/src/resources/ui/nautilus-files-view-select-items.ui +++ b/src/resources/ui/nautilus-files-view-select-items.ui @@ -1,26 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.22"/> + <requires lib="gtk" version="4.0"/> <object class="GtkDialog" id="select_items_dialog"> <property name="title" translatable="yes">Select Items Matching</property> <property name="modal">True</property> <property name="use-header-bar">1</property> <child type="action"> <object class="GtkButton" id="cancel"> - <property name="visible">True</property> <property name="label" translatable="yes">_Cancel</property> <property name="use-underline">True</property> </object> </child> <child type="action"> <object class="GtkButton" id="select"> - <property name="visible">True</property> <property name="label" translatable="yes">_Select</property> <property name="use-underline">True</property> - <property name="can-default">True</property> </object> </child> - <child internal-child="vbox"> + <child internal-child="content_area"> <object class="GtkBox"> <property name="margin-top">18</property> <property name="margin-bottom">18</property> @@ -29,25 +26,22 @@ <property name="spacing">6</property> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="halign">start</property> <property name="label" translatable="yes">Pattern</property> <attributes> - <attribute name="weight" value="bold"/> + <attribute name="weight" value="bold"></attribute> </attributes> </object> </child> <child> <object class="GtkEntry" id="pattern_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="hexpand">True</property> <property name="activates_default">True</property> </object> </child> <child> <object class="GtkLabel" id="example"> - <property name="visible">True</property> <property name="halign">start</property> </object> </child> diff --git a/src/resources/ui/nautilus-folder-is-empty.ui b/src/resources/ui/nautilus-folder-is-empty.ui index 2ef07674d..8417d823e 100644 --- a/src/resources/ui/nautilus-folder-is-empty.ui +++ b/src/resources/ui/nautilus-folder-is-empty.ui @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.0 --> <interface> - <requires lib="gtk+" version="3.20"/> + <requires lib="gtk" version="4.0"/> <object class="GtkGrid" id="folder_is_empty"> <property name="halign">center</property> <property name="valign">center</property> @@ -11,31 +10,29 @@ <property name="visible">False</property> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="pixel_size">128</property> <property name="icon_name">folder-symbolic</property> <style> <class name="dim-label"/> <class name="nautilus-empty-state-icon"/> </style> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">Folder is Empty</property> <style> <class name="large-title"/> </style> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> </child> </object> </interface> diff --git a/src/resources/ui/nautilus-list-view-column-editor.ui b/src/resources/ui/nautilus-list-view-column-editor.ui index be24516da..b71a55772 100644 --- a/src/resources/ui/nautilus-list-view-column-editor.ui +++ b/src/resources/ui/nautilus-list-view-column-editor.ui @@ -1,25 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.38.2 --> <interface> - <object class="HdyWindow" id="window"> + <requires lib="gtk" version="4.0"/> + <object class="AdwWindow" id="window"> <property name="modal">True</property> - <property name="type-hint">dialog</property> <property name="default-width">300</property> <property name="default-height">400</property> <child> <object class="GtkBox"> - <property name="visible">True</property> <property name="orientation">vertical</property> <child> - <object class="HdyHeaderBar"> - <property name="visible">True</property> - <property name="title" bind-source="window" bind-property="title" bind-flags="sync-create"/> - <property name="show-close-button">True</property> - </object> + <object class="AdwHeaderBar"/> </child> <child> <object class="GtkBox" id="box"> - <property name="visible">True</property> <property name="margin-top">12</property> <property name="margin-bottom">12</property> <property name="margin-start">12</property> @@ -29,7 +22,6 @@ <child> <object class="GtkLabel"> <property name="label" translatable="yes">Choose the order of information to appear in this folder:</property> - <property name="visible">True</property> <property name="xalign">0</property> <property name="yalign">0</property> <property name="wrap">True</property> diff --git a/src/resources/ui/nautilus-no-search-results.ui b/src/resources/ui/nautilus-no-search-results.ui index e36904707..d4242a163 100644 --- a/src/resources/ui/nautilus-no-search-results.ui +++ b/src/resources/ui/nautilus-no-search-results.ui @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.0 --> <interface> - <requires lib="gtk+" version="3.20"/> + <requires lib="gtk" version="4.0"/> <object class="GtkGrid" id="no_search_results"> <property name="halign">center</property> <property name="valign">center</property> @@ -11,44 +10,41 @@ <property name="visible">False</property> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="pixel_size">80</property> <property name="icon_name">edit-find-symbolic</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">No Results Found</property> <attributes> - <attribute name="weight" value="bold"/> - <attribute name="scale" value="1.4399999999999999"/> + <attribute name="weight" value="bold"></attribute> + <attribute name="scale" value="1.44"></attribute> </attributes> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">Try a different search</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> </child> <style> <class name="dim-label"/> diff --git a/src/resources/ui/nautilus-operations-ui-manager-request-passphrase.ui b/src/resources/ui/nautilus-operations-ui-manager-request-passphrase.ui index c66c9cd6c..8c87ed135 100644 --- a/src/resources/ui/nautilus-operations-ui-manager-request-passphrase.ui +++ b/src/resources/ui/nautilus-operations-ui-manager-request-passphrase.ui @@ -1,28 +1,25 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.20"/> + <requires lib="gtk" version="4.0"/> <object class="GtkDialog" id="request_passphrase_dialog"> <property name="title" translatable="yes">Password Required</property> <property name="modal">True</property> <property name="destroy-with-parent">True</property> <property name="use-header-bar">1</property> - <child internal-child="vbox"> + <child internal-child="content_area"> <object class="GtkBox"> - <property name="visible">True</property> <property name="margin-top">20</property> <property name="margin-bottom">20</property> <property name="margin-start">20</property> <property name="margin-end">20</property> <child> <object class="GtkLabel" id="label"> - <property name="visible">True</property> <property name="max-width-chars">60</property> <property name="wrap">True</property> </object> </child> <child> <object class="GtkEntry" id="entry"> - <property name="visible">True</property> <property name="activates-default">True</property> <property name="valign">end</property> <property name="vexpand">True</property> @@ -35,15 +32,12 @@ </child> <child type="action"> <object class="GtkButton" id="cancel_button"> - <property name="visible">True</property> <property name="label" translatable="yes">_Cancel</property> <property name="use-underline">True</property> </object> </child> <child type="action"> <object class="GtkButton" id="extract_button"> - <property name="visible">True</property> - <property name="can-default">True</property> <property name="label" translatable="yes">Extract</property> </object> </child> diff --git a/src/resources/ui/nautilus-pathbar-context-menu.ui b/src/resources/ui/nautilus-pathbar-context-menu.ui index 462bb659b..5abbcce61 100644 --- a/src/resources/ui/nautilus-pathbar-context-menu.ui +++ b/src/resources/ui/nautilus-pathbar-context-menu.ui @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> <interface> + <requires lib="gtk" version="4.0"/> <menu id="button-menu"> <item> <attribute name="label" translatable="yes">Open in New _Window</attribute> diff --git a/src/resources/ui/nautilus-preferences-window.ui b/src/resources/ui/nautilus-preferences-window.ui index 04b04d2b9..baf53a569 100644 --- a/src/resources/ui/nautilus-preferences-window.ui +++ b/src/resources/ui/nautilus-preferences-window.ui @@ -1,19 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.0 --> <interface> - <requires lib="gtk+" version="3.22"/> - <object class="HdyPreferencesWindow" id="preferences_window"> + <requires lib="gtk" version="4.0"/> + <object class="AdwPreferencesWindow" id="preferences_window"> <property name="search_enabled">False</property> <child> - <object class="HdyPreferencesPage"> + <object class="AdwPreferencesPage"> <property name="title" translatable="yes">General</property> <property name="visible">True</property> <child> - <object class="HdyPreferencesGroup"> + <object class="AdwPreferencesGroup"> <property name="title" translatable="yes">General</property> <property name="visible">True</property> <child> - <object class="HdyActionRow"> + <object class="AdwActionRow"> <property name="activatable_widget">sort_folders_first_switch</property> <property name="subtitle_lines">0</property> <property name="title" translatable="yes">Sort _Folders Before Files</property> @@ -23,13 +22,12 @@ <child> <object class="GtkSwitch" id="sort_folders_first_switch"> <property name="valign">center</property> - <property name="visible">True</property> </object> </child> </object> </child> <child> - <object class="HdyActionRow"> + <object class="AdwActionRow"> <property name="activatable_widget">use_tree_view_switch</property> <property name="subtitle_lines">0</property> <property name="title" translatable="yes">_Expandable Folders in List View</property> @@ -39,13 +37,12 @@ <child> <object class="GtkSwitch" id="use_tree_view_switch"> <property name="valign">center</property> - <property name="visible">True</property> </object> </child> </object> </child> <child> - <object class="HdyComboRow" id="open_action_row"> + <object class="AdwComboRow" id="open_action_row"> <property name="subtitle_lines">0</property> <property name="title" translatable="yes">Action to Open Items</property> <property name="title_lines">0</property> @@ -56,12 +53,12 @@ </object> </child> <child> - <object class="HdyPreferencesGroup"> + <object class="AdwPreferencesGroup"> <property name="title" translatable="yes">Optional Context Menu Actions</property> <property name="description" translatable="yes">Show more actions in the menus. Keyboard shortcuts can be used even if the actions are not shown.</property> <property name="visible">True</property> <child> - <object class="HdyActionRow"> + <object class="AdwActionRow"> <property name="activatable_widget">show_create_link_switch</property> <property name="subtitle_lines">0</property> <property name="title" translatable="yes">Create _Link</property> @@ -71,13 +68,12 @@ <child> <object class="GtkSwitch" id="show_create_link_switch"> <property name="valign">center</property> - <property name="visible">True</property> </object> </child> </object> </child> <child> - <object class="HdyActionRow"> + <object class="AdwActionRow"> <property name="activatable_widget">show_delete_permanently_switch</property> <property name="subtitle_lines">0</property> <property name="title" translatable="yes">_Delete Permanently</property> @@ -87,7 +83,6 @@ <child> <object class="GtkSwitch" id="show_delete_permanently_switch"> <property name="valign">center</property> - <property name="visible">True</property> </object> </child> </object> @@ -95,12 +90,12 @@ </object> </child> <child> - <object class="HdyPreferencesGroup"> + <object class="AdwPreferencesGroup"> <property name="title" translatable="yes">Performance</property> <property name="description" translatable="yes">These features may cause slowdowns and excess network usage, especially when browsing files outside this computer, such as on a remote server.</property> <property name="visible">True</property> <child> - <object class="HdyComboRow" id="search_recursive_row"> + <object class="AdwComboRow" id="search_recursive_row"> <property name="subtitle_lines">0</property> <property name="title" translatable="yes">Search in Subfolders</property> <property name="title_lines">0</property> @@ -109,7 +104,7 @@ </object> </child> <child> - <object class="HdyComboRow" id="thumbnails_row"> + <object class="AdwComboRow" id="thumbnails_row"> <property name="subtitle_lines">0</property> <property name="title" translatable="yes">Show Thumbnails</property> <property name="title_lines">0</property> @@ -118,7 +113,7 @@ </object> </child> <child> - <object class="HdyComboRow" id="count_row"> + <object class="AdwComboRow" id="count_row"> <property name="subtitle_lines">0</property> <property name="title" translatable="yes">Count Number of Files in Folders</property> <property name="title_lines">0</property> @@ -129,12 +124,12 @@ </object> </child> <child> - <object class="HdyPreferencesGroup"> + <object class="AdwPreferencesGroup"> <property name="description" translatable="yes">Add information to be displayed beneath file and folder names. More information will appear when zooming closer.</property> <property name="title" translatable="yes">Icon View Captions</property> <property name="visible">True</property> <child> - <object class="HdyComboRow" id="captions_0_comborow"> + <object class="AdwComboRow" id="captions_0_comborow"> <property name="subtitle_lines">0</property> <property name="title" translatable="yes" context="the n-th position of an icon caption" comments="Translators: This is an ordinal number">First</property> <property name="title_lines">0</property> @@ -143,7 +138,7 @@ </object> </child> <child> - <object class="HdyComboRow" id="captions_1_comborow"> + <object class="AdwComboRow" id="captions_1_comborow"> <property name="subtitle_lines">0</property> <property name="title" translatable="yes" context="the n-th position of an icon caption" comments="Translators: This is an ordinal number">Second</property> <property name="title_lines">0</property> @@ -152,7 +147,7 @@ </object> </child> <child> - <object class="HdyComboRow" id="captions_2_comborow"> + <object class="AdwComboRow" id="captions_2_comborow"> <property name="subtitle_lines">0</property> <property name="title" translatable="yes" context="the n-th position of an icon caption" comments="Translators: This is an ordinal number">Third</property> <property name="title_lines">0</property> diff --git a/src/resources/ui/nautilus-progress-info-widget.ui b/src/resources/ui/nautilus-progress-info-widget.ui index 064f57431..6d78a5fa3 100644 --- a/src/resources/ui/nautilus-progress-info-widget.ui +++ b/src/resources/ui/nautilus-progress-info-widget.ui @@ -1,14 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.0 --> <interface> - <requires lib="gtk+" version="3.20"/> + <requires lib="gtk" version="4.0"/> <object class="GtkImage" id="cancel_image"> - <property name="visible">True</property> <property name="icon_name">window-close-symbolic</property> </object> <template class="NautilusProgressInfoWidget" parent="GtkGrid"> - <property name="visible">True</property> - <property name="can_focus">False</property> <property name="margin_start">6</property> <property name="margin_end">6</property> <property name="margin_top">6</property> @@ -16,37 +12,34 @@ <child> <object class="GtkLabel" id="status"> <property name="width_request">300</property> - <property name="visible">True</property> <property name="margin_bottom">6</property> <property name="hexpand">True</property> <property name="label">status</property> <property name="ellipsize">middle</property> <property name="max_width_chars">40</property> <property name="xalign">0</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> </child> <child> <object class="GtkProgressBar" id="progress_bar"> - <property name="visible">True</property> <property name="valign">center</property> <property name="margin_start">2</property> <property name="margin_bottom">4</property> <property name="hexpand">True</property> <property name="pulse_step">0.050000000000000003</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> </child> <child> <object class="GtkButton" id="button"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="receives_default">True</property> <property name="valign">center</property> <property name="margin_start">20</property> @@ -59,16 +52,15 @@ <property name="icon-name">window-close-symbolic</property> </object> </child> + <layout> + <property name="column">1</property> + <property name="row">0</property> + <property name="row-span">3</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="height">3</property> - </packing> </child> <child> <object class="GtkLabel" id="details"> - <property name="visible">True</property> <property name="label">label</property> <property name="wrap">True</property> <property name="wrap_mode">word-char</property> @@ -78,13 +70,13 @@ <class name="dim-label"/> </style> <attributes> - <attribute name="font-features" value="tnum"/> + <attribute name="font-features" value="tnum"></attribute> </attributes> + <layout> + <property name="column">0</property> + <property name="row">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> </child> </template> </interface> diff --git a/src/resources/ui/nautilus-properties-window.ui b/src/resources/ui/nautilus-properties-window.ui index b546fdcfe..d53f40325 100644 --- a/src/resources/ui/nautilus-properties-window.ui +++ b/src/resources/ui/nautilus-properties-window.ui @@ -1,1183 +1,1192 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.36.0 --> <interface> - <requires lib="gtk+" version="3.20"/> - <template class="NautilusPropertiesWindow" parent="HdyWindow"> - <property name="can_focus">False</property> + <requires lib="gtk" version="4.0"/> + <template class="NautilusPropertiesWindow" parent="AdwWindow"> + <property name="focusable">False</property> <property name="modal">True</property> - <property name="type_hint">dialog</property> <child> <object class="GtkBox" id="content_box"> - <property name="visible">True</property> <property name="orientation">vertical</property> <child> - <object class="HdyHeaderBar"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_close_button">True</property> - <property name="title" bind-source="NautilusPropertiesWindow" bind-property="title" bind-flags="sync-create"/> - </object> + <object class="AdwHeaderBar"/> </child> <child> <object class="GtkNotebook" id="notebook"> <property name="hexpand">True</property> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="show_border">False</property> <child> - <object class="GtkBox" id="basic_box"> - <property name="visible">True</property> - <property name="margin-top">18</property> - <property name="margin-bottom">18</property> - <property name="margin-start">18</property> - <property name="margin-end">18</property> - <property name="orientation">vertical</property> - <property name="spacing">12</property> - <child> - <object class="GtkStack" id="icon_stack"> - <property name="visible">True</property> - <property name="halign">center</property> - <property name="valign">start</property> + <object class="GtkNotebookPage"> + <property name="tab_expand">True</property> + <property name="child"> + <object class="GtkBox" id="basic_box"> + <property name="margin-top">18</property> + <property name="margin-bottom">18</property> + <property name="margin-start">18</property> + <property name="margin-end">18</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> <child> - <object class="GtkImage" id="icon_image"> - <property name="visible">True</property> - <property name="icon-name">image-missing</property> + <object class="GtkStack" id="icon_stack"> + <property name="halign">center</property> + <property name="valign">start</property> + <child> + <object class="GtkStackPage"> + <property name="name">icon_image</property> + <property name="child"> + <object class="GtkImage" id="icon_image"> + <property name="icon-name">image-missing</property> + </object> + </property> + </object> + </child> + <child> + <object class="GtkStackPage"> + <property name="name">icon_button</property> + <property name="child"> + <object class="GtkButton" id="icon_button"> + <property name="focusable">True</property> + <property name="receives_default">True</property> + <child> + <object class="GtkImage" id="icon_button_image"> + <property name="icon-name">image-missing</property> + </object> + </child> + </object> + </property> + </object> + </child> </object> - <packing> - <property name="name">icon_image</property> - </packing> </child> <child> - <object class="GtkButton" id="icon_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> + <object class="GtkBox" id="grid_box"> + <property name="orientation">vertical</property> <child> - <object class="GtkImage" id="icon_button_image"> - <property name="visible">True</property> - <property name="icon-name">image-missing</property> + <object class="GtkGrid" id="basic_grid"> + <property name="orientation">vertical</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkLabel" id="name_title_label"> + <property name="label" translatable="yes">_Name</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">name_field</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> + </object> + </child> + <child> + <object class="GtkStack" id="name_stack"> + <child> + <object class="GtkStackPage"> + <property name="name">name_value_label</property> + <property name="child"> + <object class="GtkLabel" id="name_value_label"> + <property name="hexpand">True</property> + <property name="selectable">True</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + </object> + </property> + </object> + </child> + <child> + <object class="GtkStackPage"> + <property name="name">name_value_entry</property> + <property name="child"> + <object class="GtkEntry" id="name_field"> + <property name="focusable">True</property> + </object> + </property> + </object> + </child> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="type_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Type</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="type_value_label"> + <property name="visible">False</property> + <property name="hexpand">True</property> + <property name="selectable">True</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="link_target_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Link target</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">2</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="link_target_value_label"> + <property name="visible">False</property> + <property name="hexpand">True</property> + <property name="selectable">True</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">2</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="contents_title_label"> + <property name="visible">False</property> + <property name="valign">start</property> + <property name="label" translatable="yes">Contents</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">3</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="contents_value_label"> + <property name="visible">False</property> + <property name="wrap">True</property> + <property name="selectable">True</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">3</property> + </layout> + </object> + </child> + <child> + <object class="GtkSpinner" id="contents_spinner"> + <property name="visible">False</property> + <layout> + <property name="column">2</property> + <property name="row">3</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="size_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Size</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">4</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="size_value_label"> + <property name="visible">False</property> + <property name="selectable">True</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">4</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="parent_folder_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Parent folder</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">6</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="parent_folder_value_label"> + <property name="visible">False</property> + <property name="hexpand">True</property> + <property name="selectable">True</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">6</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="created_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Created</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">11</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="created_value_label"> + <property name="visible">False</property> + <property name="selectable">True</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">11</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="original_folder_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Original folder</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">12</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="original_folder_value_label"> + <property name="visible">False</property> + <property name="hexpand">True</property> + <property name="selectable">True</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">12</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="volume_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Volume</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">7</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="volume_value_label"> + <property name="visible">False</property> + <property name="hexpand">True</property> + <property name="selectable">True</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">7</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="trashed_on_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Trashed on</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">13</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="trashed_on_value_label"> + <property name="visible">False</property> + <property name="hexpand">True</property> + <property name="selectable">True</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">13</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="accessed_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Accessed</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">9</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="accessed_value_label"> + <property name="visible">False</property> + <property name="selectable">True</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">9</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="modified_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Modified</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">10</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="modified_value_label"> + <property name="visible">False</property> + <property name="selectable">True</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">10</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="free_space_title_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Free space</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">15</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="free_space_value_label"> + <property name="visible">False</property> + <property name="selectable">True</property> + <property name="max_width_chars">24</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">15</property> + </layout> + </object> + </child> + <child> + <object class="GtkBox" id="volume_widget_box"> + <property name="visible">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkGrid" id="volume_grid"> + <property name="hexpand">False</property> + <property name="margin-top">5</property> + <property name="margin-bottom">5</property> + <property name="margin-start">5</property> + <property name="margin-end">5</property> + <property name="row_spacing">10</property> + <property name="column_spacing">10</property> + <child> + <object class="GtkDrawingArea" id="pie_chart"> + <property name="width_request">200</property> + <property name="height_request">200</property> + <style> + <class name="disk-space-display"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">0</property> + <property name="row-span">5</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="spacer_label"> + <property name="vexpand">True</property> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> + </object> + </child> + <child> + <object class="GtkDrawingArea" id="used_color"> + <property name="width_request">20</property> + <property name="height_request">20</property> + <property name="halign">end</property> + <style> + <class name="disk-space-display"/> + <class name="used"/> + </style> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + </object> + </child> + <child> + <object class="GtkDrawingArea" id="free_color"> + <property name="width_request">20</property> + <property name="height_request">20</property> + <property name="halign">end</property> + <property name="vexpand">False</property> + <style> + <class name="disk-space-display"/> + <class name="free"/> + </style> + <layout> + <property name="column">1</property> + <property name="row">2</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="halign">end</property> + <property name="label" translatable="yes">Total capacity</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">1</property> + <property name="row">3</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="halign">end</property> + <property name="label" translatable="yes">Filesystem type</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">1</property> + <property name="row">4</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="total_capacity_value"> + <property name="halign">start</property> + <property name="label">0</property> + <layout> + <property name="column">2</property> + <property name="row">3</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="file_system_value"> + <property name="halign">start</property> + <property name="label">0</property> + <layout> + <property name="column">2</property> + <property name="row">4</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="used_value"> + <property name="halign">end</property> + <property name="vexpand">False</property> + <property name="label">0</property> + <layout> + <property name="column">2</property> + <property name="row">1</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="free_value"> + <property name="halign">end</property> + <property name="label">0</property> + <layout> + <property name="column">2</property> + <property name="row">2</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="halign">start</property> + <property name="label" translatable="yes" comments="Refers to the capacity of the filesystem">used</property> + <layout> + <property name="column">3</property> + <property name="row">1</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="halign">start</property> + <property name="label" translatable="yes" comments="Refers to the capacity of the filesystem">free</property> + <layout> + <property name="column">3</property> + <property name="row">2</property> + </layout> + </object> + </child> + </object> + </child> + <layout> + <property name="column">0</property> + <property name="row">16</property> + <property name="column-span">3</property> + </layout> + </object> + </child> + <child> + <object class="GtkButton" id="open_in_disks_button"> + <property name="visible">False</property> + <property name="label" translatable="yes">Open in Disks</property> + <property name="focusable">True</property> + <property name="receives_default">True</property> + <layout> + <property name="column">0</property> + <property name="row">17</property> + <property name="column-span">3</property> + </layout> + </object> + </child> + <child> + <object class="GtkBox" id="spacer_1"> + <property name="height_request">6</property> + <property name="orientation">vertical</property> + <layout> + <property name="column">0</property> + <property name="row">5</property> + </layout> + </object> + </child> + <child> + <object class="GtkBox" id="spacer_2"> + <property name="visible">False</property> + <property name="height_request">6</property> + <property name="orientation">vertical</property> + <layout> + <property name="column">0</property> + <property name="row">8</property> + </layout> + </object> + </child> + <child> + <object class="GtkBox" id="spacer_3"> + <property name="visible">False</property> + <property name="height_request">6</property> + <property name="orientation">vertical</property> + <layout> + <property name="column">0</property> + <property name="row">14</property> + </layout> + </object> + </child> </object> </child> </object> - <packing> - <property name="name">icon_button</property> - </packing> </child> </object> - </child> - <child> - <object class="GtkBox" id="grid_box"> - <property name="visible">True</property> + </property> + <property name="tab"> + <object class="GtkLabel" id="basic_label"> + <property name="label" translatable="yes">Basic</property> + </object> + </property> + </object> + </child> + <child> + <object class="GtkNotebookPage"> + <property name="tab_expand">True</property> + <property name="child"> + <object class="GtkBox" id="permissions_box"> + <property name="visible">False</property> + <property name="margin-top">18</property> + <property name="margin-bottom">18</property> + <property name="margin-start">18</property> + <property name="margin-end">18</property> <property name="orientation">vertical</property> <child> - <object class="GtkGrid" id="basic_grid"> - <property name="visible">True</property> + <object class="GtkLabel" id="not_the_owner_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">You are not the owner, so you cannot change these permissions.</property> + <property name="justify">center</property> + <property name="wrap">1</property> + <property name="max_width_chars">40</property> + </object> + </child> + <child> + <object class="GtkSeparator" id="bottom_prompt_seperator"> + <property name="visible">False</property> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> + </object> + </child> + <child> + <object class="GtkLabel" id="permission_indeterminable_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">The permissions of the selected file could not be determined.</property> + <property name="justify">center</property> + <property name="wrap">1</property> + <property name="max_width_chars">40</property> + </object> + </child> + <child> + <object class="GtkGrid" id="permissions_grid"> + <property name="visible">False</property> + <property name="halign">center</property> + <property name="vexpand">True</property> <property name="orientation">vertical</property> <property name="row_spacing">6</property> <property name="column_spacing">12</property> <child> - <object class="GtkLabel" id="name_title_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Name</property> + <object class="GtkLabel" id="owner_label"> + <property name="label" translatable="yes">_Owner</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">name_field</property> + <property name="mnemonic_widget">owner_combo_box</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> </child> <child> - <object class="GtkStack" id="name_stack"> - <property name="visible">True</property> + <object class="GtkStack" id="owner_value_stack"> <child> - <object class="GtkLabel" id="name_value_label"> - <property name="visible">True</property> - <property name="hexpand">True</property> - <property name="selectable">True</property> - <property name="ellipsize">end</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> + <object class="GtkStackPage"> + <property name="name">combo_box</property> + <property name="title">page0</property> + <property name="child"> + <object class="GtkComboBox" id="owner_combo_box"> + <property name="halign">start</property> + </object> + </property> </object> - <packing> - <property name="name">name_value_label</property> - </packing> </child> <child> - <object class="GtkEntry" id="name_field"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <object class="GtkStackPage"> + <property name="name">label</property> + <property name="title">page0</property> + <property name="child"> + <object class="GtkLabel" id="owner_value_label"> + <property name="selectable">True</property> + <property name="xalign">0</property> + </object> + </property> </object> - <packing> - <property name="name">name_value_entry</property> - </packing> </child> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> </child> <child> - <object class="GtkLabel" id="type_title_label"> - <property name="label" translatable="yes">Type</property> + <object class="GtkLabel" id="owner_access_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Access</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> </child> <child> - <object class="GtkLabel" id="type_value_label"> - <property name="hexpand">True</property> - <property name="selectable">True</property> - <property name="ellipsize">end</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="link_target_title_label"> - <property name="label" translatable="yes">Link target</property> + <object class="GtkLabel" id="owner_folder_access_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Folder access</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="link_target_value_label"> - <property name="hexpand">True</property> - <property name="selectable">True</property> - <property name="ellipsize">end</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> </child> <child> - <object class="GtkLabel" id="contents_title_label"> - <property name="valign">start</property> - <property name="label" translatable="yes">Contents</property> + <object class="GtkLabel" id="owner_file_access_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">File access</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">3</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - </packing> </child> <child> - <object class="GtkLabel" id="contents_value_label"> - <property name="wrap">True</property> - <property name="selectable">True</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> + <object class="GtkComboBox" id="owner_access_combo"> + <property name="visible">False</property> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + </object> + </child> + <child> + <object class="GtkComboBox" id="owner_folder_access_combo"> + <property name="visible">False</property> + <layout> + <property name="column">1</property> + <property name="row">2</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> </child> <child> - <object class="GtkSpinner" id="contents_spinner"> + <object class="GtkComboBox" id="owner_file_access_combo"> + <property name="visible">False</property> + <layout> + <property name="column">1</property> + <property name="row">3</property> + </layout> </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">3</property> - </packing> </child> <child> - <object class="GtkLabel" id="size_title_label"> - <property name="label" translatable="yes">Size</property> + <object class="GtkLabel" id="group_label"> + <property name="margin_top">12</property> + <property name="label" translatable="yes">_Group</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">group_combo_box</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">5</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">4</property> - </packing> </child> <child> - <object class="GtkLabel" id="size_value_label"> - <property name="selectable">True</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> + <object class="GtkStack" id="group_value_stack"> + <child> + <object class="GtkStackPage"> + <property name="name">combo_box</property> + <property name="title">page0</property> + <property name="child"> + <object class="GtkComboBoxText" id="group_combo_box"> + <property name="halign">start</property> + <property name="margin_top">12</property> + </object> + </property> + </object> + </child> + <child> + <object class="GtkStackPage"> + <property name="name">label</property> + <property name="title">page1</property> + <property name="child"> + <object class="GtkLabel" id="group_value_label"> + <property name="margin_top">12</property> + <property name="selectable">True</property> + <property name="xalign">0</property> + </object> + </property> + </object> + </child> + <layout> + <property name="column">1</property> + <property name="row">5</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">4</property> - </packing> </child> <child> - <object class="GtkLabel" id="parent_folder_title_label"> - <property name="label" translatable="yes">Parent folder</property> + <object class="GtkLabel" id="group_access_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Access</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">6</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">6</property> - </packing> </child> <child> - <object class="GtkLabel" id="parent_folder_value_label"> - <property name="hexpand">True</property> - <property name="selectable">True</property> - <property name="ellipsize">end</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> + <object class="GtkLabel" id="group_folder_access_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Folder access</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">7</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">6</property> - </packing> </child> <child> - <object class="GtkLabel" id="created_title_label"> - <property name="label" translatable="yes">Created</property> + <object class="GtkLabel" id="group_file_access_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">File access</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">8</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">11</property> - </packing> </child> <child> - <object class="GtkLabel" id="created_value_label"> - <property name="selectable">True</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> + <object class="GtkComboBox" id="group_access_combo"> + <property name="visible">False</property> + <layout> + <property name="column">1</property> + <property name="row">6</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">11</property> - </packing> </child> <child> - <object class="GtkLabel" id="original_folder_title_label"> - <property name="label" translatable="yes">Original folder</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> + <object class="GtkComboBox" id="group_folder_access_combo"> + <property name="visible">False</property> + <layout> + <property name="column">1</property> + <property name="row">7</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">12</property> - </packing> </child> <child> - <object class="GtkLabel" id="original_folder_value_label"> - <property name="hexpand">True</property> - <property name="selectable">True</property> - <property name="ellipsize">end</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> + <object class="GtkComboBox" id="group_file_access_combo"> + <property name="visible">False</property> + <layout> + <property name="column">1</property> + <property name="row">8</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">12</property> - </packing> </child> <child> - <object class="GtkLabel" id="volume_title_label"> - <property name="label" translatable="yes">Volume</property> + <object class="GtkLabel" id="others_label"> + <property name="margin_top">12</property> + <property name="label" translatable="yes">Others</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">10</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">7</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="volume_value_label"> - <property name="hexpand">True</property> - <property name="selectable">True</property> - <property name="ellipsize">end</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">7</property> - </packing> </child> <child> - <object class="GtkLabel" id="trashed_on_title_label"> - <property name="label" translatable="yes">Trashed on</property> + <object class="GtkLabel" id="others_access_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Access</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">11</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">13</property> - </packing> </child> <child> - <object class="GtkLabel" id="trashed_on_value_label"> - <property name="hexpand">True</property> - <property name="selectable">True</property> - <property name="ellipsize">end</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> + <object class="GtkLabel" id="others_folder_access_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">Folder access</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + <layout> + <property name="column">0</property> + <property name="row">12</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">13</property> - </packing> </child> <child> - <object class="GtkLabel" id="accessed_title_label"> - <property name="label" translatable="yes">Accessed</property> + <object class="GtkLabel" id="others_file_access_label"> + <property name="visible">False</property> + <property name="label" translatable="yes">File access</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">13</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">9</property> - </packing> </child> <child> - <object class="GtkLabel" id="accessed_value_label"> - <property name="selectable">True</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> + <object class="GtkComboBox" id="others_access_combo"> + <property name="visible">False</property> + <layout> + <property name="column">1</property> + <property name="row">11</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">9</property> - </packing> </child> <child> - <object class="GtkLabel" id="modified_title_label"> - <property name="label" translatable="yes">Modified</property> + <object class="GtkComboBox" id="others_folder_access_combo"> + <property name="visible">False</property> + <layout> + <property name="column">1</property> + <property name="row">12</property> + </layout> + </object> + </child> + <child> + <object class="GtkComboBox" id="others_file_access_combo"> + <property name="visible">False</property> + <layout> + <property name="column">1</property> + <property name="row">13</property> + </layout> + </object> + </child> + <child> + <object class="GtkLabel" id="execute_label"> + <property name="visible">False</property> + <property name="margin_top">12</property> + <property name="label" translatable="yes">Execute</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">15</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">10</property> - </packing> </child> <child> - <object class="GtkLabel" id="modified_value_label"> - <property name="selectable">True</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">10</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="free_space_title_label"> - <property name="label" translatable="yes">Free space</property> + <object class="GtkLabel" id="security_context_title_label"> + <property name="visible">False</property> + <property name="margin_top">12</property> + <property name="label" translatable="yes">Security context</property> <property name="xalign">1</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">17</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">15</property> - </packing> </child> <child> - <object class="GtkLabel" id="free_space_value_label"> + <object class="GtkLabel" id="security_context_value_label"> + <property name="visible">False</property> + <property name="margin_top">12</property> <property name="selectable">True</property> <property name="max_width_chars">24</property> <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">17</property> + </layout> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">15</property> - </packing> </child> <child> - <object class="GtkBox" id="volume_widget_box"> - <property name="orientation">vertical</property> + <object class="GtkBox" id="change_permissions_button_box"> + <property name="visible">False</property> + <property name="margin_top">12</property> <child> - <object class="GtkGrid" id="volume_grid"> - <property name="visible">True</property> - <property name="hexpand">False</property> - <property name="margin-top">5</property> - <property name="margin-bottom">5</property> - <property name="margin-start">5</property> - <property name="margin-end">5</property> - <property name="row_spacing">10</property> - <property name="column_spacing">10</property> - <child> - <object class="GtkDrawingArea" id="pie_chart"> - <property name="width_request">200</property> - <property name="height_request">200</property> - <property name="visible">True</property> - <style> - <class name="disk-space-display"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="height">5</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="spacer_label"> - <property name="visible">True</property> - <property name="vexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkDrawingArea" id="used_color"> - <property name="width_request">20</property> - <property name="height_request">20</property> - <property name="visible">True</property> - <property name="halign">end</property> - <style> - <class name="disk-space-display"/> - <class name="used"/> - </style> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkDrawingArea" id="free_color"> - <property name="width_request">20</property> - <property name="height_request">20</property> - <property name="visible">True</property> - <property name="halign">end</property> - <property name="vexpand">False</property> - <style> - <class name="disk-space-display"/> - <class name="free"/> - </style> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="halign">end</property> - <property name="label" translatable="yes">Total capacity</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="halign">end</property> - <property name="label" translatable="yes">Filesystem type</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="total_capacity_value"> - <property name="visible">True</property> - <property name="halign">start</property> - <property name="label">0</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="file_system_value"> - <property name="visible">True</property> - <property name="halign">start</property> - <property name="label">0</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="used_value"> - <property name="visible">True</property> - <property name="halign">end</property> - <property name="vexpand">False</property> - <property name="label">0</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="free_value"> - <property name="visible">True</property> - <property name="halign">end</property> - <property name="label">0</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="halign">start</property> - <property name="label" translatable="yes" comments="Refers to the capacity of the filesystem">used</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="halign">start</property> - <property name="label" translatable="yes" comments="Refers to the capacity of the filesystem">free</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">2</property> - </packing> - </child> + <object class="GtkButton" id="change_permissions_button"> + <property name="label" translatable="yes">Change Permissions for Enclosed Files…</property> + <property name="focusable">True</property> + <property name="receives_default">True</property> </object> </child> + <layout> + <property name="column">0</property> + <property name="row">19</property> + <property name="column-span">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">16</property> - <property name="width">3</property> - </packing> - </child> - <child> - <object class="GtkButton" id="open_in_disks_button"> - <property name="label" translatable="yes">Open in Disks</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">17</property> - <property name="width">3</property> - </packing> </child> <child> - <object class="GtkBox" id="spacer_1"> - <property name="height_request">6</property> - <property name="visible">True</property> - <property name="orientation">vertical</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">5</property> - </packing> - </child> - <child> - <object class="GtkBox" id="spacer_2"> - <property name="height_request">6</property> - <property name="orientation">vertical</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">8</property> - </packing> - </child> - <child> - <object class="GtkBox" id="spacer_3"> - <property name="height_request">6</property> - <property name="orientation">vertical</property> + <object class="GtkCheckButton" id="execute_checkbox"> + <property name="visible">False</property> + <property name="label" translatable="yes">Allow _executing file as program</property> + <property name="use_underline">True</property> + <property name="focusable">True</property> + <property name="margin_top">12</property> + <layout> + <property name="column">1</property> + <property name="row">15</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">14</property> - </packing> </child> </object> </child> </object> - </child> - </object> - <packing> - <property name="tab_expand">True</property> - </packing> - </child> - <child type="tab"> - <object class="GtkLabel" id="basic_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Basic</property> + </property> + <property name="tab"> + <object class="GtkLabel" id="permissions_label"> + <property name="label" translatable="yes">Permissions</property> + </object> + </property> </object> - <packing> - <property name="tab_fill">False</property> - </packing> </child> <child> - <object class="GtkBox" id="permissions_box"> - <property name="margin-top">18</property> - <property name="margin-bottom">18</property> - <property name="margin-start">18</property> - <property name="margin-end">18</property> - <property name="orientation">vertical</property> - <child> - <object class="GtkLabel" id="not_the_owner_label"> - <property name="label" translatable="yes">You are not the owner, so you cannot change these permissions.</property> - <property name="justify">center</property> - <property name="wrap">True</property> - <property name="max_width_chars">40</property> - </object> - <packing> - <property name="pack_type">end</property> - </packing> - </child> - <child> - <object class="GtkSeparator" id="bottom_prompt_seperator"> - <property name="margin-top">12</property> - <property name="margin-bottom">12</property> - </object> - <packing> - <property name="pack_type">end</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="permission_indeterminable_label"> - <property name="label" translatable="yes">The permissions of the selected file could not be determined.</property> - <property name="justify">center</property> - <property name="wrap">True</property> - <property name="max_width_chars">40</property> - </object> - </child> - <child> - <object class="GtkGrid" id="permissions_grid"> - <property name="halign">center</property> - <property name="vexpand">True</property> + <object class="GtkNotebookPage"> + <property name="tab_expand">True</property> + <property name="child"> + <object class="GtkBox" id="open_with_box"> + <property name="visible">False</property> + <property name="margin-top">18</property> + <property name="margin-bottom">18</property> + <property name="margin-start">18</property> + <property name="margin-end">18</property> <property name="orientation">vertical</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - <child> - <object class="GtkLabel" id="owner_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Owner</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">owner_combo_box</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkStack" id="owner_value_stack"> - <property name="visible">True</property> - <child> - <object class="GtkComboBox" id="owner_combo_box"> - <property name="visible">True</property> - <property name="halign">start</property> - </object> - <packing> - <property name="name">combo_box</property> - <property name="title">page0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="owner_value_label"> - <property name="visible">True</property> - <property name="selectable">True</property> - <property name="xalign">0</property> - </object> - <packing> - <property name="name">label</property> - <property name="title">page0</property> - </packing> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="owner_access_label"> - <property name="label" translatable="yes">Access</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="owner_folder_access_label"> - <property name="label" translatable="yes">Folder access</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="owner_file_access_label"> - <property name="label" translatable="yes">File access</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="owner_access_combo"> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="owner_folder_access_combo"> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> + <property name="spacing">6</property> <child> - <object class="GtkComboBox" id="owner_file_access_combo"> + <object class="GtkLabel" id="open_with_label"> + <property name="wrap">1</property> + <property name="wrap_mode">word-char</property> + <property name="max_width_chars">30</property> + <property name="xalign">0</property> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> </child> <child> - <object class="GtkLabel" id="group_label"> - <property name="visible">True</property> - <property name="margin_top">12</property> - <property name="label" translatable="yes">_Group</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">group_combo_box</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> + <object class="GtkBox" id="app_chooser_widget_box"> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">5</property> - </packing> </child> <child> - <object class="GtkStack" id="group_value_stack"> - <property name="visible">True</property> + <object class="GtkBox"> + <property name="spacing">6</property> <child> - <object class="GtkComboBoxText" id="group_combo_box"> - <property name="visible">True</property> + <object class="GtkButton" id="reset_button"> + <property name="label" translatable="yes">Reset</property> + <property name="focusable">True</property> + <property name="receives_default">True</property> + <property name="hexpand">True</property> <property name="halign">start</property> - <property name="margin_top">12</property> </object> - <packing> - <property name="name">combo_box</property> - <property name="title">page0</property> - </packing> </child> <child> - <object class="GtkLabel" id="group_value_label"> - <property name="visible">True</property> - <property name="margin_top">12</property> - <property name="selectable">True</property> - <property name="xalign">0</property> + <object class="GtkButton" id="forget_button"> + <property name="label" translatable="yes">_Forget</property> + <property name="focusable">True</property> + <property name="receives_default">True</property> + <property name="use_underline">True</property> </object> - <packing> - <property name="name">label</property> - <property name="title">page1</property> - </packing> </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">5</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="group_access_label"> - <property name="label" translatable="yes">Access</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">6</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="group_folder_access_label"> - <property name="label" translatable="yes">Folder access</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">7</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="group_file_access_label"> - <property name="label" translatable="yes">File access</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">8</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="group_access_combo"> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">6</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="group_folder_access_combo"> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">7</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="group_file_access_combo"> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">8</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="others_label"> - <property name="visible">True</property> - <property name="margin_top">12</property> - <property name="label" translatable="yes">Others</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">10</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="others_access_label"> - <property name="label" translatable="yes">Access</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">11</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="others_folder_access_label"> - <property name="label" translatable="yes">Folder access</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">12</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="others_file_access_label"> - <property name="label" translatable="yes">File access</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">13</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="others_access_combo"> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">11</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="others_folder_access_combo"> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">12</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="others_file_access_combo"> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">13</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="execute_label"> - <property name="margin_top">12</property> - <property name="label" translatable="yes">Execute</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">15</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="security_context_title_label"> - <property name="margin_top">12</property> - <property name="label" translatable="yes">Security context</property> - <property name="xalign">1</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">17</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="security_context_value_label"> - <property name="margin_top">12</property> - <property name="selectable">True</property> - <property name="max_width_chars">24</property> - <property name="xalign">0</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">17</property> - </packing> - </child> - <child> - <object class="GtkBox" id="change_permissions_button_box"> - <property name="margin_top">12</property> <child> - <object class="GtkButton" id="change_permissions_button"> - <property name="label" translatable="yes">Change Permissions for Enclosed Files…</property> - <property name="can_focus">True</property> + <object class="GtkButton" id="add_button"> + <property name="label" translatable="yes">_Add</property> + <property name="focusable">True</property> + <property name="receives_default">True</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkButton" id="set_as_default_button"> + <property name="label" translatable="yes">Set as default</property> + <property name="focusable">True</property> <property name="receives_default">True</property> </object> </child> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">19</property> - <property name="width">2</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="execute_checkbox"> - <property name="label" translatable="yes">Allow _executing file as program</property> - <property name="use_underline">True</property> - <property name="can_focus">True</property> - <property name="margin_top">12</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">15</property> - </packing> </child> </object> - </child> - </object> - <packing> - <property name="tab_expand">True</property> - </packing> - </child> - <child type="tab"> - <object class="GtkLabel" id="permissions_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Permissions</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - <child> - <object class="GtkBox" id="open_with_box"> - <property name="margin-top">18</property> - <property name="margin-bottom">18</property> - <property name="margin-start">18</property> - <property name="margin-end">18</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="open_with_label"> - <property name="visible">True</property> - <property name="wrap">True</property> - <property name="wrap_mode">word-char</property> - <property name="max_width_chars">30</property> - <property name="xalign">0</property> - </object> - </child> - <child> - <object class="GtkBox" id="app_chooser_widget_box"> - <property name="vexpand">True</property> - <property name="visible">True</property> - <property name="orientation">vertical</property> + </property> + <property name="tab"> + <object class="GtkLabel"> + <property name="label" translatable="yes">Open With</property> </object> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <object class="GtkButton" id="reset_button"> - <property name="label" translatable="yes">Reset</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="hexpand">True</property> - <property name="halign">start</property> - </object> - </child> - <child> - <object class="GtkButton" id="forget_button"> - <property name="label" translatable="yes">_Forget</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_underline">True</property> - </object> - </child> - <child> - <object class="GtkButton" id="add_button"> - <property name="label" translatable="yes">_Add</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_underline">True</property> - </object> - </child> - <child> - <object class="GtkButton" id="set_as_default_button"> - <property name="label" translatable="yes">Set as default</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - </child> - </object> - </child> + </property> </object> - <packing> - <property name="tab_expand">True</property> - </packing> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Open With</property> - </object> - <packing> - <property name="tab_fill">False</property> - </packing> - </child> - <child type="tab"> </child> </object> </child> diff --git a/src/resources/ui/nautilus-rename-file-popover.ui b/src/resources/ui/nautilus-rename-file-popover.ui index 253d2fed2..766433a2c 100644 --- a/src/resources/ui/nautilus-rename-file-popover.ui +++ b/src/resources/ui/nautilus-rename-file-popover.ui @@ -1,12 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.38.2 --> <interface> - <requires lib="gtk+" version="3.20"/> + <requires lib="gtk" version="4.0"/> <object class="GtkPopover" id="rename_file_popover"> - <property name="position">bottom</property> - <child> + <property name="child"> <object class="GtkBox"> - <property name="visible">True</property> <property name="margin-start">18</property> <property name="margin-end">18</property> <property name="margin-top">18</property> @@ -14,7 +11,6 @@ <property name="orientation">vertical</property> <child> <object class="GtkLabel" id="title_label"> - <property name="visible">True</property> <property name="margin-bottom">12</property> <style> <class name="title-2"/> @@ -23,32 +19,27 @@ </child> <child> <object class="GtkEntry" id="name_entry"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="can-default">True</property> + <property name="focusable">True</property> <property name="margin-bottom">12</property> </object> </child> <child> <object class="GtkRevealer" id="error_revealer"> - <property name="visible">True</property> - <child> + <property name="child"> <object class="GtkLabel" id="error_label"> - <property name="visible">True</property> <property name="margin-bottom">12</property> <property name="max-width-chars">0</property> <property name="wrap">True</property> <property name="xalign">0</property> </object> - </child> + </property> </object> </child> <child> <object class="GtkButton" id="rename_button"> <property name="label" translatable="yes">_Rename</property> - <property name="visible">True</property> <property name="sensitive">False</property> - <property name="can-focus">True</property> + <property name="focusable">True</property> <property name="halign">end</property> <property name="use-underline">True</property> <style> @@ -57,6 +48,6 @@ </object> </child> </object> - </child> + </property> </object> </interface> diff --git a/src/resources/ui/nautilus-search-popover.ui b/src/resources/ui/nautilus-search-popover.ui index 3ec0da3cf..9efaac63e 100644 --- a/src/resources/ui/nautilus-search-popover.ui +++ b/src/resources/ui/nautilus-search-popover.ui @@ -1,12 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.16"/> + <requires lib="gtk" version="4.0"/> <template class="NautilusSearchPopover" parent="GtkPopover"> - <property name="can_focus">False</property> - <property name="modal">True</property> - <child> - <object class="GtkGrid" > - <property name="visible">True</property> + <property name="child"> + <object class="GtkGrid"> <property name="margin-top">20</property> <property name="margin-bottom">20</property> <property name="margin-start">20</property> @@ -15,296 +12,272 @@ <property name="column_spacing">18</property> <child> <object class="GtkLabel" id="when_dim_label"> - <property name="visible">True</property> <property name="label" translatable="yes">When</property> <property name="xalign">0</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">0</property> + <property name="column-span">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">2</property> - </packing> </child> <child> <object class="GtkStack" id="date_stack"> - <property name="visible">True</property> <property name="transition_type">crossfade</property> <property name="transition_duration">250</property> <child> - <object class="GtkBox"> - <property name="visible">True</property> - <child> - <object class="GtkButton" id="select_date_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="tooltip_text" translatable="yes">Select a date</property> - <property name="hexpand">True</property> + <object class="GtkStackPage"> + <property name="name">date-button</property> + <property name="child"> + <object class="GtkBox"> <child> - <object class="GtkLabel" id="select_date_button_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Select Dates…</property> - <property name="xalign">0</property> + <object class="GtkButton" id="select_date_button"> + <property name="focusable">True</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Select a date</property> + <property name="hexpand">True</property> + <child> + <object class="GtkLabel" id="select_date_button_label"> + <property name="label" translatable="yes">Select Dates…</property> + <property name="xalign">0</property> + </object> + </child> + <signal name="clicked" handler="select_date_button_clicked" object="NautilusSearchPopover" swapped="no"/> </object> </child> - <signal name="clicked" handler="select_date_button_clicked" object="NautilusSearchPopover" swapped="no" /> - </object> - </child> - <child> - <object class="GtkButton" id="clear_date_button"> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="tooltip_text" translatable="yes">Clear the currently selected date</property> - <signal name="clicked" handler="clear_date_button_clicked" object="NautilusSearchPopover" swapped="no" /> <child> - <object class="GtkImage" id="clear_date_button_image"> - <property name="visible">True</property> - <property name="icon_name">edit-clear-symbolic</property> + <object class="GtkButton" id="clear_date_button"> + <property name="visible">False</property> + <property name="focusable">True</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Clear the currently selected date</property> + <signal name="clicked" handler="clear_date_button_clicked" object="NautilusSearchPopover" swapped="no"/> + <child> + <object class="GtkImage" id="clear_date_button_image"> + <property name="icon_name">edit-clear-symbolic</property> + </object> + </child> </object> </child> + <style> + <class name="linked"/> + </style> </object> - </child> - <style> - <class name="linked"/> - </style> + </property> </object> - <packing> - <property name="name">date-button</property> - </packing> </child> <child> - <object class="GtkEntry" id="date_entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="secondary_icon_name">x-office-calendar-symbolic</property> - <property name="secondary_icon_tooltip_text" translatable="yes">Show a calendar to select the date</property> - <signal name="icon-release" handler="toggle_calendar_icon_clicked" object="NautilusSearchPopover" swapped="no" /> - <signal name="activate" handler="date_entry_activate" object="NautilusSearchPopover" swapped="no" /> - </object> - <packing> + <object class="GtkStackPage"> <property name="name">date-entry</property> - </packing> + <property name="child"> + <object class="GtkEntry" id="date_entry"> + <property name="focusable">True</property> + <property name="secondary_icon_name">x-office-calendar-symbolic</property> + <property name="secondary_icon_tooltip_text" translatable="yes">Show a calendar to select the date</property> + <signal name="icon-release" handler="toggle_calendar_icon_clicked" object="NautilusSearchPopover" swapped="no"/> + <signal name="activate" handler="date_entry_activate" object="NautilusSearchPopover" swapped="no"/> + </object> + </property> + </object> </child> + <layout> + <property name="column">0</property> + <property name="row">1</property> + <property name="column-span">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">2</property> - </packing> </child> <child> <object class="GtkRevealer" id="around_revealer"> - <property name="transition_type">slide-down</property> - <child> + <property name="child"> <object class="GtkGrid"> - <property name="visible">True</property> <property name="row_spacing">8</property> <property name="column_spacing">12</property> <child> <object class="GtkLabel" id="around_dim_label"> - <property name="visible">True</property> <property name="margin_top">10</property> <property name="label" translatable="yes">Since…</property> <property name="xalign">0</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">0</property> + <property name="column-span">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">2</property> - </packing> </child> <child> <object class="GtkStack" id="around_stack"> - <property name="visible">True</property> <property name="vhomogeneous">False</property> <property name="transition_type">crossfade</property> <property name="transition_duration">250</property> <child> - <object class="GtkScrolledWindow"> - <property name="height_request">200</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkViewport"> - <property name="visible">True</property> - <child> - <object class="GtkListBox" id="dates_listbox"> - <property name="visible">True</property> - <property name="selection_mode">none</property> - <signal name="row-activated" handler="dates_listbox_row_activated" object="NautilusSearchPopover" swapped="no" /> + <object class="GtkStackPage"> + <property name="name">date-list</property> + <property name="child"> + <object class="GtkScrolledWindow"> + <property name="height_request">200</property> + <property name="focusable">True</property> + <property name="hexpand">True</property> + <property name="child"> + <object class="GtkViewport"> + <property name="child"> + <object class="GtkListBox" id="dates_listbox"> + <property name="selection_mode">none</property> + <signal name="row-activated" handler="dates_listbox_row_activated" object="NautilusSearchPopover" swapped="no"/> + </object> + </property> </object> - </child> + </property> </object> - </child> + </property> </object> - <packing> - <property name="name">date-list</property> - </packing> </child> <child> - <object class="GtkCalendar" id="calendar"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="valign">start</property> - <property name="show_week_numbers">True</property> - </object> - <packing> + <object class="GtkStackPage"> <property name="name">date-calendar</property> - </packing> + <property name="child"> + <object class="GtkCalendar" id="calendar"> + <property name="focusable">True</property> + <property name="valign">start</property> + <property name="show_week_numbers">True</property> + </object> + </property> + </object> </child> + <layout> + <property name="column">0</property> + <property name="row">1</property> + <property name="column-span">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">2</property> - </packing> </child> <child> - <object class="GtkRadioButton" id="last_modified_button"> + <object class="GtkCheckButton" id="last_modified_button"> <property name="label" translatable="yes">Last _modified</property> - <property name="visible">True</property> - <property name="can_focus">True</property> <property name="use_underline">True</property> <property name="active">True</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="search_time_type_changed" object="NautilusSearchPopover" swapped="no" /> + <signal name="toggled" handler="search_time_type_changed" object="NautilusSearchPopover" swapped="no"/> + <layout> + <property name="column">0</property> + <property name="row">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> </child> <child> - <object class="GtkRadioButton" id="last_used_button"> + <object class="GtkCheckButton" id="last_used_button"> <property name="label" translatable="yes">Last _used</property> - <property name="visible">True</property> - <property name="can_focus">True</property> <property name="use_underline">True</property> - <property name="draw_indicator">True</property> <property name="group">last_modified_button</property> - <signal name="toggled" handler="search_time_type_changed" object="NautilusSearchPopover" swapped="no" /> + <signal name="toggled" handler="search_time_type_changed" object="NautilusSearchPopover" swapped="no"/> + <layout> + <property name="column">0</property> + <property name="row">3</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - </packing> </child> - <child> - <object class="GtkRadioButton" id="created_button"> - <property name="label" translatable="yes">Created</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="use-underline">True</property> - <property name="xalign">0</property> - <property name="draw-indicator">True</property> - <property name="group">last_modified_button</property> - <signal name="toggled" handler="search_time_type_changed" object="NautilusSearchPopover" swapped="no"/> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">4</property> - </packing> + <child> + <object class="GtkCheckButton" id="created_button"> + <property name="label" translatable="yes">Created</property> + <property name="use-underline">True</property> + <property name="group">last_modified_button</property> + <signal name="toggled" handler="search_time_type_changed" object="NautilusSearchPopover" swapped="no"/> + <layout> + <property name="column">0</property> + <property name="row">4</property> + </layout> + </object> </child> </object> - </child> + </property> + <layout> + <property name="column">0</property> + <property name="row">2</property> + <property name="column-span">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - <property name="width">2</property> - </packing> </child> <child> <object class="GtkLabel" id="what_dim_label"> - <property name="visible">True</property> <property name="margin_top">10</property> <property name="label" translatable="yes">What</property> <property name="xalign">0</property> <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">3</property> + <property name="column-span">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - <property name="width">2</property> - </packing> </child> <child> <object class="GtkStack" id="type_stack"> - <property name="visible">True</property> <property name="vhomogeneous">False</property> <property name="transition_type">crossfade</property> <property name="transition_duration">250</property> <child> - <object class="GtkButton" id="select_type_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="tooltip_text" translatable="yes">Which file types will be searched</property> - <signal name="clicked" handler="select_type_button_clicked" object="NautilusSearchPopover" swapped="no" /> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <child> - <object class="GtkLabel" id="type_label"> - <property name="visible">True</property> - <property name="hexpand">True</property> - <property name="label" translatable="yes">Anything</property> - <property name="width_chars">30</property> - <property name="xalign">0</property> - </object> - </child> + <object class="GtkStackPage"> + <property name="name">type-button</property> + <property name="child"> + <object class="GtkButton" id="select_type_button"> + <property name="focusable">True</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Which file types will be searched</property> + <signal name="clicked" handler="select_type_button_clicked" object="NautilusSearchPopover" swapped="no"/> <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon_name">pan-down-symbolic</property> + <object class="GtkBox"> + <child> + <object class="GtkLabel" id="type_label"> + <property name="hexpand">True</property> + <property name="label" translatable="yes">Anything</property> + <property name="width_chars">30</property> + <property name="xalign">0</property> + </object> + </child> + <child> + <object class="GtkImage"> + <property name="icon_name">pan-down-symbolic</property> + </object> + </child> </object> </child> </object> - </child> + </property> </object> - <packing> - <property name="name">type-button</property> - </packing> </child> <child> - <object class="GtkScrolledWindow"> - <property name="height_request">250</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkViewport"> - <property name="visible">True</property> - <child> - <object class="GtkListBox" id="type_listbox"> - <property name="visible">True</property> - <property name="selection_mode">single</property> - <signal name="row-activated" handler="types_listbox_row_activated" object="NautilusSearchPopover" swapped="no" /> + <object class="GtkStackPage"> + <property name="name">type-list</property> + <property name="child"> + <object class="GtkScrolledWindow"> + <property name="height_request">250</property> + <property name="focusable">True</property> + <property name="child"> + <object class="GtkViewport"> + <property name="child"> + <object class="GtkListBox" id="type_listbox"> + <signal name="row-activated" handler="types_listbox_row_activated" object="NautilusSearchPopover" swapped="no"/> + </object> + </property> </object> - </child> + </property> </object> - </child> + </property> </object> - <packing> - <property name="name">type-list</property> - </packing> </child> + <layout> + <property name="column">0</property> + <property name="row">4</property> + <property name="column-span">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">4</property> - <property name="width">2</property> - </packing> </child> <child> <object class="GtkLabel" id="search_dim_label"> @@ -314,54 +287,47 @@ <style> <class name="dim-label"/> </style> + <layout> + <property name="column">0</property> + <property name="row">5</property> + <property name="column-span">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">5</property> - <property name="width">2</property> - </packing> </child> <child> <object class="GtkBox"> <property name="hexpand">True</property> - <property name="visible">True</property> <child> - <object class="GtkRadioButton" id="full_text_search_button"> + <object class="GtkToggleButton" id="full_text_search_button"> <property name="label" translatable="yes">Full Text</property> - <property name="visible">True</property> - <property name="can_focus">True</property> <property name="tooltip_text" translatable="yes">Search on the file content and name</property> <property name="hexpand">True</property> <property name="active">True</property> - <property name="draw_indicator">False</property> <signal name="toggled" handler="search_fts_mode_changed" object="NautilusSearchPopover" swapped="no" /> </object> </child> <child> - <object class="GtkRadioButton" id="filename_search_button"> + <object class="GtkToggleButton" id="filename_search_button"> <property name="label" translatable="yes">File Name</property> - <property name="visible">True</property> - <property name="can_focus">True</property> <property name="tooltip_text" translatable="yes">Search only on the file name</property> <property name="hexpand">True</property> - <property name="draw_indicator">False</property> <property name="group">full_text_search_button</property> <property name="active">True</property> - <signal name="toggled" handler="search_fts_mode_changed" object="NautilusSearchPopover" swapped="no" /> + <signal name="toggled" handler="search_fts_mode_changed" object="NautilusSearchPopover" swapped="no"/> </object> </child> <style> <class name="linked"/> </style> + <layout> + <property name="column">0</property> + <property name="row">6</property> + <property name="column-span">2</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">6</property> - <property name="width">2</property> - </packing> </child> </object> - </child> + </property> </template> <object class="GtkSizeGroup"> <property name="mode">vertical</property> @@ -373,7 +339,6 @@ </widgets> </object> <object class="GtkSizeGroup"> - <property name="mode">horizontal</property> <widgets> <widget name="search_dim_label"/> <widget name="when_dim_label"/> diff --git a/src/resources/ui/nautilus-starred-is-empty.ui b/src/resources/ui/nautilus-starred-is-empty.ui index b91ceb30c..8747fcbb3 100644 --- a/src/resources/ui/nautilus-starred-is-empty.ui +++ b/src/resources/ui/nautilus-starred-is-empty.ui @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.0 --> <interface> - <requires lib="gtk+" version="3.20"/> + <requires lib="gtk" version="4.0"/> <object class="GtkGrid" id="starred_is_empty"> <property name="halign">center</property> <property name="valign">center</property> @@ -11,31 +10,29 @@ <property name="visible">False</property> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="pixel_size">128</property> <property name="icon_name">starred-symbolic</property> <style> <class name="dim-label"/> <class name="nautilus-empty-state-icon"/> </style> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">Starred files will appear here</property> <style> <class name="large-title"/> </style> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> </child> </object> </interface> diff --git a/src/resources/ui/nautilus-toolbar-view-menu.ui b/src/resources/ui/nautilus-toolbar-view-menu.ui index 265aec606..a951047cf 100644 --- a/src/resources/ui/nautilus-toolbar-view-menu.ui +++ b/src/resources/ui/nautilus-toolbar-view-menu.ui @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.0 --> <interface> + <requires lib="gtk" version="4.0"/> <menu id="zoom_section"> <item> <attribute name="label" translatable="yes">Zoom out</attribute> diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui index 4fd29b400..e9a101029 100644 --- a/src/resources/ui/nautilus-toolbar.ui +++ b/src/resources/ui/nautilus-toolbar.ui @@ -1,15 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.0 --> <interface> - <requires lib="gtk+" version="3.22"/> - <object class="GtkPopover" id="back_menu"> - <property name="position">bottom</property> - <property name="relative-to">back_button</property> - </object> - <object class="GtkPopover" id="forward_menu"> - <property name="position">bottom</property> - <property name="relative-to">forward_button</property> - </object> + <requires lib="gtk" version="4.0"/> + <object class="GtkPopoverMenu" id="back_menu"/> + <object class="GtkPopoverMenu" id="forward_menu"/> <menu id="view_menu"> <section> <attribute name="display-hint">horizontal-buttons</attribute> @@ -109,16 +102,13 @@ </section> </menu> <object class="GtkPopover" id="operations_popover"> - <property name="can_focus">False</property> - <child> + <property name="child"> <object class="GtkScrolledWindow"> - <property name="visible">True</property> <property name="hscrollbar_policy">never</property> <property name="max_content_height">270</property> <property name="propagate_natural_height">True</property> - <child> + <property name="child"> <object class="GtkListBox" id="operations_list"> - <property name="visible">True</property> <property name="margin_start">6</property> <property name="margin_end">6</property> <property name="margin_top">6</property> @@ -129,68 +119,66 @@ <class name="operations-list"/> </style> </object> - </child> + </property> </object> - </child> + </property> <signal name="notify::visible" handler="on_operations_popover_notify_visible" object="NautilusToolbar" swapped="yes"/> </object> - <template class="NautilusToolbar" parent="GtkBin"> - <property name="visible">True</property> + <template class="NautilusToolbar" parent="AdwBin"> <child> - <object class="HdyHeaderBar"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_close_button">True</property> + <object class="AdwHeaderBar"> + <property name="focusable">False</property> <child type="title"> <object class="GtkBox" id="header_toolbar"> <property name="width_request">270</property> - <property name="visible">True</property> <property name="spacing">6</property> <child> <object class="GtkStack" id="toolbar_switcher"> - <property name="visible">True</property> <property name="valign">center</property> <property name="transition_type">crossfade</property> <child> - <object class="GtkBox" id="path_bar_container"> - <property name="valign">center</property> - </object> - <packing> + <object class="GtkStackPage"> <property name="name">pathbar</property> - </packing> + <property name="child"> + <object class="GtkBox" id="path_bar_container"> + <property name="valign">center</property> + </object> + </property> + </object> </child> <child> - <object class="GtkBox" id="location_entry_container"> - <style> - <class name="linked"/> - </style> - </object> - <packing> + <object class="GtkStackPage"> <property name="name">location</property> - </packing> + <property name="child"> + <object class="GtkBox" id="location_entry_container"> + <style> + <class name="linked"/> + </style> + </object> + </property> + </object> </child> <child> - <object class="GtkBox" id="search_container"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - </object> - <packing> + <object class="GtkStackPage"> <property name="name">search</property> - </packing> + <property name="child"> + <object class="GtkBox" id="search_container"> + <property name="orientation">vertical</property> + </object> + </property> + </object> </child> </object> </child> <child> <object class="GtkToggleButton" id="search_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="tooltip_text" translatable="yes">Search</property> <property name="halign">center</property> <property name="valign">center</property> <property name="action_name">slot.search-visible</property> <child> <object class="GtkImage" id="search_icon"> - <property name="visible">True</property> <property name="icon_name">edit-find-symbolic</property> <property name="icon_size">1</property> </object> @@ -202,20 +190,17 @@ </child> </object> </child> - <child> + <child type="start"> <object class="GtkBox" id="navigation_box"> - <property name="visible">True</property> <child> <object class="GtkButton" id="back_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="tooltip_text" translatable="yes">Go back</property> <property name="halign">center</property> <property name="valign">center</property> <property name="action_name">win.back</property> <child> <object class="GtkImage" id="back_icon"> - <property name="visible">True</property> <property name="icon_name">go-previous-symbolic</property> <property name="icon_size">1</property> </object> @@ -227,15 +212,13 @@ </child> <child> <object class="GtkButton" id="forward_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="tooltip_text" translatable="yes">Go forward</property> <property name="halign">center</property> <property name="valign">center</property> <property name="action_name">win.forward</property> <child> <object class="GtkImage" id="forward_icon"> - <property name="visible">True</property> <property name="icon_name">go-next-symbolic</property> <property name="icon_size">1</property> </object> @@ -251,19 +234,17 @@ </style> </object> </child> - <child> + <child type="end"> <object class="GtkBox"> - <property name="visible">True</property> <property name="margin_start">72</property> <child> <object class="GtkRevealer" id="operations_revealer"> - <property name="visible">True</property> <property name="halign">center</property> <property name="valign">center</property> <property name="transition_type">slide-right</property> - <child> + <property name="child"> <object class="GtkMenuButton" id="operations_button"> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="tooltip_text" translatable="yes">Show operations</property> <property name="margin_end">6</property> <property name="popover">operations_popover</property> @@ -271,34 +252,29 @@ <object class="GtkDrawingArea" id="operations_icon"> <property name="width_request">16</property> <property name="height_request">16</property> - <property name="visible">True</property> <property name="halign">center</property> <property name="valign">center</property> - <signal name="draw" handler="on_operations_icon_draw" object="NautilusToolbar" swapped="no"/> </object> </child> <style> <class name="button"/> </style> </object> - </child> + </property> </object> </child> <child> <object class="GtkBox"> - <property name="visible">True</property> <property name="halign">center</property> <property name="valign">center</property> <property name="margin_end">6</property> <child> <object class="GtkButton" id="view_toggle_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="tooltip_text" translatable="yes">Toggle view</property> <property name="action_name">slot.files-view-mode-toggle</property> <child> <object class="GtkImage" id="view_toggle_icon"> - <property name="visible">True</property> <property name="icon_size">1</property> </object> </child> @@ -309,16 +285,13 @@ </child> <child> <object class="GtkMenuButton" id="view_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="receives_default">True</property> <property name="tooltip_text" translatable="yes" comments="“View” is a noun">View options</property> <property name="halign">start</property> - <property name="action_name">win.view-menu</property> <property name="menu-model">view_menu</property> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="icon_name">pan-down-symbolic</property> </object> </child> @@ -334,14 +307,12 @@ </child> <child> <object class="GtkMenuButton" id="app_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="halign">center</property> <property name="valign">center</property> <property name="menu-model">app_menu</property> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="icon_name">open-menu-symbolic</property> <property name="icon_size">1</property> </object> @@ -352,9 +323,6 @@ </object> </child> </object> - <packing> - <property name="pack_type">end</property> - </packing> </child> </object> </child> diff --git a/src/resources/ui/nautilus-trash-is-empty.ui b/src/resources/ui/nautilus-trash-is-empty.ui index bbc387aea..1818fba55 100644 --- a/src/resources/ui/nautilus-trash-is-empty.ui +++ b/src/resources/ui/nautilus-trash-is-empty.ui @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.0 --> <interface> - <requires lib="gtk+" version="3.20"/> + <requires lib="gtk" version="4.0"/> <object class="GtkGrid" id="trash_is_empty"> <property name="halign">center</property> <property name="valign">center</property> @@ -11,31 +10,29 @@ <property name="visible">False</property> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="pixel_size">128</property> <property name="icon_name">user-trash-symbolic</property> <style> <class name="dim-label"/> <class name="nautilus-empty-state-icon"/> </style> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> </child> <child> <object class="GtkLabel"> - <property name="visible">True</property> <property name="label" translatable="yes">Trash is Empty</property> <style> <class name="large-title"/> </style> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> </child> </object> </interface> diff --git a/src/resources/ui/nautilus-view-icon-item-ui.ui b/src/resources/ui/nautilus-view-icon-item-ui.ui index 6e6121f0b..fa1fe25e1 100644 --- a/src/resources/ui/nautilus-view-icon-item-ui.ui +++ b/src/resources/ui/nautilus-view-icon-item-ui.ui @@ -1,10 +1,10 @@ -<?xml version='1.0' encoding='UTF-8'?> +<?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> + <requires lib="gtk" version="4.0"/> <template class="NautilusViewIconItemUi" parent="GtkFlowBoxChild"> <property name="halign">center</property> <property name="valign">start</property> - <child> + <property name="child"> <object class="GtkBox"> <property name="orientation">vertical</property> <property name="halign">center</property> @@ -42,7 +42,7 @@ <property name="wrap">True</property> <property name="wrap-mode">word-char</property> <attributes> - <attribute name="insert-hyphens" value="false"/> + <attribute name="insert-hyphens" value="false"></attribute> </attributes> </object> </child> @@ -91,6 +91,6 @@ </object> </child> </object> - </child> + </property> </template> </interface> diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui index 2b905dbee..cc033a153 100644 --- a/src/resources/ui/nautilus-window.ui +++ b/src/resources/ui/nautilus-window.ui @@ -1,9 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <object class="GtkPopover" id="tab_menu"> - <property name="position">bottom</property> - <property name="relative-to">notebook</property> - </object> + <requires lib="gtk" version="4.0"/> + <object class="GtkPopoverMenu" id="tab_menu"/> <menu id="tab_menu_model"> <section> <item> @@ -28,58 +26,50 @@ </item> </section> </menu> - <template class="NautilusWindow" parent="HdyApplicationWindow"> + <template class="NautilusWindow" parent="AdwApplicationWindow"> <property name="show-menubar">False</property> <property name="title" translatable="yes">_Files</property> <child> <object class="GtkBox"> - <property name="visible">True</property> <property name="orientation">vertical</property> <child> <object class="NautilusToolbar" id="toolbar"/> </child> <child> <object class="GtkPaned" id="content_paned"> - <property name="visible">True</property> + <property name="shrink-end-child">False</property> + <property name="shrink-start-child">False</property> + <property name="resize-start-child">False</property> <property name="vexpand">True</property> <property name="hexpand">True</property> <child> <object class="GtkBox" id="sidebar"> + <property name="visible">False</property> <property name="orientation">vertical</property> <property name="spacing">6</property> </object> - <packing> - <property name="resize">False</property> - <property name="shrink">False</property> - </packing> </child> <child> <object class="GtkOverlay" id="main_view"> - <property name="visible">True</property> - <child> + <property name="child"> <object class="GtkNotebook" id="notebook"> - <property name="visible">True</property> <property name="show-tabs">False</property> <property name="show-border">False</property> </object> - </child> + </property> <child type="overlay"> <object class="GtkRevealer" id="in_app_notification_undo"> - <property name="visible">True</property> <property name="halign">center</property> <property name="valign">start</property> <property name="transition_duration">100</property> - <child> + <property name="child"> <object class="GtkFrame"> - <property name="visible">True</property> - <child> + <property name="child"> <object class="GtkBox"> - <property name="visible">True</property> <property name="margin_start">12</property> <property name="margin_end">4</property> <child> <object class="GtkLabel" id="in_app_notification_undo_label"> - <property name="visible">True</property> <property name="max_width_chars">50</property> <property name="ellipsize">middle</property> <property name="margin_end">30</property> @@ -88,10 +78,8 @@ <child> <object class="GtkButton" id="in_app_notification_undo_undo_button"> <property name="label" translatable="yes">Undo</property> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="receives_default">True</property> - <property name="no_show_all">True</property> <property name="margin_end">6</property> <style> <class name="text-button"/> @@ -100,13 +88,11 @@ </child> <child> <object class="GtkButton" id="in_app_notification_undo_close_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="receives_default">True</property> <property name="focus_on_click">False</property> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="icon_name">window-close-symbolic</property> <property name="icon_size">2</property> </object> @@ -118,31 +104,27 @@ </object> </child> </object> - </child> + </property> <style> <class name="app-notification"/> </style> </object> - </child> + </property> </object> </child> <child type="overlay"> <object class="GtkRevealer" id="notification_operation"> - <property name="visible">True</property> <property name="halign">center</property> <property name="valign">start</property> <property name="transition_duration">100</property> - <child> + <property name="child"> <object class="GtkFrame"> - <property name="visible">True</property> - <child> + <property name="child"> <object class="GtkBox"> - <property name="visible">True</property> <property name="margin_start">12</property> <property name="margin_end">4</property> <child> <object class="GtkLabel" id="notification_operation_label"> - <property name="visible">True</property> <property name="max_width_chars">50</property> <property name="ellipsize">middle</property> <property name="margin_end">30</property> @@ -150,10 +132,8 @@ </child> <child> <object class="GtkButton" id="notification_operation_open"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="receives_default">True</property> - <property name="no_show_all">True</property> <property name="margin_end">6</property> <signal name="clicked" handler="on_notification_operation_open_clicked" object="NautilusWindow" swapped="no"/> <style> @@ -163,14 +143,12 @@ </child> <child> <object class="GtkButton" id="notification_operation_close"> - <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="focusable">True</property> <property name="receives_default">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="on_notification_operation_close_clicked" object="NautilusWindow" swapped="no"/> <child> <object class="GtkImage"> - <property name="visible">True</property> <property name="icon_name">window-close-symbolic</property> <property name="icon_size">2</property> </object> @@ -182,18 +160,15 @@ </object> </child> </object> - </child> + </property> <style> <class name="app-notification"/> </style> </object> - </child> + </property> </object> </child> </object> - <packing> - <property name="shrink">False</property> - </packing> </child> </object> </child> diff --git a/test/automated/display/test-nautilus-mime-actions-set.c b/test/automated/display/test-nautilus-mime-actions-set.c index 11e9ddc0d..9d364b69c 100644 --- a/test/automated/display/test-nautilus-mime-actions-set.c +++ b/test/automated/display/test-nautilus-mime-actions-set.c @@ -118,7 +118,7 @@ main (int argc, NautilusFile *file; NautilusFileAttributes attributes; - gtk_init (&argc, &argv); + gtk_init (); if (argc < 3) { diff --git a/test/automated/display/test-nautilus-mime-actions.c b/test/automated/display/test-nautilus-mime-actions.c index a6818adbc..052e9c719 100644 --- a/test/automated/display/test-nautilus-mime-actions.c +++ b/test/automated/display/test-nautilus-mime-actions.c @@ -112,7 +112,7 @@ main (int argc, NautilusFile *file; NautilusFileAttributes attributes; - gtk_init (&argc, &argv); + gtk_init (); if (argc != 2) { diff --git a/test/interactive/test.c b/test/interactive/test.c index 34a5fa8c4..0f1662e02 100644 --- a/test/interactive/test.c +++ b/test/interactive/test.c @@ -6,7 +6,7 @@ void test_init (int *argc, char ***argv) { - gtk_init (argc, argv); + gtk_init (); eel_make_warnings_and_criticals_stop_in_debugger (); } |