From ee4e96c4ad423120bc7b86b28ef37052a73531ac Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Fri, 3 Nov 2006 12:43:27 +0000 Subject: [PATCH] [elrodeo] font button for roster font in prefs window. see #2633 --- data/glade/preferences_window.glade | 54 +++++++++++++++++++++++++++++ src/common/config.py | 1 + src/config.py | 20 +++++++++-- src/roster_window.py | 7 ++++ 4 files changed, 79 insertions(+), 3 deletions(-) diff --git a/data/glade/preferences_window.glade b/data/glade/preferences_window.glade index 687f4121f..2138464ff 100644 --- a/data/glade/preferences_window.glade +++ b/data/glade/preferences_window.glade @@ -309,6 +309,7 @@ False + 0 @@ -316,6 +317,59 @@ True + + + + True + False + 12 + + + + True + _Roster Font: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + roster_fontbutton + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + True + + + + + + True + True + True + True + False + False + True + + + + 0 + False + True + + + + + diff --git a/src/common/config.py b/src/common/config.py index 1bc59b1aa..bdd0b4444 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -162,6 +162,7 @@ class Config: 'file_transfers_port': [opt_int, 28011], 'ft_override_host_to_send': [opt_str, '', _('Overrides the host we send for File Transfer in case of address translation/port forwarding.')], 'conversation_font': [opt_str, ''], + 'roster_font': [opt_str, ''], 'use_kib_mib': [opt_bool, False, _('IEC standard says KiB = 1024 bytes, KB = 1000 bytes.')], 'notify_on_all_muc_messages': [opt_bool, False], 'trayicon_notification_on_new_messages': [opt_bool, True], diff --git a/src/config.py b/src/config.py index e8cc34f96..48737f17e 100644 --- a/src/config.py +++ b/src/config.py @@ -268,6 +268,16 @@ class PreferencesWindow: else: fontbutton.set_font_name(font) + #Font for roster + roster_font = gajim.config.get('roster_font') + # try to set default font for the current desktop env + if roster_font == '': + roster_font = gtkgui_helpers.get_default_font() + if roster_font is None: + roster_font = 'Sans 10' + gajim.config.set('roster_font', roster_font) + self.xml.get_widget('roster_fontbutton').set_font_name(roster_font) + # on new message only_in_roster = True if gajim.config.get('notify_on_new_message'): @@ -737,19 +747,20 @@ class PreferencesWindow: self.update_text_tags() gajim.interface.save_config() - def on_preference_widget_font_set(self, widget, text): + def on_preference_widget_font_set(self, widget, config_name): if widget: font = widget.get_font_name() else: font = '' - gajim.config.set(text, font) + gajim.config.set(config_name, font) self.update_text_font() gajim.interface.save_config() def update_text_font(self): - '''Update text font in Opened Chat Windows''' + '''Update text font in Opened Chat Windows and in roster''' for win in gajim.interface.msg_win_mgr.windows(): win.update_font() + gajim.interface.roster.update_font() def on_incoming_msg_colorbutton_color_set(self, widget): self.on_preference_widget_color_set(widget, 'inmsgcolor') @@ -775,6 +786,9 @@ class PreferencesWindow: font_widget.set_sensitive(True) self.on_preference_widget_font_set(font_widget, 'conversation_font') + def on_roster_fontbutton_font_set(self, widget): + self.on_preference_widget_font_set(widget, 'roster_font') + def on_reset_colors_button_clicked(self, widget): for i in ('inmsgcolor', 'outmsgcolor', 'statusmsgcolor', 'urlmsgcolor'): gajim.config.set(i, gajim.interface.default_values[i]) diff --git a/src/roster_window.py b/src/roster_window.py index ebdca8e7e..0bceee161 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -21,6 +21,7 @@ import os import sys import time import urllib +import pango import common.sleepy import history_window @@ -1048,6 +1049,11 @@ class RosterWindow: if ctrl.type_id == message_control.TYPE_GC: ctrl.update_ui() + def update_font(self): + '''update the font used inthe roster''' + font = pango.FontDescription(gajim.config.get('roster_font')) + self.tree.modify_font(font) + def draw_roster(self): '''clear and draw roster''' # clear the model, only if it is not empty @@ -4160,6 +4166,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) self.collapsed_rows = gajim.config.get('collapsed_rows').split('\t') self.tooltip = tooltips.RosterTooltip() + self.update_font() self.draw_roster() ## Music Track notifications