~ubuntu-branches/ubuntu/dapper/monodevelop/dapper

« back to all changes in this revision

Viewing changes to Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-04-11 00:11:45 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060411001145-vujdmnocqeggva00
Tags: 0.10-0pre1ubuntu1
* New upstream release
* Packaging changes based on Mirco Bauer's pre1 package for Debian
* Don't apply use_nunit2.2.dpatch as it's not needed for us
* Adjust Build-Depends:
  + libnunit2.2-cil -> libnunit-cil
  + libmono*-cil -> mono-classlib-1.0
  + liblog4net1.2-cil -> liblog4net-cil
  + mozilla-dev -> firefox-dev
* debian/patches/firefox.dpatch:
  + Re-added

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// WidgetBuilderOptionPanel.cs
 
3
//
 
4
// Author:
 
5
//   Lluis Sanchez Gual
 
6
//
 
7
// Copyright (C) 2006 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
 
 
30
using System;
 
31
using System.Collections.Specialized;
 
32
using System.Collections;
 
33
using Gtk;
 
34
using Gdk;
 
35
using Glade;
 
36
        
 
37
using MonoDevelop.Core.Properties;
 
38
using MonoDevelop.Projects;
 
39
using MonoDevelop.Projects.Parser;
 
40
using MonoDevelop.Ide.Gui;
 
41
using MonoDevelop.Core.Gui;
 
42
using MonoDevelop.Core.Gui.Components;
 
43
using MonoDevelop.Components;
 
44
using MonoDevelop.Core.Gui.Dialogs;
 
45
 
 
46
 
 
47
namespace MonoDevelop.GtkCore.Dialogs
 
48
{
 
49
        public class WidgetBuilderOptionPanel: AbstractOptionPanel
 
50
        {
 
51
                class WidgetBuilderOptionPanelWidget : GladeWidgetExtract
 
52
                {
 
53
                        [Glade.Widget] Gtk.TreeView tree;
 
54
                        ListStore store;
 
55
                        TreeViewColumn column;
 
56
                        
 
57
                        Project project;
 
58
                        ArrayList selection;
 
59
                        GtkDesignInfo designInfo;
 
60
                        
 
61
                        public WidgetBuilderOptionPanelWidget (IProperties customizationObject) : base ("gui.glade", "WidgetBuilderOptions")
 
62
                        {
 
63
                                store = new ListStore (typeof(bool), typeof(Pixbuf), typeof(string), typeof(object));
 
64
                                tree.Model = store;
 
65
                                tree.HeadersVisible = false;
 
66
                                
 
67
                                column = new TreeViewColumn ();
 
68
                        
 
69
                                CellRendererToggle crtog = new CellRendererToggle ();
 
70
                                crtog.Activatable = true;
 
71
                                crtog.Toggled += new ToggledHandler (OnToggled);
 
72
                                column.PackStart (crtog, false);
 
73
                                column.AddAttribute (crtog, "active", 0);
 
74
                                
 
75
                                CellRendererPixbuf pr = new CellRendererPixbuf ();
 
76
                                column.PackStart (pr, false);
 
77
                                column.AddAttribute (pr, "pixbuf", 1);
 
78
                                
 
79
                                CellRendererText crt = new CellRendererText ();
 
80
                                column.PackStart (crt, true);
 
81
                                column.AddAttribute (crt, "text", 2);
 
82
                                
 
83
                                tree.AppendColumn (column);
 
84
                                
 
85
                                this.project = (Project)((IProperties)customizationObject).GetProperty("Project");
 
86
                                designInfo = GtkCoreService.GetGtkInfo (project);
 
87
                                
 
88
                                selection = new ArrayList ();
 
89
 
 
90
                                if (designInfo != null)
 
91
                                        selection.AddRange (designInfo.ExportedWidgets);
 
92
                                
 
93
                                foreach (IClass cls in GtkCoreService.GetExportableClasses (project)) {
 
94
                                        bool exported = designInfo != null && designInfo.IsExported (cls);
 
95
                                        string icon = IdeApp.Services.Icons.GetIcon (cls);
 
96
                                        Pixbuf pic = IdeApp.Services.Resources.GetIcon (icon);
 
97
                                        store.AppendValues (exported, pic, cls.FullyQualifiedName, cls);
 
98
                                }
 
99
                        }
 
100
                        
 
101
                        void OnToggled (object o, ToggledArgs args)
 
102
                        {
 
103
                                TreeIter it;
 
104
                                if (store.GetIter (out it, new TreePath (args.Path))) {
 
105
                                        bool sel = !(bool) store.GetValue (it, 0);
 
106
                                        store.SetValue (it, 0, sel);
 
107
                                        string txt = (string) store.GetValue (it, 2);
 
108
                                        if (sel)
 
109
                                                selection.Add (txt);
 
110
                                        else
 
111
                                                selection.Remove (txt);
 
112
                                }
 
113
                        }
 
114
                
 
115
                        public void Store (IProperties customizationObject)
 
116
                        {
 
117
                                if (selection.Count == 0 && (designInfo == null || designInfo.ExportedWidgets.Length == 0))
 
118
                                        return;
 
119
                                
 
120
                                if (designInfo == null)
 
121
                                        designInfo = GtkCoreService.EnableGtkSupport (project);
 
122
                                designInfo.ExportedWidgets = (string[]) selection.ToArray (typeof(string));
 
123
                                GtkCoreService.UpdateObjectsFile (project);
 
124
                        }
 
125
                }
 
126
                
 
127
                WidgetBuilderOptionPanelWidget widget;
 
128
 
 
129
                public override void LoadPanelContents()
 
130
                {
 
131
                        try {
 
132
                                Add (widget = new WidgetBuilderOptionPanelWidget ((IProperties) CustomizationObject));
 
133
                        } catch (Exception ex) {
 
134
                                Console.WriteLine (ex);
 
135
                        }
 
136
                }
 
137
                
 
138
                public override bool StorePanelContents()
 
139
                {
 
140
                        widget.Store ((IProperties) CustomizationObject);
 
141
                        return true;
 
142
                }
 
143
        }
 
144
        
 
145
}