Skip to content

Commit

Permalink
Merge pull request #4 from Okarisu/posudky
Browse files Browse the repository at this point in the history
Posudky
  • Loading branch information
Okarisu authored May 18, 2023
2 parents 7bf8349 + 0e3a1e9 commit 8f1a116
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 12 deletions.
20 changes: 19 additions & 1 deletion FileCommander/GUI/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.IO;
using System.Linq;
using System.Text;
using Pango;

namespace FileCommander.GUI;

Expand Down Expand Up @@ -203,7 +204,24 @@ public static DirectoryInfo OnItemActivated(ItemActivatedArgs args, DirectoryInf
}
/* Konec citace */
public static int GetFocusedPanel() => _focusedPanel;
public static void SetFocusedPanel(int panel) => _focusedPanel = panel;

public static void SetFocusedPanel(int panel)
{
_focusedPanel = panel;

//Zvýraznění aktivního panelu
switch (panel)
{
case 1:
LeftRootLabel.ModifyFg(StateType.Normal, new Gdk.Color(0, 200, 0));
RightRootLabel.ModifyFg(StateType.Normal, new Gdk.Color(255, 255, 255));
break;
case 2:
RightRootLabel.ModifyFg(StateType.Normal, new Gdk.Color(0, 200, 0));
LeftRootLabel.ModifyFg(StateType.Normal, new Gdk.Color(255, 255, 255));
break;
}
}

public static Item[] GetSelectedItems()
{
Expand Down
10 changes: 7 additions & 3 deletions FileCommander/GUI/Controllers/NavigationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ namespace FileCommander.GUI.Controllers;

public abstract class NavigationController
{
public static DirectoryInfo OnHomeClicked(ListStore store)
public static DirectoryInfo OnHomeClicked(DirectoryInfo root, Stack<DirectoryInfo> history, ListStore store)
{
var root = new DirectoryInfo(Environment.GetFolderPath(
history.Push(root);

root = new DirectoryInfo(Environment.GetFolderPath(
Environment.SpecialFolder.Personal));
FillStore(store, root);
return root;
}

public static DirectoryInfo OnUpClicked(DirectoryInfo root, ListStore store)
public static DirectoryInfo OnUpClicked(DirectoryInfo root, Stack<DirectoryInfo> history, ListStore store)
{
history.Push(root);

if (root.Parent == null)
return root;

Expand Down
7 changes: 7 additions & 0 deletions FileCommander/GUI/Controllers/TargetController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public static (string path, bool cancel, bool addSuffix) GetTargetPath(string di
NullPath();
} while (path.path == "" && !path.cancel);

foreach (var c in Path.GetInvalidFileNameChars())
{
if (!path.path.Contains(c)) continue;
new PromptUserDialogWindow("Invalid character in file name.");
return GetTargetPath(dialogTitle, promptSuffix);
}

return (path.path, path.cancel, path.addSuffix);
}
}
2 changes: 0 additions & 2 deletions FileCommander/GUI/Dialogs/PromptTargetPanelDialogWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,4 @@ public static void NullPrompt()
{
_cancel = false;
}


}
8 changes: 4 additions & 4 deletions FileCommander/GUI/Toolbars/TwinToolbars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public static Toolbar DrawLeftToolbar()
leftToolbar.Insert(leftHomeButton, 0);
leftHomeButton.Clicked += (sender, args) =>
{
LeftRoot = OnHomeClicked(LeftStore);
LeftRoot = OnHomeClicked(LeftRoot, LeftHistory, LeftStore);
UpdateRootLabel(LeftRootLabel, LeftRoot);
};

var leftUpButton = new ToolButton(Stock.GoUp);
leftToolbar.Insert(leftUpButton, 1);
leftUpButton.Clicked += (_, _) =>
{
LeftRoot = OnUpClicked(LeftRoot, LeftStore);
LeftRoot = OnUpClicked(LeftRoot, LeftHistory, LeftStore);
UpdateRootLabel(LeftRootLabel, LeftRoot);
};

Expand Down Expand Up @@ -68,15 +68,15 @@ public static Toolbar DrawRightToolbar()
rightPanelBar.Insert(rightHomeButton, 0);
rightHomeButton.Clicked += (_, args) =>
{
RightRoot = OnHomeClicked(RightStore);
RightRoot = OnHomeClicked(RightRoot, RightHistory, RightStore);
UpdateRootLabel(RightRootLabel, RightRoot);
};

var rightUpButton = new ToolButton(Stock.GoUp);
rightPanelBar.Insert(rightUpButton, 1);
rightUpButton.Clicked += (_, _) =>
{
RightRoot = OnUpClicked(RightRoot, RightStore);
RightRoot = OnUpClicked(RightRoot, RightHistory, RightStore);
UpdateRootLabel(RightRootLabel, RightRoot);
};

Expand Down
1 change: 1 addition & 0 deletions FileCommander/GUI/TwinPanels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static void DrawLeftPanel()
FillStore(LeftStore, LeftRoot);
LeftScrolledWindow.SetPolicy(PolicyType.Automatic, PolicyType.Automatic); //Nastavení chování posuvníku
LeftIconView.GrabFocus(); //Jeden z panelů musí být na začátku zaktivován kvůli předejití chybám
LeftRootLabel.ModifyFg(StateType.Normal, new Gdk.Color(0, 200, 0)); //Zvýraznění aktivního panelu
LeftIconView.SelectionMode = SelectionMode.Multiple; //Možnost výběru více souborů
LeftIconView.TextColumn = ColDisplayName; //Zobrazení jména souboru pod ikonou
LeftIconView.PixbufColumn = ColPixbuf; //Zobrazení ikony souboru
Expand Down
9 changes: 8 additions & 1 deletion FileCommander/core/New.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// ReSharper disable ObjectCreationAsStatement
// ReSharper disable ClassNeverInstantiated.Global

using System.Data;

namespace FileCommander.core;

using System;
Expand Down Expand Up @@ -48,9 +50,14 @@ public static void OnNewClicked(object sender, EventArgs e)
new PromptUserDialogWindow("Malformed folder name");
return;
}
catch (ReadOnlyException)
{
new PromptUserDialogWindow("Directory is read-only.");
return;
}
catch (IOException)
{
new PromptUserDialogWindow("Parent directory is read-only.");
new PromptUserDialogWindow("Input/output error has occurred.");
return;
}
catch (UnauthorizedAccessException)
Expand Down
9 changes: 8 additions & 1 deletion FileCommander/core/Rename.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// ReSharper disable ObjectCreationAsStatement
// ReSharper disable ClassNeverInstantiated.Global

using System.Data;

namespace FileCommander.core;

using System;
Expand Down Expand Up @@ -88,9 +90,14 @@ public static void OnRenameClicked(object sender, EventArgs e)
new PromptUserDialogWindow("Malformed name");
return;
}
catch (ReadOnlyException) //#[[ReadOnlyException]]
{
new PromptUserDialogWindow("Directory is read-only.");
return;
}
catch (IOException)
{
new PromptUserDialogWindow("Parent directory is read-only.");
new PromptUserDialogWindow("Input/output error has occurred.");
return;
}
catch (UnauthorizedAccessException)
Expand Down
Binary file added Obhajoba.pptx
Binary file not shown.

0 comments on commit 8f1a116

Please sign in to comment.