themes are back (TODO: manage themes)

This commit is contained in:
Yann Leboulanger 2005-06-13 22:11:09 +00:00
parent 5514387db7
commit e7ff7da1da
7 changed files with 76 additions and 98 deletions

View File

@ -810,12 +810,22 @@ class Chat:
self.sent_history_pos[jid] = self.sent_history_pos[jid] + 1 self.sent_history_pos[jid] = self.sent_history_pos[jid] + 1
conv_buf.set_text(self.sent_history[jid][self.sent_history_pos[jid]]) conv_buf.set_text(self.sent_history[jid][self.sent_history_pos[jid]])
def repaint_colored_widgets(self): def paint_banner(self, jid):
"""Repaint widgets (banner) in the window/tab with theme color""" theme = gajim.config.get('roster_theme')
# get the bg color of the bar from the current theme colors bgcolor = gajim.config.get_per('themes', theme, 'bannerbgcolor')
bgcolor = gajim.config.get('accountbgcolor') #FIXME: use uniq color textcolor = gajim.config.get_per('themes', theme, 'bannertextcolor')
# the backgrounds are colored by using eventboxes and
# iterate through tabs/windows and repaint # setting the bg color of the eventboxes. There is a
for jid in self.xmls: # separate event box for each component (name label and
# status icon). The avatar has one too in the glade file.
self.xmls[jid].get_widget('banner_eventbox').modify_bg( self.xmls[jid].get_widget('banner_eventbox').modify_bg(
gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor)) gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
banner_name_label = self.xmls[jid].get_widget('banner_name_label')
banner_name_label.modify_fg(gtk.STATE_NORMAL,
gtk.gdk.color_parse(textcolor))
def repaint_colored_widgets(self):
"""Repaint widgets (banner) in the window/tab with theme color"""
# iterate through tabs/windows and repaint
for jid in self.xmls:
self.paint_banner(jid)

View File

@ -61,15 +61,6 @@ class Config:
'statusmsgcolor': [ opt_color, '#1eaa1e' ], 'statusmsgcolor': [ opt_color, '#1eaa1e' ],
'collapsed_rows': [ opt_str, '' ], 'collapsed_rows': [ opt_str, '' ],
'roster_theme': [ opt_str, 'green' ], 'roster_theme': [ opt_str, 'green' ],
'accounttextcolor': [ opt_color, '#ffffff' ],
'accountbgcolor': [ opt_color, '#94aa8c' ],
'accountfont': [ opt_str, 'Sans Bold 10' ],
'grouptextcolor': [ opt_color, '#0000ff' ],
'groupbgcolor': [ opt_color, '#eff3e7' ],
'groupfont': [ opt_str, 'Sans Italic 10' ],
'contacttextcolor': [ opt_color, '#000000' ],
'contactbgcolor': [ opt_color, '#ffffff' ],
'userfont': [ opt_str, 'Sans 10' ],
'saveposition': [ opt_bool, True ], 'saveposition': [ opt_bool, True ],
'mergeaccounts': [ opt_bool, False ], 'mergeaccounts': [ opt_bool, False ],
'sort_by_show': [ opt_bool, True ], 'sort_by_show': [ opt_bool, True ],
@ -152,6 +143,19 @@ class Config:
'user': [ opt_str, '' ], 'user': [ opt_str, '' ],
'pass': [ opt_str, '' ], 'pass': [ 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, '' ],
}, {}),
} }
emoticons_default = { emoticons_default = {
@ -233,6 +237,21 @@ class Config:
'message_sent': [ True, '../data/sounds/sent.wav' ], 'message_sent': [ True, '../data/sounds/sent.wav' ],
} }
themes_default = {
'green': [ '#ffffff', '#94aa8c', 'Sans Bold 10', '#0000ff', '#eff3e7',
'Sans Italic 10', '#000000', '#ffffff', 'Sans 10', '#ffffff',
'#94aa8c' ],
'cyan': [ '#ff0000', '#9fdfff', 'Sans Bold 10', '#0000ff', '#ffffff',
'Sans Italic 10', '#000000', '#ffffff', 'Sans 10', '#ffffff',
'#9fdfff' ],
'marine': [ '#ffffff', '#918caa', 'Sans Bold 10', '#0000ff', '#e9e7f3',
'Sans Italic 10', '#000000', '#ffffff', 'Sans 10', '#ffffff',
'#918caa' ],
'human': [ '#ffffff', '#996442', 'Sans Bold 10', '#ab5920', '#e3ca94',
'Sans Italic 10', '#000000', '#ffffff', 'Sans 10', '#ffffff',
'#996442' ],
}
def foreach(self, cb, data = None): def foreach(self, cb, data = None):
for opt in self.__options: for opt in self.__options:
cb(data, opt, None, self.__options[opt]) cb(data, opt, None, self.__options[opt])

