~ubuntu-branches/debian/jessie/banshee-community-extensions/jessie

« back to all changes in this revision

Viewing changes to src/ClutterFlow/Banshee.ClutterFlow/ClutterFlowService.cs

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-09-20 18:45:46 UTC
  • mfrom: (1.2.9 upstream) (5.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20110920184546-3ahue2qplydc4t0e
Tags: 2.2.0-1
* [4940fab] Imported Upstream version 2.2.0
  + Notable bug fixes:
    - Karaoke: Fix crash when switching to Now Playing
    - Lyrics: Fix crash when switching to Now Playing

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
// THE SOFTWARE.
26
26
 
27
27
using System;
28
 
using System.Collections.Generic;
29
28
using Gtk;
30
29
using Mono.Addins;
31
30
 
32
 
using Hyena;
33
 
 
34
 
using Clutter;
35
 
 
36
31
using Banshee.ServiceStack;
37
32
using Banshee.Gui;
38
33
using Banshee.Library;
39
34
using Banshee.Sources;
40
35
using Banshee.Sources.Gui;
41
36
using Banshee.Preferences;
 
37
using Banshee.Preferences.Gui;
42
38
 
43
39
using ClutterFlow;
44
40
 
45
41
namespace Banshee.ClutterFlow
46
42
{
47
 
 
48
 
    internal static class ClutterFlowManager
 
43
    public class ClutterFlowService : IExtensionService, IDisposable
49
44
    {
50
 
        private static int state = 0;
51
 
        public static event EventHandler BeforeQuit;
52
 
 
53
 
        public static void Init ()
54
 
        {
55
 
            if (state < 1) {
56
 
                //TODO provide a static class for initialisation that does not get destroyed when this service is
57
 
                // it should hold reference to the ActorLoader instances, as they hold precious references to texture,
58
 
                // data that apparently remains in memory
59
 
                if (!GLib.Thread.Supported) GLib.Thread.Init();
60
 
                Clutter.Threads.Init();
61
 
                if (ClutterHelper.gtk_clutter_init (IntPtr.Zero, IntPtr.Zero) != InitError.Success)
62
 
                    throw new System.NotSupportedException ("Unable to initialize GtkClutter");
63
 
                System.AppDomain.CurrentDomain.ProcessExit += HandleProcessExit;
64
 
                state = 1;
65
 
            }
66
 
        }
67
 
 
68
 
        static void HandleProcessExit(object sender, EventArgs e)
69
 
        {
70
 
            if (state == 1)
71
 
                System.AppDomain.CurrentDomain.ProcessExit -= HandleProcessExit;
72
 
            Quit ();
73
 
        }
74
 
 
75
 
        public static void Quit ()
76
 
        {
77
 
            if (state == 1) {
78
 
                EventHandler handler = BeforeQuit;
79
 
                if (handler != null) {
80
 
                    handler (null, EventArgs.Empty);
81
 
                }
82
 
                Clutter.Application.Quit ();
83
 
                filter_view.Dispose ();
84
 
                filter_view = null;
85
 
                state = 2;
86
 
            }
87
 
        }
88
 
 
89
 
        private static ClutterFlowView filter_view;
90
 
        public static ClutterFlowView FilterView {
91
 
            get {
92
 
                if (filter_view==null)
93
 
                    filter_view = new ClutterFlowView ();
94
 
                else if (!filter_view.Attached)
95
 
                    filter_view.AttachEvents ();
96
 
                return filter_view;
97
 
            }
98
 
        }
99
 
    }
100
 
                
101
 
        public class ClutterFlowService : IExtensionService, IDisposable
102
 
        {               
103
 
                #region Fields
104
 
                string IService.ServiceName {
105
 
                        get { return "ClutterFlowService"; }
106
 
                }
107
 
                
108
 
                private SourceManager source_manager;
109
 
                private MusicLibrarySource music_library;
110
 
 
111
 
                private PreferenceService preference_service;
112
 
                private InterfaceActionService action_service;
 
45
        #region Fields
 
46
        string IService.ServiceName {
 
47
            get { return "ClutterFlowService"; }
 
48
        }
 
49
 
 
50
        private SourceManager source_manager;
 
51
        private MusicLibrarySource music_library;
 
52
 
 
53
        private PreferenceService preference_service;
 
54
        private InterfaceActionService action_service;
113
55
 
114
56
        private uint ui_manager_id;
115
57
        private ActionGroup clutterflow_actions;
116
 
                private ToggleAction browser_action;
117
 
                protected ToggleAction BrowserAction {
118
 
                        get {
119
 
                                if (browser_action==null)
120
 
                                        browser_action = (ToggleAction) action_service.FindAction("BrowserView.BrowserVisibleAction");
121
 
                                return browser_action;
122
 
                        }
123
 
                }
124
 
                private ToggleAction cfbrows_action;
125
 
                protected ToggleAction CfBrowsAction {
126
 
                        get {
127
 
                                if (cfbrows_action==null)
128
 
                                        cfbrows_action = (ToggleAction) action_service.FindAction("ClutterFlowView.ClutterFlowVisibleAction");
129
 
                                return cfbrows_action;
130
 
                        }
131
 
                }
132
 
                private static string menu_xml = @"
133
 
                        <ui>
134
 
                                <menubar name=""MainMenu"">
135
 
                                        <menu name=""ViewMenu"" action=""ViewMenuAction"">
136
 
                                                <placeholder name=""BrowserViews"">
137
 
                                                        <menuitem name=""ClutterFlow"" action=""ClutterFlowVisibleAction"" />
138
 
                                                </placeholder>
139
 
                                        </menu>
140
 
                                </menubar>
141
 
                        </ui>
142
 
                ";
143
 
 
144
 
                private ClutterFlowContents clutter_flow_contents;
145
 
                #endregion
146
 
                
147
 
                #region Initialization
148
 
 
149
 
                public ClutterFlowService ()
150
 
                {
151
 
            ClutterFlowManager.Init ();
152
 
                }
153
 
 
154
 
                void IExtensionService.Initialize ()
155
 
                {       
156
 
                        preference_service = ServiceManager.Get<PreferenceService> ();
157
 
                        action_service = ServiceManager.Get<InterfaceActionService> ();
158
 
 
159
 
                        source_manager = ServiceManager.SourceManager;
160
 
                        music_library = source_manager.MusicLibrary;
161
 
                        
162
 
                        if (!SetupPreferences () || !SetupInterfaceActions ())
163
 
                                ServiceManager.ServiceStarted += OnServiceStarted;
164
 
                        else if (!SetupSourceContents ())
165
 
                                source_manager.SourceAdded += OnSourceAdded;
166
 
                                
167
 
                        
168
 
                        //--> TODO Banshee.ServiceStack.Application. register Exit event to close threads etc.
169
 
                }
170
 
 
171
 
                private void OnServiceStarted (ServiceStartedArgs args)
172
 
                {
173
 
                        if (args.Service is Banshee.Preferences.PreferenceService) {
174
 
                                preference_service = (PreferenceService)args.Service;
175
 
                                SetupPreferences ();
176
 
                        } else if (args.Service is Banshee.Gui.InterfaceActionService) {
177
 
                                action_service = (InterfaceActionService)args.Service;
178
 
                                SetupInterfaceActions ();
179
 
                        }
180
 
 
181
 
                        if (!(preference_service==null || action_service==null)) {
182
 
                                ServiceManager.ServiceStarted -= OnServiceStarted;
183
 
                                if (!SetupSourceContents ())
184
 
                                        source_manager.SourceAdded += OnSourceAdded;
185
 
                        }
186
 
                }
187
 
                
188
 
                private void OnSourceAdded (SourceAddedArgs args)
189
 
                {
190
 
                        if (args.Source is MusicLibrarySource)
191
 
                                music_library = args.Source as MusicLibrarySource;
192
 
                        SetupSourceContents ();
193
 
                }
194
 
                #endregion
195
 
                
196
 
                #region Setup
197
 
                private bool SetupSourceContents ()
198
 
                {
199
 
                        if (music_library==null || preference_service==null || action_service==null
200
 
                            || ServiceManager.SourceManager.ActiveSource == null)
201
 
                                return false;           
 
58
        private ToggleAction browser_action;
 
59
        protected ToggleAction BrowserAction {
 
60
            get {
 
61
                if (browser_action==null) {
 
62
                    browser_action = (ToggleAction) action_service.FindAction("BrowserView.BrowserVisibleAction");
 
63
                }
 
64
                return browser_action;
 
65
            }
 
66
        }
 
67
        private ToggleAction cfbrows_action;
 
68
        protected ToggleAction CfBrowsAction {
 
69
            get {
 
70
                if (cfbrows_action==null) {
 
71
                    cfbrows_action = (ToggleAction) action_service.FindAction("ClutterFlowView.ClutterFlowVisibleAction");
 
72
                }
 
73
                return cfbrows_action;
 
74
            }
 
75
        }
 
76
        private static string menu_xml = @"
 
77
            <ui>
 
78
                <menubar name=""MainMenu"">
 
79
                    <menu name=""ViewMenu"" action=""ViewMenuAction"">
 
80
                        <placeholder name=""BrowserViews"">
 
81
                            <menuitem name=""ClutterFlow"" action=""ClutterFlowVisibleAction"" />
 
82
                        </placeholder>
 
83
                    </menu>
 
84
                </menubar>
 
85
            </ui>
 
86
        ";
 
87
 
 
88
        private ClutterFlowContents clutter_flow_contents;
 
89
        #endregion
 
90
 
 
91
        #region Initialization
 
92
 
 
93
        public ClutterFlowService ()
 
94
        { }
 
95
 
 
96
        void IExtensionService.Initialize ()
 
97
        {
 
98
            ClutterHelper.Init ();
 
99
 
 
100
            preference_service = ServiceManager.Get<PreferenceService> ();
 
101
            action_service = ServiceManager.Get<InterfaceActionService> ();
 
102
 
 
103
            source_manager = ServiceManager.SourceManager;
 
104
            music_library = source_manager.MusicLibrary;
 
105
 
 
106
            if (!SetupPreferences () || !SetupInterfaceActions ()) {
 
107
                ServiceManager.ServiceStarted += OnServiceStarted;
 
108
            } else if (!SetupSourceContents ()) {
 
109
                source_manager.SourceAdded += OnSourceAdded;
 
110
            }
 
111
 
 
112
            //--> TODO Banshee.ServiceStack.Application. register Exit event to close threads etc.
 
113
        }
 
114
 
 
115
        private void OnServiceStarted (ServiceStartedArgs args)
 
116
        {
 
117
            if (args.Service is Banshee.Preferences.PreferenceService) {
 
118
                preference_service = (PreferenceService)args.Service;
 
119
                SetupPreferences ();
 
120
            } else if (args.Service is Banshee.Gui.InterfaceActionService) {
 
121
                action_service = (InterfaceActionService)args.Service;
 
122
                SetupInterfaceActions ();
 
123
            }
 
124
 
 
125
            if (!(preference_service==null || action_service==null)) {
 
126
                ServiceManager.ServiceStarted -= OnServiceStarted;
 
127
                if (!SetupSourceContents ()) {
 
128
                    source_manager.SourceAdded += OnSourceAdded;
 
129
                }
 
130
            }
 
131
        }
 
132
 
 
133
        private void OnSourceAdded (SourceAddedArgs args)
 
134
        {
 
135
            if (args.Source is MusicLibrarySource) {
 
136
                music_library = args.Source as MusicLibrarySource;
 
137
            }
 
138
            SetupSourceContents ();
 
139
        }
 
140
        #endregion
 
141
 
 
142
        #region Setup
 
143
        private bool SetupSourceContents ()
 
144
        {
 
145
            if (music_library == null || preference_service == null || action_service == null
 
146
                || ServiceManager.SourceManager.ActiveSource == null) {
 
147
                return false;
 
148
            }
 
149
            source_manager.SourceAdded -= OnSourceAdded;
202
150
 
203
151
            clutter_flow_contents = new ClutterFlowContents ();
204
 
                        clutter_flow_contents.SetSource(music_library);
205
 
 
206
 
                        if (ClutterFlowSchemas.ShowClutterFlow.Get ()) {
207
 
                                BrowserAction.Active = false;
208
 
                                music_library.Properties.Set<ISourceContents> ("Nereid.SourceContents", clutter_flow_contents);
209
 
                        }
210
 
                        
211
 
                        source_manager.SourceAdded -= OnSourceAdded;
212
 
                        return true;
213
 
                }
214
 
                
215
 
                private bool SetupPreferences ()
216
 
                {
217
 
                        InstallPreferences ();
218
 
                        
219
 
                        return true;
220
 
                }
221
 
                
222
 
                private bool SetupInterfaceActions ()
223
 
                {
224
 
                        
 
152
            clutter_flow_contents.SetSource (music_library);
 
153
 
 
154
            if (ClutterFlowSchemas.ShowClutterFlow.Get ()) {
 
155
                BrowserAction.Active = false;
 
156
                music_library.Properties.Set<ISourceContents> ("Nereid.SourceContents", clutter_flow_contents);
 
157
            }
 
158
 
 
159
            LoadPreferences ();
 
160
 
 
161
            return true;
 
162
        }
 
163
 
 
164
        private bool SetupPreferences ()
 
165
        {
 
166
            InstallPreferences ();
 
167
 
 
168
            return true;
 
169
        }
 
170
 
 
171
        private bool SetupInterfaceActions ()
 
172
        {
 
173
 
225
174
            action_service = ServiceManager.Get<InterfaceActionService> ();
226
175
 
227
176
            if (action_service.FindActionGroup ("ClutterFlowView") == null) {
243
192
            CfBrowsAction.Activated += OnToggleClutterFlow;
244
193
 
245
194
            return true;
246
 
                }
247
 
                #endregion
 
195
        }
 
196
        #endregion
248
197
 
249
 
                #region Action Handling
 
198
        #region Action Handling
250
199
        private void HandleActiveSourceChanged (SourceEventArgs args)
251
200
        {
252
 
            if (args.Source==music_library)
 
201
            if (args.Source==music_library) {
253
202
                clutterflow_actions.Visible = true;
254
 
           else
 
203
            } else {
255
204
                clutterflow_actions.Visible = false;
 
205
            }
256
206
        }
257
207
 
258
 
                private void OnToggleBrowser (object sender, EventArgs e)
259
 
                {
260
 
                        if (BrowserAction.Active) {
 
208
        private void OnToggleBrowser (object sender, EventArgs e)
 
209
        {
 
210
            if (BrowserAction.Active) {
261
211
                ClutterFlowSchemas.OldShowBrowser.Set (true);
262
 
                                CfBrowsAction.Active = false;
263
 
                                ClutterFlowSchemas.ShowClutterFlow.Set (false);
264
 
                        }
265
 
                }
266
 
 
267
 
                
268
 
                private void OnToggleClutterFlow (object sender, EventArgs e)
269
 
                {
270
 
                        if (CfBrowsAction.Active) {
271
 
                                ClutterFlowSchemas.ShowClutterFlow.Set (true);
 
212
                CfBrowsAction.Active = false;
 
213
                ClutterFlowSchemas.ShowClutterFlow.Set (false);
 
214
            }
 
215
        }
 
216
 
 
217
 
 
218
        private void OnToggleClutterFlow (object sender, EventArgs e)
 
219
        {
 
220
            if (CfBrowsAction.Active) {
 
221
                ClutterFlowSchemas.ShowClutterFlow.Set (true);
272
222
                ClutterFlowSchemas.OldShowBrowser.Set (BrowserAction.Active);
273
 
                                BrowserAction.Active = false;
274
 
                                Clutter.Threads.Enter ();
275
 
                                music_library.Properties.Set<ISourceContents> ("Nereid.SourceContents", clutter_flow_contents);
276
 
                                Clutter.Threads.Leave ();
277
 
                        } else {
278
 
                                ClutterFlowSchemas.ShowClutterFlow.Set (false);
279
 
                                Clutter.Threads.Enter ();
280
 
                                music_library.Properties.Remove ("Nereid.SourceContents");
281
 
                                Clutter.Threads.Leave ();
282
 
                                BrowserAction.Active = ClutterFlowSchemas.OldShowBrowser.Get ();
283
 
                        }
284
 
                }
 
223
                BrowserAction.Active = false;
 
224
                Clutter.Threads.Enter ();
 
225
                music_library.Properties.Set<ISourceContents> ("Nereid.SourceContents", clutter_flow_contents);
 
226
                Clutter.Threads.Leave ();
 
227
            } else {
 
228
                ClutterFlowSchemas.ShowClutterFlow.Set (false);
 
229
                Clutter.Threads.Enter ();
 
230
                music_library.Properties.Remove ("Nereid.SourceContents");
 
231
                Clutter.Threads.Leave ();
 
232
                BrowserAction.Active = ClutterFlowSchemas.OldShowBrowser.Get ();
 
233
            }
 
234
        }
285
235
 
286
 
                private void RemoveClutterFlow ()
287
 
                {
 
236
        private void RemoveClutterFlow ()
 
237
        {
288
238
            Clutter.Threads.Enter ();
289
239
            music_library.Properties.Remove ("Nereid.SourceContents");
290
240
            Clutter.Threads.Leave ();
292
242
            clutter_flow_contents = null;
293
243
 
294
244
            source_manager.ActiveSourceChanged -= HandleActiveSourceChanged;
295
 
                        BrowserAction.Activated -= OnToggleBrowser;
 
245
            BrowserAction.Activated -= OnToggleBrowser;
296
246
            BrowserAction.Active = ClutterFlowSchemas.OldShowBrowser.Get ();
297
 
                        CfBrowsAction.Activated -= OnToggleClutterFlow;
 
247
            CfBrowsAction.Activated -= OnToggleClutterFlow;
298
248
            CfBrowsAction.Visible = false;
299
249
 
300
250
            action_service.RemoveActionGroup ("ClutterFlowView");
308
258
            action_service = null;
309
259
            browser_action = null;
310
260
            cfbrows_action = null;
311
 
                }
312
 
                #endregion
313
 
 
314
 
                #region Preferences
315
 
 
316
 
                private bool pref_installed = false;
317
 
                private Page pref_page;
 
261
        }
 
262
        #endregion
 
263
 
 
264
        #region Preferences
 
265
 
 
266
        private bool pref_installed = false;
 
267
        private Page pref_page;
318
268
        private Section general;
319
 
                private Section dimensions;
320
 
                
321
 
                protected void InstallPreferences ()
322
 
                {
323
 
                        if (!pref_installed) {
324
 
                                pref_page = preference_service.Add(new Page("clutterflow",
 
269
        private Section dimensions;
 
270
 
 
271
        protected void InstallPreferences ()
 
272
        {
 
273
            if (!pref_installed) {
 
274
                preference_service.InstallWidgetAdapters += OnPreferencesServiceInstallWidgetAdapters;
 
275
 
 
276
                pref_page = preference_service.Add(new Page("clutterflow",
325
277
                                                            AddinManager.CurrentLocalizer.GetString ("ClutterFlow"), 10));
326
 
                                
327
 
                    general = pref_page.Add (new Section ("general",
328
 
                        AddinManager.CurrentLocalizer.GetString ("General"), 1));
329
 
                ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.InstantPlayback, UpdateLabelVisibility);
 
278
 
 
279
                general = pref_page.Add (new Section ("general",
 
280
                    AddinManager.CurrentLocalizer.GetString ("General"), 1));
 
281
                ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.InstantPlayback, null);
330
282
                ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.DisplayLabel, UpdateLabelVisibility);
331
283
                ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.DisplayTitle, UpdateTitleVisibility);
332
284
                ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.VisibleCovers, UpdateVisibleCovers);
333
 
                                ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.DragSensitivity, UpdateDragSensitivity);
334
 
                                ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.ThreadedArtwork, UpdateThreadedArtwork);
335
 
                                
336
 
                                dimensions = pref_page.Add (new Section ("dimensions",
337
 
                        AddinManager.CurrentLocalizer.GetString ("Dimensions"), 2));
338
 
                                ClutterFlowSchemas.AddToSection (dimensions, ClutterFlowSchemas.MinCoverSize, UpdateMinCoverSize);
339
 
                                ClutterFlowSchemas.AddToSection (dimensions, ClutterFlowSchemas.MaxCoverSize, UpdateMinCoverSize);
340
 
                                ClutterFlowSchemas.AddToSection (dimensions, ClutterFlowSchemas.TextureSize, UpdateMinCoverSize);
341
 
        
342
 
                                LoadPreferences ();
343
 
 
344
 
                                pref_installed = true;
345
 
                        }
346
 
                }
347
 
 
348
 
                private void LoadPreferences ()
349
 
                {
350
 
                        UpdateThreadedArtwork ();
351
 
                        UpdateDragSensitivity ();
352
 
                        UpdateLabelVisibility ();
353
 
                        UpdateTitleVisibility ();
354
 
                        UpdateVisibleCovers ();
355
 
                        UpdateMinCoverSize ();
356
 
                        UpdateMaxCoverSize ();
357
 
                        UpdateTextureSize ();
358
 
                }
359
 
                
360
 
        private void UpdateThreadedArtwork ()
361
 
        {
362
 
 
363
 
        }
364
 
                
365
 
                private void UpdateDragSensitivity ()
366
 
                {
367
 
                        if (clutter_flow_contents != null)
368
 
                                clutter_flow_contents.FilterView.DragSensitivity =
369
 
                                        (float) ClutterFlowSchemas.DragSensitivity.Get () * 0.1f;
370
 
                }
371
 
 
372
 
                private void UpdateLabelVisibility ()
373
 
                {
374
 
                        if (clutter_flow_contents != null)
375
 
                                clutter_flow_contents.FilterView.LabelCoverIsVisible =
376
 
                                        ClutterFlowSchemas.DisplayLabel.Get ();
377
 
                }
378
 
                
379
 
                private void UpdateTitleVisibility ()
380
 
                {
381
 
                        if (clutter_flow_contents != null)
382
 
                                clutter_flow_contents.FilterView.LabelTrackIsVisible =
383
 
                                        ClutterFlowSchemas.DisplayTitle.Get ();
384
 
                }
385
 
                
386
 
                private void UpdateVisibleCovers ()
387
 
                {
388
 
                        if (clutter_flow_contents!=null)
389
 
                                clutter_flow_contents.FilterView.CoverManager.VisibleCovers =
390
 
                                        ((ClutterFlowSchemas.VisibleCovers.Get () + 1) * 2 + 1);
391
 
                }
392
 
                
393
 
                private void UpdateMinCoverSize ()
394
 
                {
395
 
                        if (clutter_flow_contents != null)
396
 
                                clutter_flow_contents.FilterView.CoverManager.Behaviour.MinCoverWidth =
397
 
                                        ClutterFlowSchemas.MinCoverSize.Get ();
398
 
                }
399
 
 
400
 
                private void UpdateMaxCoverSize ()
401
 
                {
402
 
                        if (clutter_flow_contents != null)
403
 
                                clutter_flow_contents.FilterView.CoverManager.Behaviour.MaxCoverWidth =
404
 
                                        ClutterFlowSchemas.MaxCoverSize.Get ();
405
 
                }
406
 
 
407
 
                private void UpdateTextureSize ()
408
 
                {
409
 
                        if (clutter_flow_contents != null)
410
 
                                clutter_flow_contents.FilterView.CoverManager.TextureSize =
411
 
                                        ClutterFlowSchemas.TextureSize.Get ();
412
 
                }
413
 
                
 
285
                ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.DragSensitivity, UpdateDragSensitivity);
 
