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


Python InlineAlert.hide方法代码示例

本文整理汇总了Python中jarabe.controlpanel.inlinealert.InlineAlert.hide方法的典型用法代码示例。如果您正苦于以下问题:Python InlineAlert.hide方法的具体用法?Python InlineAlert.hide怎么用?Python InlineAlert.hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jarabe.controlpanel.inlinealert.InlineAlert的用法示例。


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

示例1: AboutMe

# 需要导入模块: from jarabe.controlpanel.inlinealert import InlineAlert [as 别名]
# 或者: from jarabe.controlpanel.inlinealert.InlineAlert import hide [as 别名]

#.........这里部分代码省略.........
        grid.set_column_spacing(style.DEFAULT_SPACING)

        label_gender = Gtk.Label(label=_('Select gender:'))
        label_gender.modify_fg(Gtk.StateType.NORMAL,
                               style.COLOR_SELECTION_GREY.get_gdk_color())
        grid.attach(label_gender, 0, 0, 1, 1)
        label_gender.show()

        self._female_picker = GenderPicker(self._color, 'female')
        grid.attach(self._female_picker, 0, 1, 1, 1)
        self._female_picker.props.gender = self._gender
        self._female_picker.show()

        self._male_picker = GenderPicker(self._color, 'male')
        grid.attach(self._male_picker, 1, 1, 1, 1)
        self._male_picker.props.gender = self._gender
        self._male_picker.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()

    def _setup_age(self):
        self._age = self._model.get_age()

        grid = Gtk.Grid()
        grid.set_row_spacing(style.DEFAULT_SPACING)
        grid.set_column_spacing(style.DEFAULT_SPACING)

        self._age_pickers = []
        for i in range(len(AGES)):
            self._age_pickers.append(AgePicker(self._color, self._gender, i))

        label_age = Gtk.Label(label=_('Select age:'))
        label_age.modify_fg(Gtk.StateType.NORMAL,
                            style.COLOR_SELECTION_GREY.get_gdk_color())
        grid.attach(label_age, 0, 0, 1, 1)
        label_age.show()

        for i in range(len(AGES)):
            grid.attach(self._age_pickers[i], i, 1, 1, 1)
            self._age_pickers[i].set_age(self._age)
            self._age_pickers[i].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()

    def setup(self):
        pass

    def undo(self):
        self._model.undo()
        self._nick_alert.hide()
        self._color_alert.hide()

        self._model.set_gender(self._gender)
        self._model.set_age(self._age)

    def _update_pickers(self, color):
        for picker in self._pickers.values():
            picker.props.color = color
        self._female_picker.set_color(color, self._gender)
        self._male_picker.set_color(color, self._gender)
        for i in range(len(AGES)):
            self._age_pickers[i].set_color(color, self._age)

    def _validate(self):
        if self._nick_valid and self._color_valid:
            self.props.is_valid = True
        else:
            self.props.is_valid = False

    def __nick_changed_cb(self, widget, data=None):
        if self._nick_sid:
            GObject.source_remove(self._nick_sid)
        self._nick_sid = GObject.timeout_add(self._APPLY_TIMEOUT,
                                             self.__nick_timeout_cb, widget)

    def __nick_timeout_cb(self, widget):
        self._nick_sid = 0

        if widget.get_text() == self._model.get_nick():
            self.restart_alerts.remove('nick')
            if not self.restart_alerts:
                self.needs_restart = False
            self._nick_alert.hide()
            return False
        try:
            self._model.set_nick(widget.get_text())
        except ValueError, detail:
            self._nick_alert.props.msg = detail
            self._nick_valid = False
            self._nick_alert.show()
        else:
开发者ID:Akirato,项目名称:sugar,代码行数:104,代码来源:view.py

示例2: Frame

# 需要导入模块: from jarabe.controlpanel.inlinealert import InlineAlert [as 别名]
# 或者: from jarabe.controlpanel.inlinealert.InlineAlert import hide [as 别名]