View File

@ -148,54 +148,6 @@ class PreferencesWindow:
st = gajim.config.get('use_transports_iconsets') st = gajim.config.get('use_transports_iconsets')
self.xml.get_widget('transports_iconsets_checkbutton').set_active(st) self.xml.get_widget('transports_iconsets_checkbutton').set_active(st)
# Roster colors / font
self.theme_default = {
'green': {
'accounttextcolor': '#ffffff',
'grouptextcolor': '#0000ff',
'contacttextcolor': '#000000',
'accountbgcolor': '#94aa8c',
'groupbgcolor': '#eff3e7',
'contactbgcolor': '#ffffff',
'accountfont': 'Sans Bold 10',
'groupfont': 'Sans Italic 10',
'userfont': 'Sans 10',
},
'cyan': {
'accounttextcolor': '#ff0000',
'grouptextcolor': '#0000ff',
'contacttextcolor': '#000000',
'accountbgcolor': '#9fdfff',
'groupbgcolor': '#ffffff',
'contactbgcolor': '#ffffff',
'accountfont': 'Sans Bold 10',
'groupfont': 'Sans Italic 10',
'userfont': 'Sans 10'
},
'marine': {
'accounttextcolor': '#ffffff',
'grouptextcolor': '#0000ff',
'contacttextcolor': '#000000',
'accountbgcolor': '#918caa',
'groupbgcolor': '#e9e7f3',
'contactbgcolor': '#ffffff',
'accountfont': 'Sans Bold 10',
'groupfont': 'Sans Italic 10',
'userfont': 'Sans 10'
},
'human': {
'accounttextcolor': '#ffffff',
'grouptextcolor': '#ab5920',
'contacttextcolor': '#000000',
'accountbgcolor': '#996442',
'groupbgcolor': '#e3ca94',
'contactbgcolor': '#ffffff',
'accountfont': 'Sans Bold 10',
'groupfont': 'Sans Italic 10',
'userfont': 'Sans 10'
},
}
theme_combobox = self.xml.get_widget('theme_combobox') theme_combobox = self.xml.get_widget('theme_combobox')
cell = gtk.CellRendererText() cell = gtk.CellRendererText()
theme_combobox.pack_start(cell, True) theme_combobox.pack_start(cell, True)
@ -203,14 +155,11 @@ class PreferencesWindow:
model = gtk.ListStore(gobject.TYPE_STRING) model = gtk.ListStore(gobject.TYPE_STRING)
theme_combobox.set_model(model) theme_combobox.set_model(model)
i = 0 i = 0
for t in self.theme_default: for t in gajim.config.get_per('themes'):
model.append([t]) model.append([t])
if gajim.config.get('roster_theme') == t: if gajim.config.get('roster_theme') == t:
theme_combobox.set_active(i) theme_combobox.set_active(i)
i += 1 i += 1
model.append(['custom'])
if gajim.config.get('roster_theme') == 'custom':
theme_combobox.set_active(i)
self.on_theme_combobox_changed(theme_combobox) self.on_theme_combobox_changed(theme_combobox)
#use tabbed chat window #use tabbed chat window

View File

