Logo Search packages:      
Sourcecode: gajim version File versions  Download package

def config::PreferencesWindow::__init__ (   self  ) 

Initialize Preferences window

Definition at line 61 of file config.py.

00061                         :
            '''Initialize Preferences window'''
            self.xml = gtk.glade.XML(GTKGUI_GLADE, 'preferences_window', APP)
            self.window = self.xml.get_widget('preferences_window')
            self.iconset_combobox = self.xml.get_widget('iconset_combobox')
            self.notify_on_new_message_radiobutton = self.xml.get_widget(
                  'notify_on_new_message_radiobutton')
            self.popup_new_message_radiobutton = self.xml.get_widget(
                  'popup_new_message_radiobutton')
            self.notify_on_signin_checkbutton = self.xml.get_widget(
                  'notify_on_signin_checkbutton')
            self.notify_on_signout_checkbutton = self.xml.get_widget(
                  'notify_on_signout_checkbutton')
            self.auto_popup_away_checkbutton = self.xml.get_widget(
                  'auto_popup_away_checkbutton')
            self.auto_away_checkbutton = self.xml.get_widget('auto_away_checkbutton')
            self.auto_away_time_spinbutton = self.xml.get_widget(
                  'auto_away_time_spinbutton')
            self.auto_away_message_entry = self.xml.get_widget(
                  'auto_away_message_entry')
            self.auto_xa_checkbutton = self.xml.get_widget('auto_xa_checkbutton')
            self.auto_xa_time_spinbutton = self.xml.get_widget(
                  'auto_xa_time_spinbutton')
            self.auto_xa_message_entry = self.xml.get_widget('auto_xa_message_entry')
            self.trayicon_checkbutton = self.xml.get_widget('trayicon_checkbutton')
            self.notebook = self.xml.get_widget('preferences_notebook')
            self.one_window_type_combobox =\
                  self.xml.get_widget('one_window_type_combobox')

            #trayicon
            if gajim.interface.systray_capabilities:
                  st = gajim.config.get('trayicon')
                  self.trayicon_checkbutton.set_active(st)
            else:
                  self.trayicon_checkbutton.set_sensitive(False)

            #Save position
            st = gajim.config.get('saveposition')
            self.xml.get_widget('save_position_checkbutton').set_active(st)

            # Sort contacts by show
            st = gajim.config.get('sort_by_show')
            self.xml.get_widget('sort_by_show_checkbutton').set_active(st)

            # Display avatars in roster
            st = gajim.config.get('show_avatars_in_roster')
            self.xml.get_widget('show_avatars_in_roster_checkbutton').set_active(st)

            # Display status msg under contact name in roster
            st = gajim.config.get('show_status_msgs_in_roster')
            self.xml.get_widget('show_status_msgs_in_roster_checkbutton').set_active(
                  st)

            # emoticons
            emoticons_combobox = self.xml.get_widget('emoticons_combobox')
            emoticons_list = os.listdir(os.path.join(gajim.DATA_DIR, 'emoticons'))
            # user themes
            if os.path.isdir(gajim.MY_EMOTS_PATH):
                  emoticons_list += os.listdir(gajim.MY_EMOTS_PATH)
            renderer_text = gtk.CellRendererText()
            emoticons_combobox.pack_start(renderer_text, True)
            emoticons_combobox.add_attribute(renderer_text, 'text', 0)
            model = gtk.ListStore(str)
            emoticons_combobox.set_model(model)
            l = []
            for dir in emoticons_list:
                  if dir != '.svn':
                        l.append(dir)
            l.append('Disabled')
            for i in xrange(len(l)):
                  model.append([l[i]])
                  if gajim.config.get('emoticons_theme') == l[i]:
                        emoticons_combobox.set_active(i)
            if not gajim.config.get('emoticons_theme'):
                  emoticons_combobox.set_active(len(l)-1)

            #iconset
            iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets'))
            # new model, image in 0, string in 1
            model = gtk.ListStore(gtk.Image, str)
            renderer_image = cell_renderer_image.CellRendererImage(0, 0)
            renderer_text = gtk.CellRendererText()
            renderer_text.set_property('xpad', 5)
            self.iconset_combobox.pack_start(renderer_image, expand = False)
            self.iconset_combobox.pack_start(renderer_text, expand = True)
            self.iconset_combobox.set_attributes(renderer_text, text = 1)
            self.iconset_combobox.add_attribute(renderer_image, 'image', 0)
            self.iconset_combobox.set_model(model)
            l = []
            for dir in iconsets_list:
                  if dir != '.svn' and dir != 'transports':
                        l.append(dir)
            if l.count == 0:
                  l.append(' ')
            for i in xrange(len(l)):
                  preview = gtk.Image()
                  files = []
                  files.append(os.path.join(gajim.DATA_DIR, 'iconsets', l[i], '16x16', 'online.png'))
                  files.append(os.path.join(gajim.DATA_DIR, 'iconsets', l[i], '16x16', 'online.gif'))
                  for file in files:
                        if os.path.exists(file):
                              preview.set_from_file(file)
                  model.append([preview, l[i]])
                  if gajim.config.get('iconset') == l[i]:
                        self.iconset_combobox.set_active(i)

            # Set default for single window type
            choices = common.config.opt_one_window_types
            type = gajim.config.get('one_message_window')
            if type in choices:
                  self.one_window_type_combobox.set_active(choices.index(type))
            else:
                  self.one_window_type_combobox.set_active(0)

            # Use transports iconsets
            st = gajim.config.get('use_transports_iconsets')
            self.xml.get_widget('transports_iconsets_checkbutton').set_active(st)

            # Themes
            theme_combobox = self.xml.get_widget('theme_combobox')
            cell = gtk.CellRendererText()
            theme_combobox.pack_start(cell, True)
            theme_combobox.add_attribute(cell, 'text', 0)
            model = gtk.ListStore(str)
            theme_combobox.set_model(model)
            
            i = 0
            for config_theme in gajim.config.get_per('themes'):
                  theme = config_theme.replace('_', ' ')
                  model.append([theme])
                  if gajim.config.get('roster_theme') == config_theme:
                           theme_combobox.set_active(i)
                  i += 1
            self.on_theme_combobox_changed(theme_combobox)

            #use speller
            if os.name == 'nt':
                  self.xml.get_widget('speller_checkbutton').set_no_show_all(True)
            else:
                  if HAS_GTK_SPELL:
                        st = gajim.config.get('use_speller')
                        self.xml.get_widget('speller_checkbutton').set_active(st)
                  else:
                        self.xml.get_widget('speller_checkbutton').set_sensitive(False)

            #Print time
            st = gajim.config.get('print_ichat_every_foo_minutes')
            text = _('Every %s _minutes') % st
            self.xml.get_widget('time_sometimes_radiobutton').set_label(text)

            if gajim.config.get('print_time') == 'never':
                  self.xml.get_widget('time_never_radiobutton').set_active(True)
                  self._set_sensitivity_for_before_after_time_widgets(False)
            elif gajim.config.get('print_time') == 'sometimes':
                  self.xml.get_widget('time_sometimes_radiobutton').set_active(True)
                  self._set_sensitivity_for_before_after_time_widgets(False)
            else:
                  self.xml.get_widget('time_always_radiobutton').set_active(True)

            #before time
            st = gajim.config.get('before_time')
            self.xml.get_widget('before_time_entry').set_text(st)

            #after time
            st = gajim.config.get('after_time')
            self.xml.get_widget('after_time_entry').set_text(st)

            #before nickname
            st = gajim.config.get('before_nickname')
            self.xml.get_widget('before_nickname_entry').set_text(st)

            #after nickanme
            st = gajim.config.get('after_nickname')
            self.xml.get_widget('after_nickname_entry').set_text(st)

            #Color for incomming messages
            colSt = gajim.config.get('inmsgcolor')
            self.xml.get_widget('incoming_msg_colorbutton').set_color(
                  gtk.gdk.color_parse(colSt))

            #Color for outgoing messages
            colSt = gajim.config.get('outmsgcolor')
            self.xml.get_widget('outgoing_msg_colorbutton').set_color(
                  gtk.gdk.color_parse(colSt))

            #Color for status messages
            colSt = gajim.config.get('statusmsgcolor')
            self.xml.get_widget('status_msg_colorbutton').set_color(
                  gtk.gdk.color_parse(colSt))
            
            #Color for hyperlinks
            colSt = gajim.config.get('urlmsgcolor')
            self.xml.get_widget('url_msg_colorbutton').set_color(
                  gtk.gdk.color_parse(colSt))

            #Font for messages
            font = gajim.config.get('conversation_font')
            # try to set default font for the current desktop env
            if font == '':
                  font = gtkgui_helpers.get_default_font()
                  if font is None:
                        font = 'Sans 10'
                  gajim.config.set('conversation_font', font)
            self.xml.get_widget('conversation_fontbutton').set_font_name(font)

            # on new message
            only_in_roster = True
            if gajim.config.get('notify_on_new_message'):
                  self.xml.get_widget('notify_on_new_message_radiobutton').set_active(
                        True)
                  only_in_roster = False
            if gajim.config.get('autopopup'):
                  self.xml.get_widget('popup_new_message_radiobutton').set_active(True)
                  only_in_roster = False
            if only_in_roster:
                  self.xml.get_widget('only_in_roster_radiobutton').set_active(True)

            #notify on online statuses
            st = gajim.config.get('notify_on_signin')
            self.notify_on_signin_checkbutton.set_active(st)

            #notify on offline statuses
            st = gajim.config.get('notify_on_signout')
            self.notify_on_signout_checkbutton.set_active(st)

            #autopopupaway
            st = gajim.config.get('autopopupaway')
            self.auto_popup_away_checkbutton.set_active(st)

            #Ignore messages from unknown contacts
            self.xml.get_widget('ignore_events_from_unknown_contacts_checkbutton').\
                  set_active(gajim.config.get('ignore_unknown_contacts'))

            # send chat state notifications
            st = gajim.config.get('chat_state_notifications')
            combo = self.xml.get_widget('chat_states_combobox')
            if st == 'all':
                  combo.set_active(0)
            elif st == 'composing_only':
                  combo.set_active(1)
            else: # disabled
                  combo.set_active(2)

            #sounds
            if os.name == 'nt': # if windows, player must not become visible on show_all
                  soundplayer_hbox = self.xml.get_widget('soundplayer_hbox')
                  soundplayer_hbox.set_no_show_all(True)
            if gajim.config.get('sounds_on'):
                  self.xml.get_widget('play_sounds_checkbutton').set_active(True)
            else:
                  self.xml.get_widget('soundplayer_hbox').set_sensitive(False)
                  self.xml.get_widget('sounds_scrolledwindow').set_sensitive(False)
                  self.xml.get_widget('browse_sounds_hbox').set_sensitive(False)

            # sound player
            player = gajim.config.get('soundplayer')
            self.xml.get_widget('soundplayer_entry').set_text(player)
            if player == '': # only on first time Gajim starts
                  commands = ('aplay', 'play', 'esdplay', 'artsplay')
                  for command in commands:
                        if helpers.is_in_path(command):
                              self.xml.get_widget('soundplayer_entry').set_text(command)
                              gajim.config.set('soundplayer', command)
                              break

            #sounds treeview
            self.sound_tree = self.xml.get_widget('sounds_treeview')
            
            # active, event ui name, path to sound file, event_config_name
            model = gtk.ListStore(bool, str, str, str)
            self.sound_tree.set_model(model)

            col = gtk.TreeViewColumn(_('Active'))
            self.sound_tree.append_column(col)
            renderer = gtk.CellRendererToggle()
            renderer.set_property('activatable', True)
            renderer.connect('toggled', self.sound_toggled_cb)
            col.pack_start(renderer)
            col.set_attributes(renderer, active = 0)

            col = gtk.TreeViewColumn(_('Event'))
            self.sound_tree.append_column(col)
            renderer = gtk.CellRendererText()
            col.pack_start(renderer)
            col.set_attributes(renderer, text = 1)

            self.fill_sound_treeview()

            #Autoaway
            st = gajim.config.get('autoaway')
            self.auto_away_checkbutton.set_active(st)

            #Autoawaytime
            st = gajim.config.get('autoawaytime')
            self.auto_away_time_spinbutton.set_value(st)
            self.auto_away_time_spinbutton.set_sensitive(gajim.config.get('autoaway'))

            #autoaway message
            st = gajim.config.get('autoaway_message')
            self.auto_away_message_entry.set_text(st)
            self.auto_away_message_entry.set_sensitive(gajim.config.get('autoaway'))

            #Autoxa
            st = gajim.config.get('autoxa')
            self.auto_xa_checkbutton.set_active(st)

            #Autoxatime
            st = gajim.config.get('autoxatime')
            self.auto_xa_time_spinbutton.set_value(st)
            self.auto_xa_time_spinbutton.set_sensitive(gajim.config.get('autoxa'))

            #autoxa message
            st = gajim.config.get('autoxa_message')
            self.auto_xa_message_entry.set_text(st)
            self.auto_xa_message_entry.set_sensitive(gajim.config.get('autoxa'))

            #ask_status when online / offline
            st = gajim.config.get('ask_online_status')
            self.xml.get_widget('prompt_online_status_message_checkbutton').\
                  set_active(st)
            st = gajim.config.get('ask_offline_status')
            self.xml.get_widget('prompt_offline_status_message_checkbutton').\
                  set_active(st)

            #Status messages
            self.msg_tree = self.xml.get_widget('msg_treeview')
            model = gtk.ListStore(str, str)
            self.msg_tree.set_model(model)
            col = gtk.TreeViewColumn('name')
            self.msg_tree.append_column(col)
            renderer = gtk.CellRendererText()
            col.pack_start(renderer, True)
            col.set_attributes(renderer, text = 0)
            renderer.connect('edited', self.on_msg_cell_edited)
            renderer.set_property('editable', True)
            self.fill_msg_treeview()
            buf = self.xml.get_widget('msg_textview').get_buffer()
            buf.connect('changed', self.on_msg_textview_changed)

            #open links with
            if os.name == 'nt':
                  applications_frame = self.xml.get_widget('applications_frame')
                  applications_frame.set_no_show_all(True)
                  applications_frame.hide()
            else:
                  self.applications_combobox = self.xml.get_widget(
                        'applications_combobox')
                  self.xml.get_widget('custom_apps_frame').hide()
                  self.xml.get_widget('custom_apps_frame').set_no_show_all(True)
                  if gajim.config.get('autodetect_browser_mailer'):
                        self.applications_combobox.set_active(0)
                        gtkgui_helpers.autodetect_browser_mailer()
                  # autodetect_browser_mailer is now False.
                  # so user has 'Always Use GNOME/KDE' or Custom
                  elif gajim.config.get('openwith') == 'gnome-open':
                        self.applications_combobox.set_active(1)
                  elif gajim.config.get('openwith') == 'kfmclient exec':
                        self.applications_combobox.set_active(2)
                  elif gajim.config.get('openwith') == 'custom':
                        self.applications_combobox.set_active(3)
                        self.xml.get_widget('custom_apps_frame').show()
                        
                  self.xml.get_widget('custom_browser_entry').set_text(
                        gajim.config.get('custombrowser'))
                  self.xml.get_widget('custom_mail_client_entry').set_text(
                        gajim.config.get('custommailapp'))
                  self.xml.get_widget('custom_file_manager_entry').set_text(
                        gajim.config.get('custom_file_manager'))

            # log status changes of contacts
            st = gajim.config.get('log_contact_status_changes')
            self.xml.get_widget('log_show_changes_checkbutton').set_active(st)

            # send os info
            st = gajim.config.get('send_os_info')
            self.xml.get_widget('send_os_info_checkbutton').set_active(st)
            
            # Notify user of new gmail e-mail messages,
            # only show checkbox if user has a gtalk account
            notify_gmail_checkbutton = self.xml.get_widget('notify_gmail_checkbutton')
            notify_gmail_checkbutton.set_no_show_all(True)
            for account in gajim.config.get_per('accounts'):
                  jid = gajim.get_jid_from_account(account)
                  if gajim.get_server_from_jid(jid) == 'gmail.com':
                        st = gajim.config.get('notify_on_new_gmail_email')
                        notify_gmail_checkbutton.set_active(st)
                        notify_gmail_checkbutton.show()
                        break
            else:
                  notify_gmail_checkbutton.hide()
            
            self.xml.signal_autoconnect(self)

            self.sound_tree.get_model().connect('row-changed',
                              self.on_sounds_treemodel_row_changed)
            self.msg_tree.get_model().connect('row-changed',
                              self.on_msg_treemodel_row_changed)
            self.msg_tree.get_model().connect('row-deleted',
                              self.on_msg_treemodel_row_deleted)
            
            self.theme_preferences = None
            
            self.notebook.set_current_page(0)
            self.window.show_all()

      def on_preferences_window_key_press_event(self, widget, event):


Generated by  Doxygen 1.6.0   Back to index