当前位置: 首页>>代码示例>>Python>>正文


Python conf.GconfSetting类代码示例

本文整理汇总了Python中ubuntutweak.conf.GconfSetting的典型用法代码示例。如果您正苦于以下问题:Python GconfSetting类的具体用法?Python GconfSetting怎么用?Python GconfSetting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GconfSetting类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GconfComboBox

class GconfComboBox(gtk.ComboBox):
    def __init__(self, key=None, texts=None, values=None):
        super(GconfComboBox, self).__init__()

        self.__setting = GconfSetting(key=key)
        model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        self.set_model(model)

        cell = gtk.CellRendererText()
        self.pack_start(cell, True)
        self.add_attribute(cell, 'text', 0)

        current_value = self.__setting.get_value()

        for text, value in dict(zip(texts, values)).items():
            iter = model.append(None)
            model.set(iter, 0, text, 1, value)
            if current_value == value:
                self.set_active_iter(iter)

        self.connect("changed", self.value_changed_cb)

    def value_changed_cb(self, widget):
        iter = widget.get_active_iter()
        text = self.get_model().get_value(iter, 1)
        log.debug("GconfComboBox value changed to %s" % text)

        self.__setting.get_client().set_value(self.__setting.get_key(), text)
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:28,代码来源:widgets.py

示例2: GconfEntry

class GconfEntry(gtk.Entry):
    def __init__(self, key=None, default=None):
        gtk.Entry.__init__(self)
        self.__setting = GconfSetting(key=key, default=default, type=str)

        string = self.__setting.get_value()
        if string:
            self.set_text(string)
        else:
            self.set_text(_("Unset"))

    def is_changed(self):
        return self.get_string_value() != self.get_text()

    def get_string_value(self):
        return self.__setting.get_value()

    def connect_activate_signal(self):
        self.connect('activate', self.on_edit_finished_cb)

    def get_gsetting(self):
        return self.__setting

    def reset(self):
        self.set_text(self.get_string_value())

    def on_edit_finished_cb(self, widget):
        string = self.get_text()
        client = self.__setting.get_client()
        key = self.__setting.get_key()
        if string:
            client.set_string(key, self.get_text())
        else:
            client.unset(key)
            self.set_text(_("Unset"))
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:35,代码来源:widgets.py

示例3: GconfSpinButton

class GconfSpinButton(gtk.SpinButton):
    def __init__(self, key, min=0, max=0, step=0):
        self.__setting = GconfSetting(key=key, type=int)
        adjust = gtk.Adjustment(self.__setting.get_value(), min, max, step)

        gtk.SpinButton.__init__(self, adjust)
        self.connect('value-changed', self.on_value_changed) 

    def on_value_changed(self, widget):
        self.__setting.set_value(widget.get_value())
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:10,代码来源:widgets.py

示例4: __init__

 def __init__(self, key=None, min=None, max=None, digits=0):
     gtk.HScale.__init__(self)
     if digits > 0:
         self.__setting = GconfSetting(key=key, type=float)
     else:
         self.__setting = GconfSetting(key=key, type=int)
     
     self.set_range(min, max)
     self.set_digits(digits)
     self.set_value_pos(gtk.POS_RIGHT)
     self.connect("value-changed", self.on_value_changed) 
     self.set_value(self.__setting.get_value())
开发者ID:actiononmail,项目名称:ubuntu-tweak,代码行数:12,代码来源:widgets.py

示例5: __init__

    def __init__(self, key):
        super(gtk.Button, self).__init__()

        self.__setting = GconfSetting(key=key)

        reset_image = gtk.image_new_from_stock(gtk.STOCK_REVERT_TO_SAVED, gtk.ICON_SIZE_MENU)
        self.set_property('image', reset_image)

        self.set_tooltip_text(_('Reset setting to default value: %s') % self.get_default_value())
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:9,代码来源:widgets.py

示例6: GconfComboBox

def GconfComboBox(key=None, texts=None, values=None):
    def value_changed_cb(widget, setting):
        text = widget.get_active_text()

        setting.get_client().set_value(setting.get_key(), setting.values[setting.texts.index(text)])

    combobox = gtk.combo_box_new_text()
    setting = GconfSetting(key=key)
    setting.texts = texts
    setting.values = values

    for text in texts:
        combobox.append_text(text)

    if setting.get_value() in values:
        combobox.set_active(values.index(setting.get_value()))
    combobox.connect("changed", value_changed_cb, setting)

    return combobox
开发者ID:oldturkeybuzzard,项目名称:ubuntu-tweak,代码行数:19,代码来源:widgets.py

示例7: __init__

    def __init__(self):
        gtk.IconView.__init__(self)

        self.config = GconfSetting(key='/apps/metacity/general/button_layout')
        model = self.__create_model()
        self.set_model(model)
        self.update_model()

        self.set_text_column(self.COLUMN_LABEL)
        self.set_reorderable(True)
        self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
        self.connect('selection-changed', self.on_button_changed)
开发者ID:actiononmail,项目名称:ubuntu-tweak,代码行数:12,代码来源:metacity.py

示例8: GconfScale