@ -790,16 +790,27 @@ class Interface:
# Do not set gajim.verbose to False if -v option was given # Do not set gajim.verbose to False if -v option was given
if gajim.config.get('verbose'): if gajim.config.get('verbose'):
gajim.verbose = True gajim.verbose = True
#add default emoticons is there is not in the config file #add default emoticons if there is not in the config file
if len(gajim.config.get_per('emoticons')) == 0: if len(gajim.config.get_per('emoticons')) == 0:
for emot in gajim.config.emoticons_default: for emot in gajim.config.emoticons_default:
gajim.config.add_per('emoticons', emot) gajim.config.add_per('emoticons', emot)
gajim.config.set_per('emoticons', emot, 'path', gajim.config.emoticons_default[emot]) gajim.config.set_per('emoticons', emot, 'path', gajim.config.emoticons_default[emot])
#add default status messages is there is not in the config file #add default status messages if there is not in the config file
if len(gajim.config.get_per('statusmsg')) == 0: if len(gajim.config.get_per('statusmsg')) == 0:
for msg in gajim.config.statusmsg_default: for msg in gajim.config.statusmsg_default:
gajim.config.add_per('statusmsg', msg) gajim.config.add_per('statusmsg', msg)
gajim.config.set_per('statusmsg', msg, 'message', gajim.config.statusmsg_default[msg]) gajim.config.set_per('statusmsg', msg, 'message', gajim.config.statusmsg_default[msg])
#add default themes if there is not in the config file
if len(gajim.config.get_per('themes')) == 0:
d = ['accounttextcolor', 'accountbgcolor', 'accountfont',
'grouptextcolor', 'groupbgcolor', 'groupfont', 'contacttextcolor',
'contactbgcolor', 'contactfont', 'bannertextcolor', 'bannerbgcolor']
default = gajim.config.themes_default
for theme in default:
gajim.config.add_per('themes', theme)
for o in d:
gajim.config.set_per('themes', theme, o,
default[theme][d.index(o)])
if gajim.verbose: if gajim.verbose:
gajim.log.setLevel(gajim.logging.DEBUG) gajim.log.setLevel(gajim.logging.DEBUG)

View File

@ -669,13 +669,7 @@ class GroupchatWindow(chat.Chat):
'conversation_textview') 'conversation_textview')
self.name_labels[room_jid] = self.xmls[room_jid].get_widget( self.name_labels[room_jid] = self.xmls[room_jid].get_widget(
'banner_name_label') 'banner_name_label')
# set the fg colour of the label to white self.paint_banner(room_jid)
self.name_labels[room_jid].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('white'))
banner_eventbox = self.xmls[room_jid].get_widget('banner_eventbox')
# get the background color from the current theme
bgcolor = gajim.config.get('accountbgcolor')
banner_eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
# connect the menuitems to their respective functions # connect the menuitems to their respective functions
xm = gtk.glade.XML(GTKGUI_GLADE, 'gc_actions_menu', APP) xm = gtk.glade.XML(GTKGUI_GLADE, 'gc_actions_menu', APP)

View File

