add key shortcut to open history and information window. fixes #3233

This commit is contained in:
Yann Leboulanger 2007-09-15 10:11:46 +00:00
parent bf6c87b888
commit 29cc2d0939
4 changed files with 55 additions and 16 deletions

View File

@ -392,6 +392,7 @@ class ChatControlBase(MessageControl):
event.keyval == gtk.keysyms.Page_Up: event.keyval == gtk.keysyms.Page_Up:
self.parent_win.notebook.emit('key_press_event', event) self.parent_win.notebook.emit('key_press_event', event)
return True return True
elif event.keyval == gtk.keysyms.m and \ elif event.keyval == gtk.keysyms.m and \
(event.state & gtk.gdk.MOD1_MASK): # alt + m opens emoticons menu (event.state & gtk.gdk.MOD1_MASK): # alt + m opens emoticons menu
if gajim.config.get('emoticons_theme'): if gajim.config.get('emoticons_theme'):
@ -966,6 +967,12 @@ class ChatControl(ChatControlBase):
id = widget.connect('clicked', self.on_actions_button_clicked) id = widget.connect('clicked', self.on_actions_button_clicked)
self.handlers[id] = widget self.handlers[id] = widget
ag = gtk.accel_groups_from_object(self.parent_win.window)[0]
key, mod = gtk.accelerator_parse("<Control>h")
ag.connect_group(key, mod, gtk.ACCEL_VISIBLE, self.accel_group_func)
key, mod = gtk.accelerator_parse("<Control>i")
ag.connect_group(key, mod, gtk.ACCEL_VISIBLE, self.accel_group_func)
compact_view = gajim.config.get('compact_view') compact_view = gajim.config.get('compact_view')
self.chat_buttons_set_visible(compact_view) self.chat_buttons_set_visible(compact_view)
self.widget_set_visible(self.xml.get_widget('banner_eventbox'), self.widget_set_visible(self.xml.get_widget('banner_eventbox'),
@ -1579,13 +1586,15 @@ class ChatControl(ChatControlBase):
information_menuitem = xml.get_widget('information_menuitem') information_menuitem = xml.get_widget('information_menuitem')
convert_to_gc_menuitem = xml.get_widget('convert_to_groupchat') convert_to_gc_menuitem = xml.get_widget('convert_to_groupchat')
ag = gtk.accel_groups_from_object(self.parent_win.window)[0]
history_menuitem.add_accelerator('activate', ag, gtk.keysyms.h, gtk.gdk.CONTROL_MASK,
gtk.ACCEL_VISIBLE)
information_menuitem.add_accelerator('activate', ag, gtk.keysyms.i,
gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
contact = self.parent_win.get_active_contact() contact = self.parent_win.get_active_contact()
jid = contact.jid jid = contact.jid
# history_menuitem
if gajim.jid_is_transport(jid):
history_menuitem.set_sensitive(False)
# check if gpg capabitlies or else make gpg toggle insensitive # check if gpg capabitlies or else make gpg toggle insensitive
gpg_btn = self.xml.get_widget('gpg_togglebutton') gpg_btn = self.xml.get_widget('gpg_togglebutton')
isactive = gpg_btn.get_active() isactive = gpg_btn.get_active()
@ -1643,9 +1652,25 @@ class ChatControl(ChatControlBase):
id = convert_to_gc_menuitem.connect('activate', id = convert_to_gc_menuitem.connect('activate',
self._on_convert_to_gc_menuitem_activate) self._on_convert_to_gc_menuitem_activate)
self.handlers[id] = convert_to_gc_menuitem self.handlers[id] = convert_to_gc_menuitem
menu.connect('selection-done', lambda w:w.destroy()) menu.connect('selection-done', self.destroy_menu, history_menuitem,
information_menuitem)
return menu return menu
def destroy_menu(self, menu, history_menuitem, information_menuitem):
# destroy accelerators
ag = gtk.accel_groups_from_object(self.parent_win.window)[0]
history_menuitem.remove_accelerator(ag, gtk.keysyms.h, gtk.gdk.CONTROL_MASK)
information_menuitem.remove_accelerator(ag, gtk.keysyms.i, gtk.gdk.CONTROL_MASK)
# destroy menu
menu.destroy()
def accel_group_func(self, accel_group, acceleratable, keyval, modifier):
if modifier & gtk.gdk.CONTROL_MASK:
if keyval == gtk.keysyms.h:
self._on_history_menuitem_activate()
if keyval == gtk.keysyms.i:
self._on_contact_information_menuitem_activate(None)
def send_chatstate(self, state, contact = None): def send_chatstate(self, state, contact = None):
''' sends OUR chatstate as STANDLONE chat state message (eg. no body) ''' sends OUR chatstate as STANDLONE chat state message (eg. no body)
to contact only if new chatstate is different from the previous one to contact only if new chatstate is different from the previous one

View File

@ -722,11 +722,10 @@ def get_os_info():
full_path_to_executable = is_in_path(executable, return_abs_path = True) full_path_to_executable = is_in_path(executable, return_abs_path = True)
if full_path_to_executable: if full_path_to_executable:
command = executable + params command = executable + params
child_stdin, child_stdout = os.popen2(command) p = Popen([command], shell=True, stdin=subprocess.PIPE,
output = temp_failure_retry(child_stdout.readline).strip() stdout=subprocess.PIPE, close_fds=True)
child_stdout.close() p.wait()
child_stdin.close() output = temp_failure_retry(p.stdout.readline).strip()
os.wait()
# some distros put n/a in places, so remove those # some distros put n/a in places, so remove those
output = output.replace('n/a', '').replace('N/A', '') output = output.replace('n/a', '').replace('N/A', '')
return output return output

View File

@ -193,6 +193,10 @@ class GroupchatControl(ChatControlBase):
self.on_list_treeview_leave_notify_event) self.on_list_treeview_leave_notify_event)
self.handlers[id] = widget self.handlers[id] = widget
ag = gtk.accel_groups_from_object(self.parent_win.window)[0]
key, mod = gtk.accelerator_parse("<Control>h")
ag.connect_group(key, mod, gtk.ACCEL_VISIBLE, self.accel_group_func)
self.room_jid = self.contact.jid self.room_jid = self.contact.jid
self.nick = contact.name self.nick = contact.name
self.name = self.room_jid.split('@')[0] self.name = self.room_jid.split('@')[0]
@ -250,9 +254,9 @@ class GroupchatControl(ChatControlBase):
self._on_change_subject_menuitem_activate) self._on_change_subject_menuitem_activate)
self.handlers[id] = self.change_subject_menuitem self.handlers[id] = self.change_subject_menuitem
widget = xm.get_widget('history_menuitem') self.history_menuitem = xm.get_widget('history_menuitem')
id = widget.connect('activate', self._on_history_menuitem_activate) id = self.history_menuitem.connect('activate', self._on_history_menuitem_activate)
self.handlers[id] = widget self.handlers[id] = self.history_menuitem
self.minimize_menuitem = xm.get_widget('minimize_menuitem') self.minimize_menuitem = xm.get_widget('minimize_menuitem')
id = self.minimize_menuitem.connect('toggled', id = self.minimize_menuitem.connect('toggled',
@ -507,6 +511,9 @@ class GroupchatControl(ChatControlBase):
def prepare_context_menu(self): def prepare_context_menu(self):
'''sets sensitivity state for configure_room''' '''sets sensitivity state for configure_room'''
ag = gtk.accel_groups_from_object(self.parent_win.window)[0]
self.history_menuitem.add_accelerator('activate', ag, gtk.keysyms.h,
gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
if self.contact.jid in gajim.config.get_per('accounts', self.account, if self.contact.jid in gajim.config.get_per('accounts', self.account,
'minimized_gc').split(' '): 'minimized_gc').split(' '):
self.minimize_menuitem.set_active(True) self.minimize_menuitem.set_active(True)
@ -533,6 +540,11 @@ class GroupchatControl(ChatControlBase):
self.change_nick_menuitem.set_sensitive(False) self.change_nick_menuitem.set_sensitive(False)
return self.gc_popup_menu return self.gc_popup_menu
def accel_group_func(self, accel_group, acceleratable, keyval, modifier):
if modifier & gtk.gdk.CONTROL_MASK:
if keyval == gtk.keysyms.h:
self._on_history_menuitem_activate()
def on_message(self, nick, msg, tim, has_timestamp = False, xhtml = None, def on_message(self, nick, msg, tim, has_timestamp = False, xhtml = None,
status_code = []): status_code = []):
if '100' in status_code: if '100' in status_code:

View File

@ -70,6 +70,9 @@ class MessageWindow:
id = self.window.connect('focus-in-event', self._on_window_focus) id = self.window.connect('focus-in-event', self._on_window_focus)
self.handlers[id] = self.window self.handlers[id] = self.window
accel_group = gtk.AccelGroup()
self.window.add_accel_group(accel_group)
# gtk+ doesn't make use of the motion notify on gtkwindow by default # gtk+ doesn't make use of the motion notify on gtkwindow by default
# so this line adds that # so this line adds that
self.window.add_events(gtk.gdk.POINTER_MOTION_MASK) self.window.add_events(gtk.gdk.POINTER_MOTION_MASK)