2 /* Gnome Music Player Client (GMPC)
3 * Copyright (C) 2004-2011 Qball Cow <qball@gmpclient.org>
4 * Project homepage: http://gmpclient.org/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 private const bool use_transition_sbv
= Gmpc
.use_transition
;
27 private const string some_unique_name_sbv
= Config
.VERSION
;
29 public class MyCellRenderer
: Gtk
.CellRenderer
31 public bool show_number
{ set; get; default=false;}
32 public int number
{ set; get; default=0;}
33 private CellRendererPixbuf cr_pb
= new Gtk
.CellRendererPixbuf();
34 private CellRendererText cr_text
= new Gtk
.CellRendererText();
35 public string icon_name
{
37 cr_pb
.icon_name
= value
;
41 public int weight
{ set { cr_text
.weight
= value
;}}
42 public bool weight_set
{ set { cr_text
.weight_set
= value
;}}
44 public uint stock_size
{
46 return cr_pb
.stock_size
;
49 cr_pb
.stock_size
= value
;
63 public int image_width
{
68 public new
float xalign
{
73 /* dumb constructor */
74 public MyCellRenderer () {}
76 /* get_size method, always request a 50x50 area */
77 public override void get_size (Gtk
.Widget widget
,
78 Gdk
.Rectangle? cell_area
,
93 cr_pb
.get_size(widget
, null, out x_o
, out y_o
, out w
, out h
);
95 cr_text
.get_size(widget
, null, out tx_o
, out ty_o
, out tw
, out th
);
96 /* The bindings miss the nullable property, so we need to check if the
99 if (&x_offset
!= null) x_offset
= 0;
100 if (&y_offset
!= null) y_offset
= 0;
101 if (&width
!= null) width
= image_width
+6+tw
;
102 if (&height
!= null) height
= int.max(h
, th
);
107 public override void render (Gdk
.Window window
,
109 Gdk
.Rectangle background_area
,
110 Gdk
.Rectangle cell_area
,
111 Gdk
.Rectangle expose_area
,
112 Gtk
.CellRendererState flags
)
118 cr_pb
.get_size(widget
, null, out x_o
, out y_o
, out w
, out h
);
119 Gdk
.Rectangle ca
= Gdk
.Rectangle();
122 ca
.width
= image_width
+6;//cell_area.height;
123 ca
.height
= cell_area
.height
;
125 if(cr_pb
.icon_name
!= null )
127 cr_pb
.render(window
, widget
, background_area
, ca
, expose_area
, flags
);
130 ca
.width
-=6+image_width
;
133 cr_text
.render(window
, widget
, background_area
, ca
, expose_area
, flags
);
138 var l
= widget
.create_pango_layout("%0i".printf(number
));
139 var ct
= Gdk
.cairo_create(window
);
140 l
.get_pixel_size(out pw
, out ph
);
142 ct
.set_source_rgb(0.8,0.2,0.2);
143 ct
.rectangle(cell_area
.x
+3, cell_area
.y
+cell_area
.height
/2-ph
/2, pw
+4, ph
);
146 ct
.move_to(cell_area
.x
+2+3, cell_area
.y
+cell_area
.height
/2-ph
/2);
147 ct
.set_source_rgb(1,1,1);
148 Pango
.cairo_show_layout(ct
, l
);