class GconfScale(gtk.HScale):
    def __init__(self, key=None, min=None, max=None, digits=0, reversed=False):
        gtk.HScale.__init__(self)
        if digits > 0:
            self.__setting = GconfSetting(key=key, type=float)
        else:
            self.__setting = GconfSetting(key=key, type=int)

        if reversed:
            self.__reversed = True
        else:
            self.__reversed = False
        
        self.set_range(min, max)
        self.set_digits(digits)
        self.set_value_pos(gtk.POS_RIGHT)
        self.connect("value-changed", self.on_value_changed) 
        if self.__reversed:
            self.set_value(max - self.__setting.get_value())
        else:
            self.set_value(self.__setting.get_value())

    def on_value_changed(self, widget, data=None):
        if self.__reversed:
            self.__setting.set_value(100 - widget.get_value())
        else:
            self.__setting.set_value(widget.get_value())
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:27,代码来源:widgets.py

示例9: __init__

    def __init__(self, key=None, texts=None, values=None, type="string"):
        super(GconfComboBox, self).__init__()

        self.__setting = GconfSetting(key=key)
        if type == 'int':
            model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
        else:
            model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        self.set_model(model)

        cell = gtk.CellRendererText()
        self.pack_start(cell, True)
        self.add_attribute(cell, 'text', 0)

        current_value = self.__setting.get_value()

        for text, value in dict(zip(texts, values)).items():
            iter = model.append(None)
            model.set(iter, 0, text, 1, value)
            if current_value == value:
                self.set_active_iter(iter)

        self.connect("changed", self.value_changed_cb)
开发者ID:Adriarson,项目名称:ubuntu-tweak,代码行数:23,代码来源:widgets.py

示例10: GconfCheckButton

class GconfCheckButton(gtk.CheckButton):
    def __init__(self, label=None, key=None, default=None, tooltip=None):
        super(GconfCheckButton, self).__init__()
        self.__setting = GconfSetting(key=key, default=default, type=bool)

        self.set_label(label)
        self.set_active(self.__setting.get_value())
        if tooltip:
            self.set_tooltip_text(tooltip)

        self.__setting.get_client().notify_add(key, self.value_changed)
        self.connect("toggled", self.button_toggled)

    def value_changed(self, client, id, entry, data=None):
        self.set_active(self.__setting.get_value())

    def button_toggled(self, widget, data=None):
        self.__setting.set_value(self.get_active())
开发者ID:oldturkeybuzzard,项目名称:ubuntu-tweak,代码行数:18,代码来源:widgets.py

示例11: ButtonView

class ButtonView(gtk.IconView):
    (COLUMN_KEY,
     COLUMN_LABEL,
    ) = range(2)

    values = {
        'menu': _('Menu'),
        ':': _('Title'),
        'maximize': _('Maximize'),
        'minimize': _('Minimize'),
        'close': _('Close'),
        'spacer': _('Spacer'),
    }

    def __init__(self):
        gtk.IconView.__init__(self)

        self.config = GconfSetting(key='/apps/metacity/general/button_layout')
        model = self.__create_model()
        self.set_model(model)
        self.update_model()

        self.set_text_column(self.COLUMN_LABEL)
        self.set_reorderable(True)
        self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
        self.connect('selection-changed', self.on_button_changed)

    def __create_model(self):
        model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)

        return model

    def update_model(self, default=None):
        model = self.get_model()
        model.clear()

        value = default or self.config.get_value()
        if value:
            list = value.replace(':', ',:,').split(',')
        else:
            return model

        for k in list:
            k = k.strip()
            iter = model.append()
            if k in self.values:
                model.set(iter,
                          self.COLUMN_KEY, k,
                          self.COLUMN_LABEL, self.values[k])
            else:
                continue

        return model

    def on_button_changed(self, widget, data=None):
        model = widget.get_model()
        value = ','.join([i[self.COLUMN_KEY] for i in model])
        value = value.replace(',:', ':').replace(':,', ':')
        self.config.set_value(value)

    def add_spacer(self):
        model = self.get_model()
        iter = model.append()
        model.set(iter,
                  self.COLUMN_KEY, 'spacer',
                  self.COLUMN_LABEL, self.values['spacer'])
        self.on_button_changed(self)

    def remove_spacer(self):
        model = self.get_model()
        for i, row in enumerate(model):
            if row[self.COLUMN_KEY] == 'spacer':
                del model[i, self.COLUMN_KEY]
                break
        self.on_button_changed(self)

    def has_spacer(self):
        model = self.get_model()
        for i, row in enumerate(model):
            if row[self.COLUMN_KEY] == 'spacer':
                return True
        return False
开发者ID:actiononmail,项目名称:ubuntu-tweak,代码行数:82,代码来源:metacity.py

示例12: __init__

    def __init__(self, key, min=0, max=0, step=0):
        self.__setting = GconfSetting(key=key, type=int)
        adjust = gtk.Adjustment(self.__setting.get_value(), min, max, step)

        gtk.SpinButton.__init__(self, adjust)
        self.connect("value-changed", self.on_value_changed)
开发者ID:oldturkeybuzzard,项目名称:ubuntu-tweak,代码行数:6,代码来源:widgets.py


注:本文中的ubuntutweak.conf.GconfSetting类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。