Skip to content

Commit

Permalink
Wallpaper: replace deprecated FileChooserNative with FileDialog (#398)
Browse files Browse the repository at this point in the history
* Wallpaper: replace deprecated FileChooserNative with FileDialog

* Update Wallpaper.vala
  • Loading branch information
danirabbit authored May 7, 2024
1 parent 17bd949 commit 8d78d82
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You'll need the following dependencies:
* libswitchboard-3-dev
* libgee-0.8-dev
* libgexiv2-dev
* libgtk-4-dev (>=4.8)
* libgtk-4-dev (>=4.10)
* libgranite-7-dev (>=7.5.0)
* meson
* valac
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gio_dep = dependency('gio-2.0')
glib_dep = dependency('glib-2.0')
gobject_dep = dependency('gobject-2.0')
granite_dep = dependency('granite-7', version: '>=7.5.0')
gtk_dep = dependency('gtk4', version: '>=4.8')
gtk_dep = dependency('gtk4', version: '>=4.10')
hdy_dep = dependency ('libadwaita-1')
posix_dep = meson.get_compiler('vala').find_library('posix')

Expand Down
27 changes: 12 additions & 15 deletions src/Views/Wallpaper.vala
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,18 @@ public class PantheonShell.Wallpaper : Gtk.Box {
var filter = new Gtk.FileFilter ();
filter.add_mime_type ("image/*");

var chooser = new Gtk.FileChooserNative (
_("Import Photo"), null, Gtk.FileChooserAction.OPEN,
_("Import"),
_("Cancel")
);
chooser.filter = filter;
chooser.select_multiple = true;

chooser.show ();
chooser.response.connect ((response) => {
if (response == Gtk.ResponseType.ACCEPT) {
var files = chooser.get_files ();
for (var i = 0; i <= files.get_n_items (); i++) {
var file = (File) files.get_item (i);
var file_dialog = new Gtk.FileDialog () {
accept_label = _("Import"),
default_filter = filter,
modal = true,
title = _("Import Photos")
};

file_dialog.open_multiple.begin ((Gtk.Window) get_root (), null, (obj, res) => {
var list_model = file_dialog.open_multiple.end (res);
if (list_model != null) {
for (var i = 0; i <= list_model.get_n_items (); i++) {
var file = (File) list_model.get_item (i);

if (WallpaperOperation.get_is_file_in_bg_dir (file)) {
continue;
Expand All @@ -176,7 +174,6 @@ public class PantheonShell.Wallpaper : Gtk.Box {
add_wallpaper_from_file (file, local_uri);
}
}
chooser.destroy ();
});
}

Expand Down

0 comments on commit 8d78d82

Please sign in to comment.