286
 
 
287
                dimensions = pref_page.Add (new Section ("dimensions",
 
288
                    AddinManager.CurrentLocalizer.GetString ("Dimensions"), 2));
 
289
                dimensions.Add (new VoidPreference ("dimensions-desc"));
 
290
                ClutterFlowSchemas.AddToSection (dimensions, ClutterFlowSchemas.MinCoverSize, UpdateMinCoverSize);
 
291
                ClutterFlowSchemas.AddToSection (dimensions, ClutterFlowSchemas.MaxCoverSize, UpdateMaxCoverSize);
 
292
                ClutterFlowSchemas.AddToSection (dimensions, ClutterFlowSchemas.TextureSize, UpdateTextureSize);
 
293
 
 
294
                pref_installed = true;
 
295
            }
 
296
        }
 
297
 
 
298
        private void LoadPreferences ()
 
299
        {
 
300
            UpdateDragSensitivity ();
 
301
            UpdateLabelVisibility ();
 
302
            UpdateTitleVisibility ();
 
303
            UpdateVisibleCovers ();
 
304
            UpdateMinCoverSize ();
 
305
            UpdateMaxCoverSize ();
 
306
            UpdateTextureSize ();
 
307
        }
 
308
 
 
309
        private void UpdateDragSensitivity ()
 
