Skip to content

Commit

Permalink
fix warnings (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 authored Sep 24, 2024
1 parent 078fccd commit bddfb4f
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/API/IFileAccess.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Taxi {
*/
public async abstract List<FileInfo> get_file_list ();

public abstract GLib.Uri get_uri ();
public abstract GLib.Uri? get_uri ();

public abstract void goto_dir (GLib.Uri uri);

Expand Down
5 changes: 4 additions & 1 deletion src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public class Taxi.Taxi : Gtk.Application {

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 (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
Gtk.StyleContext.add_provider_for_screen (
Gdk.Screen.get_default (),
provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
);

var granite_settings = Granite.Settings.get_default ();
var gtk_settings = Gtk.Settings.get_default ();
Expand Down
9 changes: 5 additions & 4 deletions src/Backend/ConnectionSaver.vala
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ namespace Taxi {
}
bookmark.add_application (uri, "taxi", "taxi");
return bookmark.to_file (file_name);
} catch (BookmarkFileError e) {
} catch (Error e) {
message (e.message);
}

return false;
}

Expand All @@ -64,7 +65,7 @@ namespace Taxi {
bookmark.load_from_file (file_name);
bookmark.remove_application (uri, "taxi");
return bookmark.to_file (file_name);
} catch (BookmarkFileError e) {
} catch (Error e) {
message (e.message);
return false;
}
Expand All @@ -82,7 +83,7 @@ namespace Taxi {
foreach (string uri in bookmark.get_uris ()) {
connection_list.append (uri);
}
} catch (BookmarkFileError e) {
} catch (Error e) {
message (e.message);
}
}
Expand All @@ -96,7 +97,7 @@ namespace Taxi {
try {
bookmark.load_from_file (file_name);
return bookmark.has_item (uri);
} catch (BookmarkFileError e) {
} catch (Error e) {
message (e.message);
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/Backend/FileAccess.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,19 @@ namespace Taxi {
}
}

public virtual GLib.Uri get_uri () {
public virtual GLib.Uri? get_uri () {
var uri = file_handle.get_uri ();
if (!uri.has_suffix ("/")) {
uri += "/";
}
return GLib.Uri.parse (uri, PARSE_RELAXED);

try {
return GLib.Uri.parse (uri, PARSE_RELAXED);
} catch (Error e) {
message (e.message);
}

return null;
}

public virtual void goto_dir (GLib.Uri uri) {
Expand Down
46 changes: 29 additions & 17 deletions src/Frontend/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -274,31 +274,43 @@ class Taxi.MainWindow : Hdy.ApplicationWindow {
}

private void action_navigate (GLib.SimpleAction action, GLib.Variant? variant) {
var uri = GLib.Uri.parse (variant.get_string (), PARSE_RELAXED);
if (uri.get_scheme () == "file") {
local_access.goto_dir (uri);
update_pane (LOCAL);
} else {
remote_access.goto_dir (uri);
update_pane (REMOTE);
try {
var uri = GLib.Uri.parse (variant.get_string (), PARSE_RELAXED);
if (uri.get_scheme () == "file") {
local_access.goto_dir (uri);
update_pane (LOCAL);
} else {
remote_access.goto_dir (uri);
update_pane (REMOTE);
}
} catch (Error err) {
warning (err.message);
}
}

private void action_open (GLib.SimpleAction action, GLib.Variant? variant) {
var uri = GLib.Uri.parse (variant.get_string (), PARSE_RELAXED);
if (uri.get_scheme () == "file") {
local_access.open_file (uri);
} else {
remote_access.open_file (uri);
try {
var uri = GLib.Uri.parse (variant.get_string (), PARSE_RELAXED);
if (uri.get_scheme () == "file") {
local_access.open_file (uri);
} else {
remote_access.open_file (uri);
}
} catch (Error err) {
warning (err.message);
}
}

private void action_delete (GLib.SimpleAction action, GLib.Variant? variant) {
var uri = GLib.Uri.parse (variant.get_string (), PARSE_RELAXED);
if (uri.get_scheme () == "file") {
file_delete (uri, Location.LOCAL);
} else {
file_delete (uri, Location.REMOTE);
try {
var uri = GLib.Uri.parse (variant.get_string (), PARSE_RELAXED);
if (uri.get_scheme () == "file") {
file_delete (uri, Location.LOCAL);
} else {
file_delete (uri, Location.REMOTE);
}
} catch (Error err) {
warning (err.message);
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/Frontend/Widgets/ConnectBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ namespace Taxi {
private void submit_form () {
var protocol = ((Protocol) protocol_combobox.get_active ()).to_plain_text ();
var path = path_entry.get_text ();
var uri = Uri.parse (protocol + "://" + path, PARSE_RELAXED);
connect_initiated (uri);

try {
var uri = Uri.parse (protocol + "://" + path, PARSE_RELAXED);
connect_initiated (uri);
} catch (Error err) {
warning (err.message);
}
}

private void on_changed () {
Expand Down Expand Up @@ -116,7 +121,11 @@ namespace Taxi {

path_entry.text = split[1];

connect_initiated (GLib.Uri.parse (uri, PARSE_RELAXED));
try {
connect_initiated (GLib.Uri.parse (uri, PARSE_RELAXED));
} catch (Error err) {
warning (err.message);
}
}

public void show_favorite_icon (bool added = false) {
Expand Down
103 changes: 61 additions & 42 deletions src/Frontend/Widgets/FilePane.vala
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,16 @@ namespace Taxi {
var gee_list = glib_to_gee<FileInfo> (file_list);
alphabetical_order (gee_list);
foreach (FileInfo file_info in gee_list) {
if (file_info.get_name ().get_char (0) == '.') continue;
list_box.add (new_row (file_info));
if (file_info.get_name ().get_char (0) == '.') {
continue;
}

var row = new_row (file_info);
if (row != null) {
list_box.add (row);
}
}

list_box.show_all ();
}

Expand Down Expand Up @@ -158,7 +165,7 @@ namespace Taxi {
});
}

private Gtk.ListBoxRow new_row (FileInfo file_info) {
private Gtk.ListBoxRow? new_row (FileInfo file_info) {
var checkbox = new Gtk.CheckButton ();
checkbox.toggled.connect (on_checkbutton_toggle);

Expand Down Expand Up @@ -186,7 +193,13 @@ namespace Taxi {
row.add (size);
}

var uri = GLib.Uri.parse_relative (current_uri, file_info.get_name (), PARSE_RELAXED);
GLib.Uri uri;
try {
uri = GLib.Uri.parse_relative (current_uri, file_info.get_name (), PARSE_RELAXED);
} catch (Error e) {
message (e.message);
return null;
}

var ebrow = new Gtk.EventBox ();
ebrow.add (row);
Expand Down Expand Up @@ -240,55 +253,61 @@ namespace Taxi {


private bool on_ebr_popup_menu (Gtk.EventBox event_box) {
var uri = GLib.Uri.parse_relative (
current_uri,
event_box.get_data<string> ("name"),
PARSE_RELAXED
);
try {
var uri = GLib.Uri.parse_relative (
current_uri,
event_box.get_data<string> ("name"),
PARSE_RELAXED
);

var menu_model = new GLib.Menu ();
var menu_model = new GLib.Menu ();

var type = event_box.get_data<FileType> ("type");
if (type == FileType.DIRECTORY) {
menu_model.append (
_("Open"),
Action.print_detailed_name (
"win.navigate",
new Variant.string (uri.to_string ())
)
);
} else {
menu_model.append (
_("Open"),
var type = event_box.get_data<FileType> ("type");
if (type == FileType.DIRECTORY) {
menu_model.append (
_("Open"),
Action.print_detailed_name (
"win.navigate",
new Variant.string (uri.to_string ())
)
);
} else {
menu_model.append (
_("Open"),
Action.print_detailed_name (
"win.open",
new Variant.string (uri.to_string ())
)
);

//menu.add (new_menu_item ("Edit", u => edit (u), uri));
}

var delete_section = new GLib.Menu ();
delete_section.append (
_("Delete"),
Action.print_detailed_name (
"win.open",
"win.delete",
new Variant.string (uri.to_string ())
)
);

//menu.add (new_menu_item ("Edit", u => edit (u), uri));
}
menu_model.append_section (null, delete_section);

var delete_section = new GLib.Menu ();
delete_section.append (
_("Delete"),
Action.print_detailed_name (
"win.delete",
new Variant.string (uri.to_string ())
)
);
//add_menu_item ("Rename", menu, u => rename (u), uri);

menu_model.append_section (null, delete_section);
var menu = new Gtk.Menu.from_model (menu_model) {
attach_widget = event_box
};
menu.popup_at_pointer (null);
menu.deactivate.connect (() => list_box.select_row (null));

//add_menu_item ("Rename", menu, u => rename (u), uri);

var menu = new Gtk.Menu.from_model (menu_model) {
attach_widget = event_box
};
menu.popup_at_pointer (null);
menu.deactivate.connect (() => list_box.select_row (null));
return true;
} catch (Error err) {
warning (err.message);
}

return true;
return false;
}

public void update_pathbar (GLib.Uri uri) {
Expand Down
8 changes: 6 additions & 2 deletions src/Frontend/Widgets/PathBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ namespace Taxi {
button_style_context.add_class ("path-button");

button.clicked.connect (() => {
current_uri = GLib.Uri.parse (current_uri.get_scheme () + "://" + path, PARSE_RELAXED);
navigate (current_uri);
try {
current_uri = GLib.Uri.parse (current_uri.get_scheme () + "://" + path, PARSE_RELAXED);
navigate (current_uri);
} catch (Error err) {
warning (err.message);
}
});
add (button);
}
Expand Down

0 comments on commit bddfb4f

Please sign in to comment.