Use always an action to open the history window

- Make all menus and shortcuts use the 'app.browse-history' action
- HistoryWindow: Inherit from Gtk.ApplicationWindow
This commit is contained in:
Philipp Hörist 2018-11-04 22:19:58 +01:00
parent 3e387f5215
commit b6c4fcfb54
10 changed files with 306 additions and 312 deletions

View File

@ -313,10 +313,7 @@ def on_file_transfers(action, param):
def on_history(action, param): def on_history(action, param):
if 'logs' in interface.instances: on_browse_history(action, param)
interface.instances['logs'].window.present()
else:
interface.instances['logs'] = HistoryWindow()
def on_open_event(action, param): def on_open_event(action, param):
@ -369,3 +366,19 @@ def join_groupchat(_action, param):
account, jid = param.get_strv() account, jid = param.get_strv()
room_jid = jid.split('?')[0] room_jid = jid.split('?')[0]
app.interface.join_gc_minimal(account, room_jid) app.interface.join_gc_minimal(account, room_jid)
def on_browse_history(_action, param):
jid, account = None, None
if param is not None:
dict_ = param.unpack()
jid = dict_.get('jid')
account = dict_.get('account')
window = app.get_app_window(HistoryWindow)
if window is None:
HistoryWindow(jid, account)
else:
window.present()
if jid is not None and account is not None:
window.open_history(jid, account)

View File

@ -418,6 +418,11 @@ class GajimApplication(Gtk.Application):
act.connect("activate", app_actions.open_link) act.connect("activate", app_actions.open_link)
self.add_action(act) self.add_action(act)
act = Gio.SimpleAction.new('browse-history',
GLib.VariantType.new('a{sv}'))
act.connect("activate", app_actions.on_browse_history)
self.add_action(act)
for action in general_actions: for action in general_actions:
action_name, func = action action_name, func = action
act = Gio.SimpleAction.new(action_name, None) act = Gio.SimpleAction.new(action_name, None)

View File

@ -110,7 +110,7 @@ class ChatControl(ChatControlBase):
# Menu for the HeaderBar # Menu for the HeaderBar
self.control_menu = gui_menu_builder.get_singlechat_menu( self.control_menu = gui_menu_builder.get_singlechat_menu(
self.control_id) self.control_id, self.account, self.contact.jid)
settings_menu = self.xml.get_object('settings_menu') settings_menu = self.xml.get_object('settings_menu')
settings_menu.set_menu_model(self.control_menu) settings_menu.set_menu_model(self.control_menu)

View File

