Rework History Dialog

This commit is contained in:
Sophie Herold 2018-08-04 11:04:36 +02:00 committed by Philipp Hörist
parent 560a122ab5
commit 99ec800856
4 changed files with 564 additions and 281 deletions

View File

@ -169,7 +169,7 @@ class Config:
'roster_height': [ opt_int, 400 ],
'roster_hpaned_position': [opt_int, 200],
'roster_on_the_right': [opt_bool, False, _('Place the roster on the right in single window mode'), True],
'history_window_width': [ opt_int, 650 ],
'history_window_width': [ opt_int, -1 ],
'history_window_height': [ opt_int, 450 ],
'history_window_x-position': [ opt_int, 0 ],
'history_window_y-position': [ opt_int, 0 ],

View File

@ -1,68 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2 -->
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkApplicationWindow" id="history_window">
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
<!-- column-name gchararray2 -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Hello</col>
<col id="1" translatable="yes">user-offline-symbolic</col>
</row>
</data>
</object>
<object class="GtkPopoverMenu" id="more_menu">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Conversation History</property>
<property name="window_position">center</property>
<property name="default_width">650</property>
<property name="default_height">450</property>
<property name="show_menubar">False</property>
<signal name="destroy" handler="on_history_window_destroy" swapped="no"/>
<signal name="key-press-event" handler="on_history_window_key_press_event" swapped="no"/>
<child>
<object class="GtkBox" id="vbox">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkBox" id="vbox1">
<object class="GtkCheckButton" id="show_status_checkbutton">
<property name="label" translatable="yes">Display status changes</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">6</property>
<child>
<object class="GtkEntry" id="query_entry">
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<property name="placeholder_text" translatable="yes">Enter name / JID of contact or groupchat</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_show_status_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Search:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="search_entry">
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
<signal name="activate" handler="on_search_entry_activate" swapped="no"/>
<property name="receives_default">True</property>
<property name="action_name">app.history-manager</property>
<property name="text" translatable="yes">History Manager</property>
</object>
<packing>
<property name="expand">False</property>
@ -70,23 +68,35 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="search_in_date">
<property name="label" translatable="yes">_In date search</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Only searching within selected day</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
<property name="submenu">main</property>
<property name="position">1</property>
</packing>
</child>
</object>
<object class="GtkPopover" id="search_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Date</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
@ -94,25 +104,14 @@
</packing>
</child>
<child>
<object class="GtkPaned" id="vpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkPaned" id="hpaned">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_bottom">5</property>
<property name="position">165</property>
<child>
<object class="GtkBox" id="vbox2">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">5</property>
<property name="valign">start</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkCalendar" id="calendar">
<property name="width_request">270</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="day-selected" handler="on_calendar_day_selected" swapped="no"/>
@ -128,8 +127,8 @@
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="spacing">5</property>
<property name="valign">start</property>
<property name="homogeneous">True</property>
<property name="layout_style">expand</property>
<child>
<object class="GtkButton" id="button_first_day">
@ -211,6 +210,36 @@
<property name="position">3</property>
</packing>
</child>
<style>
<class name="linked-up"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<style>
<class name="linked"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">12</property>
<property name="label" translatable="yes">Mode</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
@ -218,32 +247,277 @@
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">False</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<object class="GtkRadioButton" id="search_complete_history">
<property name="label" translatable="yes">Search complete history</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">etched-in</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_search_complete_history_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkRadioButton" id="search_in_date">
<property name="label" translatable="yes">Search selected day only</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
<property name="group">search_complete_history</property>
<signal name="toggled" handler="on_search_in_date_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkApplicationWindow" id="history_window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Conversation History</property>
<property name="window_position">center</property>
<property name="show_menubar">False</property>
<signal name="delete-event" handler="on_history_window_delete_event" swapped="no"/>
<signal name="destroy" handler="on_history_window_destroy" swapped="no"/>
<signal name="key-press-event" handler="on_history_window_key_press_event" swapped="no"/>
<child>
<object class="GtkBox" id="vbox">
<property name="width_request">600</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">18</property>
<property name="margin_right">18</property>
<property name="margin_top">18</property>
<property name="margin_bottom">18</property>
<property name="orientation">vertical</property>
<property name="spacing">24</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Chat</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="log_history_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Record history for this chat</property>
<signal name="notify::active" handler="on_log_history_checkbutton_toggled" swapped="no"/>
</object>
<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="can_focus">True</property>
<signal name="activate" handler="on_jid_entry_activate" swapped="no"/>
</object>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
<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="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>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<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>
</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>
<style>
<class name="inline-toolbar"/>
<class name="ontop-bar"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkPaned">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="results_scrolledwindow">
<property name="can_focus">True</property>
@ -254,9 +528,10 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="rules_hint">True</property>
<signal name="row-activated" handler="on_results_treeview_row_activated" swapped="no"/>
<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" id="treeview-selection1"/>
<object class="GtkTreeSelection"/>
</child>
</object>
</child>
@ -266,6 +541,21 @@
<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>
</object>
<packing>
<property name="expand">True</property>
@ -274,87 +564,16 @@
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<object class="GtkCheckButton" id="log_history_checkbutton">
<property name="label" translatable="yes">_Log conversation history</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_status_checkbutton">
<property name="label" translatable="yes">_Show status changes</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_show_status_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButtonBox" id="hbuttonbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="close_button">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_close_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
<placeholder/>
</child>
</object>
</interface>

View File

@ -110,6 +110,32 @@ list.settings > row > box {
.popover_treeview { padding: 6px; }
.popover_treeview :hover { background-color: @theme_selected_bg_color; }
/* .inline-toolbar linked from top */
.ontop-bar {
border-width: 1px;
border-bottom: none;
border-radius: 3px 3px 0 0;
padding: 5px;
}
/* Container with buttons linked from below */
.linked-up * {
border-top: none;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
/* Highlighted label */
.tagged {
background-color: @theme_selected_bg_color;
color: @theme_selected_fg_color;
padding: 0 3px;
margin: 0 -3px;
border-radius: 3px;
text-shadow: none;
opacity: 0.95;
}
/* Text style */
.bold16 { font-size: 16px; font-weight: bold; }

View File

@ -82,16 +82,17 @@ class HistoryWindow:
self.history_buffer.create_tag('highlight', background='yellow')
self.history_buffer.create_tag('invisible', invisible=True)
self.checkbutton = xml.get_object('log_history_checkbutton')
self.checkbutton.connect('toggled',
self.on_log_history_checkbutton_toggled)
self.show_status_checkbutton = xml.get_object('show_status_checkbutton')
self.search_entry = xml.get_object('search_entry')
self.query_liststore = xml.get_object('query_liststore')
self.jid_entry = xml.get_object('query_entry')
self.jid_entry.connect('activate', self.on_jid_entry_activate)
self.results_treeview = xml.get_object('results_treeview')
self.results_window = xml.get_object('results_scrolledwindow')
self.search_in_date = xml.get_object('search_in_date')
self.date_label = xml.get_object('date_label')
self.search_menu_button = xml.get_object('search_menu_button')
self.clearing_search = False
# jid, contact_name, date, message, time, log_line_id
model = Gtk.ListStore(str, str, str, str, str, int)
@ -130,7 +131,7 @@ class HistoryWindow:
GLib.idle_add(next, task)
if jid:
self.jid_entry.set_text(jid)
self.jid_entry.get_child().set_text(jid)
else:
self._load_history(None)
@ -160,7 +161,12 @@ class HistoryWindow:
{key : (jid, account, nick_name, full_completion_name}
This is a generator and does pseudo-threading via idle_add().
"""
liststore = gtkgui_helpers.get_completion_liststore(self.jid_entry)
liststore = gtkgui_helpers.get_completion_liststore(self.jid_entry.get_child())
liststore.set_sort_column_id(1, Gtk.SortType.ASCENDING)
self.jid_entry.get_child().get_completion().connect(
'match-selected', self.on_jid_entry_match_selected)
self.jid_entry.set_model(liststore)
# Add all jids in logs.db:
db_jids = app.logger.get_jids_in_db()
@ -177,7 +183,7 @@ class HistoryWindow:
keys = list(completion_dict.keys())
# Move the actual jid at first so we load history faster
actual_jid = self.jid_entry.get_text()
actual_jid = self.jid_entry.get_child().get_text()
if actual_jid in keys:
keys.remove(actual_jid)
keys.insert(0, actual_jid)
@ -251,6 +257,9 @@ class HistoryWindow:
break
return account
def on_history_window_delete_event(self, widget, *args):
self.save_state()
def on_history_window_destroy(self, widget):
# PluginSystem: removing GUI extension points connected with
# HistoryWindow instance object
@ -264,18 +273,23 @@ class HistoryWindow:
self.save_state()
self.window.destroy()
def on_close_button_clicked(self, widget):
self.save_state()
self.window.destroy()
def on_jid_entry_match_selected(self, widget, model, iter_, *args):
self._jid_entry_search(model[iter_][1])
return True
def on_jid_entry_changed(self, widget):
# only if selected from combobox
jid = self.jid_entry.get_child().get_text()
if jid == self.jid_entry.get_active_id():
self._jid_entry_search(jid)
def on_jid_entry_activate(self, widget):
jid = self.jid_entry.get_text()
self._jid_entry_search(self.jid_entry.get_child().get_text())
def _jid_entry_search(self, jid):
self._load_history(jid, self.account)
self.results_window.set_property('visible', False)
def on_jid_entry_focus(self, widget, event):
widget.select_region(0, -1) # select text
def _load_history(self, jid_or_name, account=None):
"""
Load history for the given jid/name and show it
@ -321,7 +335,7 @@ class HistoryWindow:
self.last_day = self._get_date_from_timestamp(self.last_log)
# Select logs for last date we have logs with contact
self.calendar.set_sensitive(True)
self.search_menu_button.set_sensitive(True)
gtk_month = gtkgui_helpers.make_python_month_gtk_month(
self.last_day.month)
self.calendar.select_month(gtk_month, self.last_day.year)
@ -335,9 +349,7 @@ class HistoryWindow:
self.search_entry.set_sensitive(True)
self.search_entry.grab_focus()
title = _('Conversation History with %s') % info_name
self.window.set_title(title)
self.jid_entry.set_text(info_completion)
self.jid_entry.get_child().set_text(info_completion)
else: # neither a valid jid, nor an existing contact name was entered
# we have got nothing to show or to search in
@ -348,7 +360,7 @@ class HistoryWindow:
self.search_entry.set_sensitive(False)
self.checkbutton.set_sensitive(False)
self.calendar.set_sensitive(False)
self.search_menu_button.set_sensitive(False)
self.calendar.clear_marks()
self.button_previous_day.set_sensitive(False)
self.button_next_day.set_sensitive(False)
@ -357,14 +369,13 @@ class HistoryWindow:
self.results_window.set_property('visible', False)
title = _('Conversation History')
self.window.set_title(title)
def on_calendar_day_selected(self, widget):
if not self.jid:
return
year, month, day = self.calendar.get_date() # integers
month = gtkgui_helpers.make_gtk_month_python_month(month)
date_str = datetime.date(year, month, day).strftime('%x')
self.date_label.set_text(date_str)
self._load_conversation(year, month, day)
def on_calendar_month_changed(self, widget):
@ -594,10 +605,24 @@ class HistoryWindow:
xhtml=xhtml, additional_data=additional_data)
self.history_textview.print_real_text('\n', text_tags=['eol'])
def on_search_complete_history_toggled(self, widget):
self.date_label.get_style_context().remove_class('tagged')
def on_search_in_date_toggled(self, widget):
self.date_label.get_style_context().add_class('tagged')
def on_search_entry_activate(self, widget):
text = self.search_entry.get_text()
model = self.results_treeview.get_model()
self.clearing_search = True
model.clear()
self.clearing_search = False
start = self.history_buffer.get_start_iter()
end = self.history_buffer.get_end_iter()
self.history_buffer.remove_tag_by_name('highlight', start, end)
if text == '':
self.results_window.set_property('visible', False)
return
@ -624,6 +649,7 @@ class HistoryWindow:
show_status = self.show_status_checkbutton.get_active()
results = app.logger.search_log(account, jid, text, date)
result_found = False
#FIXME:
# add "subject: | message: " in message column if kind is single
# also do we need show at all? (we do not search on subject)
@ -642,18 +668,30 @@ class HistoryWindow:
local_time = time.localtime(row.time)
date = time.strftime('%Y-%m-%d', local_time)
result_found = True
model.append((jid, contact_name, date, row.message,
str(row.time), row.log_line_id))
def on_results_treeview_row_activated(self, widget, path, column):
if result_found:
self.results_treeview.set_cursor(0)
def on_results_treeview_cursor_changed(self, *args):
"""
A row was double clicked, get date from row, and select it in calendar
A row was selected, get date from row, and select it in calendar
which results to showing conversation logs for that date
"""
if self.clearing_search:
return
# get currently selected date
cur_year, cur_month, cur_day = self.calendar.get_date()
cur_month = gtkgui_helpers.make_gtk_month_python_month(cur_month)
model = widget.get_model()
model, paths = self.results_treeview.get_selection().get_selected_rows()
if not paths:
return
path = paths[0]
# make it a tuple (Y, M, D, 0, 0, 0...)
tim = time.strptime(model[path][Column.UNIXTIME], '%Y-%m-%d')
year = tim[0]
@ -706,7 +744,7 @@ class HistoryWindow:
mark = self.history_buffer.create_mark('match', match_start, True)
GLib.idle_add(self.history_textview.tv.scroll_to_mark, mark, 0, True, 0.0, 0.5)
def on_log_history_checkbutton_toggled(self, widget):
def on_log_history_checkbutton_toggled(self, widget, *args):
# log conversation history?
oldlog = True
no_log_for = app.config.get_per('accounts', self.account,
@ -730,7 +768,7 @@ class HistoryWindow:
"""
Load chat history of the specified jid
"""
self.jid_entry.set_text(jid)
self.jid_entry.get_child().set_text(jid)
if account and account not in self.accounts_seen_online:
# Update dict to not only show bare jid
GLib.idle_add(next, self._fill_completion_dict())