📄 configuration.py
字号:
#!/usr/bin/env python# -*- coding: utf-8 -*-# Copyright (C) 1994 Ling Li## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU Library General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.import gobject, gtk, gtk.gdk, gconffrom gtk import *from gconf import *import logging, os, stringfrom coralftp_globals import *from utils import *CONFIG_PREFIX = '/apps/coralftp'CONFIG_NAMES = { 'general' : { 'email_address' : (VALUE_STRING, Entry, 'entry_email_address'), 'default_download_path' : (VALUE_STRING, Entry, 'entry_default_download_path'), 'status_log_filename' : (VALUE_STRING, Entry, 'entry_status_log_filename'), 'enable_disk_based_logging' : (VALUE_BOOL, CheckButton, 'cb_enable_disk_based_logging'), 'trim_status_log_file' : (VALUE_BOOL, CheckButton, 'cb_trim_status_log_file'), 'status_log_file_size' : (VALUE_INT, Entry, 'spbtn_status_log_file_size'), 'connect_timeout' : (VALUE_INT, Entry, 'spbtn_connect_timeout'), 'connect_retry_delay' : (VALUE_INT, Entry, 'spbtn_connect_retry_delay'), 'scrollback_buffer' : (VALUE_INT, Entry, 'spbtn_scrollback_buffer'), 'connect_retry_count' : (VALUE_INT, Entry, 'spbtn_connect_retry_count'), 'send_keep_alive_command' : (VALUE_BOOL, CheckButton, 'cb_send_keep_alive'), 'keep_alive_command' : (VALUE_STRING, Entry, 'entry_keep_alive_command'), 'send_keep_alive_interval' : (VALUE_INT, Entry, 'spbtn_send_keep_alive_interval'), 'stop_send_keep_alive' : (VALUE_BOOL, CheckButton, 'cb_stop_send_keep_alive'), 'stop_keep_alive_after' : (VALUE_INT, Entry, 'spbtn_stop_keep_alive_after') }, 'display' : { 'display_site_name_in_caption':(VALUE_BOOL, CheckButton, 'cb_display_site_name_in_caption'), 'auto_size_file_list_columns': (VALUE_BOOL, CheckButton, 'cb_auto_size_file_list_columns'), 'auto_size_queue_list_columns':(VALUE_BOOL, CheckButton, 'cb_auto_size_queue_list_columns'), 'show_site_idle_time' : (VALUE_BOOL, CheckButton, 'cb_show_site_idle_time'), 'start_with_site_manager' : (VALUE_BOOL, CheckButton, 'cb_start_with_site_manager'), 'sort_folder_on_top' : (VALUE_BOOL, CheckButton, 'cb_sort_folder_on_top'), 'rules_hint' : (VALUE_BOOL, CheckButton, 'cb_rules_hint'), 'ftp_sort_by' : (VALUE_INT, RadioButton, ('radio_ftp_sort_by_name', 'radio_ftp_sort_by_owner', 'radio_ftp_sort_by_size', 'radio_ftp_sort_by_group', 'radio_ftp_sort_by_date', 'radio_ftp_sort_by_file_extension')), 'ftp_order' : (VALUE_INT, RadioButton, ('radio_ftp_sort_by_ascending', 'radio_ftp_sort_by_descending')), 'local_sort_by' : (VALUE_INT, RadioButton, ('radio_local_sort_by_name', 'radio_local_sort_by_type', 'radio_local_sort_by_size', 'radio_local_sort_by_date')), 'local_order' : (VALUE_INT, RadioButton, ('radio_local_sort_by_ascending', 'radio_local_sort_by_descending')), 'display_file_size_as' : (VALUE_STRING, ComboBoxEntry, 'cmbentry_display_file_size_as', ('OnlyInList','NoFocus')), } }COLOR_FONT_CONFIG_NAMES = { 'display' : { 'active_side_indicator_color' : (VALUE_STRING, ColorButton, 'cbtn_active_side_indicator'), 'command_text_color' : (VALUE_STRING, ColorButton, 'cbtn_command_text'), 'left_ftp_reply_color' : (VALUE_STRING, ColorButton, 'cbtn_left_ftp_reply_text'), 'right_ftp_reply_color' : (VALUE_STRING, ColorButton, 'cbtn_right_ftp_reply_text'), 'error_text_color' : (VALUE_STRING, ColorButton, 'cbtn_error_text'), 'misc_text_color' : (VALUE_STRING, ColorButton, 'cbtn_misc_text'), 'queue_complete_text_color' : (VALUE_STRING, ColorButton, 'cbtn_queue_complete_text'), 'background_color' : (VALUE_STRING, ColorButton, 'cbtn_background'), 'use_custom_file_listing_font' :(VALUE_BOOL, CheckButton, 'cb_file_listing'), 'file_listing_font' : (VALUE_STRING, FontButton, 'fbtn_file_listing'), 'use_custom_status_font' : (VALUE_BOOL, CheckButton, 'cb_status'), 'status_font' : (VALUE_STRING, FontButton, 'fbtn_status'), 'use_custom_queue_font' : (VALUE_BOOL, CheckButton, 'cb_queue'), 'queue_font' : (VALUE_STRING, FontButton, 'fbtn_queue'), } }def config_key(group, keyname): return '%s/%s/%s' % (CONFIG_PREFIX, group, keyname)def config_value(config, group, keyname): key = '%s/%s/%s' % (CONFIG_PREFIX, group, keyname) if CONFIG_NAMES[group].has_key(keyname): setting = CONFIG_NAMES[group][keyname] else: setting = COLOR_FONT_CONFIG_NAMES[group][keyname] if setting[0] == VALUE_STRING: return config.get_string(key) elif setting[0] == VALUE_INT: return config.get_int(key) elif setting[0] == VALUE_BOOL: return config.get_bool(key) def gconf_to_widgets(config_prefix, config_names, config, xml): """Load settings from gconf database.""" for group, settings in config_names.items(): for keyname, setting in settings.items(): key = '%s/%s/%s' % (config_prefix, group, keyname) if setting[0] == gconf.VALUE_STRING: value = config.get_string(key) elif setting[0] == gconf.VALUE_INT: value = config.get_int(key) elif setting[0] == gconf.VALUE_BOOL: value = config.get_bool(key) else: raise ValueError if setting[1] == RadioButton: widget = xml.get_widget(setting[2][value]) widget.set_property('active', TRUE) elif setting[1] == Entry: widget = xml.get_widget(setting[2]) widget.set_property('text', value) elif setting[1] == ComboBoxEntry: widget = xml.get_widget(setting[2]) model = widget.get_model() iter = model.get_iter_first() while iter: if value == model.get_path(iter).__str__(): break iter = model.iter_next(iter) if iter != None: widget.set_active_iter(iter) if 'OnlyInList' in setting[3]: widget.child.set_property('editable', False) if 'NoFocus' in setting[3]: widget.child.set_property('can-focus', False) elif setting[1] == CheckButton: widget = xml.get_widget(setting[2]) widget.set_property('active', value) elif setting[1] == ColorButton: if value == None: value = '#000000' widget = xml.get_widget(setting[2]) widget.set_property('color', gdk.color_parse(value))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -