some fixes

This commit is contained in:
Nikos Kouremenos 2005-03-05 19:47:49 +00:00
parent 6d67431f37
commit c9d65729df
2 changed files with 27 additions and 34 deletions

View File

@ -6833,7 +6833,6 @@ Custom</property>
</widget> </widget>
<widget class="GtkWindow" id="groupchat_window"> <widget class="GtkWindow" id="groupchat_window">
<property name="border_width">4</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Groupchat</property> <property name="title" translatable="yes">Groupchat</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="type">GTK_WINDOW_TOPLEVEL</property>
@ -6867,7 +6866,7 @@ Custom</property>
<child> <child>
<widget class="GtkLabel" id="label139"> <widget class="GtkLabel" id="label139">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Subject :</property> <property name="label" translatable="yes">Subject:</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
@ -6895,8 +6894,7 @@ Custom</property>
<property name="text" translatable="yes"></property> <property name="text" translatable="yes"></property>
<property name="has_frame">True</property> <property name="has_frame">True</property>
<property name="invisible_char">*</property> <property name="invisible_char">*</property>
<property name="activates_default">False</property> <property name="activates_default">True</property>
<signal name="key_press_event" handler="on_subject_entry_key_press_event" last_modification_time="Fri, 04 Mar 2005 20:46:50 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -6908,6 +6906,8 @@ Custom</property>
<child> <child>
<widget class="GtkButton" id="set_button"> <widget class="GtkButton" id="set_button">
<property name="visible">True</property> <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="can_focus">True</property>
<property name="label" translatable="yes">Set</property> <property name="label" translatable="yes">Set</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -6931,9 +6931,7 @@ Custom</property>
<child> <child>
<widget class="GtkNotebook" id="chat_notebook"> <widget class="GtkNotebook" id="chat_notebook">
<property name="border_width">4</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">True</property> <property name="show_tabs">True</property>
<property name="show_border">True</property> <property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property> <property name="tab_pos">GTK_POS_TOP</property>
@ -6978,7 +6976,6 @@ Custom</property>
<child> <child>
<widget class="GtkButton" id="close_button"> <widget class="GtkButton" id="close_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<signal name="clicked" handler="on_close_button_clicked" last_modification_time="Sat, 05 Mar 2005 10:52:53 GMT"/> <signal name="clicked" handler="on_close_button_clicked" last_modification_time="Sat, 05 Mar 2005 10:52:53 GMT"/>
@ -7012,19 +7009,16 @@ Custom</property>
<child> <child>
<widget class="GtkVPaned" id="vpaned4"> <widget class="GtkVPaned" id="vpaned4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">225</property> <property name="position">225</property>
<child> <child>
<widget class="GtkHPaned" id="hpaned"> <widget class="GtkHPaned" id="hpaned">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">100</property> <property name="position">100</property>
<child> <child>
<widget class="GtkScrolledWindow" id="scrolledwindow17"> <widget class="GtkScrolledWindow" id="scrolledwindow17">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property> <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property> <property name="shadow_type">GTK_SHADOW_IN</property>
@ -7055,7 +7049,6 @@ Custom</property>
<child> <child>
<widget class="GtkScrolledWindow" id="scrolledwindow18"> <widget class="GtkScrolledWindow" id="scrolledwindow18">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property> <property name="shadow_type">GTK_SHADOW_IN</property>
@ -7064,7 +7057,6 @@ Custom</property>
<child> <child>
<widget class="GtkTextView" id="conversation_textview"> <widget class="GtkTextView" id="conversation_textview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property> <property name="editable">False</property>
<property name="overwrite">False</property> <property name="overwrite">False</property>
<property name="accepts_tab">True</property> <property name="accepts_tab">True</property>
@ -7096,7 +7088,6 @@ Custom</property>
<child> <child>
<widget class="GtkScrolledWindow" id="scrolledwindow19"> <widget class="GtkScrolledWindow" id="scrolledwindow19">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property> <property name="shadow_type">GTK_SHADOW_IN</property>
@ -7106,6 +7097,7 @@ Custom</property>
<widget class="GtkTextView" id="message_textview"> <widget class="GtkTextView" id="message_textview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="editable">True</property> <property name="editable">True</property>
<property name="overwrite">False</property> <property name="overwrite">False</property>
<property name="accepts_tab">True</property> <property name="accepts_tab">True</property>

