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