diff --git a/src/gtkgui.glade b/src/gtkgui.glade index e2073261359b598d4dbde8904c33b6e6d46e0287..2c85fe7c6861e7bf445bca5307ba5be790c1f5e4 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -9055,7 +9055,6 @@ Custom</property> <child> <widget class="GtkHButtonBox" id="hbuttonbox11"> - <property name="border_width">4</property> <property name="visible">True</property> <property name="layout_style">GTK_BUTTONBOX_END</property> <property name="spacing">6</property> @@ -9353,6 +9352,100 @@ Custom</property> <property name="fill">True</property> </packing> </child> + + <child> + <widget class="GtkHBox" id="hbox2996"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label363"> + <property name="visible">True</property> + <property name="label" translatable="yes">Filter:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="filter_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="has_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="apply_filter_button"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-apply</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_apply_filter_button_clicked" last_modification_time="Mon, 31 Oct 2005 20:52:08 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="clear_filter_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-clear</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_clear_filter_button_clicked" last_modification_time="Mon, 31 Oct 2005 20:52:32 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> </widget> </child> </widget> diff --git a/src/history_window.py b/src/history_window.py index 03ff64dfe6d83ee8556e8e9800495adbf484c33f..7bbb946c11268e384cfee152ba9a25f0b778877d 100644 --- a/src/history_window.py +++ b/src/history_window.py @@ -20,8 +20,12 @@ import gtk import gtk.glade import time +import os + +import dialogs from common import gajim +from common import helpers from common import i18n _ = i18n._ @@ -51,6 +55,7 @@ class HistoryWindow: self.previous_button = xml.get_widget('previous_button') self.forward_button = xml.get_widget('forward_button') self.latest_button = xml.get_widget('latest_button') + self.filter_entry = xml.get_widget('filter_entry') xml.signal_autoconnect(self) tag = self.history_buffer.create_tag('incoming') @@ -84,6 +89,26 @@ class HistoryWindow: def on_close_button_clicked(self, widget): self.window.destroy() + def on_apply_filter_button_clicked(self, widget): + filter = self.filter_entry.get_text() + if len(filter) < 3: + dialogs.ErrorDialog(_('Filter query too short'), + _('Query must be at least 3 characters long.')).get_response() + return + + # FIXME: what if jid is fake (pm)? + path_to_file = os.path.join(gajim.LOGPATH, self.jid) + # FIXME: ship grep.exe for windoz? + command = 'grep %s %s' % (filter, path_to_file) + stdout = helpers.get_output_of_command(command) + if stdout is not None: + text = ' '.join(stdout) + self.history_buffer.set_text(text) + + def on_clear_filter_button_clicked(self, widget): + pass + # FIXME: reread from scratch (if it's possible to save current page it's even better) + def on_earliest_button_clicked(self, widget): start, end = self.history_buffer.get_bounds() self.history_buffer.delete(start, end) @@ -163,7 +188,7 @@ class HistoryWindow: self.latest_button.set_sensitive(False) def new_line(self, date, type, data): - '''write a new line''' + '''add a new line in textbuffer''' buff = self.history_buffer start_iter = buff.get_start_iter() tim = time.strftime('[%x %X] ', time.localtime(float(date)))