merge the bugfix_tabbed_chat branch :
the bug has been solved by not using glade anymore for this window
This commit is contained in:
commit
7efdde1695
2 changed files with 126 additions and 442 deletions
|
@ -9500,361 +9500,18 @@ on the server.</property>
|
|||
<signal name="switch_page" handler="on_notebook_switch_page" last_modification_time="Thu, 27 Jan 2005 23:16:57 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox_tab">
|
||||
<property name="border_width">5</property>
|
||||
<widget class="GtkLabel" id="label191">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2907">
|
||||
<property name="border_width">5</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">5</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_history">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_history_clicked" last_modification_time="Sun, 04 Apr 2004 05:30:58 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment36">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xscale">0</property>
|
||||
<property name="yscale">0</property>
|
||||
<property name="top_padding">0</property>
|
||||
<property name="bottom_padding">0</property>
|
||||
<property name="left_padding">0</property>
|
||||
<property name="right_padding">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2908">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">2</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image181">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-justify-fill</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label183">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">History</property>
|
||||
<property name="use_underline">True</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>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_clear">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_clear_clicked" last_modification_time="Thu, 18 Mar 2004 19:12:00 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment37">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xscale">0</property>
|
||||
<property name="yscale">0</property>
|
||||
<property name="top_padding">0</property>
|
||||
<property name="bottom_padding">0</property>
|
||||
<property name="left_padding">0</property>
|
||||
<property name="right_padding">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2909">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">2</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image182">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-clear</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label184">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Clear</property>
|
||||
<property name="use_underline">True</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>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image_status">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-no</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToggleButton" id="toggle_gpg">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NONE</property>
|
||||
<property name="focus_on_click">False</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image_gpg">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-dialog-authentication</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkFixed" id="fixed2">
|
||||
<property name="width_request">20</property>
|
||||
<property name="visible">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_contact">
|
||||
<property name="width_request">0</property>
|
||||
<property name="height_request">0</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Anonymous <id@server/res></property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NONE</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_button_contact_clicked" last_modification_time="Sun, 15 Feb 2004 14:26:53 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="x">0</property>
|
||||
<property name="y">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_close">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_close_clicked" last_modification_time="Fri, 28 Jan 2005 20:16:24 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image183">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-close</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</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>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVPaned" id="vpaned3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="position">170</property>
|
||||
|
||||
<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="conversation">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">False</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_WORD</property>
|
||||
<property name="cursor_visible">False</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>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="shrink">True</property>
|
||||
<property name="resize">True</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="message">
|
||||
<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_WORD</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="key_press_event" handler="on_msg_key_press_event" last_modification_time="Mon, 13 Oct 2003 17:48:48 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="shrink">True</property>
|
||||
<property name="resize">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<property name="label" translatable="yes"></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>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
|
|
|
@ -185,55 +185,24 @@ class tabbed_chat_Window:
|
|||
"""Class for tabbed chat window"""
|
||||
def __init__(self, user, plugin, account):
|
||||
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'tabbed_chat', APP)
|
||||
self.xmls = {}
|
||||
self.xmls[user.jid] = self.xml
|
||||
conversation = self.xml.get_widget('conversation')
|
||||
buffer_conv = conversation.get_buffer()
|
||||
message = self.xml.get_widget('message')
|
||||
message.grab_focus()
|
||||
buffer_msg = message.get_buffer()
|
||||
end_iter = buffer_conv.get_end_iter()
|
||||
buffer_conv.create_mark('end', end_iter, 0)
|
||||
|
||||
self.xml.get_widget('notebook').remove_page(0)
|
||||
self.plugin = plugin
|
||||
self.account = account
|
||||
self.widgets = {}
|
||||
self.tagIn = {}
|
||||
self.tagOut = {}
|
||||
self.tagStatus = {}
|
||||
self.users = {user.jid: user}
|
||||
self.nb_unread = {user.jid: 0}
|
||||
|
||||
self.redraw_tab(user.jid)
|
||||
self.window = self.xml.get_widget('tabbed_chat')
|
||||
self.new_user(user)
|
||||
self.show_title()
|
||||
self.draw_widgets(user)
|
||||
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
||||
self.xml.signal_connect('on_focus', self.on_focus)
|
||||
self.xml.signal_connect('on_chat_key_press_event', \
|
||||
self.on_chat_key_press_event)
|
||||
self.xml.signal_connect('on_notebook_switch_page', \
|
||||
self.on_notebook_switch_page)
|
||||
self.xml.signal_connect('on_history_clicked', self.on_history)
|
||||
self.xml.signal_connect('on_clear_clicked', self.on_clear)
|
||||
self.xml.signal_connect('on_close_clicked', self.on_close_clicked)
|
||||
self.xml.signal_connect('on_msg_key_press_event', \
|
||||
self.on_msg_key_press_event)
|
||||
self.xml.signal_connect('on_button_contact_clicked', \
|
||||
self.on_button_contact_clicked)
|
||||
self.xml.get_widget('button_contact').set_use_underline(False)
|
||||
self.tagIn = {user.jid: buffer_conv.create_tag("incoming")}
|
||||
color = self.plugin.config['inmsgcolor']
|
||||
self.tagIn[user.jid].set_property("foreground", color)
|
||||
self.tagOut = {user.jid: buffer_conv.create_tag("outgoing")}
|
||||
color = self.plugin.config['outmsgcolor']
|
||||
self.tagOut[user.jid].set_property("foreground", color)
|
||||
self.tagStatus = {user.jid: buffer_conv.create_tag("status")}
|
||||
color = self.plugin.config['statusmsgcolor']
|
||||
self.tagStatus[user.jid].set_property("foreground", color)
|
||||
|
||||
#print queued messages
|
||||
if plugin.queues[account].has_key(user.jid):
|
||||
self.read_queue(plugin.queues[account][user.jid])
|
||||
if user.show != 'online':
|
||||
self.print_conversation(_("%s is now %s (%s)") % (user.name, \
|
||||
user.show, user.status), user.jid, 'status')
|
||||
|
||||
def update_tags(self):
|
||||
for jid in self.tagIn:
|
||||
|
@ -256,16 +225,16 @@ class tabbed_chat_Window:
|
|||
self.window.set_title(start + "Chat (" + self.account + ")")
|
||||
|
||||
def draw_widgets(self, user):
|
||||
widget_img = self.xmls[user.jid].get_widget('image_status')
|
||||
widget_img = self.widgets[user.jid]['image_status']
|
||||
image = self.plugin.roster.pixbufs[user.show]
|
||||
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
|
||||
widget_img.set_from_animation(image.get_animation())
|
||||
elif image.get_storage_type() == gtk.IMAGE_PIXBUF:
|
||||
widget_img.set_from_pixbuf(image.get_pixbuf())
|
||||
self.xmls[user.jid].get_widget('button_contact').set_label(\
|
||||
self.widgets[user.jid]['button_contact'].set_label(\
|
||||
user.name + ' <' + user.jid + '>')
|
||||
if not user.keyID:
|
||||
self.xmls[user.jid].get_widget('toggle_gpg').set_sensitive(False)
|
||||
self.widgets[user.jid]['toggle_gpg'].set_sensitive(False)
|
||||
|
||||
def redraw_tab(self, jid):
|
||||
start = ''
|
||||
|
@ -274,15 +243,15 @@ class tabbed_chat_Window:
|
|||
elif self.nb_unread[jid] == 1:
|
||||
start = "* "
|
||||
nb = self.xml.get_widget("notebook")
|
||||
child = self.xmls[jid].get_widget("vbox_tab")
|
||||
child = self.widgets[jid]['vbox_tab']
|
||||
nb.set_tab_label_text(child, start + self.users[jid].name)
|
||||
|
||||
def set_image(self, image, jid):
|
||||
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
|
||||
self.xmls[jid].get_widget('image_status').\
|
||||
self.widgets[jid]['image_status'].\
|
||||
set_from_animation(image.get_animation())
|
||||
elif image.get_storage_type() == gtk.IMAGE_PIXBUF:
|
||||
self.xmls[jid].get_widget('image_status').\
|
||||
self.widgets[jid]['image_status'].\
|
||||
set_from_pixbuf(image.get_pixbuf())
|
||||
|
||||
def delete_event(self, widget):
|
||||
|
@ -296,8 +265,8 @@ class tabbed_chat_Window:
|
|||
nb = self.xml.get_widget("notebook")
|
||||
child = nb.get_nth_page(nb.get_current_page())
|
||||
jid = ''
|
||||
for j in self.xmls:
|
||||
c = self.xmls[j].get_widget("vbox_tab")
|
||||
for j in self.widgets:
|
||||
c = self.widgets[j]['vbox_tab']
|
||||
if c == child:
|
||||
jid = j
|
||||
break
|
||||
|
@ -307,7 +276,7 @@ class tabbed_chat_Window:
|
|||
"""When clear button is pressed :
|
||||
clear the conversation"""
|
||||
jid = self.get_active_jid()
|
||||
buffer = self.xmls[jid].get_widget('conversation').get_buffer()
|
||||
buffer = self.widgets[jid]['conversation'].get_buffer()
|
||||
deb, end = buffer.get_bounds()
|
||||
buffer.delete(deb, end)
|
||||
|
||||
|
@ -315,7 +284,7 @@ class tabbed_chat_Window:
|
|||
"""When close button is pressed :
|
||||
close a tab"""
|
||||
jid = self.get_active_jid()
|
||||
if len(self.xmls) == 1:
|
||||
if len(self.widgets) == 1:
|
||||
button.get_toplevel().destroy()
|
||||
else:
|
||||
nb = self.xml.get_widget('notebook')
|
||||
|
@ -323,7 +292,7 @@ class tabbed_chat_Window:
|
|||
del self.plugin.windows[self.account]['chats'][jid]
|
||||
del self.users[jid]
|
||||
del self.nb_unread[jid]
|
||||
del self.xmls[jid]
|
||||
del self.widgets[jid]
|
||||
del self.tagIn[jid]
|
||||
del self.tagOut[jid]
|
||||
del self.tagStatus[jid]
|
||||
|
@ -342,12 +311,12 @@ class tabbed_chat_Window:
|
|||
jid = self.get_active_jid()
|
||||
if not self.plugin.windows['logs'].has_key(jid):
|
||||
self.plugin.windows['logs'][jid] = log_Window(self.plugin, jid)
|
||||
|
||||
|
||||
def on_notebook_switch_page(self, nb, page, page_num):
|
||||
child = nb.get_nth_page(page_num)
|
||||
jid = ''
|
||||
for j in self.xmls:
|
||||
c = self.xmls[j].get_widget("vbox_tab")
|
||||
for j in self.widgets:
|
||||
c = self.widgets[j]['vbox_tab']
|
||||
if c == child:
|
||||
jid = j
|
||||
break
|
||||
|
@ -358,49 +327,107 @@ class tabbed_chat_Window:
|
|||
self.plugin.systray.remove_jid(jid, self.account)
|
||||
|
||||
def active_tab(self, jid):
|
||||
child = self.xmls[jid].get_widget("vbox_tab")
|
||||
child = self.widgets[jid]['vbox_tab']
|
||||
nb = self.xml.get_widget("notebook")
|
||||
nb.set_current_page(nb.page_num(child))
|
||||
message = self.xmls[jid].get_widget('message')
|
||||
message.grab_focus()
|
||||
|
||||
self.widgets[jid]['message'].grab_focus()
|
||||
|
||||
def new_user(self, user):
|
||||
self.nb_unread[user.jid] = 0
|
||||
self.users[user.jid] = user
|
||||
self.xmls[user.jid] = gtk.glade.XML(GTKGUI_GLADE, "vbox_tab", APP)
|
||||
vb = self.xmls[user.jid].get_widget("vbox_tab")
|
||||
|
||||
self.widgets[user.jid] = {}
|
||||
vb = gtk.VBox()
|
||||
vb.set_border_width(5)
|
||||
self.widgets[user.jid]['vbox_tab'] = vb
|
||||
hb = gtk.HBox(spacing=5)
|
||||
hb.set_border_width(5)
|
||||
vb.pack_start(hb, expand=False)
|
||||
|
||||
button = gtk.Button(stock=gtk.STOCK_JUSTIFY_FILL)
|
||||
button.get_children()[0].get_children()[0].get_children()[1].set_text("History")
|
||||
button.connect("clicked", self.on_history)
|
||||
hb.pack_start(button, expand=False, fill=False)
|
||||
|
||||
button = gtk.Button(stock=gtk.STOCK_CLEAR)
|
||||
button.connect("clicked", self.on_clear)
|
||||
hb.pack_start(button, expand=False, fill=False)
|
||||
|
||||
img = gtk.Image()
|
||||
hb.pack_start(img, expand=False, fill=False)
|
||||
self.widgets[user.jid]['image_status'] = img
|
||||
|
||||
img = gtk.Image()
|
||||
img.set_from_stock(gtk.STOCK_DIALOG_AUTHENTICATION, gtk.ICON_SIZE_BUTTON)
|
||||
button = gtk.ToggleButton()
|
||||
button.add(img)
|
||||
button.set_relief(gtk.RELIEF_NONE)
|
||||
hb.pack_start(button, expand=False, fill=False)
|
||||
self.widgets[user.jid]['toggle_gpg'] = button
|
||||
|
||||
fixed = gtk.Fixed()
|
||||
fixed.set_size_request(20, -1)
|
||||
hb.pack_start(fixed)
|
||||
button = gtk.Button("Anonymous")
|
||||
button.set_relief(gtk.RELIEF_NONE)
|
||||
button.connect("clicked", self.on_button_contact_clicked)
|
||||
button.set_use_underline(False)
|
||||
fixed.put(button, 0, 0)
|
||||
self.widgets[user.jid]['button_contact'] = button
|
||||
|
||||
img = gtk.Image()
|
||||
img.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_BUTTON)
|
||||
button = gtk.Button()
|
||||
button.add(img)
|
||||
button.connect("clicked", self.on_close_clicked)
|
||||
hb.pack_start(button, expand=False, fill=False)
|
||||
|
||||
vp = gtk.VPaned()
|
||||
vb.pack_start(vp)
|
||||
vp.set_position(170)
|
||||
|
||||
sw = gtk.ScrolledWindow()
|
||||
sw.set_shadow_type(gtk.SHADOW_IN)
|
||||
vp.add1(sw)
|
||||
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
tv = gtk.TextView()
|
||||
tv.set_wrap_mode(gtk.WRAP_WORD)
|
||||
tv.set_editable(False)
|
||||
tv.set_cursor_visible(False)
|
||||
sw.add(tv)
|
||||
self.widgets[user.jid]['conversation'] = tv
|
||||
buffer = tv.get_buffer()
|
||||
end_iter = buffer.get_end_iter()
|
||||
buffer.create_mark('end', end_iter, 0)
|
||||
self.tagIn[user.jid] = buffer.create_tag("incoming")
|
||||
color = self.plugin.config['inmsgcolor']
|
||||
self.tagIn[user.jid].set_property("foreground", color)
|
||||
self.tagOut[user.jid] = buffer.create_tag("outgoing")
|
||||
color = self.plugin.config['outmsgcolor']
|
||||
self.tagOut[user.jid].set_property("foreground", color)
|
||||
self.tagStatus[user.jid] = buffer.create_tag("status")
|
||||
color = self.plugin.config['statusmsgcolor']
|
||||
self.tagStatus[user.jid].set_property("foreground", color)
|
||||
|
||||
sw = gtk.ScrolledWindow()
|
||||
sw.set_shadow_type(gtk.SHADOW_IN)
|
||||
vp.add2(sw)
|
||||
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
tv = gtk.TextView()
|
||||
tv.set_wrap_mode(gtk.WRAP_WORD)
|
||||
sw.add(tv)
|
||||
self.widgets[user.jid]['message'] = tv
|
||||
tv.grab_focus()
|
||||
tv.connect('key_press_event', self.on_msg_key_press_event)
|
||||
|
||||
vb.show_all()
|
||||
nb = self.xml.get_widget("notebook")
|
||||
nb.set_current_page(nb.append_page(vb))
|
||||
|
||||
conversation = self.xmls[user.jid].get_widget('conversation')
|
||||
buffer_conv = conversation.get_buffer()
|
||||
message = self.xmls[user.jid].get_widget('message')
|
||||
message.grab_focus()
|
||||
buffer_msg = message.get_buffer()
|
||||
end_iter = buffer_conv.get_end_iter()
|
||||
buffer_conv.create_mark('end', end_iter, 0)
|
||||
self.tagIn[user.jid] = buffer_conv.create_tag("incoming")
|
||||
color = self.plugin.config['inmsgcolor']
|
||||
self.tagIn[user.jid].set_property("foreground", color)
|
||||
self.tagOut[user.jid] = buffer_conv.create_tag("outgoing")
|
||||
color = self.plugin.config['outmsgcolor']
|
||||
self.tagOut[user.jid].set_property("foreground", color)
|
||||
self.tagStatus[user.jid] = buffer_conv.create_tag("status")
|
||||
color = self.plugin.config['statusmsgcolor']
|
||||
self.tagStatus[user.jid].set_property("foreground", color)
|
||||
|
||||
self.redraw_tab(user.jid)
|
||||
self.draw_widgets(user)
|
||||
self.xmls[user.jid].signal_connect('on_history_clicked', self.on_history)
|
||||
self.xmls[user.jid].signal_connect('on_clear_clicked', self.on_clear)
|
||||
self.xmls[user.jid].signal_connect('on_close_clicked', \
|
||||
self.on_close_clicked)
|
||||
self.xmls[user.jid].signal_connect('on_msg_key_press_event', \
|
||||
self.on_msg_key_press_event)
|
||||
self.xmls[user.jid].signal_connect('on_button_contact_clicked', \
|
||||
self.on_button_contact_clicked)
|
||||
self.xmls[user.jid].get_widget('button_contact').set_use_underline(False)
|
||||
|
||||
#print queued messages
|
||||
if self.plugin.queues[self.account].has_key(user.jid):
|
||||
self.read_queue(self.plugin.queues[self.account][user.jid])
|
||||
if user.show != 'online':
|
||||
|
@ -421,7 +448,7 @@ class tabbed_chat_Window:
|
|||
if txt != '':
|
||||
keyID = ''
|
||||
jid = self.get_active_jid()
|
||||
if self.xmls[jid].get_widget('toggle_gpg').get_active():
|
||||
if self.widgets[jid]['toggle_gpg'].get_active():
|
||||
keyID = self.users[jid].keyID
|
||||
self.plugin.send('MSG', self.account, (jid, txt, keyID))
|
||||
txt_buffer.set_text('', -1)
|
||||
|
@ -434,18 +461,18 @@ class tabbed_chat_Window:
|
|||
st = "1234567890"
|
||||
if event.keyval == gtk.keysyms.Escape:
|
||||
jid = self.get_active_jid()
|
||||
if len(self.xmls) == 1:
|
||||
if len(self.widgets) == 1:
|
||||
widget.get_toplevel().destroy()
|
||||
else:
|
||||
nb.remove_page(nb.get_current_page())
|
||||
del self.plugin.windows[self.account]['chats'][jid]
|
||||
del self.users[jid]
|
||||
del self.nb_unread[jid]
|
||||
del self.xmls[jid]
|
||||
del self.widgets[jid]
|
||||
del self.tagIn[jid]
|
||||
del self.tagOut[jid]
|
||||
del self.tagStatus[jid]
|
||||
elif (event.string in st) \
|
||||
elif event.string and event.string in st \
|
||||
and (event.state & gtk.gdk.MOD1_MASK):
|
||||
nb.set_current_page(st.index(event.string))
|
||||
|
||||
|
@ -479,7 +506,7 @@ class tabbed_chat_Window:
|
|||
if contact is set to another value : it's an outgoing message
|
||||
if contact is not set : it's an incomming message"""
|
||||
user = self.users[jid]
|
||||
conversation = self.xmls[jid].get_widget('conversation')
|
||||
conversation = self.widgets[jid]['conversation']
|
||||
buffer = conversation.get_buffer()
|
||||
if not txt:
|
||||
txt = ""
|
||||
|
|
Loading…
Add table
Reference in a new issue