310
        {
 
311
            if (clutter_flow_contents != null) {
 
312
                clutter_flow_contents.FilterView.DragSensitivity =
 
313
                    (float) ClutterFlowSchemas.DragSensitivity.Get () * 0.1f;
 
314
            }
 
315
        }
 
316
 
 
317
        private void UpdateLabelVisibility ()
 
318
        {
 
319
            if (clutter_flow_contents != null) {
 
320
                clutter_flow_contents.FilterView.LabelCoverIsVisible =
 
321
                    ClutterFlowSchemas.DisplayLabel.Get ();
 
322
            }
 
323
        }
 
324
 
 
325
        private void UpdateTitleVisibility ()
 
326
        {
 
327
            if (clutter_flow_contents != null) {
 
328
                clutter_flow_contents.FilterView.LabelTrackIsVisible =
 
329
                    ClutterFlowSchemas.DisplayTitle.Get ();
 
330
            }
 
331
        }
 
332
 
 
333
        private void UpdateVisibleCovers ()
 
334
        {
 
335
            if (clutter_flow_contents!=null) {
 
336
                clutter_flow_contents.FilterView.CoverManager.VisibleCovers =
 
337
                    ((ClutterFlowSchemas.VisibleCovers.Get () + 1) * 2 + 1);
 
338
            }
 
339
        }
 