#.........这里部分代码省略.........
        self._box_sliders.pack_start(box_delay, False, True, 0)
        box_delay.show()

        self._edge_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._edge_delay_alert, False, True, 0)
        self._box_sliders.pack_start(delay_alert_box, False, True, 0)
        delay_alert_box.show()
        if 'edge_delay' in self.restart_alerts:
            self._edge_delay_alert.props.msg = self.restart_msg
            self._edge_delay_alert.show()

    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()

    def setup(self):
        self._corner_delay_slider.set_value(self._model.get_corner_delay())
        self._edge_delay_slider.set_value(self._model.get_edge_delay())
        self._trigger_size_slider.set_value(self._model.get_trigger_size())
        self._corner_delay_is_valid = True
        self._edge_delay_is_valid = True
        self._trigger_size_is_valid = True
        self.needs_restart = False
        self._corner_delay_change_handler = self._corner_delay_slider.connect(
            'value-changed', self.__corner_delay_changed_cb)
        self._edge_delay_change_handler = self._edge_delay_slider.connect(
            'value-changed', self.__edge_delay_changed_cb)
        self._trigger_size_change_handler = self._trigger_size_slider.connect(
            'value-changed', self.__trigger_size_changed_cb)

    def undo(self):
        self._corner_delay_slider.disconnect(self._corner_delay_change_handler)
        self._edge_delay_slider.disconnect(self._edge_delay_change_handler)
        self._trigger_size_slider.disconnect(self._trigger_size_change_handler)
        self._model.undo()
        self._corner_delay_alert.hide()
        self._edge_delay_alert.hide()
        self._trigger_size_alert.hide()

    def _validate(self):
        if self._edge_delay_is_valid and self._corner_delay_is_valid \
           and self._trigger_size_is_valid:
            self.props.is_valid = True
        else:
            self.props.is_valid = False

    def __corner_delay_changed_cb(self, scale, data=None):
        if self._corner_delay_sid:
            GObject.source_remove(self._corner_delay_sid)
        self._corner_delay_sid = GObject.timeout_add(
            self._APPLY_TIMEOUT, self.__corner_delay_timeout_cb, scale)

    def __corner_delay_timeout_cb(self, scale):
        self._corner_delay_sid = 0
        if scale.get_value() == self._model.get_corner_delay():
            return False
        try:
            self._model.set_corner_delay(scale.get_value())
        except ValueError, detail:
            self._corner_delay_alert.props.msg = detail
            self._corner_delay_is_valid = False
        else:
开发者ID:rcunning01,项目名称:sugar,代码行数:104,代码来源:view.py

示例3: Network

# 需要导入模块: from jarabe.controlpanel.inlinealert import InlineAlert [as 别名]
# 或者: from jarabe.controlpanel.inlinealert.InlineAlert import hide [as 别名]

