new option to be able to sort contacts by show
This commit is contained in:
parent
127142c1fe
commit
560f0665f8
|
@ -72,6 +72,7 @@ class Config:
|
|||
'userfont': [ opt_str, 'Sans 10' ],
|
||||
'saveposition': [ opt_bool, True ],
|
||||
'mergeaccounts': [ opt_bool, False ],
|
||||
'sort_by_show': [ opt_bool, True ],
|
||||
'usetabbedchat': [ opt_bool, True ],
|
||||
'use_speller': [ opt_bool, False ],
|
||||
'print_time': [ opt_str, 'always' ],
|
||||
|
|
|
@ -106,6 +106,10 @@ class Preferences_window:
|
|||
st = gajim.config.get('mergeaccounts')
|
||||
self.xml.get_widget('merge_checkbutton').set_active(st)
|
||||
|
||||
# Sort contacts by show
|
||||
st = gajim.config.get('sort_by_show')
|
||||
self.xml.get_widget('sort_by_show_checkbutton').set_active(st)
|
||||
|
||||
#Use emoticons
|
||||
st = gajim.config.get('useemoticons')
|
||||
self.xml.get_widget('use_emoticons_checkbutton').set_active(st)
|
||||
|
@ -422,6 +426,10 @@ class Preferences_window:
|
|||
self.plugin.roster.regroup = gajim.config.get('mergeaccounts')
|
||||
self.plugin.roster.draw_roster()
|
||||
|
||||
def on_sort_by_show_checkbutton_toggled(self, widget):
|
||||
self.on_checkbutton_toggled(widget, 'sort_by_show')
|
||||
self.plugin.roster.draw_roster()
|
||||
|
||||
def on_use_emoticons_checkbutton_toggled(self, widget):
|
||||
self.on_checkbutton_toggled(widget, 'useemoticons',
|
||||
[self.xml.get_widget('add_remove_emoticons_button')])
|
||||
|
|
|
@ -2968,7 +2968,6 @@
|
|||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="trayicon_checkbutton">
|
||||
<property name="visible">False</property>
|
||||
<property name="tooltip" translatable="yes">If checked, Gajim will also have a trayicon</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Icon in systray (aka. notification area)</property>
|
||||
|
@ -3029,6 +3028,26 @@
|
|||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="sort_by_show_checkbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Sort contacts by status</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<signal name="toggled" handler="on_sort_by_show_checkbutton_toggled" last_modification_time="Sun, 29 May 2005 18:26:18 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2947">
|
||||
<property name="visible">True</property>
|
||||
|
@ -4629,7 +4648,6 @@
|
|||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="soundplayer_hbox">
|
||||
<property name="visible">False</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">5</property>
|
||||
|
||||
|
@ -5372,7 +5390,6 @@
|
|||
|
||||
<child>
|
||||
<widget class="GtkFrame" id="links_frame">
|
||||
<property name="visible">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="label_yalign">0.5</property>
|
||||
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
|
||||
|
|
|
@ -1310,18 +1310,44 @@ class Roster_window:
|
|||
renderer.set_property('font', gajim.config.get('userfont'))
|
||||
renderer.set_property('xpad', 8)
|
||||
|
||||
def get_show(self, luser):
|
||||
prio = luser[0].priority
|
||||
show = luser[0].show
|
||||
for u in luser:
|
||||
if u.priority > prio:
|
||||
prio = u.priority
|
||||
show = u.show
|
||||
return show
|
||||
|
||||
def compareIters(self, model, iter1, iter2, data = None):
|
||||
'''Compare two iters to sort them'''
|
||||
name1 = model.get_value(iter1, 1)
|
||||
name2 = model.get_value(iter2, 1)
|
||||
if not name1 or not name2:
|
||||
return 0
|
||||
type = model.get_value(iter1, 2)
|
||||
if type == 'group':
|
||||
type1 = model.get_value(iter1, 2)
|
||||
type2 = model.get_value(iter2, 2)
|
||||
if type1 == 'group':
|
||||
if name1 == 'Transports':
|
||||
return 1
|
||||
if name2 == 'Transports':
|
||||
return -1
|
||||
if type1 == 'user' and type2 == 'user' and \
|
||||
gajim.config.get('sort_by_show'):
|
||||
account = model.get_value(iter1, 4)
|
||||
if account and model.get_value(iter2, 4) == account:
|
||||
jid1 = model.get_value(iter1, 3)
|
||||
jid2 = model.get_value(iter2, 3)
|
||||
luser1 = self.contacts[account][jid1]
|
||||
luser2 = self.contacts[account][jid2]
|
||||
cshow = {'online':0, 'free': 1, 'away':2, 'xa':3, 'dnd':4,
|
||||
'invisible':5, 'offline':6, 'error':7}
|
||||
show1 = cshow[self.get_show(luser1)]
|
||||
show2 = cshow[self.get_show(luser2)]
|
||||
if show1 < show2:
|
||||
return -1
|
||||
elif show1 > show2:
|
||||
return 1
|
||||
if name1.lower() < name2.lower():
|
||||
return -1
|
||||
if name2.lower < name1.lower():
|
||||
|
|
Loading…
Reference in New Issue