@ -1387,13 +1387,14 @@ class RosterWindow:
def iconCellDataFunc(self, column, renderer, model, iter, data = None): def iconCellDataFunc(self, column, renderer, model, iter, data = None):
'''When a row is added, set properties for icon renderer''' '''When a row is added, set properties for icon renderer'''
theme = gajim.config.get('roster_theme')
if model.get_value(iter, 2) == 'account': if model.get_value(iter, 2) == 'account':
renderer.set_property('cell-background', renderer.set_property('cell-background',
gajim.config.get('accountbgcolor')) gajim.config.get_per('themes', theme, 'accountbgcolor'))
renderer.set_property('xalign', 0) renderer.set_property('xalign', 0)
elif model.get_value(iter, 2) == 'group': elif model.get_value(iter, 2) == 'group':
renderer.set_property('cell-background', renderer.set_property('cell-background',
gajim.config.get('groupbgcolor')) gajim.config.get_per('themes', theme, 'groupbgcolor'))
renderer.set_property('xalign', 0.5) renderer.set_property('xalign', 0.5)
else: else:
jid = model.get_value(iter, 3) jid = model.get_value(iter, 3)
@ -1404,39 +1405,43 @@ class RosterWindow:
renderer.set_property('cell-background', '#ab6161') renderer.set_property('cell-background', '#ab6161')
else: else:
renderer.set_property('cell-background', renderer.set_property('cell-background',
gajim.config.get('userbgcolor')) gajim.config.get_per('themes', theme, 'contactbgcolor'))
renderer.set_property('xalign', 1) renderer.set_property('xalign', 1)
renderer.set_property('width', 20) renderer.set_property('width', 20)
def nameCellDataFunc(self, column, renderer, model, iter, data = None): def nameCellDataFunc(self, column, renderer, model, iter, data = None):
'''When a row is added, set properties for name renderer''' '''When a row is added, set properties for name renderer'''
theme = gajim.config.get('roster_theme')
if model.get_value(iter, 2) == 'account': if model.get_value(iter, 2) == 'account':
renderer.set_property('foreground', renderer.set_property('foreground',
gajim.config.get('accounttextcolor')) gajim.config.get_per('themes', theme, 'accounttextcolor'))
renderer.set_property('cell-background', renderer.set_property('cell-background',
gajim.config.get('accountbgcolor')) gajim.config.get_per('themes', theme, 'accountbgcolor'))
renderer.set_property('font', gajim.config.get('accountfont')) renderer.set_property('font',
gajim.config.get_per('themes', theme, 'accountfont'))
renderer.set_property('xpad', 0) renderer.set_property('xpad', 0)
elif model.get_value(iter, 2) == 'group': elif model.get_value(iter, 2) == 'group':
renderer.set_property('foreground', renderer.set_property('foreground',
gajim.config.get('grouptextcolor')) gajim.config.get_per('themes', theme, 'grouptextcolor'))
renderer.set_property('cell-background', renderer.set_property('cell-background',
gajim.config.get('groupbgcolor')) gajim.config.get_per('themes', theme, 'groupbgcolor'))
renderer.set_property('font', gajim.config.get('groupfont')) renderer.set_property('font',
gajim.config.get_per('themes', theme, 'groupfont'))
renderer.set_property('xpad', 4) renderer.set_property('xpad', 4)
else: else:
jid = model.get_value(iter, 3) jid = model.get_value(iter, 3)
account = model.get_value(iter, 4) account = model.get_value(iter, 4)
renderer.set_property('foreground', renderer.set_property('foreground',
gajim.config.get('usertextcolor')) gajim.config.get_per('themes', theme, 'contacttextcolor'))
if jid in self.newly_added[account]: if jid in self.newly_added[account]:
renderer.set_property('cell-background', '#adc3c6') renderer.set_property('cell-background', '#adc3c6')
elif jid in self.to_be_removed[account]: elif jid in self.to_be_removed[account]:
renderer.set_property('cell-background', '#ab6161') renderer.set_property('cell-background', '#ab6161')
else: else:
renderer.set_property('cell-background', renderer.set_property('cell-background',
gajim.config.get('userbgcolor')) gajim.config.get_per('themes', theme, 'contactbgcolor'))
renderer.set_property('font', gajim.config.get('userfont')) renderer.set_property('font',
gajim.config.get_per('themes', theme, 'contactfont'))
renderer.set_property('xpad', 8) renderer.set_property('xpad', 8)
def get_show(self, luser): def get_show(self, luser):

View File

@ -97,24 +97,14 @@ class TabbedChatWindow(chat.Chat):
def draw_name_banner(self, name, jid): def draw_name_banner(self, name, jid):
'''Draw the fat line at the top of the window that '''Draw the fat line at the top of the window that
houses the status icon, name, jid, and avatar''' houses the status icon, name, jid, and avatar'''
# this is the text for the big brown bar # this is the text for the big brown bar
label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \ label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
% (name, jid) % (name, jid)
# get the bg color of the bar from the current theme colors
bgcolor = gajim.config.get('accountbgcolor')
# the backgrounds are colored by using eventboxes and
# setting the bg color of the eventboxes. There is a
# separate event box for each component (name label and
# status icon). The avatar has one too in the glade file.
self.xmls[jid].get_widget('banner_eventbox').modify_bg(
gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
# setup the label that holds name and jid # setup the label that holds name and jid
banner_name_label = self.xmls[jid].get_widget('banner_name_label') banner_name_label = self.xmls[jid].get_widget('banner_name_label')
banner_name_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('white'))
banner_name_label.set_markup(label_text) banner_name_label.set_markup(label_text)
self.paint_banner(jid)
def set_avatar(self, vcard): def set_avatar(self, vcard):
if not vcard.has_key('PHOTO'): if not vcard.has_key('PHOTO'):