~ubuntu-branches/ubuntu/trusty/banshee/trusty-updates

« back to all changes in this revision

Viewing changes to src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2013-12-22 04:11:14 UTC
  • mfrom: (1.2.25) (150.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131222041114-w19a3qe6h9ld7329
* [e46e107] Merge from Debian Experimental, remaining changes:
  - Enable and recommend SoundMenu and Disable NotificationArea by default
  - Disable boo and karma extensions
  - Move desktop file for Meego UI to /usr/share/une/applications
  - Change the url for the Amazon store redirector
  - [9b356d6] Add workaround for set_Height exception.
  - [ccbcbbd] Make Banshee translatable in Launchpad
  - [2094ee5] Bump libgpod build-dep version to 0.8.2-7~
  - [03c8cad] Set debian-branch to ubuntu/raring

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
 
82
82
        private bool first_style_set = false;
83
83
 
84
 
        protected override void OnStyleSet (Style old_style)
 
84
        protected override void OnStyleUpdated ()
85
85
        {
86
 
            base.OnStyleSet (old_style);
 
86
            base.OnStyleUpdated ();
87
87
 
88
88
            if (first_style_set) {
89
89
                BuildLayouts ();
93
93
            first_style_set = true;
94
94
        }
95
95
 
96
 
        protected override void OnSizeRequested (ref Gtk.Requisition requisition)
97
 
        {
98
 
            if (!IsRealized || layout == null) {
99
 
                return;
100
 
            }
101
 
 
102
 
            int width, height;
103
 
            layout.GetPixelSize (out width, out height);
104
 
 
105
 
            requisition.Width = width;
106
 
            requisition.Height = height;
107
 
        }
108
 
 
109
 
        protected override bool OnExposeEvent (Gdk.EventExpose evnt)
 
96
        protected override void OnGetPreferredHeight (out int minimum_height, out int natural_height)
 
97
        {
 
98
            minimum_height = natural_height = 0;
 
99
            if (!IsRealized || layout == null) {
 
100
                return;
 
101
            }
 
102
 
 
103
            int width, height;
 
104
            layout.GetPixelSize (out width, out height);
 
105
            minimum_height = natural_height = height;
 
106
        }
 
107
 
 
108
        protected override void OnGetPreferredWidth (out int minimum_width, out int natural_width)
 
109
        {
 
110
            minimum_width = natural_width = 0;
 
111
            if (!IsRealized || layout == null) {
 
112
                return;
 
113
            }
 
114
 
 
115
            int width, height;
 
116
            layout.GetPixelSize (out width, out height);
 
117
            minimum_width = natural_width = width;
 
118
        }
 
119
 
 
120
        protected override bool OnDrawn (Cairo.Context cr)
110
121
        {
111
122
            int bar_width = (int)((double)Allocation.Width * buffering_progress);
112
123
            bool render_bar = false;
113
124
 
 
125
            var border = StyleContext.GetBorder (StateFlags);
114
126
            if (bar_width > 0 && IsBuffering) {
115
 
                bar_width -= 2 * Style.XThickness;
 
127
                bar_width -= border.Left + border.Right;
116
128
                render_bar = true;
117
129
 
118
 
                Gtk.Style.PaintBox (Style, GdkWindow, StateType.Normal, ShadowType.In, evnt.Area, this, null,
119
 
                    Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
 
130
                StyleContext.Save ();
 
131
                StyleContext.AddClass ("trough");
 
132
                StyleContext.RenderBackground (cr, 0, 0, Allocation.Width, Allocation.Height);
 
133
                StyleContext.RenderFrame (cr, 0, 0, Allocation.Width, Allocation.Height);
 
134
                StyleContext.Restore ();
120
135
 
121
136
                if (bar_width > 0) {
122
 
                    Gtk.Style.PaintBox (Style, GdkWindow, StateType.Selected, ShadowType.EtchedOut,
123
 
                        evnt.Area, this, "bar",
124
 
                        Allocation.X + Style.XThickness, Allocation.Y + Style.YThickness,
125
 
                        bar_width, Allocation.Height - 2 * Style.YThickness);
 
137
                    StyleContext.Save ();
 
138
                    StyleContext.AddClass ("progressbar");
 
139
                    StyleContext.RenderActivity (cr,
 
140
                        border.Left, border.Top,
 
141
                        bar_width, Allocation.Height - (border.Top + border.Bottom));
 
142
                    StyleContext.Restore ();
126
143
                }
127
144
            }
128
145
 
129
146
            int width, height;
130
147
            layout.GetPixelSize (out width, out height);
131
148
 
132
 
            int x = Allocation.X + ((Allocation.Width - width) / 2);
133
 
            int y = Allocation.Y + ((Allocation.Height - height) / 2);
134
 
            Gdk.Rectangle rect = evnt.Area;
 
149
            int x = (Allocation.Width - width) / 2;
 
150
            int y = (Allocation.Height - height) / 2;
 
151
            Gdk.Rectangle rect = new Gdk.Rectangle (0, 0, Allocation.Width, Allocation.Height);
135
152
 
136
153
            if (render_bar) {
137
 
                width = bar_width + Style.XThickness;
138
 
                rect = new Gdk.Rectangle (evnt.Area.X, evnt.Area.Y, width, evnt.Area.Height);
139
 
                Gtk.Style.PaintLayout (Style, GdkWindow, StateType.Selected, true, rect, this, null, x, y, layout);
140
 
 
 
154
                // First render the text that is on the progressbar
 
155
                int full_bar_width = bar_width + border.Left;
 
156
                rect.Width = full_bar_width;
 
157
 
 
158
                cr.Save ();
 
159
                Gdk.CairoHelper.Rectangle (cr, rect);
 
160
                cr.Clip ();
 
161
                StyleContext.Save ();
 
162
                // The entry class is need so that the text get the "selected" color
 
163
                StyleContext.AddClass ("entry");
 
164
                StyleContext.AddClass ("progressbar");
 
165
                StyleContext.RenderLayout (cr, x, y, layout);
 
166
                StyleContext.Restore ();
 
167
                cr.Restore ();
 
168
 
 
169
                // Adjust the rectangle so that the rest of the text is rendered as expected
141
170
                rect.X += rect.Width;
142
 
                rect.Width = evnt.Area.Width - rect.Width;
 
171
                rect.Width = Allocation.Width - rect.Width;
143
172
            }
144
173
 
145
 
            Gtk.Style.PaintLayout (Style, GdkWindow, StateType.Normal, false, rect, this, null, x, y, layout);
 
174
            cr.Save ();
 
175
            Gdk.CairoHelper.Rectangle (cr, rect);
 
176
            cr.Clip ();
 
177
            StyleContext.Save ();
 
178
            StyleContext.AddClass ("trough");
 
179
            StyleContext.RenderLayout (cr, x, y, layout);
 
180
            StyleContext.Restore ();
 
181
            cr.Restore ();
146
182
 
147
183
            return true;
148
184
        }