Commit 229d86ae authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

before/after_time/nickname are now textviews in pref window. So that they can...

before/after_time/nickname are now textviews in pref window. So that they can contacin \n and \t chars. Fixes #2206
parent 8c07a066
......@@ -819,7 +819,6 @@ Per type</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">before_time_entry</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
......@@ -848,7 +847,6 @@ Per type</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">after_nickname_entry</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
......@@ -998,7 +996,6 @@ Per type</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">after_time_entry</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
......@@ -1027,7 +1024,6 @@ Per type</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">before_nickname_entry</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
......@@ -1043,54 +1039,6 @@ Per type</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="after_time_entry">
<property name="width_request">39</property>
<property name="visible">True</property>
<property name="can_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">False</property>
<signal name="focus_out_event" handler="on_after_time_entry_focus_out_event" last_modification_time="Fri, 01 Apr 2005 15:57:17 GMT"/>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="after_nickname_entry">
<property name="width_request">40</property>
<property name="visible">True</property>
<property name="can_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">False</property>
<signal name="focus_out_event" handler="on_after_nickname_entry_focus_out_event" last_modification_time="Fri, 01 Apr 2005 15:58:07 GMT"/>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkColorButton" id="incoming_msg_colorbutton">
<property name="visible">True</property>
......@@ -1132,54 +1080,6 @@ Per type</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="before_nickname_entry">
<property name="width_request">40</property>
<property name="visible">True</property>
<property name="can_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">False</property>
<signal name="focus_out_event" handler="on_before_nickname_entry_focus_out_event" last_modification_time="Fri, 01 Apr 2005 15:57:44 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="before_time_entry">
<property name="width_request">40</property>
<property name="visible">True</property>
<property name="can_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">False</property>
<signal name="focus_out_event" handler="on_before_time_entry_focus_out_event" last_modification_time="Fri, 01 Apr 2005 15:54:51 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox3022">
<property name="visible">True</property>
......@@ -1298,6 +1198,166 @@ Per type</property>
<property name="x_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow25">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="before_time_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
<signal name="focus_out_event" handler="on_before_time_textview_focus_out_event" last_modification_time="Wed, 20 Sep 2006 18:21:39 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow26">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="after_time_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
<signal name="focus_out_event" handler="on_after_time_textview_focus_out_event" last_modification_time="Wed, 20 Sep 2006 19:52:22 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow27">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="before_nickname_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
<signal name="focus_out_event" handler="on_before_nickname_textview_focus_out_event" last_modification_time="Wed, 20 Sep 2006 19:52:05 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow28">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="after_nickname_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
<signal name="focus_out_event" handler="on_after_nickname_textview_focus_out_event" last_modification_time="Wed, 20 Sep 2006 19:52:51 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
......
......@@ -211,19 +211,23 @@ class PreferencesWindow:
#before time
st = gajim.config.get('before_time')
self.xml.get_widget('before_time_entry').set_text(st)
st = helpers.from_one_line(st)
self.xml.get_widget('before_time_textview').get_buffer().set_text(st)
#after time
st = gajim.config.get('after_time')
self.xml.get_widget('after_time_entry').set_text(st)
st = helpers.from_one_line(st)
self.xml.get_widget('after_time_textview').get_buffer().set_text(st)
#before nickname
st = gajim.config.get('before_nickname')
self.xml.get_widget('before_nickname_entry').set_text(st)
st = helpers.from_one_line(st)
self.xml.get_widget('before_nickname_textview').get_buffer().set_text(st)
#after nickanme
st = gajim.config.get('after_nickname')
self.xml.get_widget('after_nickname_entry').set_text(st)
st = helpers.from_one_line(st)
self.xml.get_widget('after_nickname_textview').get_buffer().set_text(st)
#Color for incomming messages
colSt = gajim.config.get('inmsgcolor')
......@@ -644,9 +648,9 @@ class PreferencesWindow:
def _set_sensitivity_for_before_after_time_widgets(self, sensitive):
self.xml.get_widget('before_time_label').set_sensitive(sensitive)
self.xml.get_widget('before_time_entry').set_sensitive(sensitive)
self.xml.get_widget('before_time_textview').set_sensitive(sensitive)
self.xml.get_widget('after_time_label').set_sensitive(sensitive)
self.xml.get_widget('after_time_entry').set_sensitive(sensitive)
self.xml.get_widget('after_time_textview').set_sensitive(sensitive)
def on_time_never_radiobutton_toggled(self, widget):
if widget.get_active():
......@@ -666,20 +670,33 @@ class PreferencesWindow:
self._set_sensitivity_for_before_after_time_widgets(True)
gajim.interface.save_config()
def on_before_time_entry_focus_out_event(self, widget, event):
gajim.config.set('before_time', widget.get_text().decode('utf-8'))
def _get_textview_text(self, tv):
buffer = tv.get_buffer()
begin, end = buffer.get_bounds()
return buffer.get_text(begin, end).decode('utf-8')
def on_before_time_textview_focus_out_event(self, widget, event):
text = self._get_textview_text(widget)
text = helpers.to_one_line(text)
gajim.config.set('before_time', text)
gajim.interface.save_config()
def on_after_time_entry_focus_out_event(self, widget, event):
gajim.config.set('after_time', widget.get_text().decode('utf-8'))
def on_after_time_textview_focus_out_event(self, widget, event):
text = self._get_textview_text(widget)
text = helpers.to_one_line(text)
gajim.config.set('after_time', text)
gajim.interface.save_config()
def on_before_nickname_entry_focus_out_event(self, widget, event):
gajim.config.set('before_nickname', widget.get_text().decode('utf-8'))
def on_before_nickname_textview_focus_out_event(self, widget, event):
text = self._get_textview_text(widget)
text = helpers.to_one_line(text)
gajim.config.set('before_nickname', text)
gajim.interface.save_config()
def on_after_nickname_entry_focus_out_event(self, widget, event):
gajim.config.set('after_nickname', widget.get_text().decode('utf-8'))
def on_after_nickname_textview_focus_out_event(self, widget, event):
text = self._get_textview_text(widget)
text = helpers.to_one_line(text)
gajim.config.set('after_nickname', text)
gajim.interface.save_config()
def update_text_tags(self):
......
......@@ -664,7 +664,9 @@ class ConversationTextview:
current_print_time = gajim.config.get('print_time')
if current_print_time == 'always' and kind != 'info':
before_str = gajim.config.get('before_time')
before_str = helpers.from_one_line(before_str)
after_str = gajim.config.get('after_time')
after_str = helpers.from_one_line(after_str)
# get difference in days since epoch (86400 = 24*3600)
# number of days since epoch for current time (in GMT) -
# number of days since epoch for message (in GMT)
......@@ -748,7 +750,9 @@ class ConversationTextview:
name_tags = other_tags_for_name[:] # create a new list
name_tags.append(kind)
before_str = gajim.config.get('before_nickname')
before_str = helpers.from_one_line(before_str)
after_str = gajim.config.get('after_nickname')
after_str = helpers.from_one_line(after_str)
format = before_str + name + after_str + ' '
buffer.insert_with_tags_by_name(end_iter, format, *name_tags)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment