2 /* Gnome Music Player Client (GMPC)
3 * Copyright (C) 2004-2012 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 private CellRendererPixbuf cr_pb
= new Gtk
.CellRendererPixbuf();
32 private CellRendererText cr_text
= new Gtk
.CellRendererText();
33 public string icon_name
36 cr_pb
.icon_name
= value
;
39 public string stock_id
42 cr_pb
.stock_id
= value
;
46 public int weight
{ set { cr_text
.weight
= value
;}}
47 public bool weight_set
{ set { cr_text
.weight_set
= value
;}}
49 public uint stock_size
52 return cr_pb
.stock_size
;
55 cr_pb
.stock_size
= value
;
70 public int image_width
76 public new
float xalign
82 /* dumb constructor */
83 public MyCellRenderer () {}
85 public override Gtk
.SizeRequestMode
get_request_mode()
87 return Gtk
.SizeRequestMode
.CONSTANT_SIZE
;
90 /* get_size method, always request a 50x50 area */
91 public override void get_size (Gtk
.Widget widget
,
92 Gdk
.Rectangle? cell_area
,
107 cr_pb
.get_size(widget
, null, out x_o
, out y_o
, out w
, out h
);
109 cr_text
.get_size(widget
, null, out tx_o
, out ty_o
, out tw
, out th
);
110 /* The bindings miss the nullable property, so we need to check if the
113 if (&x_offset
!= null) x_offset
= 0;
114 if (&y_offset
!= null) y_offset
= 0;
115 if (&width
!= null) width
= image_width
+6+tw
;
116 if (&height
!= null) height
= int.max(h
, th
);
121 public override void render (Cairo
.Context ct
,
123 Gdk
.Rectangle background_area
,
124 Gdk
.Rectangle cell_area
,
125 Gtk
.CellRendererState flags
)
131 cr_pb
.get_size(widget
, null, out x_o
, out y_o
, out w
, out h
);
132 Gdk
.Rectangle ca
= Gdk
.Rectangle();
135 ca
.width
= w
+6;//cell_area.height;
136 ca
.height
= cell_area
.height
;
138 if(cr_pb
.icon_name
!= null || cr_pb
.stock_id
!= null )
140 cr_pb
.render(ct
, widget
, background_area
, ca
, flags
);
143 ca
.width
= cell_area
.width
-ca
.width
;
147 ca
.width
= cell_area
.width
;
150 cr_text
.render(ct
, widget
, background_area
, ca
, flags
);
154 if((flags&Gtk.CellRendererState.SELECTED) == Gtk.CellRendererState.SELECTED)
156 double cax = background_area.width*0.9;
157 double bld = background_area.width*0.1;
158 if(!show_text) cax = background_area.x+image_width+3;
160 ct.move_to(background_area.x+cax, background_area.y);
161 ct.line_to(background_area.x+cax+bld, background_area.y+background_area.height/2);
162 ct.line_to(background_area.x+cax, background_area.y+background_area.height);
163 ct.line_to(background_area.x+cax+bld, background_area.y+background_area.height);
164 ct.line_to(background_area.x+cax+bld, background_area.y);
165 ct.line_to(background_area.x+cax, background_area.y);
166 Gdk.cairo_set_source_color(ct, widget.style.bg[Gtk.StateType.NORMAL]);