2008-08-15 19:31:51 +02:00
|
|
|
# -*- coding:utf-8 -*-
|
2008-08-15 05:20:23 +02:00
|
|
|
## src/gajim_themes_window.py
|
2005-06-10 00:29:06 +02:00
|
|
|
##
|
2008-08-15 05:20:23 +02:00
|
|
|
## Copyright (C) 2003-2007 Yann Leboulanger <asterix AT lagaule.org>
|
|
|
|
## Copyright (C) 2005-2006 Dimitur Kirov <dkirov AT gmail.com>
|
|
|
|
## Nikos Kouremenos <kourem AT gmail.com>
|
|
|
|
## Copyright (C) 2006 Jean-Marie Traissard <jim AT lapin.org>
|
|
|
|
## Copyright (C) 2007 Stephan Erb <steve-e AT h3c.de>
|
2005-06-10 00:29:06 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
2005-06-10 00:29:06 +02:00
|
|
|
## it under the terms of the GNU General Public License as published
|
2007-10-22 13:13:13 +02:00
|
|
|
## by the Free Software Foundation; version 3 only.
|
2005-06-10 00:29:06 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2005-06-10 00:29:06 +02:00
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-08-15 05:20:23 +02:00
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2005-06-10 00:29:06 +02:00
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## You should have received a copy of the GNU General Public License
|
2008-08-15 05:20:23 +02:00
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
2007-10-22 13:13:13 +02:00
|
|
|
##
|
2005-06-10 00:29:06 +02:00
|
|
|
|
|
|
|
import gtk
|
2005-09-16 23:32:57 +02:00
|
|
|
import pango
|
2005-09-19 17:23:18 +02:00
|
|
|
import dialogs
|
2005-12-01 20:17:23 +01:00
|
|
|
import gtkgui_helpers
|
2005-06-10 00:29:06 +02:00
|
|
|
|
2005-08-06 23:19:16 +02:00
|
|
|
from common import gajim
|
2005-06-10 00:29:06 +02:00
|
|
|
|
|
|
|
class GajimThemesWindow:
|
|
|
|
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2006-05-02 17:53:25 +02:00
|
|
|
self.xml = gtkgui_helpers.get_glade('gajim_themes_window.glade')
|
2005-06-10 00:29:06 +02:00
|
|
|
self.window = self.xml.get_widget('gajim_themes_window')
|
2006-07-17 22:27:30 +02:00
|
|
|
self.window.set_transient_for(gajim.interface.roster.window)
|
2005-06-10 00:29:06 +02:00
|
|
|
|
2005-11-03 17:21:03 +01:00
|
|
|
self.options = ['account', 'group', 'contact', 'banner']
|
2005-09-16 23:32:57 +02:00
|
|
|
self.options_combobox = self.xml.get_widget('options_combobox')
|
|
|
|
self.textcolor_checkbutton = self.xml.get_widget('textcolor_checkbutton')
|
|
|
|
self.background_checkbutton = self.xml.get_widget('background_checkbutton')
|
|
|
|
self.textfont_checkbutton = self.xml.get_widget('textfont_checkbutton')
|
|
|
|
self.text_colorbutton = self.xml.get_widget('text_colorbutton')
|
|
|
|
self.background_colorbutton = self.xml.get_widget('background_colorbutton')
|
|
|
|
self.text_fontbutton = self.xml.get_widget('text_fontbutton')
|
|
|
|
self.bold_togglebutton = self.xml.get_widget('bold_togglebutton')
|
|
|
|
self.italic_togglebutton = self.xml.get_widget('italic_togglebutton')
|
2005-08-06 23:19:16 +02:00
|
|
|
self.themes_tree = self.xml.get_widget('themes_treeview')
|
2005-09-19 17:23:18 +02:00
|
|
|
self.theme_options_vbox = self.xml.get_widget('theme_options_vbox')
|
2007-07-16 13:54:04 +02:00
|
|
|
self.theme_options_table = self.xml.get_widget('theme_options_table')
|
2006-03-18 23:40:26 +01:00
|
|
|
self.colorbuttons = {}
|
2006-09-25 06:23:31 +02:00
|
|
|
for chatstate in ('inactive', 'composing', 'paused', 'gone',
|
2006-03-18 23:40:26 +01:00
|
|
|
'muc_msg', 'muc_directed_msg'):
|
|
|
|
self.colorbuttons[chatstate] = self.xml.get_widget(chatstate + \
|
|
|
|
'_colorbutton')
|
2005-08-06 23:19:16 +02:00
|
|
|
model = gtk.ListStore(str)
|
|
|
|
self.themes_tree.set_model(model)
|
|
|
|
col = gtk.TreeViewColumn(_('Theme'))
|
|
|
|
self.themes_tree.append_column(col)
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
col.pack_start(renderer, True)
|
|
|
|
col.set_attributes(renderer, text = 0)
|
|
|
|
renderer.connect('edited', self.on_theme_cell_edited)
|
|
|
|
renderer.set_property('editable', True)
|
|
|
|
self.current_theme = gajim.config.get('roster_theme')
|
2005-09-17 11:37:40 +02:00
|
|
|
self.no_update = False
|
2005-09-16 23:32:57 +02:00
|
|
|
self.fill_themes_treeview()
|
2007-07-16 13:54:04 +02:00
|
|
|
self.select_active_theme()
|
2005-09-19 17:23:18 +02:00
|
|
|
self.current_option = self.options[0]
|
|
|
|
self.set_theme_options(self.current_theme, self.current_option)
|
|
|
|
|
2005-08-07 17:32:35 +02:00
|
|
|
self.xml.signal_autoconnect(self)
|
2006-03-01 12:03:56 +01:00
|
|
|
self.window.connect('delete-event', self.on_themese_window_delete_event)
|
2005-09-19 17:23:18 +02:00
|
|
|
self.themes_tree.get_selection().connect('changed',
|
|
|
|
self.selection_changed)
|
2005-08-07 17:32:35 +02:00
|
|
|
self.window.show_all()
|
2006-03-01 12:03:56 +01:00
|
|
|
|
|
|
|
def on_themese_window_delete_event(self, widget, event):
|
|
|
|
self.window.hide()
|
|
|
|
return True # do NOT destroy the window
|
|
|
|
|
2005-09-19 17:44:46 +02:00
|
|
|
def on_close_button_clicked(self, widget):
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'preferences' in gajim.interface.instances:
|
2007-07-17 00:20:08 +02:00
|
|
|
gajim.interface.instances['preferences'].update_theme_list()
|
2006-03-01 12:03:56 +01:00
|
|
|
self.window.hide()
|
2005-09-19 17:44:46 +02:00
|
|
|
|
2005-08-06 23:19:16 +02:00
|
|
|
def on_theme_cell_edited(self, cell, row, new_name):
|
|
|
|
model = self.themes_tree.get_model()
|
|
|
|
iter = model.get_iter_from_string(row)
|
2005-08-26 02:52:44 +02:00
|
|
|
old_name = model.get_value(iter, 0).decode('utf-8')
|
2005-08-27 16:08:00 +02:00
|
|
|
new_name = new_name.decode('utf-8')
|
2005-08-06 23:19:16 +02:00
|
|
|
if old_name == new_name:
|
|
|
|
return
|
2007-07-16 13:54:04 +02:00
|
|
|
if old_name == 'default':
|
|
|
|
dialogs.ErrorDialog(
|
|
|
|
_('You cannot make changes to the default theme'),
|
|
|
|
_('Please create a clean new theme with your desired name.'))
|
|
|
|
return
|
2005-09-01 15:47:50 +02:00
|
|
|
new_config_name = new_name.replace(' ', '_')
|
|
|
|
if new_config_name in gajim.config.get_per('themes'):
|
2005-08-06 23:19:16 +02:00
|
|
|
return
|
2005-09-01 15:47:50 +02:00
|
|
|
gajim.config.add_per('themes', new_config_name)
|
2005-10-05 12:32:20 +02:00
|
|
|
# Copy old theme values
|
2005-09-01 15:47:50 +02:00
|
|
|
old_config_name = old_name.replace(' ', '_')
|
2005-09-19 17:23:18 +02:00
|
|
|
properties = ['textcolor', 'bgcolor', 'font', 'fontattrs']
|
|
|
|
gajim.config.add_per('themes', new_config_name)
|
|
|
|
for option in self.options:
|
|
|
|
for property in properties:
|
|
|
|
option_name = option + property
|
|
|
|
gajim.config.set_per('themes', new_config_name, option_name,
|
|
|
|
gajim.config.get_per('themes', old_config_name, option_name))
|
2005-09-01 15:47:50 +02:00
|
|
|
gajim.config.del_per('themes', old_config_name)
|
2005-09-19 17:23:18 +02:00
|
|
|
if old_config_name == gajim.config.get('roster_theme'):
|
|
|
|
gajim.config.set('roster_theme', new_config_name)
|
2005-08-06 23:19:16 +02:00
|
|
|
model.set_value(iter, 0, new_name)
|
2005-10-05 12:32:20 +02:00
|
|
|
self.current_theme = new_name
|
2005-08-06 23:19:16 +02:00
|
|
|
|
|
|
|
def fill_themes_treeview(self):
|
|
|
|
model = self.themes_tree.get_model()
|
|
|
|
model.clear()
|
2005-09-01 15:47:50 +02:00
|
|
|
for config_theme in gajim.config.get_per('themes'):
|
|
|
|
theme = config_theme.replace('_', ' ')
|
2008-10-20 23:17:48 +02:00
|
|
|
model.append([theme])
|
2006-12-13 14:15:06 +01:00
|
|
|
|
|
|
|
def select_active_theme(self):
|
|
|
|
model = self.themes_tree.get_model()
|
|
|
|
iter = model.get_iter_root()
|
2007-07-16 13:54:04 +02:00
|
|
|
active_theme = gajim.config.get('roster_theme').replace('_', ' ')
|
2006-12-13 14:15:06 +01:00
|
|
|
while iter:
|
|
|
|
theme = model[iter][0]
|
|
|
|
if theme == active_theme:
|
|
|
|
self.themes_tree.get_selection().select_iter(iter)
|
|
|
|
self.xml.get_widget('remove_button').set_sensitive(True)
|
|
|
|
self.theme_options_vbox.set_sensitive(True)
|
2007-07-16 13:54:04 +02:00
|
|
|
self.theme_options_table.set_sensitive(True)
|
|
|
|
if active_theme == 'default':
|
|
|
|
self.xml.get_widget('remove_button').set_sensitive(False)
|
|
|
|
self.theme_options_vbox.set_sensitive(False)
|
|
|
|
self.theme_options_table.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.xml.get_widget('remove_button').set_sensitive(True)
|
|
|
|
self.theme_options_vbox.set_sensitive(True)
|
|
|
|
self.theme_options_table.set_sensitive(True)
|
2006-12-13 14:15:06 +01:00
|
|
|
break
|
|
|
|
iter = model.iter_next(iter)
|
|
|
|
|
2005-09-19 17:23:18 +02:00
|
|
|
def selection_changed(self, widget = None):
|
2005-08-06 23:19:16 +02:00
|
|
|
(model, iter) = self.themes_tree.get_selection().get_selected()
|
2005-09-19 17:23:18 +02:00
|
|
|
selected = self.themes_tree.get_selection().get_selected_rows()
|
|
|
|
if not iter or selected[1] == []:
|
|
|
|
self.theme_options_vbox.set_sensitive(False)
|
2007-07-16 13:54:04 +02:00
|
|
|
self.theme_options_table.set_sensitive(False)
|
2005-08-06 23:19:16 +02:00
|
|
|
return
|
2005-08-26 02:52:44 +02:00
|
|
|
self.current_theme = model.get_value(iter, 0).decode('utf-8')
|
2005-09-01 15:47:50 +02:00
|
|
|
self.current_theme = self.current_theme.replace(' ', '_')
|
2005-09-16 23:32:57 +02:00
|
|
|
self.set_theme_options(self.current_theme)
|
2007-07-16 13:54:04 +02:00
|
|
|
if self.current_theme == 'default':
|
|
|
|
self.xml.get_widget('remove_button').set_sensitive(False)
|
|
|
|
self.theme_options_vbox.set_sensitive(False)
|
|
|
|
self.theme_options_table.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.xml.get_widget('remove_button').set_sensitive(True)
|
|
|
|
self.theme_options_vbox.set_sensitive(True)
|
|
|
|
self.theme_options_table.set_sensitive(True)
|
2005-08-06 23:19:16 +02:00
|
|
|
|
|
|
|
def on_add_button_clicked(self, widget):
|
|
|
|
model = self.themes_tree.get_model()
|
|
|
|
iter = model.append()
|
|
|
|
i = 0
|
2005-09-19 17:23:18 +02:00
|
|
|
# don't confuse translators
|
|
|
|
theme_name = _('theme name')
|
|
|
|
theme_name_ns = theme_name.replace(' ', '_')
|
|
|
|
while theme_name_ns + unicode(i) in gajim.config.get_per('themes'):
|
2005-08-06 23:19:16 +02:00
|
|
|
i += 1
|
2005-09-19 17:23:18 +02:00
|
|
|
model.set_value(iter, 0, theme_name + unicode(i))
|
|
|
|
gajim.config.add_per('themes', theme_name_ns + unicode(i))
|
|
|
|
self.themes_tree.get_selection().select_iter(iter)
|
2005-09-30 19:16:17 +02:00
|
|
|
col = self.themes_tree.get_column(0)
|
|
|
|
path = model.get_path(iter)
|
|
|
|
self.themes_tree.set_cursor(path, col, True)
|
2005-08-06 23:19:16 +02:00
|
|
|
|
|
|
|
def on_remove_button_clicked(self, widget):
|
|
|
|
(model, iter) = self.themes_tree.get_selection().get_selected()
|
|
|
|
if not iter:
|
|
|
|
return
|
2005-09-19 17:23:18 +02:00
|
|
|
if self.current_theme == gajim.config.get('roster_theme'):
|
|
|
|
dialogs.ErrorDialog(
|
2005-11-02 17:34:35 +01:00
|
|
|
_('You cannot delete your current theme'),
|
2006-04-02 18:11:21 +02:00
|
|
|
_('Please first choose another for your current theme.'))
|
2005-09-19 17:23:18 +02:00
|
|
|
return
|
|
|
|
self.theme_options_vbox.set_sensitive(False)
|
2007-07-16 13:54:04 +02:00
|
|
|
self.theme_options_table.set_sensitive(False)
|
|
|
|
self.xml.get_widget('remove_button').set_sensitive(False)
|
2005-09-19 17:23:18 +02:00
|
|
|
gajim.config.del_per('themes', self.current_theme)
|
2005-08-06 23:19:16 +02:00
|
|
|
model.remove(iter)
|
2005-06-10 21:31:38 +02:00
|
|
|
|
2005-09-16 23:32:57 +02:00
|
|
|
def set_theme_options(self, theme, option = 'account'):
|
2005-09-17 11:37:40 +02:00
|
|
|
self.no_update = True
|
2005-09-16 23:32:57 +02:00
|
|
|
self.options_combobox.set_active(self.options.index(option))
|
2005-12-02 18:47:52 +01:00
|
|
|
textcolor = gajim.config.get_per('themes', theme, option + 'textcolor')
|
2005-09-16 23:32:57 +02:00
|
|
|
if textcolor:
|
|
|
|
state = True
|
|
|
|
self.text_colorbutton.set_color(gtk.gdk.color_parse(textcolor))
|
|
|
|
else:
|
|
|
|
state = False
|
|
|
|
self.textcolor_checkbutton.set_active(state)
|
|
|
|
self.text_colorbutton.set_sensitive(state)
|
2005-09-17 11:37:40 +02:00
|
|
|
bgcolor = gajim.config.get_per('themes', theme, option + 'bgcolor')
|
2005-09-16 23:32:57 +02:00
|
|
|
if bgcolor:
|
|
|
|
state = True
|
|
|
|
self.background_colorbutton.set_color(gtk.gdk.color_parse(
|
|
|
|
bgcolor))
|
|
|
|
else:
|
|
|
|
state = False
|
|
|
|
self.background_checkbutton.set_active(state)
|
|
|
|
self.background_colorbutton.set_sensitive(state)
|
2005-09-17 11:37:40 +02:00
|
|
|
|
2005-12-02 18:47:52 +01:00
|
|
|
# get the font name before we set widgets and it will not be overriden
|
2005-09-17 11:37:40 +02:00
|
|
|
font_name = gajim.config.get_per('themes', theme, option + 'font')
|
|
|
|
font_attrs = gajim.config.get_per('themes', theme, option + 'fontattrs')
|
|
|
|
self._set_font_widgets(font_attrs)
|
2005-09-16 23:32:57 +02:00
|
|
|
if font_name:
|
|
|
|
state = True
|
|
|
|
self.text_fontbutton.set_font_name(font_name)
|
|
|
|
else:
|
|
|
|
state = False
|
|
|
|
self.textfont_checkbutton.set_active(state)
|
2005-09-17 10:31:29 +02:00
|
|
|
self.text_fontbutton.set_sensitive(state)
|
2005-09-17 11:37:40 +02:00
|
|
|
self.no_update = False
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.change_roster_style(None)
|
2006-03-18 23:40:26 +01:00
|
|
|
|
2006-09-25 06:23:31 +02:00
|
|
|
for chatstate in ('inactive', 'composing', 'paused', 'gone',
|
2006-03-18 23:40:26 +01:00
|
|
|
'muc_msg', 'muc_directed_msg'):
|
|
|
|
color = gajim.config.get_per('themes', theme, 'state_' + chatstate + \
|
|
|
|
'_color')
|
|
|
|
self.colorbuttons[chatstate].set_color(gtk.gdk.color_parse(color))
|
2005-09-16 23:32:57 +02:00
|
|
|
|
|
|
|
def on_textcolor_checkbutton_toggled(self, widget):
|
|
|
|
state = widget.get_active()
|
|
|
|
self.text_colorbutton.set_sensitive(state)
|
|
|
|
self._set_color(state, self.text_colorbutton,
|
|
|
|
'textcolor')
|
2005-06-10 21:31:38 +02:00
|
|
|
|
2005-09-16 23:32:57 +02:00
|
|
|
def on_background_checkbutton_toggled(self, widget):
|
|
|
|
state = widget.get_active()
|
|
|
|
self.background_colorbutton.set_sensitive(state)
|
|
|
|
self._set_color(state, self.background_colorbutton,
|
|
|
|
'bgcolor')
|
|
|
|
|
|
|
|
def on_textfont_checkbutton_toggled(self, widget):
|
2005-09-17 10:31:29 +02:00
|
|
|
self.text_fontbutton.set_sensitive(widget.get_active())
|
|
|
|
self._set_font()
|
2005-06-10 21:31:38 +02:00
|
|
|
|
2005-09-16 23:32:57 +02:00
|
|
|
def on_text_colorbutton_color_set(self, widget):
|
|
|
|
self._set_color(True, widget, 'textcolor')
|
|
|
|
|
|
|
|
def on_background_colorbutton_color_set(self, widget):
|
|
|
|
self._set_color(True, widget, 'bgcolor')
|
2005-06-10 21:31:38 +02:00
|
|
|
|
2005-09-16 23:32:57 +02:00
|
|
|
def on_text_fontbutton_font_set(self, widget):
|
2005-09-17 10:31:29 +02:00
|
|
|
self._set_font()
|
2005-08-06 23:19:16 +02:00
|
|
|
|
2005-09-16 23:32:57 +02:00
|
|
|
def on_options_combobox_changed(self, widget):
|
|
|
|
index = self.options_combobox.get_active()
|
|
|
|
if index == -1:
|
|
|
|
return
|
|
|
|
self.current_option = self.options[index]
|
|
|
|
self.set_theme_options(self.current_theme,
|
|
|
|
self.current_option)
|
|
|
|
|
2005-09-17 10:31:29 +02:00
|
|
|
def on_bold_togglebutton_toggled(self, widget):
|
2005-12-02 18:47:52 +01:00
|
|
|
if not self.no_update:
|
|
|
|
self._set_font()
|
2005-09-17 10:31:29 +02:00
|
|
|
|
|
|
|
def on_italic_togglebutton_toggled(self, widget):
|
2005-12-02 18:47:52 +01:00
|
|
|
if not self.no_update:
|
|
|
|
self._set_font()
|
2005-09-17 10:31:29 +02:00
|
|
|
|
2005-09-16 23:32:57 +02:00
|
|
|
def _set_color(self, state, widget, option):
|
|
|
|
''' set color value in prefs and update the UI '''
|
|
|
|
if state:
|
|
|
|
color = widget.get_color()
|
2005-12-01 20:17:23 +01:00
|
|
|
color_string = gtkgui_helpers.make_color_string(color)
|
2005-09-16 23:32:57 +02:00
|
|
|
else:
|
|
|
|
color_string = ''
|
2006-03-26 20:01:18 +02:00
|
|
|
begin_option = ''
|
|
|
|
if not option.startswith('state'):
|
|
|
|
begin_option = self.current_option
|
2005-09-16 23:32:57 +02:00
|
|
|
gajim.config.set_per('themes', self.current_theme,
|
2006-03-26 20:01:18 +02:00
|
|
|
begin_option + option, color_string)
|
2005-09-17 11:37:40 +02:00
|
|
|
# use faster functions for this
|
2005-09-17 10:31:29 +02:00
|
|
|
if self.current_option == 'banner':
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.repaint_themed_widgets()
|
|
|
|
gajim.interface.save_config()
|
2005-09-19 17:23:18 +02:00
|
|
|
return
|
2005-09-17 11:37:40 +02:00
|
|
|
if self.no_update:
|
|
|
|
return
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.change_roster_style(self.current_option)
|
|
|
|
gajim.interface.save_config()
|
2005-09-16 23:32:57 +02:00
|
|
|
|
2005-09-17 10:31:29 +02:00
|
|
|
def _set_font(self):
|
2005-09-16 23:32:57 +02:00
|
|
|
''' set font value in prefs and update the UI '''
|
2005-09-17 10:31:29 +02:00
|
|
|
state = self.textfont_checkbutton.get_active()
|
2005-09-16 23:32:57 +02:00
|
|
|
if state:
|
2005-09-17 10:31:29 +02:00
|
|
|
font_string = self.text_fontbutton.get_font_name()
|
2005-09-16 23:32:57 +02:00
|
|
|
else:
|
|
|
|
font_string = ''
|
|
|
|
gajim.config.set_per('themes', self.current_theme,
|
2005-09-17 10:31:29 +02:00
|
|
|
self.current_option + 'font', font_string)
|
|
|
|
font_attrs = self._get_font_attrs()
|
|
|
|
gajim.config.set_per('themes', self.current_theme,
|
|
|
|
self.current_option + 'fontattrs', font_attrs)
|
2005-09-17 11:37:40 +02:00
|
|
|
# use faster functions for this
|
2005-09-17 10:31:29 +02:00
|
|
|
if self.current_option == 'banner':
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.repaint_themed_widgets()
|
2005-09-17 11:37:40 +02:00
|
|
|
if self.no_update:
|
|
|
|
return
|
2005-10-20 13:17:17 +02:00
|
|
|
gajim.interface.roster.change_roster_style(self.current_option)
|
|
|
|
gajim.interface.save_config()
|
2005-09-17 10:31:29 +02:00
|
|
|
|
|
|
|
def _toggle_font_widgets(self, font_props):
|
2005-09-17 11:37:40 +02:00
|
|
|
''' toggle font buttons with the bool values of font_props tuple'''
|
2005-09-17 10:31:29 +02:00
|
|
|
self.bold_togglebutton.set_active(font_props[0])
|
|
|
|
self.italic_togglebutton.set_active(font_props[1])
|
|
|
|
|
|
|
|
def _get_font_description(self):
|
|
|
|
''' return a FontDescription from togglebuttons
|
|
|
|
states'''
|
|
|
|
fd = pango.FontDescription()
|
|
|
|
if self.bold_togglebutton.get_active():
|
|
|
|
fd.set_weight(pango.WEIGHT_BOLD)
|
|
|
|
if self.italic_togglebutton.get_active():
|
|
|
|
fd.set_style(pango.STYLE_ITALIC)
|
|
|
|
return fd
|
|
|
|
|
2005-09-17 11:37:40 +02:00
|
|
|
def _set_font_widgets(self, font_attrs):
|
|
|
|
''' set the correct toggle state of font style buttons by
|
2005-11-02 17:34:35 +01:00
|
|
|
a font string of type 'BI' '''
|
2005-09-17 11:37:40 +02:00
|
|
|
font_props = [False, False, False]
|
|
|
|
if font_attrs:
|
|
|
|
if font_attrs.find('B') != -1:
|
|
|
|
font_props[0] = True
|
|
|
|
if font_attrs.find('I') != -1:
|
|
|
|
font_props[1] = True
|
|
|
|
self._toggle_font_widgets(font_props)
|
|
|
|
|
2005-09-17 10:31:29 +02:00
|
|
|
def _get_font_attrs(self):
|
2005-11-02 17:34:35 +01:00
|
|
|
''' get a string with letters of font attribures: 'BI' '''
|
2005-09-17 10:31:29 +02:00
|
|
|
attrs = ''
|
|
|
|
if self.bold_togglebutton.get_active():
|
|
|
|
attrs += 'B'
|
|
|
|
if self.italic_togglebutton.get_active():
|
|
|
|
attrs += 'I'
|
|
|
|
return attrs
|
|
|
|
|
2005-09-17 11:37:40 +02:00
|
|
|
|
2005-09-17 10:31:29 +02:00
|
|
|
def _get_font_props(self, font_name):
|
2005-11-02 17:34:35 +01:00
|
|
|
''' get tuple of font properties: Weight, Style '''
|
2005-09-17 10:31:29 +02:00
|
|
|
font_props = [False, False, False]
|
|
|
|
font_description = pango.FontDescription(font_name)
|
|
|
|
if font_description.get_weight() != pango.WEIGHT_NORMAL:
|
|
|
|
font_props[0] = True
|
|
|
|
if font_description.get_style() != pango.STYLE_ITALIC:
|
|
|
|
font_props[1] = True
|
2005-09-30 19:16:17 +02:00
|
|
|
return font_props
|
2006-03-18 23:40:26 +01:00
|
|
|
|
|
|
|
def on_inactive_colorbutton_color_set(self, widget):
|
|
|
|
self.no_update = True
|
|
|
|
self._set_color(True, widget, 'state_inactive_color')
|
|
|
|
self.no_update = False
|
|
|
|
|
|
|
|
def on_composing_colorbutton_color_set(self, widget):
|
|
|
|
self.no_update = True
|
|
|
|
self._set_color(True, widget, 'state_composing_color')
|
|
|
|
self.no_update = False
|
|
|
|
|
|
|
|
def on_paused_colorbutton_color_set(self, widget):
|
|
|
|
self.no_update = True
|
|
|
|
self._set_color(True, widget, 'state_paused_color')
|
|
|
|
self.no_update = False
|
|
|
|
|
|
|
|
def on_gone_colorbutton_color_set(self, widget):
|
|
|
|
self.no_update = True
|
|
|
|
self._set_color(True, widget, 'state_gone_color')
|
|
|
|
self.no_update = False
|
|
|
|
|
|
|
|
def on_muc_msg_colorbutton_color_set(self, widget):
|
|
|
|
self.no_update = True
|
|
|
|
self._set_color(True, widget, 'state_muc_msg_color')
|
|
|
|
self.no_update = False
|
|
|
|
|
|
|
|
def on_muc_directed_msg_colorbutton_color_set(self, widget):
|
|
|
|
self.no_update = True
|
|
|
|
self._set_color(True, widget, 'state_muc_directed_msg_color')
|
|
|
|
self.no_update = False
|
2008-07-29 21:49:31 +02:00
|
|
|
|
2008-08-15 05:20:23 +02:00
|
|
|
# vim: se ts=3:
|