View File

@ -488,8 +488,7 @@ class tabbed_chat_window:
else: else:
self.chat_notebook.set_current_page(0) self.chat_notebook.set_current_page(0)
else: # it's a normal key press make sure message_textview has focus else: # it's a normal key press make sure message_textview has focus
message_textview = self.xmls[jid].\ message_textview = self.xmls[jid].get_widget('message_textview')
get_widget('message_textview')
if not message_textview.is_focus(): if not message_textview.is_focus():
message_textview.grab_focus() message_textview.grab_focus()
@ -805,12 +804,6 @@ class Groupchat_window:
self.subjects[room_jid] = subject self.subjects[room_jid] = subject
self.xml.get_widget('subject_entry').set_text(subject) self.xml.get_widget('subject_entry').set_text(subject)
def on_subject_entry_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Return:
room_jid = self.get_active_jid()
subject = widget.get_text()
self.plugin.send('GC_SUBJECT', self.account, (room_jid, subject))
def on_set_button_clicked(self, widget): def on_set_button_clicked(self, widget):
room_jid = self.get_active_jid() room_jid = self.get_active_jid()
subject = self.xml.get_widget('subject_entry').get_text() subject = self.xml.get_widget('subject_entry').get_text()
@ -821,10 +814,10 @@ class Groupchat_window:
self.remove_tab(room_jid) self.remove_tab(room_jid)
def on_message_textview_key_press_event(self, widget, event): def on_message_textview_key_press_event(self, widget, event):
"""When a key is pressed : """When a key is pressed:
if enter is pressed without the shit key, message (if not empty) is sent if enter is pressed without the shit key, message (if not empty) is sent
and printed in the conversation""" and printed in the conversation. Tab does autocompete in nickames"""
if event.keyval == gtk.keysyms.Return: if event.keyval == gtk.keysyms.Return: # ENTER
if (event.state & gtk.gdk.SHIFT_MASK): if (event.state & gtk.gdk.SHIFT_MASK):
return 0 return 0
message_buffer = widget.get_buffer() message_buffer = widget.get_buffer()
@ -837,7 +830,7 @@ class Groupchat_window:
message_buffer.set_text('', -1) message_buffer.set_text('', -1)
widget.grab_focus() widget.grab_focus()
return 1 return 1
elif event.keyval == gtk.keysyms.Tab: elif event.keyval == gtk.keysyms.Tab: # TAB
room_jid = self.get_active_jid() room_jid = self.get_active_jid()
list_nick = self.get_user_list(room_jid) list_nick = self.get_user_list(room_jid)
message_buffer = widget.get_buffer() message_buffer = widget.get_buffer()
@ -848,19 +841,19 @@ class Groupchat_window:
begin = txt.split()[-1] begin = txt.split()[-1]
for nick in list_nick: for nick in list_nick:
if nick.find(begin) == 0: if nick.find(begin) == 0:
message_buffer.insert_at_cursor(nick[len(begin):] + ' ') message_buffer.insert_at_cursor(nick[len(begin):] + ': ')
return 1 return 1
return 0 return 0
def on_groupchat_window_key_press_event(self, widget, event): def on_groupchat_window_key_press_event(self, widget, event):
st = "1234567890" st = "1234567890" # humans count from 1, pc from 0 :P
room_jid = self.get_active_jid() room_jid = self.get_active_jid()
if event.keyval == gtk.keysyms.Escape: if event.keyval == gtk.keysyms.Escape: #ESCAPE
self.remove_tab(room_jid) self.remove_tab(room_jid)
elif event.string and event.string in st \ elif event.string and event.string in st \
and (event.state & gtk.gdk.MOD1_MASK): and (event.state & gtk.gdk.MOD1_MASK): # alt + 1,2,3 ...
self.chat_notebook.set_current_page(st.index(event.string)) self.chat_notebook.set_current_page(st.index(event.string))
elif event.keyval == gtk.keysyms.Page_Down: elif event.keyval == gtk.keysyms.Page_Down: # PAGEDOWN
if event.state & gtk.gdk.CONTROL_MASK: if event.state & gtk.gdk.CONTROL_MASK:
current = self.chat_notebook.get_current_page() current = self.chat_notebook.get_current_page()
if current > 0: if current > 0:
@ -875,7 +868,7 @@ class Groupchat_window:
iter = conversation_textview.get_iter_at_location(rect.x,\ iter = conversation_textview.get_iter_at_location(rect.x,\
rect.y + rect.height) rect.y + rect.height)
conversation_textview.scroll_to_iter(iter, 0.1, True, 0, 0) conversation_textview.scroll_to_iter(iter, 0.1, True, 0, 0)
elif event.keyval == gtk.keysyms.Page_Up: elif event.keyval == gtk.keysyms.Page_Up: # PAGEUP
if event.state & gtk.gdk.CONTROL_MASK: if event.state & gtk.gdk.CONTROL_MASK:
current = self.chat_notebook.get_current_page() current = self.chat_notebook.get_current_page()
if current < (self.chat_notebook.get_n_pages()-1): if current < (self.chat_notebook.get_n_pages()-1):
@ -889,13 +882,22 @@ class Groupchat_window:
iter = conversation_textview.get_iter_at_location(rect.x, rect.y) iter = conversation_textview.get_iter_at_location(rect.x, rect.y)
conversation_textview.scroll_to_iter(iter, 0.1, True, 0, 1) conversation_textview.scroll_to_iter(iter, 0.1, True, 0, 1)
elif event.keyval == gtk.keysyms.Tab and \ elif event.keyval == gtk.keysyms.Tab and \
(event.state & gtk.gdk.CONTROL_MASK): (event.state & gtk.gdk.CONTROL_MASK): # CTRL+TAB
current = self.chat_notebook.get_current_page() current = self.chat_notebook.get_current_page()
if current < (self.chat_notebook.get_n_pages()-1): if current < (self.chat_notebook.get_n_pages()-1):
self.chat_notebook.set_current_page(current+1) self.chat_notebook.set_current_page(current+1)
else: else:
self.chat_notebook.set_current_page(0) self.chat_notebook.set_current_page(0)
'''FIXME:
NOT GOOD steals focus from Subject entry and I cannot find a way to prevent this
else: # it's a normal key press make sure message_textview has focus
message_textview = self.xmls[room_jid].get_widget('message_textview')
if not message_textview.is_focus():
message_textview.grab_focus()
'''
def print_conversation(self, txt, room_jid, contact = None, tim = None): def print_conversation(self, txt, room_jid, contact = None, tim = None):
"""Print a line in the conversation : """Print a line in the conversation :
if contact is set : it's a message from someone if contact is set : it's a message from someone
@ -1237,10 +1239,9 @@ class Groupchat_window:
self.on_groupchat_window_key_press_event) self.on_groupchat_window_key_press_event)
self.xml.signal_connect('on_chat_notebook_switch_page', \ self.xml.signal_connect('on_chat_notebook_switch_page', \
self.on_chat_notebook_switch_page) self.on_chat_notebook_switch_page)
self.xml.signal_connect('on_subject_entry_key_press_event', \
self.on_subject_entry_key_press_event)
self.xml.signal_connect('on_set_button_clicked', \ self.xml.signal_connect('on_set_button_clicked', \
self.on_set_button_clicked) self.on_set_button_clicked)
#FIXME: (nk) WHY AUTOCONNECT segfaults? [haven't test here but looks the same] with tabbed chat window ;P
class history_window: class history_window:
"""Class for bowser agent window : """Class for bowser agent window :