2
# Project: gespeaker - A GTK frontend for espeak
3
# Author: Fabio Castelli <muflone@vbsimple.net>
4
# Copyright: 2009 Fabio Castelli
6
# This program is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License as published by the Free
8
# Software Foundation; either version 2 of the License, or (at your option)
11
# This program is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16
# On Debian GNU/Linux systems, the full text of the GNU General Public License
17
# can be found in the file /usr/share/common-licenses/GPL-2.
22
def TextBuffer_get_text(buffer):
23
"Return the whole text on the TextBuffer"
24
return buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter())
26
def Radio_get_active(group):
27
"Return the currently active radio button on the group"
29
if button.get_active():
32
def Pixbuf_load_file(filename, size=None):
33
"Load an image file with the desired size if requested"
34
if size and len(size) == 2:
35
return gtk.gdk.pixbuf_new_from_file_at_size(filename, size[0], size[1])
37
return gtk.gdk.pixbuf_new_from_file(filename)
39
def Window_change_cursor(window, cursor, refresh=False):
40
"Change a window's cursor and optionally forces the refresh"
41
window.set_cursor(cursor and gtk.gdk.Cursor(cursor) or None)
45
def Button_change_stock_description(button, caption, use_underline=None):
46
"Change stock button description"
47
alignment = button.get_children()[0]
48
box = alignment.get_children()[0]
49
first, second = box.get_children()
51
if type(first) is gtk.Label:
53
elif type(second) is gtk.Label:
58
label.set_text(caption)
60
if use_underline is not None:
61
label.set_use_underline(use_underline)
63
def TreeModel_find_text(model, column, text):
64
"Return the path of the found text in the model"
65
iter = model.get_iter_first()
67
if model.get_value(iter, column) == text:
68
return int(model.get_string_from_iter(iter))
69
iter = model.iter_next(iter)
71
def ComboBox_set_item_from_text(combo, column, text):
72
path = TreeModel_find_text(combo.get_model(), column, text)
74
combo.set_active(path)
77
def ComboBox_get_text(combo, column):
78
active = combo.get_active()
79
if not active is None:
80
return combo.get_model()[active][column]