do not show tabs in tabbed chat window when there is only one tab (close ticket #37)

This commit is contained in:
Yann Leboulanger 2005-03-02 10:24:49 +00:00
parent d9552a9b4f
commit 8e0efb5061
2 changed files with 21 additions and 25 deletions

View File

@ -8143,8 +8143,7 @@ Custom</property>
<child> <child>
<widget class="GtkNotebook" id="notebook"> <widget class="GtkNotebook" id="notebook">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="show_tabs">False</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>
<property name="scrollable">False</property> <property name="scrollable">False</property>

View File

@ -292,18 +292,7 @@ class tabbed_chat_Window:
"""When close button is pressed : """When close button is pressed :
close a tab""" close a tab"""
jid = self.get_active_jid() jid = self.get_active_jid()
if len(self.widgets) == 1: self.remove_tab(jid)
button.get_toplevel().destroy()
else:
nb = self.xml.get_widget('notebook')
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.widgets[jid]
del self.tagIn[jid]
del self.tagOut[jid]
del self.tagStatus[jid]
def on_focus(self, widget, event): def on_focus(self, widget, event):
"""When window get focus""" """When window get focus"""
@ -340,6 +329,22 @@ class tabbed_chat_Window:
nb.set_current_page(nb.page_num(child)) nb.set_current_page(nb.page_num(child))
self.widgets[jid]['message'].grab_focus() self.widgets[jid]['message'].grab_focus()
def remove_tab(self, jid):
if len(self.widgets) == 1:
self.window.destroy()
else:
nb = self.xml.get_widget('notebook')
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.widgets[jid]
del self.tagIn[jid]
del self.tagOut[jid]
del self.tagStatus[jid]
if len(self.widgets) == 1:
nb.set_show_tabs(False)
def new_user(self, user): def new_user(self, user):
self.nb_unread[user.jid] = 0 self.nb_unread[user.jid] = 0
self.users[user.jid] = user self.users[user.jid] = user
@ -430,6 +435,8 @@ class tabbed_chat_Window:
vb.show_all() vb.show_all()
nb = self.xml.get_widget("notebook") nb = self.xml.get_widget("notebook")
nb.append_page(vb) nb.append_page(vb)
if len(self.widgets) > 1:
nb.set_show_tabs(True)
self.redraw_tab(user.jid) self.redraw_tab(user.jid)
self.draw_widgets(user) self.draw_widgets(user)
@ -468,17 +475,7 @@ class tabbed_chat_Window:
st = "1234567890" st = "1234567890"
if event.keyval == gtk.keysyms.Escape: if event.keyval == gtk.keysyms.Escape:
jid = self.get_active_jid() jid = self.get_active_jid()
if len(self.widgets) == 1: self.remove_tab(jid)
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.widgets[jid]
del self.tagIn[jid]
del self.tagOut[jid]
del self.tagStatus[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):
nb.set_current_page(st.index(event.string)) nb.set_current_page(st.index(event.string))