2
// GeneralOptionsPanel.cs
5
// Marcos David Marin Amador <MarcosMarin@gmail.com>
7
// Copyright (C) 2007 Marcos David Marin Amador
10
// This source code is licenced under The MIT License:
12
// Permission is hereby granted, free of charge, to any person obtaining
13
// a copy of this software and associated documentation files (the
14
// "Software"), to deal in the Software without restriction, including
15
// without limitation the rights to use, copy, modify, merge, publish,
16
// distribute, sublicense, and/or sell copies of the Software, and to
17
// permit persons to whom the Software is furnished to do so, subject to
18
// the following conditions:
20
// The above copyright notice and this permission notice shall be
21
// included in all copies or substantial portions of the Software.
23
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33
using System.Collections.Generic;
37
using MonoDevelop.Core;
38
using MonoDevelop.Core.Gui.Dialogs;
42
public partial class GeneralOptionsPanel : Gtk.Bin
44
ICompiler default_c_compiler;
45
List<ICompiler> c_compilers = new List<ICompiler> ();
47
ICompiler default_cpp_compiler;
48
List<ICompiler> cpp_compilers = new List<ICompiler> ();
50
public GeneralOptionsPanel ()
54
object[] compilers = AddinManager.GetExtensionObjects ("/CBinding/Compilers");
56
foreach (ICompiler compiler in compilers) {
57
if (compiler.Language == Language.C) {
58
c_compilers.Add (compiler);
59
} else if (compiler.Language == Language.CPP) {
60
cpp_compilers.Add (compiler);
64
foreach (ICompiler compiler in c_compilers)
65
cCombo.AppendText (compiler.Name);
67
foreach (ICompiler compiler in cpp_compilers)
68
cppCombo.AppendText (compiler.Name);
70
string c_compiler = PropertyService.Get<string> ("CBinding.DefaultCCompiler", new GccCompiler ().Name);
71
string cpp_compiler = PropertyService.Get<string> ("CBinding.DefaultCppCompiler", new GppCompiler ().Name);
72
parseSystemTagsCheck.Active = PropertyService.Get<bool> ("CBinding.ParseSystemTags", true);
74
foreach (ICompiler compiler in c_compilers) {
75
if (compiler.Name == c_compiler) {
76
default_c_compiler = compiler;
80
if (default_c_compiler == null)
81
default_c_compiler = new GccCompiler ();
83
foreach (ICompiler compiler in cpp_compilers) {
84
if (compiler.Name == cpp_compiler) {
85
default_cpp_compiler = compiler;
89
if (default_cpp_compiler == null)
90
default_cpp_compiler = new GppCompiler ();
97
store = (Gtk.ListStore)cCombo.Model;
98
store.GetIterFirst (out iter);
100
while (store.IterIsValid (iter)) {
101
if ((string)store.GetValue (iter, 0) == default_c_compiler.Name) {
104
store.IterNext (ref iter);
108
cCombo.Active = active;
111
store = (Gtk.ListStore)cppCombo.Model;
112
store.GetIterFirst (out iter);
114
while (store.IterIsValid (iter)) {
115
if ((string)store.GetValue (iter, 0) == default_cpp_compiler.Name) {
118
store.IterNext (ref iter);
122
cppCombo.Active = active;
127
PropertyService.Set ("CBinding.DefaultCCompiler", default_c_compiler.Name);
128
PropertyService.Set ("CBinding.DefaultCppCompiler", default_cpp_compiler.Name);
129
PropertyService.Set ("CBinding.ParseSystemTags", parseSystemTagsCheck.Active);
130
PropertyService.SaveProperties ();
134
protected virtual void OnCComboChanged (object sender, System.EventArgs e)
136
string activeCompiler = cCombo.ActiveText;
138
foreach (ICompiler compiler in c_compilers) {
139
if (compiler.Name == activeCompiler) {
140
default_c_compiler = compiler;
144
if (default_c_compiler == null)
145
default_c_compiler = new GccCompiler ();
148
protected virtual void OnCppComboChanged (object sender, System.EventArgs e)
150
string activeCompiler = cppCombo.ActiveText;
152
foreach (ICompiler compiler in cpp_compilers) {
153
if (compiler.Name == activeCompiler) {
154
default_cpp_compiler = compiler;
158
if (default_cpp_compiler == null)
159
default_cpp_compiler = new GppCompiler ();
163
public class GeneralOptionsPanelBinding : AbstractOptionPanel
165
private GeneralOptionsPanel panel;
167
public override void LoadPanelContents ()
169
panel = new GeneralOptionsPanel ();
173
public override bool StorePanelContents ()
175
return panel.Store ();