From 3545dd3b90d88df57f935610104f6742acf9dcd6 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 26 Apr 2007 16:44:00 +0000 Subject: [PATCH] [TheCurse] single-clicking ability. fixes #2072 --- src/common/gajim.py | 2 ++ src/gajim.py | 12 +++++++++- src/groupchat_control.py | 52 ++++++++++++++++++++++++---------------- src/roster_window.py | 41 ++++++++++++++++++------------- 4 files changed, 69 insertions(+), 38 deletions(-) diff --git a/src/common/gajim.py b/src/common/gajim.py index add7911e5..fc109e8d0 100644 --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -124,6 +124,8 @@ status_before_autoaway = {} # be online 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', 'invisible', 'error'] diff --git a/src/gajim.py b/src/gajim.py index 704a1c22b..cdc8d55bd 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -2146,7 +2146,17 @@ class Interface: if os.name != 'nt' and gajim.config.get('check_if_gajim_is_default'): 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: for msg in gajim.config.statusmsg_default: gajim.config.add_per('statusmsg', msg) diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 32fee9b33..0a6c363af 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -1757,8 +1757,9 @@ class GroupchatControl(ChatControlBase): win.set_active_tab(nick_jid, self.account) win.window.present() - def on_list_treeview_row_activated(self, widget, path, col = 0): - '''When an iter is double clicked: open the chat window''' + def on_row_activated(self, widget, path): + '''When an iter is activated (dubblick or single click if gnome is set + this way''' model = widget.get_model() if len(path) == 1: # It's a group if (widget.row_expanded(path)): @@ -1768,6 +1769,11 @@ class GroupchatControl(ChatControlBase): else: # We want to send a private message nick = model[path][C_NICK].decode('utf-8') 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): '''popup user's group's or agent menu''' @@ -1808,26 +1814,30 @@ class GroupchatControl(ChatControlBase): widget.get_selection().unselect_all() return - 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() + if gajim.single_click: + self.on_row_activated(widget, path) 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): message_buffer = self.msg_textview.get_buffer() diff --git a/src/roster_window.py b/src/roster_window.py index 0465d03d4..3e6422354 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2883,24 +2883,27 @@ class RosterWindow: elif event.button == 1: # Left click model = self.tree.get_model() type_ = model[path][C_TYPE] - if type_ == 'group' and x < 27: - # first cell in 1st column (the arrow SINGLE clicked) - if (self.tree.row_expanded(path)): - self.tree.collapse_row(path) - else: - 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 gajim.single_click: + self.on_row_activated(widget, path) + else: + if type_ == 'group' and x < 27: + # first cell in 1st column (the arrow SINGLE clicked) if (self.tree.row_expanded(path)): self.tree.collapse_row(path) else: 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_): '''Remove a contact. list_ is a list of (contact, account) tuples''' @@ -3785,8 +3788,9 @@ class RosterWindow: win.window.present() - def on_roster_treeview_row_activated(self, widget, path, col = 0): - '''When an iter is double clicked: open the first event window''' + def on_row_activated(self, widget, path): + '''When an iter is activated (dubblick or single click if gnome is set + this way''' model = self.tree.get_model() account = model[path][C_ACCOUNT].decode('utf-8') type_ = model[path][C_TYPE] @@ -3830,6 +3834,11 @@ class RosterWindow: resource = c.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): '''When a row is expanded change the icon of the arrow''' model = self.tree.get_model()