[TheCurse] single-clicking ability. fixes #2072
This commit is contained in:
parent
798fd0e25a
commit
3545dd3b90
|
@ -124,6 +124,8 @@ status_before_autoaway = {}
|
||||||
# be online
|
# be online
|
||||||
transport_avatar = {} # {transport_jid: [jid_list]}
|
transport_avatar = {} # {transport_jid: [jid_list]}
|
||||||
|
|
||||||
|
# Is Gnome configured to activate on single click ?
|
||||||
|
single_click = False
|
||||||
SHOW_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
|
SHOW_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
|
||||||
'invisible', 'error']
|
'invisible', 'error']
|
||||||
|
|
||||||
|
|
12
src/gajim.py
12
src/gajim.py
|
@ -2146,7 +2146,17 @@ class Interface:
|
||||||
if os.name != 'nt' and gajim.config.get('check_if_gajim_is_default'):
|
if os.name != 'nt' and gajim.config.get('check_if_gajim_is_default'):
|
||||||
gtkgui_helpers.possibly_set_gajim_as_xmpp_handler()
|
gtkgui_helpers.possibly_set_gajim_as_xmpp_handler()
|
||||||
|
|
||||||
#add default status messages if there is not in the config file
|
# Is gnome configured to activate row on single click ?
|
||||||
|
try:
|
||||||
|
import gconf
|
||||||
|
client = gconf.client_get_default()
|
||||||
|
click_policy = client.get_string(
|
||||||
|
'/apps/nautilus/preferences/click_policy')
|
||||||
|
if click_policy == 'single':
|
||||||
|
gajim.single_click = True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
# 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)
|
||||||
|
|
|
@ -1757,8 +1757,9 @@ class GroupchatControl(ChatControlBase):
|
||||||
win.set_active_tab(nick_jid, self.account)
|
win.set_active_tab(nick_jid, self.account)
|
||||||
win.window.present()
|
win.window.present()
|
||||||
|
|
||||||
def on_list_treeview_row_activated(self, widget, path, col = 0):
|
def on_row_activated(self, widget, path):
|
||||||
'''When an iter is double clicked: open the chat window'''
|
'''When an iter is activated (dubblick or single click if gnome is set
|
||||||
|
this way'''
|
||||||
model = widget.get_model()
|
model = widget.get_model()
|
||||||
if len(path) == 1: # It's a group
|
if len(path) == 1: # It's a group
|
||||||
if (widget.row_expanded(path)):
|
if (widget.row_expanded(path)):
|
||||||
|
@ -1768,6 +1769,11 @@ class GroupchatControl(ChatControlBase):
|
||||||
else: # We want to send a private message
|
else: # We want to send a private message
|
||||||
nick = model[path][C_NICK].decode('utf-8')
|
nick = model[path][C_NICK].decode('utf-8')
|
||||||
self._start_private_message(nick)
|
self._start_private_message(nick)
|
||||||
|
|
||||||
|
def on_list_treeview_row_activated(self, widget, path, col = 0):
|
||||||
|
'''When an iter is double clicked: open the chat window'''
|
||||||
|
if not gajim.single_click:
|
||||||
|
self.on_row_activated(widget, path)
|
||||||
|
|
||||||
def on_list_treeview_button_press_event(self, widget, event):
|
def on_list_treeview_button_press_event(self, widget, event):
|
||||||
'''popup user's group's or agent menu'''
|
'''popup user's group's or agent menu'''
|
||||||
|
@ -1808,26 +1814,30 @@ class GroupchatControl(ChatControlBase):
|
||||||
widget.get_selection().unselect_all()
|
widget.get_selection().unselect_all()
|
||||||
return
|
return
|
||||||
|
|
||||||
model = widget.get_model()
|
if gajim.single_click:
|
||||||
iter = model.get_iter(path)
|
self.on_row_activated(widget, path)
|
||||||
nick = model[iter][C_NICK].decode('utf-8')
|
|
||||||
if not nick in gajim.contacts.get_nick_list(self.account,
|
|
||||||
self.room_jid):
|
|
||||||
#it's a group
|
|
||||||
col = widget.get_column(0)
|
|
||||||
avatar_cell = col.get_cell_renderers()[0]
|
|
||||||
(pos, avatar_size) = col.cell_get_position(avatar_cell)
|
|
||||||
status_cell = col.get_cell_renderers()[1]
|
|
||||||
(pos, status_size) = col.cell_get_position(status_cell)
|
|
||||||
if x > avatar_size and x < avatar_size + status_size:
|
|
||||||
if (widget.row_expanded(path)):
|
|
||||||
widget.collapse_row(path)
|
|
||||||
else:
|
|
||||||
widget.expand_row(path, False)
|
|
||||||
elif event.state & gtk.gdk.SHIFT_MASK:
|
|
||||||
self.append_nick_in_msg_textview(self.msg_textview, nick)
|
|
||||||
self.msg_textview.grab_focus()
|
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
model = widget.get_model()
|
||||||
|
iter = model.get_iter(path)
|
||||||
|
nick = model[iter][C_NICK].decode('utf-8')
|
||||||
|
if not nick in gajim.contacts.get_nick_list(self.account,
|
||||||
|
self.room_jid):
|
||||||
|
#it's a group
|
||||||
|
col = widget.get_column(0)
|
||||||
|
avatar_cell = col.get_cell_renderers()[0]
|
||||||
|
(pos, avatar_size) = col.cell_get_position(avatar_cell)
|
||||||
|
status_cell = col.get_cell_renderers()[1]
|
||||||
|
(pos, status_size) = col.cell_get_position(status_cell)
|
||||||
|
if x > avatar_size and x < avatar_size + status_size:
|
||||||
|
if (widget.row_expanded(path)):
|
||||||
|
widget.collapse_row(path)
|
||||||
|
else:
|
||||||
|
widget.expand_row(path, False)
|
||||||
|
elif event.state & gtk.gdk.SHIFT_MASK:
|
||||||
|
self.append_nick_in_msg_textview(self.msg_textview, nick)
|
||||||
|
self.msg_textview.grab_focus()
|
||||||
|
return True
|
||||||
|
|
||||||
def append_nick_in_msg_textview(self, widget, nick):
|
def append_nick_in_msg_textview(self, widget, nick):
|
||||||
message_buffer = self.msg_textview.get_buffer()
|
message_buffer = self.msg_textview.get_buffer()
|
||||||
|
|
|
@ -2883,24 +2883,27 @@ class RosterWindow:
|
||||||
elif event.button == 1: # Left click
|
elif event.button == 1: # Left click
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
type_ = model[path][C_TYPE]
|
type_ = model[path][C_TYPE]
|
||||||
if type_ == 'group' and x < 27:
|
if gajim.single_click:
|
||||||
# first cell in 1st column (the arrow SINGLE clicked)
|
self.on_row_activated(widget, path)
|
||||||
if (self.tree.row_expanded(path)):
|
else:
|
||||||
self.tree.collapse_row(path)
|
if type_ == 'group' and x < 27:
|
||||||
else:
|
# first cell in 1st column (the arrow SINGLE clicked)
|
||||||
self.tree.expand_row(path, False)
|
|
||||||
|
|
||||||
elif type_ == 'contact' and x < 27:
|
|
||||||
account = model[path][C_ACCOUNT].decode('utf-8')
|
|
||||||
jid = model[path][C_JID].decode('utf-8')
|
|
||||||
# first cell in 1st column (the arrow SINGLE clicked)
|
|
||||||
iters = self.get_contact_iter(jid, account)
|
|
||||||
for iter in iters:
|
|
||||||
path = model.get_path(iter)
|
|
||||||
if (self.tree.row_expanded(path)):
|
if (self.tree.row_expanded(path)):
|
||||||
self.tree.collapse_row(path)
|
self.tree.collapse_row(path)
|
||||||
else:
|
else:
|
||||||
self.tree.expand_row(path, False)
|
self.tree.expand_row(path, False)
|
||||||
|
|
||||||
|
elif type_ == 'contact' and x < 27:
|
||||||
|
account = model[path][C_ACCOUNT].decode('utf-8')
|
||||||
|
jid = model[path][C_JID].decode('utf-8')
|
||||||
|
# first cell in 1st column (the arrow SINGLE clicked)
|
||||||
|
iters = self.get_contact_iter(jid, account)
|
||||||
|
for iter in iters:
|
||||||
|
path = model.get_path(iter)
|
||||||
|
if (self.tree.row_expanded(path)):
|
||||||
|
self.tree.collapse_row(path)
|
||||||
|
else:
|
||||||
|
self.tree.expand_row(path, False)
|
||||||
|
|
||||||
def on_req_usub(self, widget, list_):
|
def on_req_usub(self, widget, list_):
|
||||||
'''Remove a contact. list_ is a list of (contact, account) tuples'''
|
'''Remove a contact. list_ is a list of (contact, account) tuples'''
|
||||||
|
@ -3785,8 +3788,9 @@ class RosterWindow:
|
||||||
|
|
||||||
win.window.present()
|
win.window.present()
|
||||||
|
|
||||||
def on_roster_treeview_row_activated(self, widget, path, col = 0):
|
def on_row_activated(self, widget, path):
|
||||||
'''When an iter is double clicked: open the first event window'''
|
'''When an iter is activated (dubblick or single click if gnome is set
|
||||||
|
this way'''
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
account = model[path][C_ACCOUNT].decode('utf-8')
|
account = model[path][C_ACCOUNT].decode('utf-8')
|
||||||
type_ = model[path][C_TYPE]
|
type_ = model[path][C_TYPE]
|
||||||
|
@ -3830,6 +3834,11 @@ class RosterWindow:
|
||||||
resource = c.resource
|
resource = c.resource
|
||||||
self.on_open_chat_window(widget, c, account, resource = resource)
|
self.on_open_chat_window(widget, c, account, resource = resource)
|
||||||
|
|
||||||
|
def on_roster_treeview_row_activated(self, widget, path, col = 0):
|
||||||
|
'''When an iter is double clicked: open the first event window'''
|
||||||
|
if not gajim.single_click:
|
||||||
|
self.on_row_activated(widget, path)
|
||||||
|
|
||||||
def on_roster_treeview_row_expanded(self, widget, iter, path):
|
def on_roster_treeview_row_expanded(self, widget, iter, path):
|
||||||
'''When a row is expanded change the icon of the arrow'''
|
'''When a row is expanded change the icon of the arrow'''
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
|
|
Loading…
Reference in New Issue