[gjc]commit better analogy for colors in contact row
This commit is contained in:
parent
58ae3ed63f
commit
99636d5ccf
3 changed files with 38 additions and 14 deletions
|
@ -23,6 +23,7 @@
|
||||||
<signal name="delete_event" handler="on_roster_window_delete_event" last_modification_time="Mon, 21 Mar 2005 12:34:59 GMT"/>
|
<signal name="delete_event" handler="on_roster_window_delete_event" last_modification_time="Mon, 21 Mar 2005 12:34:59 GMT"/>
|
||||||
<signal name="focus_in_event" handler="on_roster_window_focus_in_event" last_modification_time="Sun, 04 Sep 2005 16:33:35 GMT"/>
|
<signal name="focus_in_event" handler="on_roster_window_focus_in_event" last_modification_time="Sun, 04 Sep 2005 16:33:35 GMT"/>
|
||||||
<signal name="key_press_event" handler="on_roster_window_key_press_event" last_modification_time="Tue, 20 Sep 2005 19:26:27 GMT"/>
|
<signal name="key_press_event" handler="on_roster_window_key_press_event" last_modification_time="Tue, 20 Sep 2005 19:26:27 GMT"/>
|
||||||
|
<signal name="focus_out_event" handler="on_roster_window_focus_out_event" last_modification_time="Tue, 08 Nov 2005 14:01:01 GMT"/>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkVBox" id="roster_vbox">
|
<widget class="GtkVBox" id="roster_vbox">
|
||||||
|
@ -376,6 +377,7 @@
|
||||||
<signal name="motion_notify_event" handler="on_roster_treeview_motion_notify_event" last_modification_time="Wed, 06 Jul 2005 14:38:58 GMT"/>
|
<signal name="motion_notify_event" handler="on_roster_treeview_motion_notify_event" last_modification_time="Wed, 06 Jul 2005 14:38:58 GMT"/>
|
||||||
<signal name="leave_notify_event" handler="on_roster_treeview_leave_notify_event" last_modification_time="Wed, 06 Jul 2005 14:39:06 GMT"/>
|
<signal name="leave_notify_event" handler="on_roster_treeview_leave_notify_event" last_modification_time="Wed, 06 Jul 2005 14:39:06 GMT"/>
|
||||||
<signal name="scroll_event" handler="on_roster_treeview_scroll_event" last_modification_time="Fri, 08 Jul 2005 22:09:03 GMT"/>
|
<signal name="scroll_event" handler="on_roster_treeview_scroll_event" last_modification_time="Fri, 08 Jul 2005 22:09:03 GMT"/>
|
||||||
|
<signal name="style_set" handler="on_roster_treeview_style_set" last_modification_time="Tue, 08 Nov 2005 14:03:30 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -384,20 +384,25 @@ def file_is_locked(path_to_file):
|
||||||
hfile.Close()
|
hfile.Close()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _get_fade_color(treeview, selected):
|
def _get_fade_color(treeview, selected, focused):
|
||||||
'''get a gdk color that is halfway between foreground and background
|
'''get a gdk color that is between foreground and background in 0.3
|
||||||
colors of the cell for the given treeview'''
|
0.7 respectively colors of the cell for the given treeview'''
|
||||||
style = treeview.style
|
style = treeview.style
|
||||||
if selected:
|
if selected:
|
||||||
state = gtk.STATE_SELECTED
|
if focused: # is the window focused?
|
||||||
|
state = gtk.STATE_SELECTED
|
||||||
|
else: # is it not? NOTE: many gtk themes change bg on this
|
||||||
|
state = gtk.STATE_ACTIVE
|
||||||
else:
|
else:
|
||||||
state = gtk.STATE_NORMAL
|
state = gtk.STATE_NORMAL
|
||||||
bg = style.base[state]
|
bg = style.base[state]
|
||||||
fg = style.text[state]
|
fg = style.text[state]
|
||||||
|
|
||||||
return gtk.gdk.Color((bg.red + fg.red)/2,
|
p = 0.3 # background
|
||||||
(bg.green + fg.green)/2,
|
q = 0.7 # foreground # p + q should do 1.0
|
||||||
(bg.blue + fg.blue)/2)
|
return gtk.gdk.Color(int(bg.red*p + fg.red*q),
|
||||||
|
int(bg.green*p + fg.green*q),
|
||||||
|
int(bg.blue*p + fg.blue*q))
|
||||||
|
|
||||||
def get_scaled_pixbuf(pixbuf, type):
|
def get_scaled_pixbuf(pixbuf, type):
|
||||||
'''returns scaled pixbuf, keeping ratio etc
|
'''returns scaled pixbuf, keeping ratio etc
|
||||||
|
|
|
@ -237,7 +237,7 @@ class RosterWindow:
|
||||||
return self.transports_state_images[transport]
|
return self.transports_state_images[transport]
|
||||||
return self.jabber_state_images
|
return self.jabber_state_images
|
||||||
|
|
||||||
def draw_contact(self, jid, account, selected=False):
|
def draw_contact(self, jid, account, selected=False, focus=False):
|
||||||
'''draw the correct state image and name'''
|
'''draw the correct state image and name'''
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
iters = self.get_contact_iter(jid, account)
|
iters = self.get_contact_iter(jid, account)
|
||||||
|
@ -255,7 +255,7 @@ class RosterWindow:
|
||||||
status = contact.status.strip()
|
status = contact.status.strip()
|
||||||
if status != '':
|
if status != '':
|
||||||
# escape markup entities and make them small italic and fg color
|
# escape markup entities and make them small italic and fg color
|
||||||
color = gtkgui_helpers._get_fade_color(self.tree, selected)
|
color = gtkgui_helpers._get_fade_color(self.tree, selected, focus)
|
||||||
colorstring = "#%04x%04x%04x" % (color.red, color.green, color.blue)
|
colorstring = "#%04x%04x%04x" % (color.red, color.green, color.blue)
|
||||||
name += '\n<span size="small" style="italic" foreground="%s">%s</span>'\
|
name += '\n<span size="small" style="italic" foreground="%s">%s</span>'\
|
||||||
% (colorstring, gtkgui_helpers.escape_for_pango_markup(status))
|
% (colorstring, gtkgui_helpers.escape_for_pango_markup(status))
|
||||||
|
@ -1751,12 +1751,29 @@ _('If "%s" accepts this request you will know his status.') %jid)
|
||||||
return True # do NOT destory the window
|
return True # do NOT destory the window
|
||||||
|
|
||||||
def on_roster_window_focus_in_event(self, widget, event):
|
def on_roster_window_focus_in_event(self, widget, event):
|
||||||
'''roster received focus, so if we had urgency REMOVE IT
|
# roster received focus, so if we had urgency REMOVE IT
|
||||||
NOTE: we do not have to read the message to remove urgency
|
# NOTE: we do not have to read the message to remove urgency
|
||||||
so this functions does that'''
|
# so this functions does that
|
||||||
if gtk.gtk_version >= (2, 8, 0) and gtk.pygtk_version >= (2, 8, 0):
|
if gtk.gtk_version >= (2, 8, 0) and gtk.pygtk_version >= (2, 8, 0):
|
||||||
if widget.props.urgency_hint:
|
if widget.props.urgency_hint:
|
||||||
widget.props.urgency_hint = False
|
widget.props.urgency_hint = False
|
||||||
|
|
||||||
|
# if a contact row is selected, update colors (eg. for status msg)
|
||||||
|
# because gtk engines may differ in bg when window is selected
|
||||||
|
# or not
|
||||||
|
if self._last_selected_contact is not None:
|
||||||
|
jid, account = self._last_selected_contact
|
||||||
|
self.draw_contact(jid, account, selected = True,
|
||||||
|
focus = True)
|
||||||
|
|
||||||
|
def on_roster_window_focus_out_event(self, widget, event):
|
||||||
|
# if a contact row is selected, update colors (eg. for status msg)
|
||||||
|
# because gtk engines may differ in bg when window is selected
|
||||||
|
# or not
|
||||||
|
if self._last_selected_contact is not None:
|
||||||
|
jid, account = self._last_selected_contact
|
||||||
|
self.draw_contact(jid, account, selected = True,
|
||||||
|
focus = False)
|
||||||
|
|
||||||
def on_roster_window_key_press_event(self, widget, event):
|
def on_roster_window_key_press_event(self, widget, event):
|
||||||
if event.keyval == gtk.keysyms.Escape:
|
if event.keyval == gtk.keysyms.Escape:
|
||||||
|
@ -2378,7 +2395,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
|
||||||
group_iter = model.iter_next(group_iter)
|
group_iter = model.iter_next(group_iter)
|
||||||
account_iter = model.iter_next(account_iter)
|
account_iter = model.iter_next(account_iter)
|
||||||
|
|
||||||
def _on_treeview_style_set(self, treeview, style):
|
def on_roster_treeview_style_set(self, treeview, style):
|
||||||
'''When style (theme) changes, redraw all contacts'''
|
'''When style (theme) changes, redraw all contacts'''
|
||||||
for contact in self.iter_contact_rows():
|
for contact in self.iter_contact_rows():
|
||||||
self.draw_contact(contact[C_JID], contact[C_ACCOUNT])
|
self.draw_contact(contact[C_JID], contact[C_ACCOUNT])
|
||||||
|
@ -2404,7 +2421,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
|
||||||
self.tree = self.xml.get_widget('roster_treeview')
|
self.tree = self.xml.get_widget('roster_treeview')
|
||||||
self.tree.get_selection().connect('changed',
|
self.tree.get_selection().connect('changed',
|
||||||
self._on_treeview_selection_changed)
|
self._on_treeview_selection_changed)
|
||||||
self.tree.connect('style-set', self._on_treeview_style_set)
|
|
||||||
self._last_selected_contact = None # None or holds jid, account tupple
|
self._last_selected_contact = None # None or holds jid, account tupple
|
||||||
self.nb_unread = 0
|
self.nb_unread = 0
|
||||||
self.last_save_dir = None
|
self.last_save_dir = None
|
||||||
|
|
Loading…
Add table
Reference in a new issue