#.........这里部分代码省略.........
        self._entry.show()
        box_mesh.pack_start(box_server, False, True, 0)
        box_server.show()

        self._jabber_alert = InlineAlert()
        label_jabber_error = Gtk.Label()
        group.add_widget(label_jabber_error)
        self._jabber_alert_box.pack_start(label_jabber_error, False, True, 0)
        label_jabber_error.show()
        self._jabber_alert_box.pack_start(self._jabber_alert, False, True, 0)
        box_mesh.pack_end(self._jabber_alert_box, False, True, 0)
        self._jabber_alert_box.show()
        if 'jabber' in self.restart_alerts:
            self._jabber_alert.props.msg = self.restart_msg
            self._jabber_alert.show()

        workspace.pack_start(box_mesh, False, True, 0)
        box_mesh.show()

        self.setup()

    def setup(self):
        self._entry.set_text(self._model.get_jabber())
        try:
            radio_state = self._model.get_radio()
        except self._model.ReadError as detail:
            self._radio_alert.props.msg = detail
            self._radio_alert.show()
        else:
            self._button.set_active(radio_state)

        self._jabber_valid = True
        self._radio_valid = True
        self.needs_restart = False
        self._radio_change_handler = self._button.connect(
            'toggled', self.__radio_toggled_cb)
        self._jabber_change_handler = self._entry.connect(
            'changed', self.__jabber_changed_cb)
        self._wireless_configuration_reset_handler =  \
            self._clear_wireless_button.connect(
                'clicked', self.__wireless_configuration_reset_cb)

    def undo(self):
        self._button.disconnect(self._radio_change_handler)
        self._entry.disconnect(self._jabber_change_handler)
        self._model.undo()
        self._jabber_alert.hide()
        self._radio_alert.hide()

    def _validate(self):
        if self._jabber_valid and self._radio_valid:
            self.props.is_valid = True
        else:
            self.props.is_valid = False

    def __radio_toggled_cb(self, widget, data=None):
        radio_state = widget.get_active()
        try:
            self._model.set_radio(radio_state)
        except self._model.ReadError as detail:
            self._radio_alert.props.msg = detail
            self._radio_valid = False
        else:
            self._radio_valid = True
            if self._model.have_wireless_networks():
                self._clear_wireless_button.set_sensitive(True)

        self._validate()
        return False

    def __jabber_changed_cb(self, widget, data=None):
        if self._jabber_sid:
            GObject.source_remove(self._jabber_sid)
        self._jabber_sid = GObject.timeout_add(_APPLY_TIMEOUT,
                                               self.__jabber_timeout_cb,
                                               widget)

    def __jabber_timeout_cb(self, widget):
        self._jabber_sid = 0
        if widget.get_text() == self._model.get_jabber:
            return
        try:
            self._model.set_jabber(widget.get_text())
        except self._model.ReadError as detail:
            self._jabber_alert.props.msg = detail
            self._jabber_valid = False
            self._jabber_alert.show()
            self.restart_alerts.append('jabber')
        else:
            self._jabber_valid = True
            self._jabber_alert.hide()

        self._validate()
        return False

    def __wireless_configuration_reset_cb(self, widget):
        # FIXME: takes effect immediately, not after CP is closed with
        # confirmation button
        self._model.clear_wireless_networks()
        self._clear_wireless_button.set_sensitive(False)
开发者ID:curiousguy13,项目名称:sugar,代码行数:104,代码来源:view.py

示例4: TimeZone

# 需要导入模块: from jarabe.controlpanel.inlinealert import InlineAlert [as 别名]
# 或者: from jarabe.controlpanel.inlinealert.InlineAlert import hide [as 别名]
class TimeZone(SectionView):
    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()

    def setup(self):
        zone = self._model.get_timezone()
        for row in self._store:
            if zone == row[0]:
                self._treeview.set_cursor(row.path, self._timezone_column,
                                          False)
                self._treeview.scroll_to_cell(row.path, self._timezone_column,
                                              True, 0.5, 0.5)
                break

        self.needs_restart = False
        self._cursor_change_handler = self._treeview.connect(
            'cursor-changed', self.__zone_changed_cd)

    def undo(self):
        self._treeview.disconnect(self._cursor_change_handler)
        self._model.undo()
        self._zone_alert.hide()

    def __realize_cb(self, widget):
        self._entry.grab_focus()

    def _search(self, model, column, key, iterator, data=None):
        value = model.get_value(iterator, column)
        if key.lower() in value.lower():
            return False
        return True

    def __zone_changed_cd(self, treeview, data=None):
        list_, row = treeview.get_selection().get_selected()
        if not row:
            return False
        if self._model.get_timezone() == self._store.get_value(row, 0):
            return False

        if self._zone_sid:
            GObject.source_remove(self._zone_sid)
        self._zone_sid = GObject.timeout_add(self._APPLY_TIMEOUT,
                                             self.__zone_timeout_cb, row)
        return True
#.........这里部分代码省略.........
开发者ID:AbrahmAB,项目名称:sugar-prototype,代码行数:103,代码来源:view.py

示例5: Language

# 需要导入模块: from jarabe.controlpanel.inlinealert import InlineAlert [as 别名]
# 或者: from jarabe.controlpanel.inlinealert.InlineAlert import hide [as 别名]

