Added 'show roster on startup' option. Fixes #6793

This commit is contained in:
Denis Fomin 2011-02-04 23:52:03 +03:00
parent 4b987beeb2
commit e61f7aa4db
4 changed files with 85 additions and 12 deletions

View File

@ -107,6 +107,23 @@
</row>
</data>
</object>
<object class="GtkListStore" id="liststore7">
<columns>
<!-- column-name item -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Always</col>
</row>
<row>
<col id="0" translatable="yes">Never</col>
</row>
<row>
<col id="0" translatable="yes">Last state</col>
</row>
</data>
</object>
<object class="GtkWindow" id="preferences_window">
<property name="border_width">6</property>
<property name="title" translatable="yes">Preferences</property>
@ -332,7 +349,7 @@
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">5</property>
<property name="n_rows">6</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
@ -391,8 +408,8 @@
</object>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@ -409,8 +426,8 @@
</object>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@ -426,8 +443,8 @@
</object>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@ -451,6 +468,41 @@
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label28">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="label" translatable="yes">_Show roster on startup:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">show_roster_on_startup</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="show_roster_on_startup">
<property name="width_request">50</property>
<property name="visible">True</property>
<property name="model">liststore7</property>
<signal name="changed" handler="on_show_roster_on_startup_changed"/>
<child>
<object class="GtkCellRendererText" id="cellrenderertext7"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</object>
</child>
</object>

View File

@ -52,6 +52,7 @@ opt_str = [ 'string', 0 ]
opt_bool = [ 'boolean', 0 ]
opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()$' ]
opt_one_window_types = ['never', 'always', 'always_with_roster', 'peracct', 'pertype']
opt_show_roster_on_startup = ['always', 'never', 'last_state']
opt_treat_incoming_messages = ['', 'chat', 'normal']
class Config:
@ -171,7 +172,7 @@ class Config:
'muc_autorejoin_timeout': [opt_int, 1, _('How many seconds to wait before trying to autorejoin to a conference you are being disconnected from. Set to 0 to disable autorejoining.')],
'muc_autorejoin_on_kick': [opt_bool, False, _('Should autorejoin be activated when we are being kicked from a conference?')],
'send_on_ctrl_enter': [opt_bool, False, _('Send message on Ctrl+Enter and with Enter make new line (Mirabilis ICQ Client default behaviour).')],
'show_roster_on_startup': [opt_bool, True],
'last_roster_visible': [opt_bool, True],
'key_up_lines': [opt_int, 25, _('How many lines to store for Ctrl+KeyUP.')],
'version': [ opt_str, defs.version ], # which version created the config
'search_engine': [opt_str, 'http://www.google.com/search?&q=%s&sourceid=gajim'],
@ -244,6 +245,7 @@ class Config:
'one_message_window': [opt_str, 'always',
#always, never, peracct, pertype should not be translated
_('Controls the window where new messages are placed.\n\'always\' - All messages are sent to a single window.\n\'always_with_roster\' - Like \'always\' but the messages are in a single window along with the roster.\n\'never\' - All messages get their own window.\n\'peracct\' - Messages for each account are sent to a specific window.\n\'pertype\' - Each message type (e.g., chats vs. groupchats) are sent to a specific window.')],
'show_roster_on_startup':[opt_str, 'always', _('Show roster on startup.\n\'always\' - Always show roster.\n\'never\' - Never show roster.\n\'last_state\' - Restore the last state roster.')],
'show_avatar_in_chat': [opt_bool, True, _('If False, you will no longer see the avatar in the chat window.')],
'escape_key_closes': [opt_bool, True, _('If True, pressing the escape key closes a tab/window.')],
'compact_view': [opt_bool, False, _('Hides the buttons in chat windows.')],

View File

@ -183,6 +183,15 @@ class PreferencesWindow:
else:
self.one_window_type_combobox.set_active(0)
# Show roster on startup
show_roster_combobox = self.xml.get_object('show_roster_on_startup')
choices = common.config.opt_show_roster_on_startup
type_ = gajim.config.get('show_roster_on_startup')
if type_ in choices:
show_roster_combobox.set_active(choices.index(type_))
else:
show_roster_combobox.set_active(0)
# Compact View
st = gajim.config.get('compact_view')
self.xml.get_object('compact_view_checkbutton').set_active(st)
@ -685,6 +694,12 @@ class PreferencesWindow:
gajim.interface.save_config()
gajim.interface.msg_win_mgr.reconfig()
def on_show_roster_on_startup_changed(self, widget):
active = widget.get_active()
config_type = common.config.opt_show_roster_on_startup[active]
gajim.config.set('show_roster_on_startup', config_type)
gajim.interface.save_config()
def on_compact_view_checkbutton_toggled(self, widget):
active = widget.get_active()
for ctrl in self._get_all_controls():

View File

@ -2349,7 +2349,7 @@ class RosterWindow:
# then we want to save (i.e. the window will grow every startup)
# so adjust.
msgwin_width_adjust = -1 * width
gajim.config.set('show_roster_on_startup',
gajim.config.set('last_roster_visible',
self.window.get_property('visible'))
gajim.interface.msg_win_mgr.shutdown(msgwin_width_adjust)
@ -6310,13 +6310,17 @@ class RosterWindow:
self._toggeling_row = False
self.setup_and_draw_roster()
if gajim.config.get('show_roster_on_startup'):
if gajim.config.get('show_roster_on_startup') == 'always':
self.window.show_all()
else:
elif gajim.config.get('show_roster_on_startup') == 'never':
if gajim.config.get('trayicon') != 'always':
# Without trayicon, user should see the roster!
self.window.show_all()
gajim.config.set('show_roster_on_startup', True)
gajim.config.set('last_roster_visible', True)
else:
if gajim.config.get('last_roster_visible') or \
gajim.config.get('trayicon') != 'always':
self.window.show_all()
if len(gajim.connections) == 0: # if we have no account
def _open_wizard():