1
###############################################################################
2
# Copyright 2008 Ian McIntosh <ian@openanswers.org>
4
# This program 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 2 of the License, or
7
# (at your option) any later version.
9
# This program 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 Library General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
###############################################################################
19
# extend/simplify/standardize some GTK objects
21
#################################
23
#################################
27
if active? # is this window the current top level window on the current desktop?
30
present # show / move to current desktop / bring to top
37
return Gdk::Rectangle.new(self.x - m, self.y - m, self.width + m*2, self.height + m*2)
45
return false if x < self.x
46
return false if y < self.y
47
return false if x > self.x + self.width
48
return false if y > self.y + self.height
53
return [self.x + (self.width/2), self.y + (self.height/2)]
58
def to_hex # use Gdk::Color.parse to parse
59
sprintf('#%x%x%x', red, green, blue)
63
#################################
65
#################################
68
def show_pango_layout_centered(pangolayout, x, y)
69
w,h = pangolayout.pixel_size
70
move_to(x - (w / 2), y - (h / 2))
71
show_pango_layout(pangolayout)
76
def set_font_from_string(str)
77
set_font_description(Pango::FontDescription.new(str))
86
def full_key_name(key)
87
return @root + '/' + key if @root
92
get(full_key_name(key))
96
set(full_key_name(key), value)