#.........这里部分代码省略.........
        self._country_codes.append(locale_code)

        self._language_buttons.append(new_language_button)
        self._attach_to_table(
            new_language_button, 1, 2, self._selected_lang_count * 2 - 1,
            yoptions=Gtk.AttachOptions.SHRINK)

        self._language_widgets.append(new_language_widget)
        self._attach_to_table(new_language_widget, 1, 2,
                              self._selected_lang_count * 2,
                              xpadding=style.DEFAULT_PADDING,
                              ypadding=0)

        self._country_buttons.append(new_country_button)
        self._attach_to_table(
            new_country_button, 2, 3, self._selected_lang_count * 2 - 1,
            yoptions=Gtk.AttachOptions.SHRINK)

        self._country_widgets.append(new_country_widget)
        self._attach_to_table(new_country_widget, 2, 3,
                              self._selected_lang_count * 2,
                              xpadding=style.DEFAULT_PADDING,
                              ypadding=0)

        add_remove_box = self._create_add_remove_box()
        self._add_remove_boxes.append(add_remove_box)
        self._attach_to_table(add_remove_box, 3, 4,
                              self._selected_lang_count * 2 - 1)

        add_remove_box.show_all()

        if self._selected_lang_count > 1:
            previous_add_removes = self._add_remove_boxes[-2]
            previous_add_removes.hide()

        # Hide the Remove button if the new added row is the only
        # language.
        elif self._selected_lang_count == 1:
            add_button_, remove_button = add_remove_box.get_children()
            remove_button.props.visible = False

        new_language_button.show()
        new_country_button.show()

    def _build_country_list(self, language, idx=None):
        country_list = []
        if idx is None:
            idx = len(self._country_buttons)

        for country, code in sorted((_translate_country(entry[1]), entry[0])
                                    for entry in self._country_dict[language]):
            country_list.append(
                {'label': country,
                 'code': code,
                 'index': idx,
                 'callback': self._country_changed})
        return country_list

    def _attach_to_table(self, widget, left, right, above,
                         xpadding=style.DEFAULT_SPACING,
                         ypadding=style.DEFAULT_SPACING,
                         yoptions=Gtk.AttachOptions.FILL):
        self._table.attach(widget, left, right,
                           above,
                           above + 1,
                           xoptions=Gtk.AttachOptions.FILL,
开发者ID:AbrahmAB,项目名称:sugar,代码行数:70,代码来源:view.py

示例6: Language

# 需要导入模块: from jarabe.controlpanel.inlinealert import InlineAlert [as 别名]
# 或者: from jarabe.controlpanel.inlinealert.InlineAlert import hide [as 别名]

#.........这里部分代码省略.........
                                       _translate_country(country))
            store.append([code, description])

        combobox = Gtk.ComboBox(model=store)
        cell = Gtk.CellRendererText()
        combobox.pack_start(cell, True)
        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.AttachOptions.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()

        if self._selected_lang_count > 1:
            previous_add_removes = self._add_remove_boxes[-2]
            previous_add_removes.hide()

        # Hide the Remove button if the new added row is the only
        # language.
        elif self._selected_lang_count == 1:
            add_button_, remove_button = add_remove_box.get_children()
            remove_button.props.visible = False

        combobox.show()

    def _attach_to_table(self, widget, row, column, padding=20,
                         yoptions=Gtk.AttachOptions.FILL):
        self._table.attach(widget, row, column,
                           self._selected_lang_count -
                           1, self._selected_lang_count,
                           xoptions=Gtk.AttachOptions.FILL,
                           yoptions=yoptions,
                           xpadding=padding,
                           ypadding=padding)

    def _delete_last_row(self):
        """Deletes the last row of the table"""

        self._selected_lang_count -= 1

        label, add_remove_box, combobox, store_ = self._get_last_row()

        label.destroy()
        add_remove_box.destroy()
        combobox.destroy()

        self._table.resize(self._selected_lang_count, 3)
开发者ID:Anubhav-J,项目名称:sugar,代码行数:69,代码来源:view.py

示例7: AboutMe

# 需要导入模块: from jarabe.controlpanel.inlinealert import InlineAlert [as 别名]
# 或者: from jarabe.controlpanel.inlinealert.InlineAlert import hide [as 别名]

