minimize menuitem -> minimize on close checkbutton. see #3034

This commit is contained in:
Yann Leboulanger 2007-06-14 17:44:24 +00:00
parent 0d81760650
commit b6eb2f94c9
4 changed files with 50 additions and 32 deletions

View File

@ -90,17 +90,10 @@
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="minimize_menuitem">
<widget class="GtkCheckMenuItem" id="minimize_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Minimize</property>
<property name="label" translatable="yes">_Minimize on close</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1411">
<property name="visible">True</property>
<property name="stock">gtk-goto-bottom</property>
<property name="icon_size">1</property>
</widget>
</child>
</widget>
</child>
<child>

View File

@ -670,25 +670,21 @@ class ChatControlBase(MessageControl):
isactive = widget.get_active()
self.chat_buttons_set_visible(isactive)
def _on_minimize_menuitem_activate(self, widget):
def on_minimize_menuitem_toggled(self, widget):
'''When a grouchat is minimized, unparent the tab, put it in roster etc'''
win = gajim.interface.msg_win_mgr.get_window(self.contact.jid, self.account)
ctrl = win.get_control(self.contact.jid, self.account)
ctrl_page = win.notebook.page_num(ctrl.widget)
control = win.notebook.get_nth_page(ctrl_page)
win.notebook.remove_page(ctrl_page)
control.unparent()
ctrl.parent_win = None
gajim.interface.minimized_controls[self.account][self.contact.jid] = ctrl
del win._controls[self.account][self.contact.jid]
win.check_tabs()
gajim.interface.roster.add_groupchat_to_roster(self.account,
self.contact.jid, status = self.subject)
old_value = False
minimized_gc = gajim.config.get_per('accounts', self.account,
'minimized_gc').split()
if self.contact.jid in minimized_gc:
old_value = True
minimize = widget.get_active()
if minimize and not self.contact.jid in minimized_gc:
minimized_gc.append(self.contact.jid)
if not minimize and self.contact.jid in minimized_gc:
minimized_gc.remove(self.contact.jid)
if old_value != minimize:
gajim.config.set_per('accounts', self.account, 'minimized_gc',
' '.join(minimized_gc))
def set_control_active(self, state):
if state:
@ -1515,7 +1511,7 @@ class ChatControl(ChatControlBase):
# compact_view_menuitem
compact_view_menuitem.set_active(self.hide_chat_buttons_current)
# add_to_roster_menuitem
if _('Not in Roster') in contact.groups:
add_to_roster_menuitem.show()
@ -1653,7 +1649,6 @@ class ChatControl(ChatControlBase):
del self.handlers[i]
self.conv_textview.del_handlers()
self.msg_textview.destroy()
def allow_shutdown(self, method):
if time.time() - gajim.last_message_time[self.account]\

View File

@ -259,6 +259,7 @@ class Config:
'gpgpassword': [ opt_str, '' ],
'sync_with_global_status': [ opt_bool, False, ],
'no_log_for': [ opt_str, '' ],
'minimized_gc': [ opt_str, '' ],
'attached_gpg_keys': [ opt_str, '' ],
'keep_alives_enabled': [ opt_bool, True],
# send keepalive every N seconds of inactivity

View File

@ -248,9 +248,10 @@ class GroupchatControl(ChatControlBase):
id = widget.connect('activate', self._on_history_menuitem_activate)
self.handlers[id] = widget
widget = xm.get_widget('minimize_menuitem')
id = widget.connect('activate', self._on_minimize_menuitem_activate)
self.handlers[id] = widget
self.minimize_menuitem = xm.get_widget('minimize_menuitem')
id = self.minimize_menuitem.connect('toggled',
self.on_minimize_menuitem_toggled)
self.handlers[id] = self.minimize_menuitem
self.gc_popup_menu = xm.get_widget('gc_control_popup_menu')
@ -491,6 +492,9 @@ class GroupchatControl(ChatControlBase):
sets sensitivity state for configure_room'''
# Check compact view menuitem
self.compact_view_menuitem.set_active(self.hide_chat_buttons_current)
if self.contact.jid in gajim.config.get_per('accounts', self.account,
'minimized_gc').split(' '):
self.minimize_menuitem.set_active(True)
if gajim.gc_connected[self.account][self.room_jid]:
c = gajim.contacts.get_gc_contact(self.account, self.room_jid,
self.nick)
@ -1431,6 +1435,28 @@ class GroupchatControl(ChatControlBase):
is_modal = False, ok_handler = on_ok)
def shutdown(self, status='offline'):
if self.contact.jid in gajim.config.get_per('accounts', self.account,
'minimized_gc').split(' '):
# Minimize it
win = gajim.interface.msg_win_mgr.get_window(self.contact.jid,
self.account)
ctrl = win.get_control(self.contact.jid, self.account)
ctrl_page = win.notebook.page_num(ctrl.widget)
control = win.notebook.get_nth_page(ctrl_page)
win.notebook.remove_page(ctrl_page)
control.unparent()
ctrl.parent_win = None
gajim.interface.minimized_controls[self.account][self.contact.jid] = \
ctrl
del win._controls[self.account][self.contact.jid]
gajim.interface.roster.add_groupchat_to_roster(self.account,
self.contact.jid, status = self.subject)
return
gajim.connections[self.account].send_gc_status(self.nick, self.room_jid,
show='offline', status=status)
nick_list = gajim.contacts.get_nick_list(self.account, self.room_jid)
@ -1461,6 +1487,9 @@ class GroupchatControl(ChatControlBase):
def allow_shutdown(self, method):
'''If check_selection is True, '''
if self.contact.jid in gajim.config.get_per('accounts', self.account,
'minimized_gc').split(' '):
return True
if method == self.parent_win.CLOSE_ESC:
model, iter = self.list_treeview.get_selection().get_selected()
if iter: