~ubuntu-branches/ubuntu/feisty/monodevelop/feisty

« back to all changes in this revision

Viewing changes to Core/src/MonoDevelop.Projects.Gui/MonoDevelop.Projects.Gui.Completion/CompletionListWindow.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-08-18 00:51:23 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060818005123-5iit07y0j7wjg55f
Tags: 0.11+svn20060818-0ubuntu1
* New SVN snapshot
  + Works with Gtk# 2.9.0
* debian/control:
  + Updated Build-Depends
* debian/patches/use_nunit2.2.dpatch,
  debian/patches/use_real_libs.dpatch:
  + Updated
* debian/patches/versioncontrol_buildfix.dpatch:
  + Fix build failure in the version control addin

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
using Gtk;
5
5
using MonoDevelop.Projects;
 
6
using MonoDevelop.Core;
6
7
using MonoDevelop.Core.Gui;
7
8
 
8
9
namespace MonoDevelop.Projects.Gui.Completion
13
14
                ICompletionData[] completionData;
14
15
                DeclarationViewWindow declarationviewwindow = new DeclarationViewWindow ();
15
16
                ICompletionData currentData;
 
17
                ICompletionDataProvider provider;
 
18
                IMutableCompletionDataProvider mutableProvider;
 
19
                Widget parsingMessage;
 
20
                char firstChar;
 
21
                
16
22
                const int declarationWindowMargin = 3;
 
23
                
17
24
                static DataComparer dataComparer = new DataComparer ();
18
25
                
19
26
                class DataComparer: IComparer
51
58
                                
52
59
                                wnd.PartialWord = text; 
53
60
                                //if there is only one matching result we take it by default
54
 
                                if (wnd.IsUniqueMatch)
 
61
                                if (wnd.IsUniqueMatch && !wnd.IsChanging)
55
62
                                {       
 
63
                                        wnd.UpdateWord ();
56
64
                                        wnd.Hide ();
57
65
                                }
58
66
                                
59
 
                                wnd.UpdateWord ();
60
 
                                
61
 
                                wnd.PartialWord = wnd.CompleteWord;
62
67
                        } catch (Exception ex) {
63
68
                                Console.WriteLine (ex);
64
69
                        }
66
71
                
67
72
                bool ShowListWindow (char firstChar, ICompletionDataProvider provider, ICompletionWidget completionWidget)
68
73
                {
 
74
                        if (mutableProvider != null) {
 
75
                                mutableProvider.CompletionDataChanging -= OnCompletionDataChanging;
 
76
                                mutableProvider.CompletionDataChanged -= OnCompletionDataChanged;
 
77
                        }
 
78
                        
 
79
                        this.provider = provider;
 
80
                        mutableProvider = provider as IMutableCompletionDataProvider;
 
81
                        
 
82
                        if (mutableProvider != null) {
 
83
                                mutableProvider.CompletionDataChanging += OnCompletionDataChanging;
 
84
                                mutableProvider.CompletionDataChanged += OnCompletionDataChanged;
 
85
                        
 
86
                                if (mutableProvider.IsChanging)
 
87
                                        OnCompletionDataChanging (null, null);
 
88
                        }
 
89
                        
69
90
                        this.completionWidget = completionWidget;
70
 
                        
 
91
                        this.firstChar = firstChar;
 
92
 
 
93
                        return FillList ();
 
94
                }
 
95
                
 
96
                bool FillList ()
 
97
                {
71
98
                        completionData = provider.GenerateCompletionData (completionWidget, firstChar);
72
 
 
73
 
                        if (completionData == null || completionData.Length == 0) return false;
 
99
                        if ((completionData == null || completionData.Length == 0) && !IsChanging)
 
100
                                return false;
74
101
                        
75
102
                        this.Style = completionWidget.GtkStyle;
76
103
                        
77
 
                        Array.Sort (completionData, dataComparer);
 
104
                        if (completionData == null)
 
105
                                completionData = new ICompletionData [0];
 
106
                        else
 
107
                                Array.Sort (completionData, dataComparer);
78
108
                        
79
109
                        DataProvider = this;
80
110
 
140
170
                
141
171
                void UpdateWord ()
142
172
                {
143
 
                        completionWidget.SetCompletionText(wnd.PartialWord, wnd.CompleteWord);
 
173
                        string word = wnd.CompleteWord;
 
174
                        if (word != null)
 
175
                                completionWidget.SetCompletionText(wnd.PartialWord, word);
144
176
                }
145
177
                
146
178
                public new void Hide ()
172
204
                
173
205
                void UpdateDeclarationView ()
174
206
                {
175
 
                        if (completionData == null || List.Selection >= completionData.Length)
 
207
                        if (completionData == null || List.Selection >= completionData.Length || List.Selection == -1)
176
208
                                return;
177
209
 
178
210
                        if (List.GdkWindow == null) return;
256
288
                {
257
289
                        return RenderIcon (completionData[n].Image, Gtk.IconSize.Menu, "");
258
290
                }
 
291
                
 
292
                internal bool IsChanging {
 
293
                        get { return mutableProvider != null && mutableProvider.IsChanging; }
 
294
                }
 
295
                
 
296
                void OnCompletionDataChanging (object s, EventArgs args)
 
297
                {
 
298
                        if (parsingMessage == null) {
 
299
                                VBox box = new VBox ();
 
300
                                box.PackStart (new Gtk.HSeparator (), false, false, 0);
 
301
                                HBox hbox = new HBox ();
 
302
                                hbox.BorderWidth = 3;
 
303
                                hbox.PackStart (new Gtk.Image (Gtk.Stock.DialogInfo, Gtk.IconSize.Menu), false, false, 0);
 
304
                                Gtk.Label lab = new Gtk.Label (GettextCatalog.GetString ("Gathering class information..."));
 
305
                                lab.Xalign = 0;
 
306
                                hbox.PackStart (lab, true, true, 3);
 
307
                                hbox.ShowAll ();
 
308
                                parsingMessage = hbox;
 
309
                        }
 
310
                        wnd.ShowFooter (parsingMessage);
 
311
                }
 
312
                
 
313
                void OnCompletionDataChanged (object s, EventArgs args)
 
314
                {
 
315
                        wnd.HideFooter ();
 
316
                        Reset ();
 
317
                        FillList ();
 
318
                }
259
319
        }
260
320
}