@ -388,11 +388,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
action.connect("change-state", self.change_encryption) action.connect("change-state", self.change_encryption)
self.parent_win.window.add_action(action) self.parent_win.window.add_action(action)
action = Gio.SimpleAction.new(
'browse-history-%s' % self.control_id, GLib.VariantType.new('s'))
action.connect('activate', self._on_history)
self.parent_win.window.add_action(action)
action = Gio.SimpleAction.new( action = Gio.SimpleAction.new(
'send-file-%s' % self.control_id, None) 'send-file-%s' % self.control_id, None)
action.connect('activate', self._on_send_file) action.connect('activate', self._on_send_file)
@ -413,21 +408,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
# Actions # Actions
def _on_history(self, action, param):
"""
When history menuitem is pressed: call history window
"""
jid = param.get_string()
if jid == 'none':
jid = self.contact.jid
if 'logs' in app.interface.instances:
app.interface.instances['logs'].window.present()
app.interface.instances['logs'].open_history(jid, self.account)
else:
from gajim.gtk.history import HistoryWindow
app.interface.instances['logs'] = HistoryWindow(jid, self.account)
def change_encryption(self, action, param): def change_encryption(self, action, param):
encryption = param.get_string() encryption = param.get_string()
if encryption == 'disabled': if encryption == 'disabled':
@ -1039,20 +1019,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
start, end = buffer_.get_bounds() start, end = buffer_.get_bounds()
buffer_.delete(start, end) buffer_.delete(start, end)
def _on_history_menuitem_activate(self, widget=None, jid=None):
"""
When history menuitem is pressed: call history window
"""
if not jid:
jid = self.contact.jid
if 'logs' in app.interface.instances:
app.interface.instances['logs'].window.present()
app.interface.instances['logs'].open_history(jid, self.account)
else:
from gajim.gtk.history import HistoryWindow
app.interface.instances['logs'] = HistoryWindow(jid, self.account)
def _on_send_file(self, action, param): def _on_send_file(self, action, param):
# get file transfer preference # get file transfer preference
ft_pref = app.config.get_per('accounts', self.account, ft_pref = app.config.get_per('accounts', self.account,

View File

@ -278,101 +278,218 @@
</object> </object>
</child> </child>
</object> </object>
<object class="GtkApplicationWindow" id="history_window"> <object class="GtkBox" id="history_box">
<property name="width_request">600</property>
<property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="title" translatable="yes">Conversation History</property> <property name="margin_left">18</property>
<property name="window_position">center</property> <property name="margin_right">18</property>
<property name="show_menubar">False</property> <property name="margin_top">18</property>
<signal name="delete-event" handler="on_history_window_delete_event" swapped="no"/> <property name="margin_bottom">18</property>
<signal name="destroy" handler="on_history_window_destroy" swapped="no"/> <property name="orientation">vertical</property>
<signal name="key-press-event" handler="on_history_window_key_press_event" swapped="no"/> <property name="spacing">24</property>
<child type="titlebar">
<placeholder/>
</child>
<child> <child>
<object class="GtkBox" id="vbox"> <object class="GtkGrid">
<property name="width_request">600</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_left">18</property> <property name="row_spacing">6</property>
<property name="margin_right">18</property> <property name="column_spacing">12</property>
<property name="margin_top">18</property>
<property name="margin_bottom">18</property>
<property name="orientation">vertical</property>
<property name="spacing">24</property>
<child> <child>
<object class="GtkGrid"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">6</property> <property name="halign">start</property>
<property name="column_spacing">12</property> <property name="label" translatable="yes">Chat</property>
<child> <style>
<object class="GtkLabel"> <class name="dim-label"/>
<property name="visible">True</property> </style>
<property name="can_focus">False</property> </object>
<property name="halign">start</property> <packing>
<property name="label" translatable="yes">Chat</property> <property name="left_attach">0</property>
<style> <property name="top_attach">0</property>
<class name="dim-label"/> </packing>
</style> </child>
</object> <child>
<packing> <object class="GtkSwitch" id="log_history_checkbutton">
<property name="left_attach">0</property> <property name="visible">True</property>
<property name="top_attach">0</property> <property name="can_focus">True</property>
</packing> <property name="tooltip_text" translatable="yes">Record history for this chat</property>
</child> <signal name="notify::active" handler="on_log_history_checkbutton_toggled" swapped="no"/>
<child> </object>
<object class="GtkSwitch" id="log_history_checkbutton"> <packing>
<property name="left_attach">3</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="label" translatable="yes">Record History</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="query_entry">
<property name="width_request">400</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="model">liststore1</property>
<property name="tearoff_title" translatable="yes">Ttitle</property>
<property name="has_entry">True</property>
<property name="entry_text_column">1</property>
<property name="id_column">1</property>
<signal name="changed" handler="on_jid_entry_changed" swapped="no"/>
<child internal-child="entry">
<object class="GtkEntry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Record history for this chat</property> <signal name="activate" handler="on_jid_entry_activate" swapped="no"/>
<signal name="notify::active" handler="on_log_history_checkbutton_toggled" swapped="no"/>
</object> </object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">0</property>
</packing>
</child> </child>
<child> </object>
<object class="GtkLabel"> <packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child type="center">
<object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_left">6</property> <child>
<property name="label" translatable="yes">Record History</property> <object class="GtkSearchEntry" id="search_entry">
<property name="width_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
<signal name="activate" handler="on_search_entry_activate" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="search_menu_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">start</property>
<property name="popover">search_menu</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="date_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">3</property>
<property name="margin_right">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">pan-down-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style> <style>
<class name="dim-label"/> <class name="linked"/>
</style> </style>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="expand">False</property>
<property name="top_attach">0</property> <property name="fill">True</property>
<property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkComboBox" id="query_entry"> <object class="GtkBox">
<property name="width_request">400</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="orientation">vertical</property>
<property name="model">liststore1</property> <child>
<property name="tearoff_title" translatable="yes">Ttitle</property> <object class="GtkMenuButton">
<property name="has_entry">True</property>
<property name="entry_text_column">1</property>
<property name="id_column">1</property>
<signal name="changed" handler="on_jid_entry_changed" swapped="no"/>
<child internal-child="entry">
<object class="GtkEntry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<signal name="activate" handler="on_jid_entry_activate" swapped="no"/> <property name="receives_default">True</property>
<property name="popover">more_menu</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-more-symbolic</property>
</object>
</child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="expand">False</property>
<property name="top_attach">0</property> <property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
<style>
<class name="inline-toolbar"/>
<class name="ontop-bar"/>
</style>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -381,193 +498,62 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkBox"> <object class="GtkPaned">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox"> <object class="GtkScrolledWindow" id="results_scrolledwindow">
<property name="visible">True</property> <property name="can_focus">True</property>
<property name="can_focus">False</property> <property name="no_show_all">True</property>
<child type="center"> <property name="shadow_type">in</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkSearchEntry" id="search_entry">
<property name="width_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
<signal name="activate" handler="on_search_entry_activate" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="search_menu_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">start</property>
<property name="popover">search_menu</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="date_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">3</property>
<property name="margin_right">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">pan-down-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="linked"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkBox"> <object class="GtkTreeView" id="results_treeview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="orientation">vertical</property> <property name="rules_hint">True</property>
<child> <property name="hover_expand">True</property>
<object class="GtkMenuButton"> <signal name="cursor-changed" handler="on_results_treeview_cursor_changed" swapped="no"/>
<property name="visible">True</property> <child internal-child="selection">
<property name="can_focus">True</property> <object class="GtkTreeSelection"/>
<property name="receives_default">True</property>
<property name="popover">more_menu</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-more-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child> </child>
<style>
<class name="inline-toolbar"/>
<class name="ontop-bar"/>
</style>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="resize">True</property>
<property name="fill">True</property> <property name="shrink">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkPaned"> <object class="GtkScrolledWindow" id="scrolledwindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="vexpand">True</property> <property name="shadow_type">etched-in</property>
<property name="orientation">vertical</property> <property name="min_content_height">200</property>
<child> <child>
<object class="GtkScrolledWindow" id="results_scrolledwindow"> <placeholder/>
<property name="can_focus">True</property>
<property name="no_show_all">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="results_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="rules_hint">True</property>
<property name="hover_expand">True</property>
<signal name="cursor-changed" handler="on_results_treeview_cursor_changed" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
</object>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">etched-in</property>
<property name="min_content_height">200</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="resize">True</property>
<property name="fill">True</property> <property name="shrink">True</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child> </child>
</object> </object>
</interface> </interface>

View File

@ -494,7 +494,9 @@ class GroupchatControl(ChatControlBase):
# GC Roster tooltip # GC Roster tooltip
self.gc_tooltip = GCTooltip() self.gc_tooltip = GCTooltip()
self.control_menu = gui_menu_builder.get_groupchat_menu(self.control_id) self.control_menu = gui_menu_builder.get_groupchat_menu(self.control_id,
self.account,
self.room_jid)
settings_menu = self.xml.get_object('settings_menu') settings_menu = self.xml.get_object('settings_menu')
settings_menu.set_menu_model(self.control_menu) settings_menu.set_menu_model(self.control_menu)
@ -2714,8 +2716,11 @@ class GroupchatControl(ChatControlBase):
self.handlers[id_] = item self.handlers[id_] = item
item = xml.get_object('history_menuitem') item = xml.get_object('history_menuitem')
id_ = item.connect('activate', self.on_history, nick) item.set_action_name('app.browse-history')
self.handlers[id_] = item dict_ = {'jid': GLib.Variant('s', fjid),
'account': GLib.Variant('s', self.account)}
variant = GLib.Variant('a{sv}', dict_)
item.set_action_target_value(variant)
item = xml.get_object('add_to_roster_menuitem') item = xml.get_object('add_to_roster_menuitem')
our_jid = app.get_jid_from_account(self.account) our_jid = app.get_jid_from_account(self.account)
@ -2981,10 +2986,6 @@ class GroupchatControl(ChatControlBase):
app.interface.instances[self.account]['infos'][contact.jid] = \ app.interface.instances[self.account]['infos'][contact.jid] = \
vcard.VcardWindow(contact, self.account, gc_contact) vcard.VcardWindow(contact, self.account, gc_contact)
def on_history(self, widget, nick):
jid = app.construct_fjid(self.room_jid, nick)
self._on_history_menuitem_activate(widget=widget, jid=jid)
def on_add_to_roster(self, widget, jid): def on_add_to_roster(self, widget, jid):
AddNewContactWindow(self.account, jid) AddNewContactWindow(self.account, jid)

View File

@ -69,14 +69,17 @@ class Column(IntEnum):
LOG_LINE_ID = 5 LOG_LINE_ID = 5
class HistoryWindow: class HistoryWindow(Gtk.ApplicationWindow):
"""
Class for browsing logs of conversations with contacts
"""
def __init__(self, jid=None, account=None): def __init__(self, jid=None, account=None):
Gtk.ApplicationWindow.__init__(self)
self.set_application(app.app)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_show_menubar(False)
self.set_title(_('Conversation History'))
self._ui = get_builder('history_window.ui') self._ui = get_builder('history_window.ui')
self._ui.history_window.set_application(app.app)
self.add(self._ui.history_box)
self.history_textview = conversation_textview.ConversationTextview( self.history_textview = conversation_textview.ConversationTextview(
account, used_in_history_window=True) account, used_in_history_window=True)
@ -130,15 +133,18 @@ class HistoryWindow:
else: else:
self._load_history(None) self._load_history(None)
resize_window(self._ui.history_window, resize_window(self,
app.config.get('history_window_width'), app.config.get('history_window_width'),
app.config.get('history_window_height')) app.config.get('history_window_height'))
move_window(self._ui.history_window, move_window(self,
app.config.get('history_window_x-position'), app.config.get('history_window_x-position'),
app.config.get('history_window_y-position')) app.config.get('history_window_y-position'))
self._ui.connect_signals(self) self._ui.connect_signals(self)
self._ui.history_window.show_all() self.connect('delete-event', self._on_delete)
self.connect('destroy', self._on_destroy)
self.connect('key-press-event', self._on_key_press)
self.show_all()
# PluginSystem: adding GUI extension point for # PluginSystem: adding GUI extension point for
# HistoryWindow instance object # HistoryWindow instance object
@ -255,21 +261,20 @@ class HistoryWindow:
break break
return account return account
def on_history_window_delete_event(self, widget, *args): def _on_delete(self, widget, *args):
self.save_state() self.save_state()
def on_history_window_destroy(self, widget): def _on_destroy(self, widget):
# PluginSystem: removing GUI extension points connected with # PluginSystem: removing GUI extension points connected with
# HistoryWindow instance object # HistoryWindow instance object
app.plugin_manager.remove_gui_extension_point( app.plugin_manager.remove_gui_extension_point(
'history_window', self) 'history_window', self)
self.history_textview.del_handlers() self.history_textview.del_handlers()
del app.interface.instances['logs']
def on_history_window_key_press_event(self, widget, event): def _on_key_press(self, widget, event):
if event.keyval == Gdk.KEY_Escape: if event.keyval == Gdk.KEY_Escape:
self.save_state() self.save_state()
self._ui.history_window.destroy() self.destroy()
def on_jid_entry_match_selected(self, widget, model, iter_, *args): def on_jid_entry_match_selected(self, widget, model, iter_, *args):
self._jid_entry_search(model[iter_][1]) self._jid_entry_search(model[iter_][1])
@ -799,8 +804,8 @@ class HistoryWindow:
self._ui.results_scrolledwindow.set_property('visible', False) self._ui.results_scrolledwindow.set_property('visible', False)
def save_state(self): def save_state(self):
x, y = self._ui.history_window.get_window().get_root_origin() x, y = self.get_window().get_root_origin()
width, height = self._ui.history_window.get_size() width, height = self.get_size()
app.config.set('history_window_x-position', x) app.config.set('history_window_x-position', x)
app.config.set('history_window_y-position', y) app.config.set('history_window_y-position', y)

View File

@ -272,7 +272,12 @@ control=None, gc_contact=None, is_anonymous=True):
rename_menuitem.connect('activate', roster.on_rename, 'contact', jid, rename_menuitem.connect('activate', roster.on_rename, 'contact', jid,
account) account)
history_menuitem.connect('activate', roster.on_history, contact, account)
history_menuitem.set_action_name('app.browse-history')
dict_ = {'jid': GLib.Variant('s', contact.jid),
'account': GLib.Variant('s', account)}
variant = GLib.Variant('a{sv}', dict_)
history_menuitem.set_action_target_value(variant)
if control: if control:
convert_to_gc_menuitem.connect('activate', convert_to_gc_menuitem.connect('activate',
@ -605,7 +610,7 @@ def show_save_as_menu(sha, name):
menu.popup_at_pointer() menu.popup_at_pointer()
def get_singlechat_menu(control_id): def get_singlechat_menu(control_id, account, jid):
singlechat_menu = [ singlechat_menu = [
(_('Send File…'), [ (_('Send File…'), [
('win.send-file-httpupload-', _('Upload File…')), ('win.send-file-httpupload-', _('Upload File…')),
@ -616,7 +621,7 @@ def get_singlechat_menu(control_id):
('win.toggle-audio-', _('Audio Session')), ('win.toggle-audio-', _('Audio Session')),
('win.toggle-video-', _('Video Session')), ('win.toggle-video-', _('Video Session')),
('win.information-', _('Information')), ('win.information-', _('Information')),
('win.browse-history-', _('History')), ('app.browse-history', _('History')),
] ]
def build_menu(preset): def build_menu(preset):
@ -624,8 +629,14 @@ def get_singlechat_menu(control_id):
for item in preset: for item in preset:
if isinstance(item[1], str): if isinstance(item[1], str):
action_name, label = item action_name, label = item
if action_name == 'win.browse-history-': if action_name == 'app.browse-history':
menu.append(label, action_name + control_id + '::none') menuitem = Gio.MenuItem.new(label, action_name)
dict_ = {'account': GLib.Variant('s', account),
'jid': GLib.Variant('s', jid)}
variant_dict = GLib.Variant('a{sv}', dict_)
menuitem.set_action_and_target_value(action_name,
variant_dict)
menu.append_item(menuitem)
else: else:
menu.append(label, action_name + control_id) menu.append(label, action_name + control_id)
else: else:
@ -638,7 +649,7 @@ def get_singlechat_menu(control_id):
return build_menu(singlechat_menu) return build_menu(singlechat_menu)
def get_groupchat_menu(control_id): def get_groupchat_menu(control_id, account, jid):
groupchat_menu = [ groupchat_menu = [
(_('Manage Room'), [ (_('Manage Room'), [
('win.change-subject-', _('Change Subject')), ('win.change-subject-', _('Change Subject')),
@ -653,7 +664,7 @@ def get_groupchat_menu(control_id):
('win.notify-on-message-', _('Notify on all messages')), ('win.notify-on-message-', _('Notify on all messages')),
('win.minimize-', _('Minimize on close')), ('win.minimize-', _('Minimize on close')),
('win.execute-command-', _('Execute command')), ('win.execute-command-', _('Execute command')),
('win.browse-history-', _('History')), ('app.browse-history', _('History')),
('win.disconnect-', _('Disconnect')), ('win.disconnect-', _('Disconnect')),
] ]
@ -662,8 +673,14 @@ def get_groupchat_menu(control_id):
for item in preset: for item in preset:
if isinstance(item[1], str): if isinstance(item[1], str):
action_name, label = item action_name, label = item
if action_name == 'win.browse-history-': if action_name == 'app.browse-history':
menu.append(label, action_name + control_id + '::none') menuitem = Gio.MenuItem.new(label, action_name)
dict_ = {'account': GLib.Variant('s', account),
'jid': GLib.Variant('s', jid)}
variant_dict = GLib.Variant('a{sv}', dict_)
menuitem.set_action_and_target_value(action_name,
variant_dict)
menu.append_item(menuitem)
else: else:
menu.append(label, action_name + control_id) menu.append(label, action_name + control_id)
else: else:

View File

@ -355,9 +355,10 @@ class MessageWindow:
if keyval == Gdk.KEY_h: # CTRL + h if keyval == Gdk.KEY_h: # CTRL + h
if Gtk.Settings.get_default().get_property( if Gtk.Settings.get_default().get_property(
'gtk-key-theme-name') != 'Emacs': 'gtk-key-theme-name') != 'Emacs':
arg = GLib.Variant('s', 'none') dict_ = {'jid': GLib.Variant('s', control.contact.jid),
self.window.lookup_action( 'account': GLib.Variant('s', control.account)}
'browse-history-%s' % control.control_id).activate(arg) variant = GLib.Variant('a{sv}', dict_)
app.app.activate_action('browse-history', variant)
return True return True
elif control.type_id == message_control.TYPE_CHAT and \ elif control.type_id == message_control.TYPE_CHAT and \
keyval == Gdk.KEY_f: # CTRL + f keyval == Gdk.KEY_f: # CTRL + f

View File

@ -78,7 +78,6 @@ from gajim.gtk.bookmarks import ManageBookmarksWindow
from gajim.gtk.account_wizard import AccountCreationWizard from gajim.gtk.account_wizard import AccountCreationWizard
from gajim.gtk.service_registration import ServiceRegistration from gajim.gtk.service_registration import ServiceRegistration
from gajim.gtk.discovery import ServiceDiscoveryWindow from gajim.gtk.discovery import ServiceDiscoveryWindow
from gajim.gtk.history import HistoryWindow
from gajim.gtk.accounts import AccountsWindow from gajim.gtk.accounts import AccountsWindow
from gajim.gtk.tooltips import RosterTooltip from gajim.gtk.tooltips import RosterTooltip
from gajim.gtk.adhoc_commands import CommandWindow from gajim.gtk.adhoc_commands import CommandWindow
@ -3041,16 +3040,6 @@ class RosterWindow:
def on_edit_groups(self, widget, list_): def on_edit_groups(self, widget, list_):
dialogs.EditGroupsDialog(list_) dialogs.EditGroupsDialog(list_)
def on_history(self, widget, contact, account):
"""
When history menuitem is activated: call log window
"""
if 'logs' in app.interface.instances:
app.interface.instances['logs'].window.present()
app.interface.instances['logs'].open_history(contact.jid, account)
else:
app.interface.instances['logs'] = HistoryWindow(contact.jid, account)
def on_disconnect(self, widget, jid, account): def on_disconnect(self, widget, jid, account):
""" """
When disconnect menuitem is activated: disconnect from room When disconnect menuitem is activated: disconnect from room
@ -3756,6 +3745,9 @@ class RosterWindow:
self.on_info(widget, contact, account) self.on_info(widget, contact, account)
elif event.get_state() & Gdk.ModifierType.CONTROL_MASK and event.keyval == \ elif event.get_state() & Gdk.ModifierType.CONTROL_MASK and event.keyval == \
Gdk.KEY_h: Gdk.KEY_h:
if app.config.get('one_message_window') == 'always_with_roster':
# Let MessageWindow handle this
return
treeselection = self.tree.get_selection() treeselection = self.tree.get_selection()
model, list_of_paths = treeselection.get_selected_rows() model, list_of_paths = treeselection.get_selected_rows()
if len(list_of_paths) != 1: if len(list_of_paths) != 1:
@ -3767,7 +3759,10 @@ class RosterWindow:
account = model[path][Column.ACCOUNT] account = model[path][Column.ACCOUNT]
contact = app.contacts.get_first_contact_from_jid(account, contact = app.contacts.get_first_contact_from_jid(account,
jid) jid)
self.on_history(widget, contact, account) dict_ = {'jid': GLib.Variant('s', jid),
'account': GLib.Variant('s', account)}
app.app.activate_action('browse-history',
GLib.Variant('a{sv}', dict_))
def on_roster_window_popup_menu(self, widget): def on_roster_window_popup_menu(self, widget):
event = Gdk.Event.new(Gdk.EventType.KEY_PRESS) event = Gdk.Event.new(Gdk.EventType.KEY_PRESS)
@ -5392,7 +5387,12 @@ class RosterWindow:
menu.append(item) menu.append(item)
history_menuitem = Gtk.MenuItem.new_with_mnemonic(_('_History')) history_menuitem = Gtk.MenuItem.new_with_mnemonic(_('_History'))
history_menuitem.connect('activate', self.on_history, contact, account) history_menuitem.set_action_name('app.browse-history')
dict_ = {'jid': GLib.Variant('s', contact.jid),
'account': GLib.Variant('s', account)}
variant = GLib.Variant('a{sv}', dict_)
history_menuitem.set_action_target_value(variant)
menu.append(history_menuitem) menu.append(history_menuitem)
event_button = gtkgui_helpers.get_possible_button_event(event) event_button = gtkgui_helpers.get_possible_button_event(event)