~ubuntu-branches/ubuntu/raring/banshee/raring

« back to all changes in this revision

Viewing changes to .pc/workaround-clideps-meego.patch/src/Extensions/Banshee.MeeGo/Banshee.MeeGo/MeeGoPanel.cs

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2012-01-23 23:16:49 UTC
  • mfrom: (6.3.22 experimental)
  • Revision ID: package-import@ubuntu.com-20120123231649-safm1f8eycltcgsf
Tags: 2.3.4.ds-1ubuntu1
* Merge from Debian Experimental, remaining changes:
  + Enable and recommend SoundMenu and Disable NotificationArea by default
  + Disable boo and karma extensions
  + Enable and suggest u1ms
  + Move desktop file for Meego UI to /usr/share/une/applications
  + Change the url for the Amazon store redirector
  + [08dea2c] Revert "Fix invalid cast causing ftbfs with libgpod"
* [b617fe0] Convert Ubuntu-specific patches to gbp-pq patches
* Also fixes Launchpad bugs:
  - Fixes race condition while starting (LP: #766303)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// MeeGoPanel.cs
3
 
//
4
 
// Author:
5
 
//   Aaron Bockover <abockover@novell.com>
6
 
//
7
 
// Copyright 2009-2010 Novell, Inc.
8
 
//
9
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
 
// of this software and associated documentation files (the "Software"), to deal
11
 
// in the Software without restriction, including without limitation the rights
12
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 
// copies of the Software, and to permit persons to whom the Software is
14
 
// furnished to do so, subject to the following conditions:
15
 
//
16
 
// The above copyright notice and this permission notice shall be included in
17
 
// all copies or substantial portions of the Software.
18
 
//
19
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
 
// THE SOFTWARE.
26
 
 
27
 
using System;
28
 
using Mono.Unix;
29
 
 
30
 
using Gtk;
31
 
using MeeGo.Panel;
32
 
 
33
 
using Hyena;
34
 
using Banshee.Base;
35
 
using Banshee.ServiceStack;
36
 
 
37
 
namespace Banshee.MeeGo
38
 
{
39
 
    public class MeeGoPanel : IDisposable
40
 
    {
41
 
        public static MeeGoPanel Instance { get; private set; }
42
 
 
43
 
        private PanelGtk embedded_panel;
44
 
        private Window window_panel;
45
 
 
46
 
        public MediaPanelContents Contents { get; private set; }
47
 
 
48
 
        public MeeGoPanel ()
49
 
        {
50
 
            if (Instance != null) {
51
 
                throw new InvalidOperationException ("Only one Netbook Panel (MeegoPanel) instance should exist");
52
 
            }
53
 
 
54
 
            Instance = this;
55
 
 
56
 
            var timer = Log.DebugTimerStart ();
57
 
 
58
 
            try {
59
 
                Log.Debug ("Attempting to create Netbook toolbar panel");
60
 
                embedded_panel = new PanelGtk ("banshee", Catalog.GetString ("media"),
61
 
                    null, "media-button", true);
62
 
                embedded_panel.ShowBeginEvent += (o, e) => {
63
 
                    ServiceManager.SourceManager.SetActiveSource (ServiceManager.SourceManager.MusicLibrary);
64
 
                    if (Contents != null) {
65
 
                        Contents.SyncSearchEntry ();
66
 
                    }
67
 
                };
68
 
                while (Gtk.Application.EventsPending ()) {
69
 
                    Gtk.Application.RunIteration ();
70
 
                }
71
 
            } catch (Exception e) {
72
 
                if (!(e is DllNotFoundException)) {
73
 
                    Log.Exception ("Could not bind to Netbook panel", e);
74
 
                }
75
 
                window_panel = new Gtk.Window ("Netbook Media Panel");
76
 
            }
77
 
 
78
 
            Log.DebugTimerPrint (timer, "Netbook panel created: {0}");
79
 
        }
80
 
 
81
 
        public void Dispose ()
82
 
        {
83
 
        }
84
 
 
85
 
        public void BuildContents ()
86
 
        {
87
 
            var timer = Log.DebugTimerStart ();
88
 
            Contents = new MediaPanelContents ();
89
 
            Contents.ShowAll ();
90
 
            Log.DebugTimerPrint (timer, "Netbook panel contents created: {0}");
91
 
 
92
 
            if (embedded_panel != null) {
93
 
                embedded_panel.SetChild (Contents);
94
 
            } else if (window_panel != null) {
95
 
                window_panel.Add (Contents);
96
 
                window_panel.SetDefaultSize (1000, 500);
97
 
                window_panel.WindowPosition = WindowPosition.Center;
98
 
                window_panel.Show ();
99
 
                GLib.Timeout.Add (1000, () => {
100
 
                    window_panel.Present ();
101
 
                    return false;
102
 
                });
103
 
            }
104
 
        }
105
 
 
106
 
        public void Hide ()
107
 
        {
108
 
            window_panel.Hide ();
109
 
            if (embedded_panel != null) {
110
 
                embedded_panel.Hide ();
111
 
            }
112
 
        }
113
 
 
114
 
        public void Show ()
115
 
        {
116
 
            window_panel.Show ();
117
 
            if (embedded_panel != null) {
118
 
                embedded_panel.Show ();
119
 
            }
120
 
        }
121
 
    }
122
 
}