[gbrainy] - Remove browsing directories from FileBrowser class which was not used - Class is used to select a
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] - Remove browsing directories from FileBrowser class which was not used - Class is used to select a
- Date: Tue, 23 Aug 2022 14:37:37 +0000 (UTC)
commit bd56592fe5f164a28e2c173520acab0327606d44
Author: Jordi Mas <jmas softcatala org>
Date: Tue Aug 23 16:35:29 2022 +0200
- Remove browsing directories from FileBrowser class which was not used
- Class is used to select a file to be generated, fix the dialog type accordingly
src/Clients/Classical/Dialogs/PdfExportDialog.cs | 5 ++--
src/Clients/Classical/Widgets/BrowseFile.cs | 31 ++++++------------------
2 files changed, 10 insertions(+), 26 deletions(-)
---
diff --git a/src/Clients/Classical/Dialogs/PdfExportDialog.cs
b/src/Clients/Classical/Dialogs/PdfExportDialog.cs
index 010f2a10..2c23e9d5 100644
--- a/src/Clients/Classical/Dialogs/PdfExportDialog.cs
+++ b/src/Clients/Classical/Dialogs/PdfExportDialog.cs
@@ -65,12 +65,13 @@ namespace gbrainy.Clients.Classical.Dialogs
}
// File selection
string def_file;
+ string def_dir = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
def_file = System.IO.Path.Combine (
- Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments),
+ def_dir,
// Translators: default file name used when exporting PDF files (keep the pdf
extension please)
Catalog.GetString ("games.pdf"));
- file = new BrowseFile (hbox_file, def_file, true);
+ file = new BrowseFile (hbox_file, def_file, def_dir);
FileFilter[] filters = new FileFilter [2];
filters[0] = new FileFilter ();
diff --git a/src/Clients/Classical/Widgets/BrowseFile.cs b/src/Clients/Classical/Widgets/BrowseFile.cs
index 6c50b78e..59c7394f 100644
--- a/src/Clients/Classical/Widgets/BrowseFile.cs
+++ b/src/Clients/Classical/Widgets/BrowseFile.cs
@@ -28,15 +28,14 @@ namespace gbrainy.Clients.Classical.Widgets
{
Entry filename;
Button browse;
- bool browse_file;
Gtk.FileFilter[] filters;
- string default_dir;
+ string default_dir;
public virtual event EventHandler FileSelectedChanged;
- public BrowseFile (Box parent, string file, bool browse_file)
+ public BrowseFile (Box parent, string file, string default_dir)
{
- this.browse_file = browse_file;
+ this.default_dir = default_dir;
filename = new Entry ();
browse = new Button (Catalog.GetString ("Browse..."));
Filename = file;
@@ -63,15 +62,6 @@ namespace gbrainy.Clients.Classical.Widgets
}
}
- public string DefaultDirectory {
- set {
- if (browse_file == false)
- throw new InvalidOperationException ("Default directory can only be
set when browsing files");
-
- default_dir = value;
- }
- }
-
public Gtk.FileFilter[] Filters {
set { filters = value; }
}
@@ -80,19 +70,12 @@ namespace gbrainy.Clients.Classical.Widgets
{
FileChooserDialog chooser_dialog = new FileChooserDialog (
Catalog.GetString ("Open Location") , null,
- browse_file ? FileChooserAction.Open : FileChooserAction.SelectFolder);
-
-
- if (browse_file) {
- if (default_dir != null)
- chooser_dialog.SetCurrentFolder (default_dir);
- }
- else {
- chooser_dialog.SetCurrentFolder (filename.Text);
- }
+ FileChooserAction.Save);
+ chooser_dialog.SetCurrentFolder (this.default_dir);
+ chooser_dialog.CurrentName = filename.Text;
chooser_dialog.AddButton (Stock.Cancel, ResponseType.Cancel);
- chooser_dialog.AddButton (Stock.Open, ResponseType.Ok);
+ chooser_dialog.AddButton (Stock.Save, ResponseType.Ok);
chooser_dialog.DefaultResponse = ResponseType.Ok;
chooser_dialog.LocalOnly = false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]