~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/addins/SourceEditor2/MonoDevelop.SourceEditor.Gui.OptionPanels/SyntaxHighlightingPanel.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
using System;
2
 
using System.IO;
3
 
using System.Text;
4
 
using System.Collections;
5
 
 
6
 
using Gtk;
7
 
using Pango;
8
 
using GtkSourceView;
9
 
 
10
 
using MonoDevelop.Components;
11
 
 
12
 
using MonoDevelop.Core;
13
 
using MonoDevelop.Core.Gui.Dialogs;
14
 
 
15
 
using MonoDevelop.Ide.Gui.Content;
16
 
 
17
 
namespace MonoDevelop.SourceEditor.Gui.OptionPanels
18
 
{
19
 
        class SyntaxHighlightingPanel : AbstractOptionPanel
20
 
        {
21
 
                SyntaxHighlightingPanelWidget widget;
22
 
                
23
 
                public override void LoadPanelContents()
24
 
                {
25
 
                        Add (widget = new SyntaxHighlightingPanelWidget ());
26
 
                }
27
 
                
28
 
                public override bool StorePanelContents()
29
 
                {
30
 
                        widget.Store ();
31
 
                        return true;
32
 
                }
33
 
        
34
 
                class SyntaxHighlightingPanelWidget : GladeWidgetExtract 
35
 
                {       
36
 
                        [Glade.Widget] CheckButton enableSyntaxHighlighting;
37
 
                        [Glade.Widget] ComboBox sourceLanguages;
38
 
                        [Glade.Widget] Gtk.TreeView stylesTreeView;
39
 
                        [Glade.Widget] ToggleButton boldToggle;
40
 
                        [Glade.Widget] ToggleButton italicToggle;
41
 
                        [Glade.Widget] ToggleButton underlineToggle;
42
 
                        [Glade.Widget] ToggleButton strikeToggle;
43
 
                        [Glade.Widget] ColorButton fgColorButton;
44
 
                        [Glade.Widget] ColorButton bgColorButton;
45
 
                        [Glade.Widget] Button restoreDefaultButton;
46
 
                        [Glade.Widget] VBox childrenVBox;
47
 
                        [Glade.Widget] CheckButton checkColor;
48
 
                        [Glade.Widget] CheckButton checkBackground;
49
 
                        
50
 
                        SourceLanguage currentLanguage;
51
 
                        SourceStyleScheme currentStyle;
52
 
                        string styleid;
53
 
                        
54
 
                        public SyntaxHighlightingPanelWidget () :  base ("EditorBindings.glade", "SyntaxHighlightingPanel")
55
 
                        {
56
 
                                enableSyntaxHighlighting.Active = TextEditorProperties.SyntaxHighlight;
57
 
                                
58
 
                                // add available sourceLanguages
59
 
                                ListStore store = new ListStore (typeof (string));
60
 
                                foreach (SourceLanguage sl in SourceViewService.AvailableLanguages)
61
 
                                        store.AppendValues (sl.Name);
62
 
                                store.SetSortColumnId (0, SortType.Ascending);
63
 
                                sourceLanguages.Model = store;
64
 
 
65
 
                                CellRendererText cr = new CellRendererText ();
66
 
                                sourceLanguages.PackStart (cr, true);
67
 
                                sourceLanguages.AddAttribute (cr, "text", 0);
68
 
                                sourceLanguages.Active = 0;
69
 
 
70
 
                                stylesTreeView.AppendColumn ("styles", new CellRendererText (), "text", 0);
71
 
                                stylesTreeView.Selection.Changed += new EventHandler (OnStyleChanged);
72
 
                        }
73
 
 
74
 
                        public void Store ()
75
 
                        {
76
 
                                TextEditorProperties.SyntaxHighlight = enableSyntaxHighlighting.Active;
77
 
                        }
78
 
 
79
 
                        void SetCurrentLanguage (string name)
80
 
                        {
81
 
                                currentLanguage = SourceViewService.FindLanguage (name);
82
 
                                SetTreeValues ();
83
 
                        }
84
 
 
85
 
                        void SetSourceTagStyle ()
86
 
                        {
87
 
                                //FIXME GTKSV2
88
 
                                /*
89
 
                                SourceTagStyle sts = currentStyle;
90
 
                                boldToggle.Active = sts.Bold;
91
 
                                italicToggle.Active = sts.Italic;
92
 
                                underlineToggle.Active = sts.Underline;
93
 
                                strikeToggle.Active = sts.Strikethrough;
94
 
                                fgColorButton.Color = sts.Foreground;
95
 
                                bgColorButton.Color = sts.Background;
96
 
                                checkColor.Active = (sts.Mask & 2) != 0;
97
 
                                checkBackground.Active = (sts.Mask & 1) != 0;
98
 
                                fgColorButton.Sensitive = checkColor.Active;
99
 
                                bgColorButton.Sensitive = checkBackground.Active;
100
 
                                restoreDefaultButton.Sensitive = !sts.IsDefault;*/
101
 
                        }
102
 
 
103
 
                        void SetTreeValues ()
104
 
                        {
105
 
                                //FIXME GTKSV2
106
 
                                /*
107
 
                                // name, id
108
 
                                ListStore store = new ListStore (typeof (string), typeof (string));
109
 
                                foreach (SourceTag t in currentLanguage.Tags)
110
 
                                        store.AppendValues (t.Name, t.Id);
111
 
                                stylesTreeView.Model = store;
112
 
 
113
 
                                TreeIter first;
114
 
                                store.GetIterFirst (out first);
115
 
                                stylesTreeView.Selection.SelectIter (first);*/
116
 
                        }
117
 
 
118
 
                        protected void OnButtonToggled (object sender, EventArgs a)
119
 
                        {
120
 
                                //FIXME GTKSV2
121
 
                                /*
122
 
                                SourceTagStyle sts = currentStyle;
123
 
                                sts.Bold = boldToggle.Active;
124
 
                                sts.Italic = italicToggle.Active;
125
 
                                sts.Underline = underlineToggle.Active;
126
 
                                sts.Strikethrough = strikeToggle.Active;
127
 
                                sts.IsDefault = false;
128
 
                                currentLanguage.SetTagStyle (styleid, sts);
129
 
                                restoreDefaultButton.Sensitive = true;*/
130
 
                        }
131
 
 
132
 
                        protected void OnColorSet (object sender, EventArgs a)
133
 
                        {
134
 
                                //FIXME GTKSV2
135
 
                                /*
136
 
                                SourceTagStyle sts = currentStyle;
137
 
                                sts.Foreground = fgColorButton.Color;
138
 
                                sts.Background = bgColorButton.Color;
139
 
                                sts.Mask = checkColor.Active ? 2u : 0u;
140
 
                                sts.Mask += checkBackground.Active ? 1u : 0u;
141
 
                                fgColorButton.Sensitive = checkColor.Active;
142
 
                                bgColorButton.Sensitive = checkBackground.Active;
143
 
                                sts.IsDefault = false;
144
 
                                currentLanguage.SetTagStyle (styleid, sts);
145
 
                                restoreDefaultButton.Sensitive = true;*/
146
 
                        }
147
 
 
148
 
                        protected void OnHighlightingToggled (object sender, EventArgs a)
149
 
                        {
150
 
                                CheckButton cb = sender as CheckButton;
151
 
                                childrenVBox.Sensitive = cb.Active;
152
 
                        }
153
 
 
154
 
                        protected void OnLanguageSelected (object sender, EventArgs a)
155
 
                        {
156
 
                                TreeIter iter;
157
 
                                if (sourceLanguages.GetActiveIter (out iter)) {
158
 
                                        SetCurrentLanguage ((string) sourceLanguages.Model.GetValue (iter, 0));
159
 
                                }
160
 
                        }
161
 
 
162
 
                        protected void OnRestoreClicked (object sender, EventArgs a)
163
 
                        {
164
 
                                //FIXME GTKSV2
165
 
                                /*
166
 
                                currentLanguage = svs.RestoreDefaults (currentLanguage);
167
 
                                OnStyleChanged (stylesTreeView.Selection, EventArgs.Empty);
168
 
                                */
169
 
                        }
170
 
 
171
 
                        private void OnStyleChanged (object sender, EventArgs a)
172
 
                        {
173
 
                                //FIXME GTKSV2
174
 
                                /*
175
 
                                TreeIter iter;
176
 
                                TreeModel model;
177
 
                                TreeSelection selection = sender as TreeSelection;
178
 
 
179
 
                                if (selection.GetSelected (out model, out iter)) {
180
 
                                        styleid = (string) model.GetValue (iter, 1);
181
 
                                        currentStyle = currentLanguage.GetTagStyle (styleid);
182
 
                                        SetSourceTagStyle ();
183
 
                                }*/
184
 
                        }
185
 
                }
186
 
        }
187
 
}
188