340
 
 
341
        private void UpdateMinCoverSize ()
 
342
        {
 
343
            if (clutter_flow_contents != null) {
 
344
                clutter_flow_contents.FilterView.CoverManager.Behaviour.MinCoverWidth =
 
345
                    ClutterFlowSchemas.MinCoverSize.Get ();
 
346
            }
 
347
        }
 
348
 
 
349
        private void UpdateMaxCoverSize ()
 
350
        {
 
351
            if (clutter_flow_contents != null) {
 
352
                clutter_flow_contents.FilterView.CoverManager.Behaviour.MaxCoverWidth =
 
353
                    ClutterFlowSchemas.MaxCoverSize.Get ();
 
354
            }
 
355
        }
 
356
 
 
357
        private void UpdateTextureSize ()
 
358
        {
 
359
            if (clutter_flow_contents != null) {
 
360
                clutter_flow_contents.FilterView.CoverManager.TextureSize =
 
361
                    ClutterFlowSchemas.TextureSize.Get ();
 
362
            }
 
363
        }
 
364
 
414
365
        private void UninstallPreferences ()
415
366
        {
 
367
            preference_service.InstallWidgetAdapters -= OnPreferencesServiceInstallWidgetAdapters;
 
368
 
416
369
            preference_service.Remove (pref_page);
417
370
            pref_page = null;
418
371
            general = null;
419
 
                        dimensions = null;
420
 
                        pref_installed = false;
421
 
        }
