本文整理汇总了Python中jarabe.controlpanel.inlinealert.InlineAlert类的典型用法代码示例。如果您正苦于以下问题:Python InlineAlert类的具体用法?Python InlineAlert怎么用?Python InlineAlert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InlineAlert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_trigger
def _setup_trigger(self):
box_trigger = Gtk.HBox(spacing=style.DEFAULT_SPACING)
label_trigger = Gtk.Label(label=_('Trigger Size'))
label_trigger.set_alignment(1, 0.75)
label_trigger.modify_fg(Gtk.StateType.NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
box_trigger.pack_start(label_trigger, False, True, 0)
self._group.add_widget(label_trigger)
label_trigger.show()
adj = Gtk.Adjustment(value=1, lower=1, upper=style.GRID_CELL_SIZE,
step_incr=1, page_incr=1, page_size=0)
self._trigger_size_slider = Gtk.HScale()
self._trigger_size_slider.set_adjustment(adj)
self._trigger_size_slider.set_digits(0)
self._trigger_size_slider.connect('format-value',
self.__trigger_size_format_cb)
box_trigger.pack_start(self._trigger_size_slider, True, True, 0)
self._trigger_size_slider.show()
self._box_sliders.pack_start(box_trigger, False, True, 0)
box_trigger.show()
self._trigger_size_alert = InlineAlert()
label_trigger_error = Gtk.Label()
self._group.add_widget(label_trigger_error)
trigger_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)
trigger_alert_box.pack_start(label_trigger_error, False, True, 0)
label_trigger_error.show()
trigger_alert_box.pack_start(self._trigger_size_alert, False, True, 0)
self._box_sliders.pack_start(trigger_alert_box, False, True, 0)
trigger_alert_box.show()
if 'trigger_size' in self.restart_alerts:
self._trigger_size_alert.props.msg = self.restart_msg
self._trigger_size_alert.show()
示例2: _setup_corner
def _setup_corner(self):
box_delay = Gtk.HBox(spacing=style.DEFAULT_SPACING)
label_delay = Gtk.Label(label=_('Corner'))
label_delay.set_alignment(1, 0.75)
label_delay.modify_fg(Gtk.StateType.NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
box_delay.pack_start(label_delay, False, True, 0)
self._group.add_widget(label_delay)
label_delay.show()
adj = Gtk.Adjustment(value=100, lower=0, upper=_MAX_DELAY,
step_incr=100, page_incr=100, page_size=0)
self._corner_delay_slider = Gtk.HScale()
self._corner_delay_slider.set_adjustment(adj)
self._corner_delay_slider.set_digits(0)
self._corner_delay_slider.connect('format-value',
self.__corner_delay_format_cb)
box_delay.pack_start(self._corner_delay_slider, True, True, 0)
self._corner_delay_slider.show()
self._box_sliders.pack_start(box_delay, False, True, 0)
box_delay.show()
self._corner_delay_alert = InlineAlert()
label_delay_error = Gtk.Label()
self._group.add_widget(label_delay_error)
delay_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)
delay_alert_box.pack_start(label_delay_error, False, True, 0)
label_delay_error.show()
delay_alert_box.pack_start(self._corner_delay_alert, False, True, 0)
self._box_sliders.pack_start(delay_alert_box, False, True, 0)
delay_alert_box.show()
if 'corner_delay' in self.restart_alerts:
self._corner_delay_alert.props.msg = self.restart_msg
self._corner_delay_alert.show()
示例3: __init__
def __init__(self, model, alerts):
SectionView.__init__(self)
self._model = model
self.restart_alerts = alerts
self._automatic_pm_valid = True
self._automatic_pm_change_handler = None
self.set_border_width(style.DEFAULT_SPACING * 2)
self.set_spacing(style.DEFAULT_SPACING)
group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
self._automatic_pm_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)
separator_pm = Gtk.HSeparator()
self.pack_start(separator_pm, False, True, 0)
separator_pm.show()
label_pm = Gtk.Label(label=_('Power management'))
label_pm.set_alignment(0, 0)
self.pack_start(label_pm, False, True, 0)
label_pm.show()
box_pm = Gtk.VBox()
box_pm.set_border_width(style.DEFAULT_SPACING * 2)
box_pm.set_spacing(style.DEFAULT_SPACING)
box_automatic_pm = Gtk.HBox(spacing=style.DEFAULT_SPACING)
label_automatic_pm = Gtk.Label(label=
_('Automatic power management (increases battery life)'))
label_automatic_pm.set_alignment(0, 0.5)
self._automatic_button = Gtk.CheckButton()
self._automatic_button.set_alignment(0, 0)
box_automatic_pm.pack_start(self._automatic_button, False, True, 0)
box_automatic_pm.pack_start(label_automatic_pm, False, True, 0)
self._automatic_button.show()
label_automatic_pm.show()
group.add_widget(label_automatic_pm)
box_pm.pack_start(box_automatic_pm, False, True, 0)
box_automatic_pm.show()
self._automatic_pm_alert = InlineAlert()
label_automatic_pm_error = Gtk.Label()
group.add_widget(label_automatic_pm_error)
self._automatic_pm_alert_box.pack_start(label_automatic_pm_error,
expand=False, fill=True,
padding=0)
label_automatic_pm_error.show()
self._automatic_pm_alert_box.pack_start(self._automatic_pm_alert,
expand=False, fill=True,
padding=0)
box_pm.pack_end(self._automatic_pm_alert_box, False, True, 0)
self._automatic_pm_alert_box.show()
if 'automatic_pm' in self.restart_alerts:
self._automatic_pm_alert.props.msg = self.restart_msg
self._automatic_pm_alert.show()
self.pack_start(box_pm, False, True, 0)
box_pm.show()
self.setup()
示例4: _setup_nick
def _setup_nick(self):
grid = Gtk.Grid()
grid.set_row_spacing(style.DEFAULT_SPACING)
grid.set_column_spacing(style.DEFAULT_SPACING)
self._nick_entry = Gtk.Entry()
self._nick_entry.set_width_chars(25)
grid.attach(self._nick_entry, 0, 0, 1, 1)
self._nick_entry.show()
alert_grid = Gtk.Grid()
self._nick_alert = InlineAlert()
alert_grid.attach(self._nick_alert, 0, 0, 1, 1)
if 'nick' in self.restart_alerts:
self._nick_alert.props.msg = self.restart_msg
self._nick_alert.show()
center_in_panel = Gtk.Alignment.new(0.5, 0, 0, 0)
center_in_panel.add(grid)
grid.show()
center_alert = Gtk.Alignment.new(0.5, 0, 0, 0)
center_alert.add(alert_grid)
alert_grid.show()
self.pack_start(center_in_panel, False, False, 0)
self.pack_start(center_alert, False, False, 0)
center_in_panel.show()
center_alert.show()
示例5: _setup_nick
def _setup_nick(self):
self._nick_entry = gtk.Entry()
self._nick_entry.modify_bg(gtk.STATE_INSENSITIVE,
style.COLOR_WHITE.get_gdk_color())
self._nick_entry.modify_base(gtk.STATE_INSENSITIVE,
style.COLOR_WHITE.get_gdk_color())
self._nick_entry.set_width_chars(25)
self._nick_box.pack_start(self._nick_entry, expand=False)
self._nick_entry.show()
label_entry_error = gtk.Label()
self._group.add_widget(label_entry_error)
self._nick_alert_box.pack_start(label_entry_error, expand=False)
label_entry_error.show()
self._nick_alert = InlineAlert()
self._nick_alert_box.pack_start(self._nick_alert)
if 'nick' in self.restart_alerts:
self._nick_alert.props.msg = self.restart_msg
self._nick_alert.show()
self._center_in_panel = gtk.Alignment(0.5)
self._center_in_panel.add(self._nick_box)
self.pack_start(self._center_in_panel, False)
self.pack_start(self._nick_alert_box, False)
self._nick_box.show()
self._nick_alert_box.show()
self._center_in_panel.show()
示例6: __init__
def __init__(self, model, alerts):
SectionView.__init__(self)
self._model = model
self.restart_alerts = alerts
self._zone_sid = 0
self._cursor_change_handler = None
self.set_border_width(style.DEFAULT_SPACING * 2)
self.set_spacing(style.DEFAULT_SPACING)
self.connect('realize', self.__realize_cb)
self._entry = iconentry.IconEntry()
self._entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY,
'entry-search')
self._entry.add_clear_button()
self.pack_start(self._entry, False, False, 0)
self._entry.show()
self._scrolled_window = Gtk.ScrolledWindow()
self._scrolled_window.set_policy(Gtk.PolicyType.NEVER,
Gtk.PolicyType.AUTOMATIC)
self._scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
self._store = Gtk.ListStore(GObject.TYPE_STRING)
zones = model.read_all_timezones()
for zone in zones:
self._store.append([zone])
self._treeview = Gtk.TreeView(self._store)
self._treeview.set_search_entry(self._entry)
self._treeview.set_search_equal_func(self._search, None)
self._treeview.set_search_column(0)
self._scrolled_window.add(self._treeview)
self._treeview.show()
self._timezone_column = Gtk.TreeViewColumn(_('Timezone'))
self._cell = Gtk.CellRendererText()
self._timezone_column.pack_start(self._cell, True)
self._timezone_column.add_attribute(self._cell, 'text', 0)
self._timezone_column.set_sort_column_id(0)
self._treeview.append_column(self._timezone_column)
self.pack_start(self._scrolled_window, True, True, 0)
self._scrolled_window.show()
self._zone_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)
self.pack_start(self._zone_alert_box, False, False, 0)
self._zone_alert = InlineAlert()
self._zone_alert_box.pack_start(self._zone_alert, True, True, 0)
if 'zone' in self.restart_alerts:
self._zone_alert.props.msg = self.restart_msg
self._zone_alert.show()
self._zone_alert_box.show()
self.setup()
示例7: _setup_color
def _setup_color(self):
grid = Gtk.Grid()
grid.set_row_spacing(style.DEFAULT_SPACING)
grid.set_column_spacing(style.DEFAULT_SPACING)
self._color_alert = None
self._pickers = {
_PREVIOUS_FILL_COLOR: ColorPicker(_PREVIOUS_FILL_COLOR),
_NEXT_FILL_COLOR: ColorPicker(_NEXT_FILL_COLOR),
_CURRENT_COLOR: ColorPicker(_CURRENT_COLOR),
_NEXT_STROKE_COLOR: ColorPicker(_NEXT_STROKE_COLOR),
_PREVIOUS_STROKE_COLOR: ColorPicker(_PREVIOUS_STROKE_COLOR),
}
label_color = Gtk.Label(label=_('Click to change your color:'))
label_color.modify_fg(Gtk.StateType.NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
grid.attach(label_color, 0, 0, 3, 1)
label_color.show()
current = 0
for picker_index in sorted(self._pickers.keys()):
if picker_index == _CURRENT_COLOR:
left_separator = Gtk.SeparatorToolItem()
grid.attach(left_separator, current, 1, 1, 1)
left_separator.show()
current += 1
picker = self._pickers[picker_index]
picker.show()
grid.attach(picker, current, 1, 1, 1)
current += 1
if picker_index == _CURRENT_COLOR:
right_separator = Gtk.SeparatorToolItem()
right_separator.show()
grid.attach(right_separator, current, 1, 1, 1)
current += 1
label_color_error = Gtk.Label()
grid.attach(label_color_error, 0, 2, 3, 1)
label_color_error.show()
self._color_alert = InlineAlert()
grid.attach(self._color_alert, 0, 3, 3, 1)
if 'color' in self.restart_alerts:
self._color_alert.props.msg = self.restart_msg
self._color_alert.show()
center_in_panel = Gtk.Alignment.new(0.5, 0, 0, 0)
center_in_panel.add(grid)
grid.show()
self.pack_start(center_in_panel, False, False, 0)
center_in_panel.show()
示例8: __init__
def __init__(self, model, alerts):
SectionView.__init__(self)
self._model = model
self.restart_alerts = alerts
self._lang_sid = 0
self._selected_lang_count = 0
self._labels = []
self._stores = []
self._comboboxes = []
self._add_remove_boxes = []
self._changed = False
self._cursor_change_handler = None
self._available_locales = self._model.read_all_languages()
self._selected_locales = self._model.get_languages()
self.set_border_width(style.DEFAULT_SPACING * 2)
self.set_spacing(style.DEFAULT_SPACING)
explanation = gettext.gettext('Add languages in the order you prefer.'
' If a translation is not available,'
' the next in the list will be used.')
self._text = gtk.Label(explanation)
self._text.set_width_chars(100)
self._text.set_line_wrap(True)
self._text.set_alignment(0, 0)
self.pack_start(self._text, False)
self._text.show()
scrolled = gtk.ScrolledWindow()
scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scrolled.show()
self.pack_start(scrolled, expand=True)
self._table = gtk.Table(rows=1, columns=3, homogeneous=False)
self._table.set_border_width(style.DEFAULT_SPACING * 2)
self._table.show()
scrolled.add_with_viewport(self._table)
self._lang_alert_box = gtk.HBox(spacing=style.DEFAULT_SPACING)
self.pack_start(self._lang_alert_box, False)
self._lang_alert = InlineAlert()
self._lang_alert_box.pack_start(self._lang_alert)
if 'lang' in self.restart_alerts:
self._lang_alert.props.msg = self.restart_msg
self._lang_alert.show()
self._lang_alert_box.show()
self.setup()
示例9: _setup_color
def _setup_color(self):
label_color = Gtk.Label(label=_("Click to change your color:"))
label_color.modify_fg(Gtk.StateType.NORMAL, style.COLOR_SELECTION_GREY.get_gdk_color())
self._group.add_widget(label_color)
self._color_label.attach(label_color, 0, 0, 1, 1)
label_color.show()
current = 1
for picker_index in sorted(self._pickers.keys()):
if picker_index == _CURRENT_COLOR:
left_separator = Gtk.SeparatorToolItem()
self._color_box.attach(left_separator, current, 0, 1, 1)
left_separator.show()
current += 1
picker = self._pickers[picker_index]
picker.show()
self._color_box.attach(picker, current, 0, 1, 1)
current += 1
if picker_index == _CURRENT_COLOR:
right_separator = Gtk.SeparatorToolItem()
right_separator.show()
self._color_box.attach(right_separator, current, 0, 1, 1)
current += 1
label_color_error = Gtk.Label()
self._group.add_widget(label_color_error)
self._color_alert_box.attach(label_color_error, 0, 0, 1, 1)
label_color_error.show()
self._color_alert = InlineAlert()
self._color_alert_box.attach(self._color_alert, 0, 0, 1, 1)
if "color" in self.restart_alerts:
self._color_alert.props.msg = self.restart_msg
self._color_alert.show()
self._center_in_panel = Gtk.Alignment.new(0.5, 0, 0, 0)
self._center_in_panel.add(self._color_box)
center_alert = Gtk.Alignment.new(0.5, 0, 0, 0)
center_alert.add(self._color_alert_box)
self.pack_start(self._color_label, False, False, 0)
self.pack_start(self._center_in_panel, False, False, 0)
self.pack_start(center_alert, False, False, 0)
self._color_label.show()
self._color_box.show()
self._color_alert_box.show()
self._center_in_panel.show()
center_alert.show()
示例10: _setup_color
def _setup_color(self):
label_color = gtk.Label(_('Click to change your color:'))
label_color.modify_fg(gtk.STATE_NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
self._group.add_widget(label_color)
self._color_label.pack_start(label_color, expand=False)
label_color.show()
for picker_index in sorted(self._pickers.keys()):
if picker_index == _CURRENT_COLOR:
left_separator = gtk.SeparatorToolItem()
left_separator.show()
self._color_box.pack_start(left_separator, expand=False)
picker = self._pickers[picker_index]
picker.show()
self._color_box.pack_start(picker, expand=False)
if picker_index == _CURRENT_COLOR:
right_separator = gtk.SeparatorToolItem()
right_separator.show()
self._color_box.pack_start(right_separator, expand=False)
label_color_error = gtk.Label()
self._group.add_widget(label_color_error)
self._color_alert_box.pack_start(label_color_error, expand=False)
label_color_error.show()
self._color_alert = InlineAlert()
self._color_alert_box.pack_start(self._color_alert)
if 'color' in self.restart_alerts:
self._color_alert.props.msg = self.restart_msg
self._color_alert.show()
self._center_in_panel = gtk.Alignment(0.5)
self._center_in_panel.add(self._color_box)
self.pack_start(self._color_label, False)
self.pack_start(self._center_in_panel, False)
self.pack_start(self._color_alert_box, False)
self._color_label.show()
self._color_box.show()
self._color_alert_box.show()
self._center_in_panel.show()
示例11: _setup_nick
def _setup_nick(self):
self._nick_entry = Gtk.Entry()
self._nick_entry.set_width_chars(25)
self._nick_box.attach(self._nick_entry, 0, 0, 1, 1)
self._nick_entry.show()
self._nick_alert = InlineAlert()
self._nick_alert_box.attach(self._nick_alert, 0, 0, 1, 1)
if "nick" in self.restart_alerts:
self._nick_alert.props.msg = self.restart_msg
self._nick_alert.show()
self._center_in_panel = Gtk.Alignment.new(0.5, 0, 0, 0)
self._center_in_panel.add(self._nick_box)
center_alert = Gtk.Alignment.new(0.5, 0, 0, 0)
center_alert.add(self._nick_alert_box)
self.pack_start(self._center_in_panel, False, False, 0)
self.pack_start(center_alert, False, False, 0)
self._nick_box.show()
self._nick_alert_box.show()
self._center_in_panel.show()
center_alert.show()
示例12: _setup_nick
def _setup_nick(self):
self._nick_entry = Gtk.Entry()
self._nick_entry.set_width_chars(25)
self._nick_box.pack_start(self._nick_entry, False, True, 0)
self._nick_entry.show()
label_entry_error = Gtk.Label()
self._group.add_widget(label_entry_error)
self._nick_alert_box.pack_start(label_entry_error, False, True, 0)
label_entry_error.show()
self._nick_alert = InlineAlert()
self._nick_alert_box.pack_start(self._nick_alert, True, True, 0)
if 'nick' in self.restart_alerts:
self._nick_alert.props.msg = self.restart_msg
self._nick_alert.show()
self._center_in_panel = Gtk.Alignment.new(0.5, 0, 0, 0)
self._center_in_panel.add(self._nick_box)
self.pack_start(self._center_in_panel, False, False, 0)
self.pack_start(self._nick_alert_box, False, False, 0)
self._nick_box.show()
self._nick_alert_box.show()
self._center_in_panel.show()
示例13: Language
class Language(SectionView):
def __init__(self, model, alerts):
SectionView.__init__(self)
self._model = model
self.restart_alerts = alerts
self.props.is_deferrable = False
self._lang_sid = 0
self._selected_lang_count = 0
self._labels = []
self._language_dict = {}
self._country_dict = {}
self._language_buttons = []
self._country_buttons = []
self._language_widgets = []
self._country_widgets = []
self._country_codes = []
self._add_remove_boxes = []
self._changed = False
self._cursor_change_handler = None
self._available_locales = self._model.read_all_languages()
self._selected_locales = self._model.get_languages()
for language, country, code in self._available_locales:
if language not in self._language_dict:
self._language_dict[language] = _translate_language(language)
self._country_dict[language] = [[code, country]]
else:
self._country_dict[language].append([code, country])
self.set_border_width(style.DEFAULT_SPACING * 2)
self.set_spacing(style.DEFAULT_SPACING)
explanation = gettext.gettext('Add languages in the order you prefer.'
' If a translation is not available,'
' the next in the list will be used.')
self._text = Gtk.Label(label=explanation)
self._text.set_line_wrap(True)
self._text.set_alignment(0, 0)
self.pack_start(self._text, False, False, 0)
self._text.show()
scrolled = Gtk.ScrolledWindow()
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
scrolled.show()
self.pack_start(scrolled, True, True, 0)
self._table = Gtk.Table(rows=2, columns=4, homogeneous=False)
self._table.set_border_width(style.DEFAULT_SPACING * 2)
self._table.show()
scrolled.add_with_viewport(self._table)
self._lang_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)
self.pack_start(self._lang_alert_box, False, True, 0)
self._lang_alert = InlineAlert()
self._lang_alert_box.pack_start(self._lang_alert, True, True, 0)
if 'lang' in self.restart_alerts:
self._lang_alert.props.msg = self.restart_msg
self._lang_alert.show()
self._lang_alert_box.show()
self.setup()
def _add_row(self, locale_code=None):
"""Adds two rows to the table:
(1) the buttons and labels for language and country;
(2) the tables of languages and country options"""
self._selected_lang_count += 1
self._table.resize(self._selected_lang_count * 2, 3)
label = Gtk.Label(label=str(self._selected_lang_count))
label.modify_fg(Gtk.StateType.NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
self._labels.append(label)
self._attach_to_table(label, 0, 1, self._selected_lang_count * 2 - 1,
xpadding=1, ypadding=1)
label.show()
locale_language = None
locale_country = None
if locale_code is not None:
for language, country, code in self._available_locales:
if code == locale_code:
locale_language = language
locale_country = country
for language, country, code in self._available_locales:
if code == '.'.join([locale_code, 'utf8']):
locale_language = language
locale_country = country
language_palette = []
key_list = self._language_dict.keys()
for language_key in sorted(key_list):
language_palette.append(
{'label': self._language_dict[language_key],
#.........这里部分代码省略.........
示例14: Language
class Language(SectionView):
def __init__(self, model, alerts):
SectionView.__init__(self)
self._model = model
self.restart_alerts = alerts
self._lang_sid = 0
self._selected_lang_count = 0
self._labels = []
self._stores = []
self._comboboxes = []
self._add_remove_boxes = []
self._changed = False
self._cursor_change_handler = None
self._available_locales = self._model.read_all_languages()
self._selected_locales = self._model.get_languages()
self.set_border_width(style.DEFAULT_SPACING * 2)
self.set_spacing(style.DEFAULT_SPACING)
explanation = gettext.gettext('Add languages in the order you prefer.'
' If a translation is not available,'
' the next in the list will be used.')
self._text = gtk.Label(explanation)
self._text.set_width_chars(100)
self._text.set_line_wrap(True)
self._text.set_alignment(0, 0)
self.pack_start(self._text, False)
self._text.show()
scrolled = gtk.ScrolledWindow()
scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scrolled.show()
self.pack_start(scrolled, expand=True)
self._table = gtk.Table(rows=1, columns=3, homogeneous=False)
self._table.set_border_width(style.DEFAULT_SPACING * 2)
self._table.show()
scrolled.add_with_viewport(self._table)
self._lang_alert_box = gtk.HBox(spacing=style.DEFAULT_SPACING)
self.pack_start(self._lang_alert_box, False)
self._lang_alert = InlineAlert()
self._lang_alert_box.pack_start(self._lang_alert)
if 'lang' in self.restart_alerts:
self._lang_alert.props.msg = self.restart_msg
self._lang_alert.show()
self._lang_alert_box.show()
self.setup()
def _add_row(self, locale_code=None):
"""Adds a row to the table"""
self._selected_lang_count += 1
self._table.resize(self._selected_lang_count, 3)
label = gtk.Label(str=str(self._selected_lang_count))
label.modify_fg(gtk.STATE_NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
self._labels.append(label)
self._attach_to_table(label, 0, 1, padding=1)
label.show()
store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
for language, country, code in self._available_locales:
description = '%s (%s)' % (_translate_language(language), \
_translate_country(country))
store.append([code, description])
combobox = gtk.ComboBox(model=store)
cell = gtk.CellRendererText()
combobox.pack_start(cell)
combobox.add_attribute(cell, 'text', 1)
if locale_code:
for row in store:
lang = locale_code.split('.')[0]
lang_column = row[0].split('.')[0]
if lang in lang_column:
combobox.set_active_iter(row.iter)
break
else:
combobox.set_active(1)
combobox.connect('changed', self.__combobox_changed_cb)
self._stores.append(store)
self._comboboxes.append(combobox)
self._attach_to_table(combobox, 1, 2, yoptions=gtk.SHRINK)
add_remove_box = self._create_add_remove_box()
self._add_remove_boxes.append(add_remove_box)
self._attach_to_table(add_remove_box, 2, 3)
add_remove_box.show_all()
#.........这里部分代码省略.........
示例15: Power
class Power(SectionView):
def __init__(self, model, alerts):
SectionView.__init__(self)
self._model = model
self.restart_alerts = alerts
self._automatic_pm_valid = True
self._automatic_pm_change_handler = None
self.set_border_width(style.DEFAULT_SPACING * 2)
self.set_spacing(style.DEFAULT_SPACING)
group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
self._automatic_pm_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)
separator_pm = Gtk.HSeparator()
self.pack_start(separator_pm, False, True, 0)
separator_pm.show()
label_pm = Gtk.Label(label=_('Power management'))
label_pm.set_alignment(0, 0)
self.pack_start(label_pm, False, True, 0)
label_pm.show()
box_pm = Gtk.VBox()
box_pm.set_border_width(style.DEFAULT_SPACING * 2)
box_pm.set_spacing(style.DEFAULT_SPACING)
box_automatic_pm = Gtk.HBox(spacing=style.DEFAULT_SPACING)
label_automatic_pm = Gtk.Label(
label=_('Automatic power management (increases battery life)'))
label_automatic_pm.set_alignment(0, 0.5)
self._automatic_button = Gtk.CheckButton()
self._automatic_button.set_alignment(0, 0)
box_automatic_pm.pack_start(self._automatic_button, False, True, 0)
box_automatic_pm.pack_start(label_automatic_pm, False, True, 0)
self._automatic_button.show()
label_automatic_pm.show()
group.add_widget(label_automatic_pm)
box_pm.pack_start(box_automatic_pm, False, True, 0)
box_automatic_pm.show()
self._automatic_pm_alert = InlineAlert()
label_automatic_pm_error = Gtk.Label()
group.add_widget(label_automatic_pm_error)
self._automatic_pm_alert_box.pack_start(label_automatic_pm_error,
expand=False, fill=True,
padding=0)
label_automatic_pm_error.show()
self._automatic_pm_alert_box.pack_start(self._automatic_pm_alert,
expand=False, fill=True,
padding=0)
box_pm.pack_end(self._automatic_pm_alert_box, False, True, 0)
self._automatic_pm_alert_box.show()
if 'automatic_pm' in self.restart_alerts:
self._automatic_pm_alert.props.msg = self.restart_msg
self._automatic_pm_alert.show()
self.pack_start(box_pm, False, True, 0)
box_pm.show()
self.setup()
def setup(self):
try:
automatic_state = self._model.get_automatic_pm()
except Exception as detail:
self._automatic_pm_alert.props.msg = detail
self._automatic_pm_alert.show()
else:
self._automatic_button.set_active(automatic_state)
self._automatic_pm_valid = True
self.needs_restart = False
self._automatic_pm_change_handler = self._automatic_button.connect(
'toggled', self.__automatic_pm_toggled_cb)
def undo(self):
self._automatic_button.disconnect(self._automatic_pm_change_handler)
self._model.undo()
self._automatic_pm_alert.hide()
def _validate(self):
if self._automatic_pm_valid:
self.props.is_valid = True
else:
self.props.is_valid = False
def __automatic_pm_toggled_cb(self, widget, data=None):
state = widget.get_active()
try:
self._model.set_automatic_pm(state)
except Exception as detail:
print(detail)
self._automatic_pm_alert.props.msg = detail
else:
self._automatic_pm_valid = True
self._validate()
return False