theme manager is here
This commit is contained in:
parent
ed91010872
commit
acb2b33df7
|
@ -183,17 +183,17 @@ class Config:
|
|||
'jid': [ opt_str, ''],
|
||||
}, {}),
|
||||
'themes': ({
|
||||
'accounttextcolor': [ opt_color, '' ],
|
||||
'accountbgcolor': [ opt_color, '' ],
|
||||
'accountfont': [ opt_str, '' ],
|
||||
'grouptextcolor': [ opt_color, '' ],
|
||||
'groupbgcolor': [ opt_color, '' ],
|
||||
'groupfont': [ opt_str, '' ],
|
||||
'contacttextcolor': [ opt_color, '' ],
|
||||
'contactbgcolor': [ opt_color, '' ],
|
||||
'contactfont': [ opt_str, '' ],
|
||||
'bannertextcolor': [ opt_color, '' ],
|
||||
'bannerbgcolor': [ opt_color, '' ],
|
||||
'accounttextcolor': [ opt_color, '#ffffff' ],
|
||||
'accountbgcolor': [ opt_color, '#000000' ],
|
||||
'accountfont': [ opt_str, 'Sans 10' ],
|
||||
'grouptextcolor': [ opt_color, '#ffffff' ],
|
||||
'groupbgcolor': [ opt_color, '#000000' ],
|
||||
'groupfont': [ opt_str, 'Sans 10' ],
|
||||
'contacttextcolor': [ opt_color, '#ffffff' ],
|
||||
'contactbgcolor': [ opt_color, '#000000' ],
|
||||
'contactfont': [ opt_str, 'Sans 10' ],
|
||||
'bannertextcolor': [ opt_color, '#ffffff' ],
|
||||
'bannerbgcolor': [ opt_color, '#000000' ],
|
||||
}, {}),
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ class Config:
|
|||
if not self.__options_per_key.has_key(typename):
|
||||
# raise RuntimeError, 'option %s does not exist' % typename
|
||||
return
|
||||
|
||||
|
||||
opt = self.__options_per_key[typename]
|
||||
del opt[1][name]
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
|
||||
import gtk
|
||||
import gtk.glade
|
||||
from config import mk_color_string
|
||||
|
||||
from common import gajim
|
||||
from common import i18n
|
||||
_ = i18n._
|
||||
APP = i18n.APP
|
||||
|
@ -40,48 +42,107 @@ class GajimThemesWindow:
|
|||
self.window.show_all()
|
||||
|
||||
|
||||
color_widgets = {
|
||||
self.color_widgets = {
|
||||
'account_text_colorbutton': 'accounttextcolor',
|
||||
'group_text_colorbutton': 'grouptextcolor',
|
||||
'user_text_colorbutton': 'contacttextcolor',
|
||||
'banner_colorbutton': 'bannertextcolor',
|
||||
'account_text_bg_colorbutton': 'accountbgcolor',
|
||||
'group_text_bg_colorbutton': 'groupbgcolor',
|
||||
'user_text_bg_colorbutton': 'contactbgcolor'
|
||||
'user_text_bg_colorbutton': 'contactbgcolor',
|
||||
'banner_bg_colorbutton': 'bannerbgcolor',
|
||||
}
|
||||
font_widgets = {
|
||||
self.font_widgets = {
|
||||
'account_text_fontbutton': 'accountfont',
|
||||
'group_text_fontbutton': 'groupfont',
|
||||
'user_text_fontbutton': 'userfont'
|
||||
'user_text_fontbutton': 'contactfont',
|
||||
}
|
||||
|
||||
self.themes_tree = self.xml.get_widget('themes_treeview')
|
||||
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.fill_themes_treeview()
|
||||
|
||||
'''
|
||||
fonts_colors_table = self.xml.get_widget('fonts_colors_table')
|
||||
if theme == 'custom':
|
||||
fonts_colors_table.show()
|
||||
else:
|
||||
fonts_colors_table.hide()
|
||||
for w in color_widgets:
|
||||
widg = self.xml.get_widget(w)
|
||||
if theme == 'custom':
|
||||
widg.set_color(gtk.gdk.color_parse(gajim.config.get(
|
||||
color_widgets[w])))
|
||||
else:
|
||||
widg.set_color(gtk.gdk.color_parse(self.theme_default[theme]\
|
||||
[color_widgets[w]]))
|
||||
self.on_roster_widget_color_set(widg, color_widgets[w])
|
||||
for w in font_widgets:
|
||||
widg = self.xml.get_widget(w)
|
||||
if theme == 'custom':
|
||||
widg.set_font_name(gajim.config.get(font_widgets[w]))
|
||||
else:
|
||||
widg.set_font_name(self.theme_default[theme][font_widgets[w]])
|
||||
self.on_widget_font_set(widg, font_widgets[w])
|
||||
'''
|
||||
|
||||
self.current_theme = gajim.config.get('roster_theme')
|
||||
self.set_widgets(self.current_theme)
|
||||
|
||||
def on_theme_cell_edited(self, cell, row, new_name):
|
||||
model = self.themes_tree.get_model()
|
||||
iter = model.get_iter_from_string(row)
|
||||
old_name = model.get_value(iter, 0)
|
||||
if old_name == new_name:
|
||||
return
|
||||
if new_name in gajim.config.get_per('themes'):
|
||||
#ErrorDialog()
|
||||
return
|
||||
gajim.config.add_per('themes', new_name)
|
||||
#Copy old theme values
|
||||
for option in self.color_widgets.values():
|
||||
gajim.config.set_per('themes', new_name, option,
|
||||
gajim.config.get_per('themes', old_name, option))
|
||||
for option in self.font_widgets.values():
|
||||
gajim.config.set_per('themes', new_name, option,
|
||||
gajim.config.get_per('themes', old_name, option))
|
||||
gajim.config.del_per('themes', old_name)
|
||||
model.set_value(iter, 0, new_name)
|
||||
|
||||
def fill_themes_treeview(self):
|
||||
self.xml.get_widget('remove_button').set_sensitive(False)
|
||||
self.xml.get_widget('fonts_colors_table').set_sensitive(False)
|
||||
model = self.themes_tree.get_model()
|
||||
model.clear()
|
||||
for theme in gajim.config.get_per('themes'):
|
||||
iter = model.append()
|
||||
model.set_value(iter, 0, theme)
|
||||
|
||||
def on_roster_widget_color_set(self, widget, text):
|
||||
def on_themes_treeview_cursor_changed(self, widget):
|
||||
(model, iter) = self.themes_tree.get_selection().get_selected()
|
||||
if not iter:
|
||||
return
|
||||
self.xml.get_widget('remove_button').set_sensitive(True)
|
||||
self.xml.get_widget('fonts_colors_table').set_sensitive(True)
|
||||
self.current_theme = model.get_value(iter, 0)
|
||||
self.set_widgets(self.current_theme)
|
||||
|
||||
def on_add_button_clicked(self, widget):
|
||||
model = self.themes_tree.get_model()
|
||||
iter = model.append()
|
||||
i = 0
|
||||
while _('theme_name') + str(i) in gajim.config.get_per('themes'):
|
||||
i += 1
|
||||
model.set_value(iter, 0, _('theme_name') + str(i))
|
||||
gajim.config.add_per('themes', _('theme_name') + str(i))
|
||||
|
||||
def on_remove_button_clicked(self, widget):
|
||||
(model, iter) = self.themes_tree.get_selection().get_selected()
|
||||
if not iter:
|
||||
return
|
||||
name = model.get_value(iter, 0)
|
||||
gajim.config.del_per('themes', name)
|
||||
model.remove(iter)
|
||||
|
||||
def set_widgets(self, theme):
|
||||
for w in self.color_widgets:
|
||||
widg = self.xml.get_widget(w)
|
||||
widg.set_color(gtk.gdk.color_parse(gajim.config.get_per('themes',
|
||||
theme, self.color_widgets[w])))
|
||||
for w in self.font_widgets:
|
||||
widg = self.xml.get_widget(w)
|
||||
widg.set_font_name(gajim.config.get_per('themes', theme,
|
||||
self.font_widgets[w]))
|
||||
|
||||
def on_roster_widget_color_set(self, widget, option):
|
||||
color = widget.get_color()
|
||||
color_string = mk_color_string(color)
|
||||
gajim.config.set(text, color_string)
|
||||
gajim.config.set_per('themes', self.current_theme, option, color_string)
|
||||
self.plugin.roster.draw_roster()
|
||||
self.plugin.save_config()
|
||||
|
||||
|
@ -103,9 +164,15 @@ class GajimThemesWindow:
|
|||
def on_user_text_bg_colorbutton_color_set(self, widget):
|
||||
self.on_roster_widget_color_set(widget, 'contactbgcolor')
|
||||
|
||||
def on_widget_font_set(self, widget, text):
|
||||
def on_banner_text_colorbutton_color_set(self, widget):
|
||||
self.on_roster_widget_color_set(widget, 'bannertextcolor')
|
||||
|
||||
def on_banner_bg_colorbutton_color_set(self, widget):
|
||||
self.on_roster_widget_color_set(widget, 'bannerbgcolor')
|
||||
|
||||
def on_widget_font_set(self, widget, option):
|
||||
font_string = widget.get_font_name()
|
||||
gajim.config.set(text, font_string)
|
||||
gajim.config.set_per('themes', self.current_theme, option, font_string)
|
||||
self.plugin.roster.draw_roster()
|
||||
self.plugin.save_config()
|
||||
|
||||
|
@ -116,4 +183,4 @@ class GajimThemesWindow:
|
|||
self.on_widget_font_set(widget, 'groupfont')
|
||||
|
||||
def on_user_text_fontbutton_font_set(self, widget):
|
||||
self.on_widget_font_set(widget, 'userfont')
|
||||
self.on_widget_font_set(widget, 'contactfont')
|
||||
|
|
|
@ -14726,13 +14726,14 @@ the Jabber network.</property>
|
|||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="treeview2">
|
||||
<widget class="GtkTreeView" id="themes_treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="rules_hint">False</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
<signal name="cursor_changed" handler="on_themes_treeview_cursor_changed" last_modification_time="Sat, 06 Aug 2005 18:27:22 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
@ -14750,7 +14751,7 @@ the Jabber network.</property>
|
|||
<property name="spacing">6</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button38">
|
||||
<widget class="GtkButton" id="add_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
|
@ -14758,11 +14759,12 @@ the Jabber network.</property>
|
|||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_add_button_clicked" last_modification_time="Sat, 06 Aug 2005 18:55:20 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button39">
|
||||
<widget class="GtkButton" id="remove_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
|
@ -14770,6 +14772,7 @@ the Jabber network.</property>
|
|||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_remove_button_clicked" last_modification_time="Sat, 06 Aug 2005 18:55:07 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
@ -15113,7 +15116,6 @@ the Jabber network.</property>
|
|||
|
||||
<child>
|
||||
<widget class="GtkFontButton" id="fontbutton1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="show_style">True</property>
|
||||
<property name="show_size">True</property>
|
||||
|
@ -15138,7 +15140,7 @@ the Jabber network.</property>
|
|||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="color_set" handler="on_user_text_colorbutton_color_set" last_modification_time="Sun, 06 Mar 2005 14:24:35 GMT"/>
|
||||
<signal name="color_set" handler="on_banner_bg_colorbutton_color_set" last_modification_time="Sat, 06 Aug 2005 17:18:18 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">3</property>
|
||||
|
@ -15156,7 +15158,7 @@ the Jabber network.</property>
|
|||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="color_set" handler="on_user_text_colorbutton_color_set" last_modification_time="Sun, 06 Mar 2005 14:24:35 GMT"/>
|
||||
<signal name="color_set" handler="on_banner_text_colorbutton_color_set" last_modification_time="Sat, 06 Aug 2005 17:18:29 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
|
Loading…
Reference in New Issue