Got viewing files and diffing files (arbitrary commits) to work.
[Widgit.git] / UI / PreferencesEditor.cs
blob1069d7eb73be0240e271969f1cfb1527b732ea77
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
9 namespace Widgit
11 public partial class PreferencesEditor : Form
13 internal Prefs m_prefs;
15 internal PreferencesEditor(Prefs p)
17 m_prefs = p;
18 InitializeComponent();
19 m_gitPath.Text = m_prefs.GitDir;
20 m_editor.Text = m_prefs.ViewerApp;
21 m_editorArgs.Text = m_prefs.ViewerArgs;
22 m_difftool.Text = m_prefs.DiffApp;
23 m_difftoolArgs.Text = m_prefs.DiffArgs;
24 m_mergeTool.Text = m_prefs.MergeApp;
25 m_mergetoolArgs.Text = m_prefs.MergeArgs;
28 protected string ChooseDir(bool bDirs)
30 DialogResult r;
31 string s = "";
32 if (bDirs)
34 r = m_folderChooser.ShowDialog();
35 s = m_folderChooser.SelectedPath;
37 else
39 r = m_fileChooser.ShowDialog();
40 s = m_fileChooser.FileName;
42 return s;
45 private void OnChooseMinGWPath(object sender, EventArgs e)
47 string dir = ChooseDir(true);
48 if (!String.IsNullOrEmpty(dir))
50 m_gitPath.Text = dir;
54 private void OnSave(object sender, EventArgs e)
56 string dir = m_gitPath.Text;
57 if (!System.IO.File.Exists(dir + System.IO.Path.DirectorySeparatorChar + "git-init-db") &&
58 !System.IO.File.Exists(dir + System.IO.Path.DirectorySeparatorChar + "git-init-db.exe"))
60 MessageBox.Show("The location does not appear to have git executables in it.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
61 return;
63 m_prefs.GitDir = dir;
64 m_prefs.DiffApp = m_difftool.Text;
65 m_prefs.DiffArgs = m_difftoolArgs.Text;
66 m_prefs.ViewerApp = m_editor.Text;
67 m_prefs.ViewerArgs = m_editorArgs.Text;
68 m_prefs.MergeApp = m_mergeTool.Text;
69 m_prefs.MergeArgs = m_mergetoolArgs.Text;
70 m_prefs.Save();
71 Close();
74 private void OnBrowseEditor(object sender, EventArgs e)
76 string dir = ChooseDir(false);
77 if (!String.IsNullOrEmpty(dir))
79 m_editor.Text = dir;
83 private void OnBrowseDifftool(object sender, EventArgs e)
85 string dir = ChooseDir(false);
86 if (!String.IsNullOrEmpty(dir))
88 m_difftool.Text = dir;
92 private void OnBrowseMegetool(object sender, EventArgs e)
94 string dir = ChooseDir(false);
95 if (!String.IsNullOrEmpty(dir))
97 m_mergeTool.Text = dir;