1/* This file is part of Cawbird, a Gtk+ linux Twitter client forked from Corebird. 2 * Copyright (C) 2013 Timm Bäder (Corebird) 3 * 4 * Cawbird is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * Cawbird is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with cawbird. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18class ImpostorWidget : Gtk.Image { 19 private new Cairo.Surface? surface = null; 20 21 22 public ImpostorWidget () { 23 this.halign = Gtk.Align.FILL; 24 this.valign = Gtk.Align.FILL; 25 } 26 27 28 29 public override bool draw (Cairo.Context ct) { 30 if (this.surface == null) 31 return false; 32 33 ct.set_source_surface (this.surface, 0, 0); 34 ct.rectangle (0, 0, this.get_allocated_width (), this.get_allocated_height ()); 35 ct.fill (); 36 return false; 37 } 38 39 40 public void clone (Gtk.Widget widget) { 41 int widget_width = widget.get_allocated_width (); 42 int widget_height = widget.get_allocated_height (); 43 44 this.surface = widget.get_window ().create_similar_surface (Cairo.Content.COLOR_ALPHA, 45 widget_width, 46 widget_height); 47 var ct = new Cairo.Context (surface); 48 widget.draw (ct); 49 } 50} 51