~bratsche/ubuntu/maverick/monodevelop/disable-appmenu

« back to all changes in this revision

Viewing changes to src/addins/CBinding/Gui/GeneralOptionsPanel.cs

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-03-29 23:36:33 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20080329233633-wq5p1rktg8ek3vxc
Tags: 1.0+dfsg-1ubuntu1
* Merge from Debian unstable. (LP: #209012) Remaining Ubuntu changes:
+ debian/control: 
  - Build-dep on xulrunner-1.9-dev instead of firefox-dev
  - Depend on xulrunner-1.9 instead of firefox
+ don't do any MOZILLA_HOME/MOZILLA_FIVE_HOME business which isn't needed
  for xulrunner-1.9 using the standalone glue anymore (gecko gil uses
  standalone by default)
  - add debian/patches/use_xulrunner_1.9.dpatch
  - update debian/patches/00list
* Remove build-dep on libxul-dev and the dep on libxul0d
  since we are using xulrunner1.9 instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// GeneralOptionsPanel.cs
 
3
//
 
4
// Authors:
 
5
//   Marcos David Marin Amador <MarcosMarin@gmail.com>
 
6
//
 
7
// Copyright (C) 2007 Marcos David Marin Amador
 
8
//
 
9
//
 
10
// This source code is licenced under The MIT License:
 
11
//
 
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:
 
19
// 
 
20
// The above copyright notice and this permission notice shall be
 
21
// included in all copies or substantial portions of the Software.
 
22
// 
 
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.
 
30
//
 
31
 
 
32
using System;
 
33
using System.Collections.Generic;
 
34
 
 
35
using Mono.Addins;
 
36
 
 
37
using MonoDevelop.Core;
 
38
using MonoDevelop.Core.Gui.Dialogs;
 
39
 
 
40
namespace CBinding
 
41
{
 
42
        public partial class GeneralOptionsPanel : Gtk.Bin
 
43
        {
 
44
                ICompiler default_c_compiler;
 
45
                List<ICompiler> c_compilers = new List<ICompiler> ();
 
46
                
 
47
                ICompiler default_cpp_compiler;
 
48
                List<ICompiler> cpp_compilers = new List<ICompiler> ();
 
49
                
 
50
                public GeneralOptionsPanel ()
 
51
                {
 
52
                        this.Build ();
 
53
                        
 
54
                        object[] compilers = AddinManager.GetExtensionObjects ("/CBinding/Compilers");
 
55
                
 
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);
 
61
                                }
 
62
                        }
 
63
                        
 
64
                        foreach (ICompiler compiler in c_compilers)
 
65
                                cCombo.AppendText (compiler.Name);
 
66
                        
 
67
                        foreach (ICompiler compiler in cpp_compilers)
 
68
                                cppCombo.AppendText (compiler.Name);
 
69
                        
 
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);
 
73
                        
 
74
                        foreach (ICompiler compiler in c_compilers) {
 
75
                                if (compiler.Name == c_compiler) {
 
76
                                        default_c_compiler = compiler;
 
77
                                }
 
78
                        }
 
79
                        
 
80
                        if (default_c_compiler == null)
 
81
                                default_c_compiler = new GccCompiler ();
 
82
                        
 
83
                        foreach (ICompiler compiler in cpp_compilers) {
 
84
                                if (compiler.Name == cpp_compiler) {
 
85
                                        default_cpp_compiler = compiler;
 
86
                                }
 
87
                        }
 
88
                        
 
89
                        if (default_cpp_compiler == null)
 
90
                                default_cpp_compiler = new GppCompiler ();
 
91
                        
 
92
                        int active;
 
93
                        Gtk.TreeIter iter;
 
94
                        Gtk.ListStore store;
 
95
                        
 
96
                        active = 0;
 
97
                        store = (Gtk.ListStore)cCombo.Model;
 
98
                        store.GetIterFirst (out iter);
 
99
                        
 
100
                        while (store.IterIsValid (iter)) {
 
101
                                if ((string)store.GetValue (iter, 0) == default_c_compiler.Name) {
 
102
                                        break;
 
103
                                }
 
104
                                store.IterNext (ref iter);
 
105
                                active++;
 
106
                        }
 
107
 
 
108
                        cCombo.Active = active;
 
109
                        
 
110
                        active = 0;
 
111
                        store = (Gtk.ListStore)cppCombo.Model;
 
112
                        store.GetIterFirst (out iter);
 
113
                        
 
114
                        while (store.IterIsValid (iter)) {
 
115
                                if ((string)store.GetValue (iter, 0) == default_cpp_compiler.Name) {
 
116
                                        break;
 
117
                                }
 
118
                                store.IterNext (ref iter);
 
119
                                active++;
 
120
                        }
 
121
 
 
122
                        cppCombo.Active = active;
 
123
                }
 
124
                
 
125
                public bool Store ()
 
126
                {
 
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 ();
 
131
                        return true;
 
132
                }
 
133
 
 
134
                protected virtual void OnCComboChanged (object sender, System.EventArgs e)
 
135
                {
 
136
                         string activeCompiler = cCombo.ActiveText;
 
137
                        
 
138
                        foreach (ICompiler compiler in c_compilers) {
 
139
                                if (compiler.Name == activeCompiler) {
 
140
                                        default_c_compiler = compiler;
 
141
                                }
 
142
                        }
 
143
                        
 
144
                        if (default_c_compiler == null)
 
145
                                default_c_compiler = new GccCompiler ();
 
146
                }
 
147
 
 
148
                protected virtual void OnCppComboChanged (object sender, System.EventArgs e)
 
149
                {
 
150
                        string activeCompiler = cppCombo.ActiveText;
 
151
                        
 
152
                        foreach (ICompiler compiler in cpp_compilers) {
 
153
                                if (compiler.Name == activeCompiler) {
 
154
                                        default_cpp_compiler = compiler;
 
155
                                }
 
156
                        }
 
157
                        
 
158
                        if (default_cpp_compiler == null)
 
159
                                default_cpp_compiler = new GppCompiler ();
 
160
                }
 
161
        }
 
162
        
 
163
        public class GeneralOptionsPanelBinding : AbstractOptionPanel
 
164
        {
 
165
                private GeneralOptionsPanel panel;
 
166
                
 
167
                public override void LoadPanelContents ()
 
168
                {
 
169
                        panel = new GeneralOptionsPanel ();
 
170
                        Add (panel);
 
171
                }
 
172
                
 
173
                public override bool StorePanelContents ()
 
174
                {
 
175
                        return panel.Store ();
 
176
                }
 
177
        }
 
178
}