~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CommonAssemblySigningPreferences.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-09-10 16:54:48 UTC
  • mfrom: (19.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100910165448-0rybfk25zd4o9431
Tags: 2.4+dfsg-2
* debian/patches/inject_Mono.Debugger.Soft_source.patch,
  debian/patches/use_system_Mono.Debugger.Soft.patch,
  debian/control:
  + Build against system Soft Debugger, since we now have a new
    enough Mono to match MonoDevelop's required API

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// CommonAssemblySigningPreferences.cs
 
3
//
 
4
// Author:
 
5
//   Mike Krüger <mkrueger@novell.com>
 
6
//
 
7
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
 
8
//
 
9
// Permission is hereby granted, free of charge, to any person obtaining
 
10
// a copy of this software and associated documentation files (the
 
11
// "Software"), to deal in the Software without restriction, including
 
12
// without limitation the rights to use, copy, modify, merge, publish,
 
13
// distribute, sublicense, and/or sell copies of the Software, and to
 
14
// permit persons to whom the Software is furnished to do so, subject to
 
15
// the following conditions:
 
16
// 
 
17
// The above copyright notice and this permission notice shall be
 
18
// included in all copies or substantial portions of the Software.
 
19
// 
 
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
27
//
 
28
 
 
29
using System;
 
30
using System.Collections.Generic;
 
31
using MonoDevelop.Ide.Gui.Dialogs;
 
32
using MonoDevelop.Projects;
 
33
using MonoDevelop.Core;
 
34
 
 
35
namespace MonoDevelop.Ide.Projects.OptionPanels
 
36
{
 
37
        internal partial class CommonAssemblySigningPreferences : Gtk.Bin
 
38
        {
 
39
                ItemConfiguration[] configurations;
 
40
                string keyFile;
 
41
                
 
42
                public CommonAssemblySigningPreferences ()
 
43
                {
 
44
                        this.Build();
 
45
                }
 
46
                
 
47
                public void LoadPanelContents (Project project, ItemConfiguration[] configurations)
 
48
                {
 
49
                        this.configurations = configurations;
 
50
                        
 
51
                        int signAsm = -1;
 
52
                        
 
53
                        keyFile = null;
 
54
                        foreach (DotNetProjectConfiguration c in configurations) {
 
55
                                int r = c.SignAssembly ? 1 : 0;
 
56
                                if (signAsm == -1)
 
57
                                        signAsm = r;
 
58
                                else if (signAsm != r)
 
59
                                        signAsm = 2;
 
60
                                if (keyFile == null)
 
61
                                        keyFile = c.AssemblyKeyFile;
 
62
                                else if (keyFile != c.AssemblyKeyFile)
 
63
                                        keyFile = "?";
 
64
                        }
 
65
                        
 
66
                        if (signAsm == 2)
 
67
                                signAssemblyCheckbutton.Inconsistent = true;
 
68
                        else {
 
69
                                signAssemblyCheckbutton.Inconsistent = false;
 
70
                                signAssemblyCheckbutton.Active = signAsm == 1;
 
71
                        }
 
72
                        
 
73
                        if (keyFile == null || keyFile == "?")
 
74
                                this.strongNameFileEntry.Path = string.Empty;
 
75
                        else
 
76
                                this.strongNameFileEntry.Path = keyFile;
 
77
                        
 
78
                        this.strongNameFileEntry.DefaultPath = project.BaseDirectory;
 
79
                        this.strongNameFileLabel.Sensitive = this.strongNameFileEntry.Sensitive = signAsm != 0;
 
80
                        this.signAssemblyCheckbutton.Toggled += new EventHandler (SignAssemblyCheckbuttonActivated);
 
81
                }
 
82
                
 
83
                void SignAssemblyCheckbuttonActivated (object sender, EventArgs e)
 
84
                {
 
85
                        signAssemblyCheckbutton.Inconsistent = false;
 
86
                        this.strongNameFileLabel.Sensitive = this.strongNameFileEntry.Sensitive = this.signAssemblyCheckbutton.Active;
 
87
                }
 
88
                
 
89
                public void StorePanelContents ()
 
90
                {
 
91
                        foreach (DotNetProjectConfiguration c in configurations) {
 
92
                                if (!signAssemblyCheckbutton.Inconsistent)
 
93
                                        c.SignAssembly = this.signAssemblyCheckbutton.Active;
 
94
                                if (strongNameFileEntry.Path.Length > 0 || keyFile != "?")
 
95
                                        c.AssemblyKeyFile = this.strongNameFileEntry.Path;
 
96
                        }
 
97
                }
 
98
        }
 
99
        
 
100
        class CommonAssemblySigningPreferencesPanel: MultiConfigItemOptionsPanel
 
101
        {
 
102
                CommonAssemblySigningPreferences widget;
 
103
                
 
104
                public override bool IsVisible ()
 
105
                {
 
106
                        return ConfiguredProject is DotNetProject;
 
107
                }
 
108
 
 
109
                
 
110
                public override Gtk.Widget CreatePanelWidget ()
 
111
                {
 
112
                        AllowMixedConfigurations = true;
 
113
                        return (widget = new CommonAssemblySigningPreferences ());
 
114
                }
 
115
                
 
116
                protected override bool ConfigurationsAreEqual (IEnumerable<ItemConfiguration> configs)
 
117
                {
 
118
                        DotNetProjectConfiguration cref = null;
 
119
                        foreach (DotNetProjectConfiguration c in configs) {
 
120
                                if (cref == null)
 
121
                                        cref = c;
 
122
                                else {
 
123
                                        if (c.SignAssembly != cref.SignAssembly)
 
124
                                                return false;
 
125
                                        if (c.AssemblyKeyFile != cref.AssemblyKeyFile)
 
126
                                                return false;
 
127
                                }
 
128
                        }
 
129
                        return true;
 
130
                }
 
131
                
 
132
                public override void LoadConfigData ()
 
133
                {
 
134
                        widget.LoadPanelContents (ConfiguredProject, CurrentConfigurations);
 
135
                }
 
136
 
 
137
                public override void ApplyChanges ()
 
138
                {
 
139
                        widget.StorePanelContents ();
 
140
                }
 
141
        }
 
142
}