Updating linux build.
[Widgit.git] / UI / PreferencesEditor.cs
blobe8b30a99a1228dec3d8030f54d4b598f2c6428b5
1 //Widgit is free software; you can redistribute it and/or modify
2 //it under the terms of the GNU General Public License as published by
3 //the Free Software Foundation; either version 2 of the License, or
4 //(at your option) any later version.
6 //Widgit is distributed in the hope that it will be useful,
7 //but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 //GNU General Public License for more details.
11 //You should have received a copy of the GNU General Public License
12 //along with Widgit; if not, write to the Free Software
13 //Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System;
15 using System;
16 using System.Collections.Generic;
17 using System.ComponentModel;
18 using System.Data;
19 using System.Drawing;
20 using System.Text;
21 using System.Windows.Forms;
23 namespace Widgit
25 public partial class PreferencesEditor : Form
27 internal Prefs m_prefs;
29 internal PreferencesEditor(Prefs p)
31 m_prefs = p;
32 InitializeComponent();
33 m_gitPath.Text = m_prefs.GitDir;
34 m_editor.Text = m_prefs.ViewerApp;
35 m_editorArgs.Text = m_prefs.ViewerArgs;
36 m_difftool.Text = m_prefs.DiffApp;
37 m_difftoolArgs.Text = m_prefs.DiffArgs;
38 m_mergeTool.Text = m_prefs.MergeApp;
39 m_mergetoolArgs.Text = m_prefs.MergeArgs;
42 protected string ChooseDir(bool bDirs)
44 string s = "";
45 if (bDirs)
47 m_folderChooser.ShowDialog();
48 s = m_folderChooser.SelectedPath;
50 else
52 m_fileChooser.ShowDialog();
53 s = m_fileChooser.FileName;
55 return s;
58 private void OnChooseMinGWPath(object sender, EventArgs e)
60 string dir = ChooseDir(true);
61 if (!String.IsNullOrEmpty(dir))
63 m_gitPath.Text = dir;
67 private void OnSave(object sender, EventArgs e)
69 string dir = m_gitPath.Text;
70 if (!System.IO.File.Exists(dir + System.IO.Path.DirectorySeparatorChar + "git-init-db") &&
71 !System.IO.File.Exists(dir + System.IO.Path.DirectorySeparatorChar + "git-init-db.exe"))
73 MessageBox.Show("The location does not appear to have git executables in it.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
74 return;
76 m_prefs.GitDir = dir;
77 m_prefs.DiffApp = m_difftool.Text;
78 m_prefs.DiffArgs = m_difftoolArgs.Text;
79 m_prefs.ViewerApp = m_editor.Text;
80 m_prefs.ViewerArgs = m_editorArgs.Text;
81 m_prefs.MergeApp = m_mergeTool.Text;
82 m_prefs.MergeArgs = m_mergetoolArgs.Text;
83 m_prefs.Save();
84 Close();
87 private void OnBrowseEditor(object sender, EventArgs e)
89 string dir = ChooseDir(false);
90 if (!String.IsNullOrEmpty(dir))
92 m_editor.Text = dir;
96 private void OnBrowseDifftool(object sender, EventArgs e)
98 string dir = ChooseDir(false);
99 if (!String.IsNullOrEmpty(dir))
101 m_difftool.Text = dir;
105 private void OnBrowseMegetool(object sender, EventArgs e)
107 string dir = ChooseDir(false);
108 if (!String.IsNullOrEmpty(dir))
110 m_mergeTool.Text = dir;