#.........这里部分代码省略.........
        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()

    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.pack_start(label_color, False, True, 0)
        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, False, True, 0)

            picker = self._pickers[picker_index]
            picker.show()
            self._color_box.pack_start(picker, False, True, 0)

            if picker_index == _CURRENT_COLOR:
                right_separator = Gtk.SeparatorToolItem()
                right_separator.show()
                self._color_box.pack_start(right_separator, False, True, 0)

        label_color_error = Gtk.Label()
        self._group.add_widget(label_color_error)
        self._color_alert_box.pack_start(label_color_error, False, True, 0)
        label_color_error.show()

        self._color_alert = InlineAlert()
        self._color_alert_box.pack_start(self._color_alert, True, True, 0)
        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)
        self.pack_start(self._color_label, False, False, 0)
        self.pack_start(self._center_in_panel, False, False, 0)
        self.pack_start(self._color_alert_box, False, False, 0)
        self._color_label.show()
        self._color_box.show()
        self._color_alert_box.show()
        self._center_in_panel.show()

    def setup(self):
        self._nick_entry.set_text(self._model.get_nick())
        self._color_valid = True
        self._nick_valid = True
        self.needs_restart = False

        self._nick_entry.connect('changed', self.__nick_changed_cb)
        for picker in self._pickers.values():
            picker.connect('color-changed', self.__color_changed_cb)

    def undo(self):
        self._model.undo()
        self._nick_alert.hide()
        self._color_alert.hide()

    def _update_pickers(self, color):
        for picker in self._pickers.values():
            picker.update(color)

    def _validate(self):
        if self._nick_valid and self._color_valid:
            self.props.is_valid = True
        else:
            self.props.is_valid = False

    def __nick_changed_cb(self, widget, data=None):
        if self._nick_sid:
            GObject.source_remove(self._nick_sid)
        self._nick_sid = GObject.timeout_add(self._APPLY_TIMEOUT,
                                             self.__nick_timeout_cb, widget)

    def __nick_timeout_cb(self, widget):
        self._nick_sid = 0

        if widget.get_text() == self._model.get_nick():
            return False
        try:
            self._model.set_nick(widget.get_text())
        except ValueError, detail:
            self._nick_alert.props.msg = detail
            self._nick_valid = False
        else:
开发者ID:ajaygarg84,项目名称:sugar,代码行数:104,代码来源:view.py

示例8: Power

# 需要导入模块: from jarabe.controlpanel.inlinealert import InlineAlert [as 别名]
# 或者: from jarabe.controlpanel.inlinealert.InlineAlert import hide [as 别名]
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
开发者ID:curiousguy13,项目名称:sugar,代码行数:101,代码来源:view.py

示例9: Language

# 需要导入模块: from jarabe.controlpanel.inlinealert import InlineAlert [as 别名]
# 或者: from jarabe.controlpanel.inlinealert.InlineAlert import hide [as 别名]

#.........这里部分代码省略.........
            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()

        if self._selected_lang_count > 1:
            previous_add_removes = self._add_remove_boxes[-2]
            previous_add_removes.hide_all()

        self._determine_add_remove_visibility()

        combobox.show()

    def _attach_to_table(self, widget, row, column, padding=20, \
            yoptions=gtk.FILL):
        self._table.attach(widget, row, column, \
            self._selected_lang_count - 1, self._selected_lang_count, \
            xoptions=gtk.FILL, yoptions=yoptions, xpadding=padding, \
                ypadding=padding)

    def _delete_last_row(self):
        """Deletes the last row of the table"""

        self._selected_lang_count -= 1

        label, add_remove_box, combobox, store_ = self._get_last_row()

        label.destroy()
        add_remove_box.destroy()
        combobox.destroy()

        self._table.resize(self._selected_lang_count, 3)

        self._add_remove_boxes[-1].show_all()

    def _get_last_row(self):
        label = self._labels.pop()
        add_remove_box = self._add_remove_boxes.pop()
        combobox = self._comboboxes.pop()
        store = self._stores.pop()
开发者ID:nemesiscodex,项目名称:JukyOS-sugar,代码行数:70,代码来源:view.py


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