Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Gtk4 #90

Merged
merged 20 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions data/Application.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,16 @@ button.pathbar {
border-radius: 0;
padding: 0 6px;
}

.linked .combo {
padding: 2.5px 3px;
}

.transition {
transition: all 175ms ease-in-out;
}

.drop-target:drop(active) {
border-radius: 6px;
background: alpha(@color_primary, 0.15);
}
2 changes: 1 addition & 1 deletion po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ src/Frontend/MainWindow.vala
src/Frontend/Widgets/ConnectBox.vala
src/Frontend/Widgets/FilePane.vala
src/Frontend/Widgets/OperationsPopover.vala
src/Frontend/Widgets/PathBarSeparator.vala
src/Frontend/Widgets/PathBar.vala
src/Frontend/Widgets/FileRow.vala
2 changes: 0 additions & 2 deletions src/API/IFileOperations.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ namespace Taxi {

public signal void operation_added (IOperationInfo operation);
public signal void operation_removed (IOperationInfo operation);
public signal int ask_overwrite (File destination);

public async abstract bool delete_recursive (
File file,
Cancellable? cancellable
Expand Down
18 changes: 14 additions & 4 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public class Taxi.Taxi : Gtk.Application {
protected override void startup () {
base.startup ();

Hdy.init ();
Granite.init ();

var provider = new Gtk.CssProvider ();
provider.load_from_resource ("com/github/alecaddd/taxi/Application.css");
Gtk.StyleContext.add_provider_for_screen (
Gdk.Screen.get_default (),
Gtk.StyleContext.add_provider_for_display (
Gdk.Display.get_default (),
provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
);

Expand All @@ -57,7 +57,17 @@ public class Taxi.Taxi : Gtk.Application {
new ConnectionSaver ()
);

main_window.show_all ();
var settings = new Settings ("com.github.alecaddd.taxi.state");
settings.bind ("window-height", main_window, "default-height", SettingsBindFlags.DEFAULT);
settings.bind ("window-width", main_window, "default-width", SettingsBindFlags.DEFAULT);

if (settings.get_boolean ("maximized")) {
main_window.maximize ();
}

settings.bind ("maximized", main_window, "maximized", SettingsBindFlags.SET);

main_window.present ();
}

public static int main (string[] args) {
Expand Down
33 changes: 32 additions & 1 deletion src/Backend/FileOperations.vala
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace Taxi {
} else if (file_type == FileType.REGULAR) {
var tmp_flag = *flags;
if (*flags == FileCopyFlags.NONE && destination.query_exists ()) {
switch ((ConflictFlag)ask_overwrite (destination)) {
switch ((ConflictFlag) ask_overwrite (destination)) {
case ConflictFlag.REPLACE_ALL:
*flags = FileCopyFlags.OVERWRITE;
tmp_flag = *flags;
Expand All @@ -138,6 +138,7 @@ namespace Taxi {
return;
}
}

yield source.copy_async (
destination,
tmp_flag,
Expand All @@ -149,4 +150,34 @@ namespace Taxi {
}
}
}

private int ask_overwrite (File destination) {
var message_dialog = new Granite.MessageDialog (
_("Replace existing file?"),
_("<i>\"%s\"</i> already exists. You can replace this file, replace all conflicting files or choose not to replace the file by skipping.".printf (destination.get_basename ())),
alainm23 marked this conversation as resolved.
Show resolved Hide resolved
new ThemedIcon ("dialog-warning"),
Gtk.ButtonsType.CANCEL
) {
modal = true
};

message_dialog.add_button (_("Replace All Conflicts"), ConflictFlag.REPLACE_ALL);
message_dialog.add_button (_("Skip"), ConflictFlag.SKIP);
var replace_button = message_dialog.add_button (_("Replace"), ConflictFlag.REPLACE);
replace_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);

message_dialog.show ();

int response = 0;
var loop = new MainLoop ();
message_dialog.response.connect ((response_id) => {
response = response_id;
message_dialog.destroy ();
loop.quit ();
});

loop.run ();

return response;
}
}
Loading