422
 
                #endregion
 
372
            dimensions = null;
 
373
            pref_installed = false;
 
374
        }
 
375
 
 
376
        private void OnPreferencesServiceInstallWidgetAdapters (object o, EventArgs args)
 
377
        {
 
378
            if (dimensions == null) {
 
379
                return;
 
380
            }
 
381
 
 
382
            var description_label = new DescriptionLabel (AddinManager.CurrentLocalizer.GetString (
 
383
                "For changes to these values to take effect, you need to restart Banshee"));
 
384
            dimensions["dimensions-desc"].ShowLabel = false;
 
385
            dimensions["dimensions-desc"].DisplayWidget = description_label;
 
386
        }
 
387
 
 
388
        #endregion
423
389
 
424
390
        private bool disposed = false;
425
 
                public void Dispose ()
426
 
                {
427
 
            if (disposed)
 
391
        public void Dispose ()
 
392
        {
 
393
            if (disposed) {
428
394
                return;
 
395
            }
429
396
            disposed = true;
430
397
 
431
398
            ServiceManager.ServiceStarted -= OnServiceStarted;
433
400
 
434
401
            UninstallPreferences ();
435
402
            RemoveClutterFlow ();
436
 
                }
437
 
        }
 
403
 
 
404
            ClutterHelper.Quit ();
 
405
         }
 
406
    }
438
407
}