2
// WidgetBuilderOptionPanel.cs
7
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
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:
17
// The above copyright notice and this permission notice shall be
18
// included in all copies or substantial portions of the Software.
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.
31
using System.Collections.Specialized;
32
using System.Collections;
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;
47
namespace MonoDevelop.GtkCore.Dialogs
49
public class WidgetBuilderOptionPanel: AbstractOptionPanel
51
class WidgetBuilderOptionPanelWidget : GladeWidgetExtract
53
[Glade.Widget] Gtk.TreeView tree;
55
TreeViewColumn column;
59
GtkDesignInfo designInfo;
61
public WidgetBuilderOptionPanelWidget (IProperties customizationObject) : base ("gui.glade", "WidgetBuilderOptions")
63
store = new ListStore (typeof(bool), typeof(Pixbuf), typeof(string), typeof(object));
65
tree.HeadersVisible = false;
67
column = new TreeViewColumn ();
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);
75
CellRendererPixbuf pr = new CellRendererPixbuf ();
76
column.PackStart (pr, false);
77
column.AddAttribute (pr, "pixbuf", 1);
79
CellRendererText crt = new CellRendererText ();
80
column.PackStart (crt, true);
81
column.AddAttribute (crt, "text", 2);
83
tree.AppendColumn (column);
85
this.project = (Project)((IProperties)customizationObject).GetProperty("Project");
86
designInfo = GtkCoreService.GetGtkInfo (project);
88
selection = new ArrayList ();
90
if (designInfo != null)
91
selection.AddRange (designInfo.ExportedWidgets);
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);
101
void OnToggled (object o, ToggledArgs args)
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);
111
selection.Remove (txt);
115
public void Store (IProperties customizationObject)
117
if (selection.Count == 0 && (designInfo == null || designInfo.ExportedWidgets.Length == 0))
120
if (designInfo == null)
121
designInfo = GtkCoreService.EnableGtkSupport (project);
122
designInfo.ExportedWidgets = (string[]) selection.ToArray (typeof(string));
123
GtkCoreService.UpdateObjectsFile (project);
127
WidgetBuilderOptionPanelWidget widget;
129
public override void LoadPanelContents()
132
Add (widget = new WidgetBuilderOptionPanelWidget ((IProperties) CustomizationObject));
133
} catch (Exception ex) {
134
Console.WriteLine (ex);
138
public override bool StorePanelContents()
140
widget.Store ((IProperties) CustomizationObject);