本文整理汇总了Python中ubuntutweak.settings.GSetting.get_value方法的典型用法代码示例。如果您正苦于以下问题:Python GSetting.get_value方法的具体用法?Python GSetting.get_value怎么用?Python GSetting.get_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ubuntutweak.settings.GSetting
的用法示例。
在下文中一共展示了GSetting.get_value方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UbuntuTweakWindow
# 需要导入模块: from ubuntutweak.settings import GSetting [as 别名]
# 或者: from ubuntutweak.settings.GSetting import get_value [as 别名]
#.........这里部分代码省略.........
self.search_page.connect('module_selected', self.on_module_selected)
admins_page.connect('module_selected', self.on_module_selected)
self.apps_page.connect('loaded', self.show_apps_page)
clip_page.connect('load_module', lambda widget, name: self.do_load_module(name))
clip_page.connect('load_feature', lambda widget, name: self.select_target_feature(name))
self.mainwindow.show()
if module:
self.do_load_module(module)
elif feature:
self.select_target_feature(feature)
accel_group = Gtk.AccelGroup()
self.search_entry.add_accelerator('activate',
accel_group,
Gdk.KEY_f,
Gdk.ModifierType.CONTROL_MASK,
Gtk.AccelFlags.VISIBLE)
self.mainwindow.add_accel_group(accel_group)
thread.start_new_thread(self.preload_proxy_cache, ())
def show_apps_page(self, widget):
self.notebook.set_current_page(self.feature_dict['apps'])
def preload_proxy_cache(self):
#This function just called to make sure the cache is loaded as soon as possible
proxy.is_package_installed('ubuntu-tweak')
def on_search_entry_activate(self, widget):
widget.grab_focus()
self.on_search_entry_changed(widget)
def on_search_entry_changed(self, widget):
text = widget.get_text()
self.set_current_module(None, None)
if text:
self.notebook.set_current_page(self.feature_dict['search'])
self.search_page.search(text)
self.search_entry.set_property('secondary-icon-name', 'edit-clear')
else:
self.on_feature_button_clicked(getattr(self, '%s_button' % self.current_feature), self.current_feature)
self.search_page.clean()
self.search_entry.set_property('secondary-icon-name', 'edit-find')
def on_search_entry_icon_press(self, widget, icon_pos, event):
widget.set_text('')
def get_module_and_index(self, name):
index = self.loaded_modules[name]
return self.modules_index[index], index
def select_target_feature(self, text):
toggle_button = getattr(self, '%s_button' % text, None)
log.info("select_target_feature: %s" % text)
if toggle_button:
self.current_feature = text
toggle_button.set_active(True)
def _initialize_ui_states(self, widget, splash_window):
self.window_size_setting = GSetting('com.ubuntu-tweak.tweak.window-size')
width, height = self.window_size_setting.get_value()
if width >= 900 and height >= 506:
self.mainwindow.set_default_size(width, height)
for feature_button in ('overview_button', 'apps_button', 'admins_button', \
'tweaks_button', 'janitor_button'):
button = getattr(self, feature_button)
label = button.get_child().get_label()
button.get_child().set_markup('<b>%s</b>' % label)
button.get_child().set_use_underline(True)
splash_window.destroy()
def _crete_wait_page(self):
vbox = Gtk.VBox()
label = Gtk.Label()
label.set_markup("<span size=\"xx-large\">%s</span>" % \
_('Please wait a moment...'))
label.set_justify(Gtk.Justification.FILL)
vbox.pack_start(label, False, False, 50)
hbox = Gtk.HBox()
vbox.pack_start(hbox, False, False, 0)
vbox.show_all()
return vbox
def on_mainwindow_destroy(self, widget=None):
allocation = widget.get_allocation()
self.window_size_setting.set_value((allocation.width, allocation.height))
Gtk.main_quit()
try:
proxy.exit()
except Exception, e:
log.error(e)
示例2: JanitorPage
# 需要导入模块: from ubuntutweak.settings import GSetting [as 别名]
# 或者: from ubuntutweak.settings.GSetting import get_value [as 别名]
class JanitorPage(Gtk.VBox, GuiBuilder):
(JANITOR_CHECK,
JANITOR_ICON,
JANITOR_NAME,
JANITOR_DISPLAY,
JANITOR_PLUGIN,
JANITOR_SPINNER_ACTIVE,
JANITOR_SPINNER_PULSE) = range(7)
(RESULT_CHECK,
RESULT_ICON,
RESULT_NAME,
RESULT_DISPLAY,
RESULT_DESC,
RESULT_PLUGIN,
RESULT_CRUFT) = range(7)
max_janitor_view_width = 0
def __init__(self):
GObject.GObject.__init__(self)
self.scan_tasks = []
self.clean_tasks = []
self._total_count = 0
self.set_border_width(6)
GuiBuilder.__init__(self, 'janitorpage.ui')
self.autoscan_setting = GSetting('com.ubuntu-tweak.janitor.auto-scan')
self.autoscan_setting.connect_notify(self.on_autoscan_button_toggled)
self.plugins_setting = GSetting('com.ubuntu-tweak.janitor.plugins')
self.view_width_setting = GSetting('com.ubuntu-tweak.janitor.janitor-view-width')
self.pack_start(self.vbox1, True, True, 0)
self.connect('realize', self.setup_ui_tasks)
self.janitor_view.get_selection().connect('changed', self.on_janitor_selection_changed)
self.plugins_setting.connect_notify(self.update_model, True)
self.show()
def on_move_handle(self, widget, gproperty):
log.debug("on_move_handle: %d", widget.get_property('position'))
self.view_width_setting.set_value(widget.get_property('position'))
# cancel the size request, or it will fail to resize
# TODO why the first scan will make it fail?
self.janitor_view.set_size_request(self.max_janitor_view_width, -1)
def is_auto_scan(self):
return self.autoscan_setting.get_value()
@log_func(log)
def on_result_view_row_activated(self, treeview, path, column):
iter = self.result_model.get_iter(path)
cruft = self.result_model[iter][self.RESULT_CRUFT]
display = self.result_model[iter][self.RESULT_DISPLAY]
if 'red' in display:
plugin = self.result_model[iter][self.RESULT_PLUGIN]
error = plugin.get_property('error')
self.result_model[iter][self.RESULT_DISPLAY] = '<span color="red"><b>%s</b></span>' % error
elif hasattr(cruft, 'get_path'):
path = cruft.get_path()
if not os.path.isdir(path):
path = os.path.dirname(path)
os.system("xdg-open '%s' &" % path)
def setup_ui_tasks(self, widget):
self.janitor_model.set_sort_column_id(self.JANITOR_NAME, Gtk.SortType.ASCENDING)
#add janitor columns
janitor_column = Gtk.TreeViewColumn()
renderer = Gtk.CellRendererToggle()
renderer.connect('toggled', self.on_janitor_check_button_toggled)
janitor_column.pack_start(renderer, False)
janitor_column.add_attribute(renderer, 'active', self.JANITOR_CHECK)
self.janitor_view.append_column(janitor_column)
janitor_column = Gtk.TreeViewColumn()
renderer = Gtk.CellRendererPixbuf()
janitor_column.pack_start(renderer, False)
janitor_column.add_attribute(renderer, 'pixbuf', self.JANITOR_ICON)
janitor_column.set_cell_data_func(renderer,
self.icon_column_view_func,
self.JANITOR_ICON)
renderer = Gtk.CellRendererText()
renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
janitor_column.pack_start(renderer, True)
janitor_column.add_attribute(renderer, 'markup', self.JANITOR_DISPLAY)
renderer = Gtk.CellRendererSpinner()
janitor_column.pack_start(renderer, False)
janitor_column.add_attribute(renderer, 'active', self.JANITOR_SPINNER_ACTIVE)
janitor_column.add_attribute(renderer, 'pulse', self.JANITOR_SPINNER_PULSE)
#.........这里部分代码省略.........
示例3: JanitorPage
# 需要导入模块: from ubuntutweak.settings import GSetting [as 别名]
# 或者: from ubuntutweak.settings.GSetting import get_value [as 别名]
#.........这里部分代码省略.........
janitor_column.add_attribute(renderer, 'active', self.JANITOR_SPINNER_ACTIVE)
janitor_column.add_attribute(renderer, 'pulse', self.JANITOR_SPINNER_PULSE)
self.janitor_view.append_column(janitor_column)
#end janitor columns
#add result columns
result_column = Gtk.TreeViewColumn()
renderer = Gtk.CellRendererToggle()
renderer.connect('toggled', self.on_result_check_renderer_toggled)
result_column.pack_start(renderer, False)
result_column.add_attribute(renderer, 'active', self.RESULT_CHECK)
renderer = Gtk.CellRendererPixbuf()
result_column.pack_start(renderer, False)
result_column.add_attribute(renderer, 'pixbuf', self.RESULT_ICON)
result_column.set_cell_data_func(renderer,
self.icon_column_view_func,
self.RESULT_ICON)
renderer = Gtk.CellRendererText()
renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
result_column.pack_start(renderer, True)
result_column.add_attribute(renderer, 'markup', self.RESULT_DISPLAY)
renderer = Gtk.CellRendererText()
result_column.pack_start(renderer, False)
result_column.add_attribute(renderer, 'text', self.RESULT_DESC)
self.result_view.append_column(result_column)
#end result columns
auto_scan = self.autoscan_setting.get_value()
log.info("Auto scan status: %s", auto_scan)
self.scan_button.set_visible(not auto_scan)
self.autoscan_button.set_active(auto_scan)
self.update_model()
self._expand_janitor_view()
def _expand_janitor_view(self):
self.janitor_view.expand_all()
if self.max_janitor_view_width:
self.janitor_view.set_size_request(self.max_janitor_view_width, -1)
def set_busy(self):
self.get_parent_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
def unset_busy(self):
self.get_parent_window().set_cursor(None)
def on_janitor_selection_changed(self, selection):
model, iter = selection.get_selected()
if iter:
if self.janitor_model.iter_has_child(iter):
iter = self.janitor_model.iter_children(iter)
plugin = model[iter][self.JANITOR_PLUGIN]
for row in self.result_model:
if row[self.RESULT_PLUGIN] == plugin:
self.result_view.get_selection().select_path(row.path)
self.result_view.scroll_to_cell(row.path)
示例4: FeaturePage
# 需要导入模块: from ubuntutweak.settings import GSetting [as 别名]
# 或者: from ubuntutweak.settings.GSetting import get_value [as 别名]
class FeaturePage(Gtk.ScrolledWindow):
__gsignals__ = {
'module_selected': (GObject.SignalFlags.RUN_FIRST,
None,
(GObject.TYPE_STRING,))
}
_categories = None
_boxes = []
def __str__(self):
return '<FeaturePage: %s>' % self._feature
def __init__(self, feature_name):
GObject.GObject.__init__(self,
hscrollbar_policy=Gtk.PolicyType.NEVER,
vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
self.set_property('shadow-type', Gtk.ShadowType.NONE)
self.set_border_width(12)
self._feature = feature_name
self._setting = GSetting('com.ubuntu-tweak.tweak.%s' % feature_name)
self._categories = {}
self._boxes = []
self._box = Gtk.VBox(spacing=6)
viewport = Gtk.Viewport()
viewport.set_property('shadow-type', Gtk.ShadowType.NONE)
viewport.add(self._box)
self.add(viewport)
self.load_modules()
# TODO this will cause Bug #880663 randomly, as current there's no user extension for features, just disable it
# self._setting.connect_notify(self.load_modules)
self.show_all()
def load_modules(self, *args, **kwargs):
log.debug("Loading modules...")
loader = ModuleLoader(self._feature)
self._boxes = []
for child in self._box.get_children():
self._box.remove(child)
for category, category_name in loader.get_categories():
modules = loader.get_modules_by_category(category)
if modules:
module_to_loads = self._setting.get_value()
for module in modules:
if module.is_user_extension() and module.get_name() not in module_to_loads:
modules.remove(module)
category_box = CategoryBox(modules=modules, category_name=category_name)
self._connect_signals(category_box)
self._boxes.append(category_box)
self._box.pack_start(category_box, False, False, 0)
self.rebuild_boxes()
def _connect_signals(self, category_box):
for button in category_box.get_buttons():
button.connect('clicked', self.on_button_clicked)
def on_button_clicked(self, widget):
log.info('Button clicked')
module = widget.get_module()
self.emit('module_selected', module.get_name())
def rebuild_boxes(self, widget=None, event=None):
request = self.get_allocation()
ncols = request.width / 164 # 32 + 120 + 6 + 4
width = ncols * (164 + 2 * 4) + 40
if width > request.width:
ncols -= 1
pos = 0
children = self._box.get_children()
for box in self._boxes:
modules = box.get_modules()
if len (modules) == 0:
if box in children:
self._box.remove(box)
else:
if box not in children:
self._box.pack_start(box, False, False, 0)
self._box.reorder_child(box, pos)
box.rebuild_table(ncols)
pos += 1
示例5: UbuntuTweakWindow
# 需要导入模块: from ubuntutweak.settings import GSetting [as 别名]
# 或者: from ubuntutweak.settings.GSetting import get_value [as 别名]
class UbuntuTweakWindow(GuiBuilder):
current_feature = "overview"
feature_dict = {}
navigation_dict = {"tweaks": [None, None]}
# the module name and page index: 'Compiz': 2
loaded_modules = {}
# reversed dict: 2: 'CompizClass'
modules_index = {}
def __init__(self, feature="", module=""):
GuiBuilder.__init__(self, file_name="mainwindow.ui")
tweaks_page = FeaturePage("tweaks")
admins_page = FeaturePage("admins")
clip_page = ClipPage()
apps_page = AppsPage()
janitor_page = JanitorPage()
self.preferences_dialog = PreferencesDialog(self.mainwindow)
self.rencently_used_settings = GSetting("com.ubuntu-tweak.tweak.rencently-used")
self.feature_dict["overview"] = self.notebook.append_page(clip_page, Gtk.Label())
self.feature_dict["apps"] = self.notebook.append_page(apps_page, Gtk.Label())
self.feature_dict["tweaks"] = self.notebook.append_page(tweaks_page, Gtk.Label())
self.feature_dict["admins"] = self.notebook.append_page(admins_page, Gtk.Label())
self.feature_dict["janitor"] = self.notebook.append_page(janitor_page, Gtk.Label())
self.feature_dict["wait"] = self.notebook.append_page(self._crete_wait_page(), Gtk.Label())
# Always show welcome page at first
self.mainwindow.connect("realize", self._initialize_ui_states)
tweaks_page.connect("module_selected", self.on_module_selected)
admins_page.connect("module_selected", self.on_module_selected)
clip_page.connect("load_module", lambda widget, name: self.do_load_module(name))
clip_page.connect("load_feature", lambda widget, name: self.select_target_feature(name))
self.mainwindow.show()
self.link_button.hide()
if module:
self.do_load_module(module)
elif feature:
self.select_target_feature(feature)
# TODO remove when natty is deprecated
def on_header_button_press_event(self, widget, event):
self.mainwindow.begin_move_drag(event.button, event.x_root, event.y_root, event.time)
def get_module_and_index(self, name):
index = self.loaded_modules[name]
return self.modules_index[index], index
def select_target_feature(self, text):
toggle_button = getattr(self, "%s_button" % text, None)
log.info("select_target_feature: %s" % text)
if toggle_button:
self.current_feature = text
toggle_button.set_active(True)
def _initialize_ui_states(self, widget):
# TODO implement the search feature
self.window_size_setting = GSetting("com.ubuntu-tweak.tweak.window-size")
width, height = self.window_size_setting.get_value()
if width >= 800 and height >= 480:
self.mainwindow.set_default_size(width, height)
self.search_entry.hide()
def _crete_wait_page(self):
vbox = Gtk.VBox()
label = Gtk.Label()
label.set_markup('<span size="xx-large">%s</span>' % _("Please wait a moment..."))
label.set_justify(Gtk.Justification.FILL)
vbox.pack_start(label, False, False, 50)
hbox = Gtk.HBox()
vbox.pack_start(hbox, False, False, 0)
vbox.show_all()
return vbox
def on_mainwindow_destroy(self, widget):
allocation = widget.get_allocation()
self.window_size_setting.set_value((allocation.width, allocation.height))
Gtk.main_quit()
try:
proxy.exit()
except Exception, e:
log.error(e)
示例6: FeaturePage
# 需要导入模块: from ubuntutweak.settings import GSetting [as 别名]
# 或者: from ubuntutweak.settings.GSetting import get_value [as 别名]
class FeaturePage(Gtk.ScrolledWindow):
__gsignals__ = {"module_selected": (GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_STRING,))}
_categories = None
_boxes = []
def __init__(self, feature_name):
GObject.GObject.__init__(
self,
shadow_type=Gtk.ShadowType.NONE,
hscrollbar_policy=Gtk.PolicyType.NEVER,
vscrollbar_policy=Gtk.PolicyType.AUTOMATIC,
)
self.set_border_width(12)
self._feature = feature_name
self._setting = GSetting("com.ubuntu-tweak.tweak.%s" % feature_name)
self._categories = {}
self._boxes = []
self._box = Gtk.VBox(spacing=6)
viewport = Gtk.Viewport(shadow_type=Gtk.ShadowType.NONE)
viewport.add(self._box)
self.add(viewport)
self.load_modules()
self.connect("draw", self.rebuild_boxes)
self._setting.connect_notify(self.load_modules, True)
self.show_all()
def load_modules(self, a=None, b=None, remove=False):
log.debug("Load modules, remove: %s" % remove)
loader = ModuleLoader(self._feature)
if remove:
self._boxes = []
for child in self._box.get_children():
self._box.remove(child)
for category, category_name in loader.get_categories():
modules = loader.get_modules_by_category(category)
if modules:
module_to_loads = self._setting.get_value()
for module in modules:
if module.is_user_extension() and module.get_name() not in module_to_loads:
modules.remove(module)
category_box = CategoryBox(modules=modules, category_name=category_name)
self._connect_signals(category_box)
self._boxes.append(category_box)
self._box.pack_start(category_box, False, False, 0)
if remove:
self.rebuild_boxes()
def _connect_signals(self, category_box):
for button in category_box.get_buttons():
button.connect("clicked", self.on_button_clicked)
def on_button_clicked(self, widget):
log.info("Button clicked")
module = widget.get_module()
self.emit("module_selected", module.get_name())
def rebuild_boxes(self, widget=None, event=None):
request = self.get_allocation()
ncols = request.width / 164 # 32 + 120 + 6 + 4
width = ncols * (164 + 2 * 4) + 40
if width > request.width:
ncols -= 1
pos = 0
last_box = None
children = self._box.get_children()
for box in self._boxes:
modules = box.get_modules()
if len(modules) == 0:
if box in children:
self._box.remove(box)
else:
if box not in children:
self._box.pack_start(box, False, False, 0)
self._box.reorder_child(box, pos)
box.rebuild_table(ncols)
pos += 1
last_box = box
示例7: PreferencesDialog
# 需要导入模块: from ubuntutweak.settings import GSetting [as 别名]
# 或者: from ubuntutweak.settings.GSetting import get_value [as 别名]
#.........这里部分代码省略.........
TweakModule,
'tweaks',
self.tweaks_setting,
self._update_feature_model,
_('"%s" is not a Tweaks Extension!'))
def on_admins_install_button_clicked(self, widget):
self.on_install_extension(_('Choose a Admins Extension'),
TweakModule,
'admins',
self.admins_setting,
self._update_feature_model,
_('"%s" is not a Admins Extension!'))
def on_janitor_install_button_clicked(self, widget):
self.on_install_extension(_('Choose a Janitor Extension'),
JanitorPlugin,
'janitor',
self.janitor_setting,
self._update_feature_model,
_('"%s" is not a Janitor Extension!'))
def on_install_extension(self, dialog_label, klass, feature,
setting, update_func, error_message):
dialog = Gtk.FileChooserDialog(dialog_label,
action=Gtk.FileChooserAction.OPEN,
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT))
filter = Gtk.FileFilter()
filter.set_name(_('Ubuntu Tweak Extension (*.py, *.tar.gz)'))
filter.add_pattern('*.py')
filter.add_pattern('*.tar.gz')
dialog.add_filter(filter)
dialog.set_current_folder(self.clips_location_setting.get_value() or
GLib.get_home_dir())
filename = ''
install_done = False
not_extension = False
if dialog.run() == Gtk.ResponseType.ACCEPT:
filename = dialog.get_filename()
dialog.destroy()
if filename:
self.clips_location_setting.set_value(os.path.dirname(filename))
log.debug("Start to check the class in %s" % filename)
if filename.endswith('.tar.gz'):
tar_file = TarFile(filename)
if tar_file.is_valid():
tar_file.extract(TEMP_ROOT)
#TODO if multi-root
if tar_file.get_root_name():
temp_dir = os.path.join(TEMP_ROOT, tar_file.get_root_name())
if ModuleLoader.is_target_class(temp_dir, klass):
target = os.path.join(ModuleLoader.get_user_extension_dir(feature), os.path.basename(temp_dir))
copy = True
if os.path.exists(target):
dialog = QuestionDialog(message=_("Would you like to remove it then install again?"),
title=_('"%s" has already installed' % os.path.basename(target)))
response = dialog.run()
dialog.destroy()
if response == Gtk.ResponseType.YES:
示例8: SourceEditor
# 需要导入模块: from ubuntutweak.settings import GSetting [as 别名]
# 或者: from ubuntutweak.settings.GSetting import get_value [as 别名]
class SourceEditor(TweakModule):
__title__ = _('Source Editor')
__desc__ = _('Manually edit your software sources to suit your needs.')
__icon__ = 'system-software-update'
__category__ = 'system'
def __init__(self):
TweakModule.__init__(self, 'sourceeditor.ui')
self.auto_backup_setting = GSetting('com.ubuntu-tweak.tweak.auto-backup')
self.textview = SourceView(SOURCES_LIST)
self.textview.set_sensitive(False)
self.sw1.add(self.textview)
self.textview.get_buffer().connect('changed', self.on_buffer_changed)
un_lock = PolkitButton(PK_ACTION_SOURCE)
un_lock.connect('authenticated', self.on_polkit_action)
self._authenticated = False
self.hbuttonbox2.pack_end(un_lock, False, False, 0)
self.list_selection = self.list_view.get_selection()
self.list_selection.connect("changed", self.on_selection_changed)
self.infobar = Gtk.InfoBar()
self.info_label = Gtk.Label('Current view the list')
self.info_label.set_alignment(0, 0.5)
self.infobar.get_content_area().add(self.info_label)
self.infobar.connect("response", self.on_infobar_response)
self.infobar.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
self.infobar.hide()
self.text_vbox.pack_start(self.infobar, False, False, 0)
self.connect('realize', self.on_ui_realize)
self.add_start(self.hbox1)
def on_ui_realize(self, widget):
self.infobar.hide()
self.update_source_model()
self.list_selection.select_iter(self.list_model.get_iter_first())
self.auto_backup_button.set_active(self.auto_backup_setting.get_value())
self.auto_backup_button.connect('toggled', self.on_auto_backup_button_toggled)
def set_infobar_backup_info(self, name, list_name):
self.info_label.set_markup(_('You\'re viewing the backup "<b>%s</b>" for'
'"<b>%s</b>"') % (name, list_name))
def on_auto_backup_button_toggled(self, widget):
self.auto_backup_setting.set_value(widget.get_active())
def on_infobar_response(self, widget, response_id):
model, iter = self.list_selection.get_selected()
if iter:
list_path = model[iter][0]
self.textview.set_path(list_path)
self.textview.update_content()
self.save_button.set_sensitive(False)
self.redo_button.set_sensitive(False)
self.infobar.hide()
def on_selection_changed(self, selection):
model, iter = selection.get_selected()
if iter:
self.textview.set_path(model[iter][0])
self.update_sourceslist()
self.update_backup_model()
def update_source_model(self):
model = self.list_model
model.clear()
model.append(('/etc/apt/sources.list', 'sources.list'))
SOURCE_LIST_D = '/etc/apt/sources.list.d'
if not os.path.exists(SOURCE_LIST_D):
self.source_combo.set_active(0)
return
files = glob.glob(SOURCE_LIST_D + '/*.list')
files.sort()
for file in files:
if os.path.isdir(file):
continue
model.append((file, os.path.basename(file)))
def update_backup_model(self):
def file_cmp(f1, f2):
return cmp(os.stat(f1).st_ctime, os.stat(f2).st_ctime)
model, iter = self.list_selection.get_selected()
if iter:
#.........这里部分代码省略.........
示例9: UbuntuTweakWindow
# 需要导入模块: from ubuntutweak.settings import GSetting [as 别名]
# 或者: from ubuntutweak.settings.GSetting import get_value [as 别名]
class UbuntuTweakWindow(GuiBuilder):
current_feature = 'overview'
feature_dict = {}
navigation_dict = {'tweaks': [None, None]}
# the module name and page index: 'Compiz': 2
loaded_modules = {}
# reversed dict: 2: 'CompizClass'
modules_index = {}
def __init__(self, feature='', module=''):
GuiBuilder.__init__(self, file_name='mainwindow.ui')
self.window_size_setting = GSetting('com.ubuntu-tweak.tweak.window-size')
width, height = self.window_size_setting.get_value()
if width >= 800 and height >= 480:
self.mainwindow.set_default_size(width, height)
Gtk.rc_parse(os.path.join(DATA_DIR, 'theme/ubuntu-tweak.rc'))
tweaks_page = FeaturePage('tweaks')
admins_page = FeaturePage('admins')
clip_page = ClipPage()
# apps_page = AppsPage()
janitor_page = JanitorPage()
self.preferences_dialog = PreferencesDialog(self.mainwindow)
self.rencently_used_settings = GSetting('com.ubuntu-tweak.tweak.rencently-used')
self.feature_dict['overview'] = self.notebook.append_page(clip_page, Gtk.Label())
# self.feature_dict['apps'] = self.notebook.append_page(apps_page, Gtk.Label())
self.feature_dict['tweaks'] = self.notebook.append_page(tweaks_page, Gtk.Label())
self.feature_dict['admins'] = self.notebook.append_page(admins_page, Gtk.Label())
self.feature_dict['janitor'] = self.notebook.append_page(janitor_page, Gtk.Label())
self.feature_dict['wait'] = self.notebook.append_page(self._crete_wait_page(),
Gtk.Label())
# Always show welcome page at first
self.mainwindow.connect('realize', self._initialize_ui_states)
tweaks_page.connect('module_selected', self.on_module_selected)
admins_page.connect('module_selected', self.on_module_selected)
clip_page.connect('load_module', lambda widget, name: self.load_module(name))
clip_page.connect('load_feature', lambda widget, name: self.select_target_feature(name))
self.mainwindow.show()
self.link_button.hide()
if module:
self.load_module(module)
elif feature:
self.select_target_feature(feature)
def on_header_button_press_event(self, widget, event):
self.mainwindow.begin_move_drag(event.button,
event.x_root,
event.y_root,
event.time)
def get_module_and_index(self, name):
index = self.loaded_modules[name]
return self.modules_index[index], index
def select_target_feature(self, text):
toggle_button = getattr(self, '%s_button' % text, None)
log.info("select_target_feature: %s" % text)
if toggle_button:
self.current_feature = text
toggle_button.set_active(True)
def _initialize_ui_states(self, widget):
#TODO implement the search feature
self.search_entry.hide()
def _crete_wait_page(self):
vbox = Gtk.VBox()
label = Gtk.Label()
label.set_markup("<span size=\"xx-large\">%s</span>" % \
_('Please wait a moment...'))
label.set_justify(Gtk.Justification.FILL)
vbox.pack_start(label, False, False, 50)
hbox = Gtk.HBox()
vbox.pack_start(hbox, False, False, 0)
vbox.show_all()
return vbox
def on_mainwindow_destroy(self, widget):
allocation = widget.get_allocation()
self.window_size_setting.set_value((allocation.width, allocation.height))
Gtk.main_quit()
try:
proxy.exit()
except Exception, e:
log.error(e)