Dont use depracted override_color()
This commit is contained in:
parent
e00341e83e
commit
9ecabd561e
|
@ -1226,7 +1226,7 @@ class ChatControl(ChatControlBase):
|
||||||
else:
|
else:
|
||||||
self.old_msg_kind = kind
|
self.old_msg_kind = kind
|
||||||
|
|
||||||
def get_tab_label(self, chatstate):
|
def get_tab_label(self):
|
||||||
unread = ''
|
unread = ''
|
||||||
if self.resource:
|
if self.resource:
|
||||||
jid = self.contact.get_full_jid()
|
jid = self.contact.get_full_jid()
|
||||||
|
@ -1239,48 +1239,13 @@ class ChatControl(ChatControlBase):
|
||||||
elif num_unread > 1:
|
elif num_unread > 1:
|
||||||
unread = '[' + str(num_unread) + ']'
|
unread = '[' + str(num_unread) + ']'
|
||||||
|
|
||||||
# Draw tab label using chatstate
|
|
||||||
theme = gajim.config.get('roster_theme')
|
|
||||||
color_s = None
|
|
||||||
if not chatstate:
|
|
||||||
chatstate = self.contact.chatstate
|
|
||||||
if chatstate is not None:
|
|
||||||
if chatstate == 'composing':
|
|
||||||
color_s = gajim.config.get_per('themes', theme,
|
|
||||||
'state_composing_color')
|
|
||||||
elif chatstate == 'inactive':
|
|
||||||
color_s = gajim.config.get_per('themes', theme,
|
|
||||||
'state_inactive_color')
|
|
||||||
elif chatstate == 'gone':
|
|
||||||
color_s = gajim.config.get_per('themes', theme,
|
|
||||||
'state_gone_color')
|
|
||||||
elif chatstate == 'paused':
|
|
||||||
color_s = gajim.config.get_per('themes', theme,
|
|
||||||
'state_paused_color')
|
|
||||||
|
|
||||||
context = self.parent_win.notebook.get_style_context()
|
|
||||||
if color_s:
|
|
||||||
# We set the color for when it's the current tab or not
|
|
||||||
color = Gdk.RGBA()
|
|
||||||
ok = Gdk.RGBA.parse(color, color_s)
|
|
||||||
if not ok:
|
|
||||||
del color
|
|
||||||
color = context.get_color(Gtk.StateFlags.ACTIVE)
|
|
||||||
# In inactive tab color to be lighter against the darker inactive
|
|
||||||
# background
|
|
||||||
if chatstate in ('inactive', 'gone') and\
|
|
||||||
self.parent_win.get_active_control() != self:
|
|
||||||
color = self.lighten_color(color)
|
|
||||||
else: # active or not chatstate, get color from gtk
|
|
||||||
color = context.get_color(Gtk.StateFlags.ACTIVE)
|
|
||||||
|
|
||||||
name = self.contact.get_shown_name()
|
name = self.contact.get_shown_name()
|
||||||
if self.resource:
|
if self.resource:
|
||||||
name += '/' + self.resource
|
name += '/' + self.resource
|
||||||
label_str = GLib.markup_escape_text(name)
|
label_str = GLib.markup_escape_text(name)
|
||||||
if num_unread: # if unread, text in the label becomes bold
|
if num_unread: # if unread, text in the label becomes bold
|
||||||
label_str = '<b>' + unread + label_str + '</b>'
|
label_str = '<b>' + unread + label_str + '</b>'
|
||||||
return (label_str, color)
|
return label_str
|
||||||
|
|
||||||
def get_tab_image(self, count_unread=True):
|
def get_tab_image(self, count_unread=True):
|
||||||
if self.resource:
|
if self.resource:
|
||||||
|
|
|
@ -1181,14 +1181,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
|
||||||
message = '> %s\n' % message.replace('\n', '\n> ')
|
message = '> %s\n' % message.replace('\n', '\n> ')
|
||||||
msg_buf.set_text(message)
|
msg_buf.set_text(message)
|
||||||
|
|
||||||
def lighten_color(self, color):
|
|
||||||
p = 0.4
|
|
||||||
mask = 0
|
|
||||||
color.red = int((color.red * p) + (mask * (1 - p)))
|
|
||||||
color.green = int((color.green * p) + (mask * (1 - p)))
|
|
||||||
color.blue = int((color.blue * p) + (mask * (1 - p)))
|
|
||||||
return color
|
|
||||||
|
|
||||||
def widget_set_visible(self, widget, state):
|
def widget_set_visible(self, widget, state):
|
||||||
"""
|
"""
|
||||||
Show or hide a widget
|
Show or hide a widget
|
||||||
|
|
|
@ -3379,10 +3379,6 @@ class XMLConsoleWindow:
|
||||||
self.enabled = True
|
self.enabled = True
|
||||||
self.xml.get_object('enable_checkbutton').set_active(True)
|
self.xml.get_object('enable_checkbutton').set_active(True)
|
||||||
|
|
||||||
col = Gdk.RGBA()
|
|
||||||
Gdk.RGBA.parse(col, color)
|
|
||||||
self.input_textview.override_color(Gtk.StateType.NORMAL, col)
|
|
||||||
|
|
||||||
if len(gajim.connections) > 1:
|
if len(gajim.connections) > 1:
|
||||||
title = _('XML Console for %s') % self.account
|
title = _('XML Console for %s') % self.account
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -709,29 +709,17 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
has_focus = self.parent_win.window.get_property('has-toplevel-focus')
|
has_focus = self.parent_win.window.get_property('has-toplevel-focus')
|
||||||
current_tab = self.parent_win.get_active_control() == self
|
current_tab = self.parent_win.get_active_control() == self
|
||||||
color_name = None
|
|
||||||
color = None
|
color = None
|
||||||
theme = gajim.config.get('roster_theme')
|
|
||||||
context = self.parent_win.notebook.get_style_context()
|
|
||||||
if chatstate == 'attention' and (not has_focus or not current_tab):
|
if chatstate == 'attention' and (not has_focus or not current_tab):
|
||||||
self.attention_flag = True
|
self.attention_flag = True
|
||||||
color_name = gajim.config.get_per('themes', theme,
|
color = 'state_muc_directed_msg_color'
|
||||||
'state_muc_directed_msg_color')
|
elif chatstate == 'active' or (current_tab and has_focus):
|
||||||
elif chatstate:
|
self.attention_flag = False
|
||||||
if chatstate == 'active' or (current_tab and has_focus):
|
# get active color from gtk
|
||||||
self.attention_flag = False
|
color = 'active'
|
||||||
# get active color from gtk
|
elif chatstate == 'newmsg' and (not has_focus or not current_tab) \
|
||||||
color = context.get_color(Gtk.StateFlags.ACTIVE)
|
and not self.attention_flag:
|
||||||
elif chatstate == 'newmsg' and (not has_focus or not current_tab) \
|
color = 'state_muc_msg_color'
|
||||||
and not self.attention_flag:
|
|
||||||
color_name = gajim.config.get_per('themes', theme,
|
|
||||||
'state_muc_msg_color')
|
|
||||||
if color_name:
|
|
||||||
color = Gdk.RGBA()
|
|
||||||
ok = Gdk.RGBA.parse(color, color_name)
|
|
||||||
if not ok:
|
|
||||||
del color
|
|
||||||
color = context.get_color(Gtk.StateFlags.ACTIVE)
|
|
||||||
|
|
||||||
if self.is_continued:
|
if self.is_continued:
|
||||||
# if this is a continued conversation
|
# if this is a continued conversation
|
||||||
|
|
|
@ -1120,7 +1120,10 @@ def convert_config_to_css():
|
||||||
'state_inactive_color': ('', 'color'),
|
'state_inactive_color': ('', 'color'),
|
||||||
'state_gone_color': ('', 'color'),
|
'state_gone_color': ('', 'color'),
|
||||||
'state_paused_color': ('', 'color'),
|
'state_paused_color': ('', 'color'),
|
||||||
'msgcorrectingcolor': ('text', 'background')}
|
'msgcorrectingcolor': ('text', 'background'),
|
||||||
|
'state_muc_directed_msg_color': ('', 'color'),
|
||||||
|
'state_muc_msg_color': ('', 'color')}
|
||||||
|
|
||||||
|
|
||||||
theme = gajim.config.get('roster_theme')
|
theme = gajim.config.get('roster_theme')
|
||||||
for key, values in themed_widgets.items():
|
for key, values in themed_widgets.items():
|
||||||
|
@ -1145,7 +1148,8 @@ def add_css_class(widget, class_name):
|
||||||
for css_cls in style.list_classes():
|
for css_cls in style.list_classes():
|
||||||
if css_cls.startswith('theme_'):
|
if css_cls.startswith('theme_'):
|
||||||
style.remove_class(css_cls)
|
style.remove_class(css_cls)
|
||||||
style.add_class('theme_' + class_name)
|
if class_name:
|
||||||
|
style.add_class('theme_' + class_name)
|
||||||
|
|
||||||
def remove_css_class(widget, class_name):
|
def remove_css_class(widget, class_name):
|
||||||
style = widget.get_style_context()
|
style = widget.get_style_context()
|
||||||
|
|
|
@ -39,6 +39,7 @@ import gtkgui_helpers
|
||||||
import message_control
|
import message_control
|
||||||
import dialogs
|
import dialogs
|
||||||
from chat_control_base import ChatControlBase
|
from chat_control_base import ChatControlBase
|
||||||
|
from chat_control import ChatControl
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from gtkgui_helpers import get_action
|
from gtkgui_helpers import get_action
|
||||||
|
@ -636,7 +637,7 @@ class MessageWindow(object):
|
||||||
window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER
|
window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER
|
||||||
self.notebook.set_show_tabs(show_tabs_if_one_tab)
|
self.notebook.set_show_tabs(show_tabs_if_one_tab)
|
||||||
|
|
||||||
def redraw_tab(self, ctrl, chatstate = None):
|
def redraw_tab(self, ctrl, chatstate=None):
|
||||||
tab = self.notebook.get_tab_label(ctrl.widget)
|
tab = self.notebook.get_tab_label(ctrl.widget)
|
||||||
if not tab:
|
if not tab:
|
||||||
return
|
return
|
||||||
|
@ -653,11 +654,20 @@ class MessageWindow(object):
|
||||||
|
|
||||||
# Update nick
|
# Update nick
|
||||||
nick_label.set_max_width_chars(10)
|
nick_label.set_max_width_chars(10)
|
||||||
(tab_label_str, tab_label_color) = ctrl.get_tab_label(chatstate)
|
if isinstance(ctrl, ChatControl):
|
||||||
|
tab_label_str = ctrl.get_tab_label()
|
||||||
|
# Set Label Color
|
||||||
|
class_name = 'state_{}_color'.format(chatstate)
|
||||||
|
gtkgui_helpers.add_css_class(nick_label, class_name)
|
||||||
|
else:
|
||||||
|
tab_label_str, color = ctrl.get_tab_label(chatstate)
|
||||||
|
# Set Label Color
|
||||||
|
if color == 'active':
|
||||||
|
gtkgui_helpers.add_css_class(nick_label, None)
|
||||||
|
elif color is not None:
|
||||||
|
gtkgui_helpers.add_css_class(nick_label, color)
|
||||||
|
|
||||||
nick_label.set_markup(tab_label_str)
|
nick_label.set_markup(tab_label_str)
|
||||||
if tab_label_color:
|
|
||||||
nick_label.override_color(Gtk.StateFlags.NORMAL, tab_label_color)
|
|
||||||
nick_label.override_color(Gtk.StateFlags.ACTIVE, tab_label_color)
|
|
||||||
|
|
||||||
tab_img = ctrl.get_tab_image()
|
tab_img = ctrl.get_tab_image()
|
||||||
if tab_img:
|
if tab_img:
|
||||||
|
|
Loading…
Reference in New Issue