def __create_empty_file_cb(self, button): alert = Alert() alert.props.title = _('Create new file') alert.props.msg = _('Select the name of the file') # HACK alert._hbox.remove(alert._buttons_box) alert.entry = Gtk.Entry() alert._hbox.pack_start(alert.entry, True, True, 0) alert._buttons_box = Gtk.HButtonBox() alert._buttons_box.set_layout(Gtk.ButtonBoxStyle.END) alert._buttons_box.set_spacing(style.DEFAULT_SPACING) alert._hbox.pack_start(alert._buttons_box, True, True, 0) icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel'), icon) icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('Ok'), icon) alert.show_all() # self.add_alert(alert) alert.connect('response', self.__create_file_alert_cb)
def _value_changed(self, cell, path, new_text, model, activity): _logger.debug("Change '%s' to '%s'" % (model[path][1], new_text)) is_number = True number = new_text.replace(",", ".") try: float(number) except ValueError: is_number = False if is_number: decimals = utils.get_decimals(str(float(number))) new_text = locale.format('%.' + decimals + 'f', float(number)) model[path][1] = str(new_text) self.emit("value-changed", str(path), number) elif not is_number: alert = Alert() alert.props.title = _('Invalid Value') alert.props.msg = \ _('The value must be a number (integer or decimal)') ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) ok_icon.show() alert.connect('response', lambda a, r: activity.remove_alert(a)) activity.add_alert(alert) alert.show()
def _incompatible(self): ''' Display abbreviated activity user interface with alert ''' toolbox = ToolbarBox() stop = StopButton(self) toolbox.toolbar.add(stop) self.set_toolbar_box(toolbox) title = _('Activity not compatible with this system.') msg = _('Please downgrade activity and try again.') alert = Alert(title=title, msg=msg) alert.add_button(0, 'Stop', Icon(icon_name='activity-stop')) self.add_alert(alert) label = Gtk.Label( _('Uh oh, WebKit2 is too old. ' 'Browse-200 and later require WebKit2 API 4.0, ' 'sorry!')) self.set_canvas(label) ''' Workaround: start Terminal activity, then type sugar-erase-bundle org.laptop.WebActivity then in My Settings, choose Software Update, which will offer older Browse. ''' alert.connect('response', self.__incompatible_response_cb) stop.connect('clicked', self.__incompatible_stop_clicked_cb, alert) self.show_all()
def can_close(self): if self._force_close: return True elif downloadmanager.can_quit(): return True else: alert = Alert() alert.props.title = ngettext('Download in progress', 'Downloads in progress', downloadmanager.num_downloads()) message = ngettext('Stopping now will erase your download', 'Stopping now will erase your downloads', downloadmanager.num_downloads()) alert.props.msg = message cancel_icon = Icon(icon_name='dialog-cancel') cancel_label = ngettext('Continue download', 'Continue downloads', downloadmanager.num_downloads()) alert.add_button(Gtk.ResponseType.CANCEL, cancel_label, cancel_icon) stop_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('Stop'), stop_icon) stop_icon.show() self.add_alert(alert) alert.connect('response', self.__inprogress_response_cb) alert.show() self.present() return False
def _object_chooser(self, mime_type, type_name): chooser = ObjectChooser() matches_mime_type = False response = chooser.run() if response == Gtk.ResponseType.ACCEPT: jobject = chooser.get_selected_object() metadata = jobject.metadata file_path = jobject.file_path if metadata['mime_type'] == mime_type: matches_mime_type = True else: alert = Alert() alert.props.title = _('Invalid object') alert.props.msg = \ _('The selected object must be a %s file' % (type_name)) ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) ok_icon.show() alert.connect('response', lambda a, r: self.remove_alert(a)) self.add_alert(alert) alert.show() return matches_mime_type, file_path, metadata['title']
def _incompatible(self): ''' Display abbreviated activity user interface with alert ''' toolbox = ToolbarBox() stop = StopButton(self) toolbox.toolbar.add(stop) self.set_toolbar_box(toolbox) title = _('Activity not compatible with this system.') msg = _('Please downgrade activity and try again.') alert = Alert(title=title, msg=msg) alert.add_button(0, 'Stop', Icon(icon_name='activity-stop')) self.add_alert(alert) label = Gtk.Label(_('Uh oh, WebKit2 is too old. ' 'Browse-200 and later require WebKit2 API 4.0, ' 'sorry!')) self.set_canvas(label) ''' Workaround: start Terminal activity, then type sugar-erase-bundle org.laptop.WebActivity then in My Settings, choose Software Update, which will offer older Browse. ''' alert.connect('response', self.__incompatible_response_cb) stop.connect('clicked', self.__incompatible_stop_clicked_cb, alert) self.show_all()
def _check_current_cell_text(self): """Check the user-entered text for the current cell. If it matches the expected value, also check to see if the user's filled in all blank cells and hence has won. """ # Check whether the answer is correct. If so, change the cell to be # uneditable. expected_num = self._calculate_pascal_number(self._current_cell) if int(self._current_cell_text) == expected_num: self._blank_cells.remove(self._current_cell) self._update_current_cell((-1, -1)) # Check whether all blank cells have been filled. if len(self._blank_cells) == 0: alert = Alert() alert.props.title = _('You\'ve won!') alert.props.msg = _('Well done! You\'ve completed the Pascal ' 'Triangle. Do you want to play again?') icon = Icon(icon_name='emblem-favorite') alert.props.icon = icon icon.show() icon = Icon(icon_name='add') alert.add_button(Gtk.ResponseType.ACCEPT, _('New Game'), icon) icon.show() alert.connect('response', self.__alert_response_cb) alert.show() self._alert = alert self.add_alert(alert)
def _value_changed(self, cell, path, new_text, model, activity): _logger.info("Change '%s' to '%s'" % (model[path][1], new_text)) is_number = True number = new_text.replace(",", ".") try: float(number) except ValueError: is_number = False if is_number: decimals = utils.get_decimals(str(float(number))) new_text = locale.format('%.' + decimals + 'f', float(number)) model[path][1] = str(new_text) self.emit("value-changed", str(path), number) elif not is_number: alert = Alert() alert.props.title = _('Invalid Value') alert.props.msg = \ _('The value must be a number (integer or decimal)') ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) ok_icon.show() alert.connect('response', lambda a, r: activity.remove_alert(a)) activity.add_alert(alert) alert.show()
def _show_alert(self, message, title=None): alert = Alert() if title is None: title = _('Atention') alert.props.title = title alert.props.msg = message alert.add_button(Gtk.ResponseType.OK, _('Ok')) self.add_alert(alert) alert.connect('response', self._alert_response_cb)
def __crashed_cb(self, browser): self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.LEFT_PTR)) uri = browser.cached_uri logging.error('WebKit2 WebView at uri %r has crashed', uri) self.close_tab(browser.get_parent()) alert = Alert(title=_('This tab has crashed Browse: %s') % uri, msg=_('If you reopen the tab, it may just crash again')) alert.add_button(Gtk.ResponseType.OK, _('Reopen')) alert.add_button(Gtk.ResponseType.CANCEL, _('Disregard')) alert.connect('response', self.__crashed_alert_cb, uri) self._activity.add_alert(alert)
def __activate_game_cb(self, menu, i): self._game_selected_index = i if self.activity.game.model.is_demo: self._change_game() else: alert = Alert() alert.props.title = _('Discard your modified game?') icon = Icon(icon_name='dialog-ok') alert.add_button(1, _('Discard'), icon) icon = Icon(icon_name='dialog-cancel') alert.add_button(0, _('Do not discard'), icon) alert.connect('response', self._change_game_alert_cb) self.activity.add_alert(alert)
def __activate_art4apps_game_cb(self, menu, category, language): self._art4apps_data = (category, language) if self.activity.game.model.is_demo: self._change_art4apps_game(category, language) else: alert = Alert() alert.props.title = _('Discard your modified game?') icon = Icon(icon_name='dialog-ok') alert.add_button(1, _('Discard'), icon) icon = Icon(icon_name='dialog-cancel') alert.add_button(0, _('Do not discard'), icon) alert.connect('response', self._change_art4apps_game_alert_cb) self.activity.add_alert(alert)
def _invalid_number_alert(activity): alert = Alert() alert.props.title = _('Invalid Value') alert.props.msg = _('The value must be a number (integer or decimal)') ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) ok_icon.show() alert.connect('response', lambda a, r: activity.remove_alert(a)) activity.add_alert(alert) alert.show()
def _clear_game_bt(self, button): if self.activity.game.model.is_demo or \ len(self.activity.cardlist.pairs) == 0: self.clear_game() else: alert = Alert() alert.props.title = _('Clear all the tiles from the game?') icon = Icon(icon_name='dialog-ok') alert.add_button(1, _('Clear'), icon) icon = Icon(icon_name='dialog-cancel') alert.add_button(0, _('Do not clear'), icon) alert.connect('response', self._clear_game_alert_cb) self.activity.add_alert(alert)
def __save_ebook_clicked_cb(self, button): alert = Alert() alert.props.title = _('Book creation') alert.props.msg = _('Do you want to add an image for the cover?') icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.YES, _('Yes'), icon) icon.show() icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.NO, _('No'), icon) icon.show() alert.connect('response', self.__add_cover_response_cb, self._set_cover_and_create_book) self.add_alert(alert)
def _show_alert(self, title, msg): _stop_alert = Alert() _stop_alert.props.title = title _stop_alert.props.msg = msg _stop_alert.add_button(Gtk.ResponseType.OK, _('Ok'), Icon(icon_name='dialog-ok')) # Remove other alerts for alert in self._alerts: self.remove_alert(alert) self.add_alert(_stop_alert) _stop_alert.connect('response', self.__stop_response_cb) _stop_alert.show_all()
def _new_game_alert(self): alert = Alert() alert.props.title = _('New game') alert.props.msg = _('Do you want to play a new game?') icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel'), icon) icon.show() ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('New game'), ok_icon) ok_icon.show() alert.connect('response', self.__game_alert_response_cb) self._parent.add_alert(alert) alert.show()
def __erase_activate_cb(self, menu_item): alert = Alert() erase_string = _("Erase") alert.props.title = erase_string alert.props.msg = _('Do you want to permanently erase "%s"?') % self._metadata["title"] icon = Icon(icon_name="dialog-cancel") alert.add_button(Gtk.ResponseType.CANCEL, _("Cancel"), icon) icon.show() ok_icon = Icon(icon_name="dialog-ok") alert.add_button(Gtk.ResponseType.OK, erase_string, ok_icon) ok_icon.show() alert.connect("response", self.__erase_alert_response_cb) journalwindow.get_journal_window().add_alert(alert) alert.show()
def create_alert(self, path): alert = Alert() alert.props.title = _('This file is already exists.') alert.props.msg = _('%s already exists, Overwrite it?' % path) cancel = Gtk.Image.new_from_icon_name('dialog-cancel', Gtk.IconSize.MENU) save = Gtk.Image.new_from_icon_name('filesave', Gtk.IconSize.MENU) alert.add_button(Gtk.ResponseType.NO, _('Cancel'), icon=cancel) alert.add_button(Gtk.ResponseType.YES, _('Save'), icon=save) alert.connect('response', self.__alert_response, path) self.vbox.pack_start(alert, False, False, 0) self.vbox.reorder_child(alert, 1)
def _show_keep_failed_dialog(self): alert = Alert() alert.props.title = _('Keep error') alert.props.msg = _('Keep error: all changes will be lost') cancel_icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Don\'t stop'), cancel_icon) stop_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('Stop anyway'), stop_icon) self.add_alert(alert) alert.connect('response', self._keep_failed_dialog_response_cb) self.reveal()
def _erase_button_clicked_cb(self, button): alert = Alert() erase_string = _('Erase') alert.props.title = erase_string alert.props.msg = _('Do you want to permanently erase \"%s\"?') \ % self._metadata['title'] icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel'), icon) icon.show() ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, erase_string, ok_icon) ok_icon.show() alert.connect('response', self.__erase_alert_response_cb) journalwindow.get_journal_window().add_alert(alert) alert.show()
def __pdf_alert(self, object_id): alert = Alert() alert.props.title = _("Page saved") alert.props.msg = _("The page has been saved as PDF to journal") alert.add_button(Gtk.ResponseType.APPLY, _("Show in Journal"), Icon(icon_name="zoom-activity")) alert.add_button(Gtk.ResponseType.OK, _("Ok"), Icon(icon_name="dialog-ok")) # Remove other alerts for alert in self._activity._alerts: self._activity.remove_alert(alert) self._activity.add_alert(alert) alert.connect("response", self.__pdf_response_alert, object_id) alert.show_all()
def __erase_activate_cb(self, menu_item): alert = Alert() erase_string = _('Erase') alert.props.title = erase_string alert.props.msg = _('Do you want to permanently erase \"%s\"?') \ % self._metadata['title'] icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel'), icon) icon.show() ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, erase_string, ok_icon) ok_icon.show() alert.connect('response', self.__erase_alert_response_cb) journalwindow.get_journal_window().add_alert(alert) alert.show()
def __register_activate_cb(self, icon): alert = Alert() try: schoolserver.register_laptop() except RegisterError as e: alert.props.title = _('Registration Failed') alert.props.msg = '%s' % e else: alert.props.title = _('Registration Successful') alert.props.msg = _('You are now registered ' 'with your school server.') ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) self._box.add_alert(alert) alert.connect('response', self.__register_alert_response_cb)
def _save_epub(self): epub_file_name = create_ebub_from_book_model( self.metadata['title'], self._book_model) # create a new journal item fileObject = datastore.create() fileObject.metadata['title'] = \ _('"%s" as book') % self.metadata['title'] fileObject.metadata['mime_type'] = 'application/epub+zip' full_text = '' for page in self._book_model.get_pages(): full_text += page.text + '\n' fileObject.metadata['fulltext'] = full_text fileObject.metadata['icon-color'] = self.metadata['icon-color'] fileObject.metadata['keep'] = self.metadata.get('keep', '0') fileObject.metadata['preview'] = self.metadata['preview'] fileObject.file_path = epub_file_name # store the journal item datastore.write(fileObject, transfer_ownership=True) book_object_id = fileObject.object_id fileObject.destroy() del fileObject shutil.rmtree(os.path.dirname(epub_file_name)) finish_alert = Alert() finish_alert.props.title = _('Book created') finish_alert.props.msg = _('You can read the book in your Journal') open_icon = Icon(icon_name='zoom-activity') finish_alert.add_button(Gtk.ResponseType.APPLY, _('Show in Journal'), open_icon) open_icon.show() ok_icon = Icon(icon_name='dialog-ok') finish_alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) ok_icon.show() # Remove other alerts for alert in self._alerts: self.remove_alert(alert) self.add_alert(finish_alert) finish_alert.connect('response', self.__book_saved_alert_response_cb, book_object_id) finish_alert.show()
def __erase_activated_cb(self, tree_view, bundle_id): registry = bundleregistry.get_registry() activity_info = registry.get_bundle(bundle_id) alert = Alert() alert.props.title = _("Confirm erase") alert.props.msg = _("Confirm erase: Do you want to permanently erase %s?") % activity_info.get_name() cancel_icon = Icon(icon_name="dialog-cancel") alert.add_button(Gtk.ResponseType.CANCEL, _("Keep"), cancel_icon) erase_icon = Icon(icon_name="dialog-ok") alert.add_button(Gtk.ResponseType.OK, _("Erase"), erase_icon) alert.connect("response", self.__erase_confirmation_dialog_response_cb, bundle_id) self.add_alert(alert)
def _save_epub(self): epub_file_name = create_ebub_from_book_model(self.metadata['title'], self._book_model) # create a new journal item fileObject = datastore.create() fileObject.metadata['title'] = \ _('"%s" as book') % self.metadata['title'] fileObject.metadata['mime_type'] = 'application/epub+zip' full_text = '' for page in self._book_model.get_pages(): full_text += page.text + '\n' fileObject.metadata['fulltext'] = full_text fileObject.metadata['icon-color'] = self.metadata['icon-color'] fileObject.metadata['keep'] = self.metadata.get('keep', '0') fileObject.metadata['preview'] = self.metadata['preview'] fileObject.file_path = epub_file_name # store the journal item datastore.write(fileObject, transfer_ownership=True) book_object_id = fileObject.object_id fileObject.destroy() del fileObject shutil.rmtree(os.path.dirname(epub_file_name)) finish_alert = Alert() finish_alert.props.title = _('Book created') finish_alert.props.msg = _('You can read the book in your Journal') open_icon = Icon(icon_name='zoom-activity') finish_alert.add_button(Gtk.ResponseType.APPLY, _('Show in Journal'), open_icon) open_icon.show() ok_icon = Icon(icon_name='dialog-ok') finish_alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) ok_icon.show() # Remove other alerts for alert in self._alerts: self.remove_alert(alert) self.add_alert(finish_alert) finish_alert.connect('response', self.__book_saved_alert_response_cb, book_object_id) finish_alert.show()
def __pdf_alert(self, object_id): alert = Alert() alert.props.title = _('Page saved') alert.props.msg = _('The page has been saved as PDF to journal') alert.add_button(Gtk.ResponseType.APPLY, _('Show in Journal'), Icon(icon_name='zoom-activity')) alert.add_button(Gtk.ResponseType.OK, _('Ok'), Icon(icon_name='dialog-ok')) # Remove other alerts for alert in self._activity._alerts: self._activity.remove_alert(alert) self._activity.add_alert(alert) alert.connect('response', self.__pdf_response_alert, object_id) alert.show_all()
def _show_journal_alert(self, title, msg, object_id): open_alert = Alert() open_alert.props.title = title open_alert.props.msg = msg open_icon = Icon(icon_name='zoom-activity') open_alert.add_button(Gtk.ResponseType.APPLY, _('Show in Journal'), open_icon) open_icon.show() ok_icon = Icon(icon_name='dialog-ok') open_alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) ok_icon.show() # Remove other alerts for alert in self._alerts: self.remove_alert(alert) self.add_alert(open_alert) open_alert.connect('response', self.__open_response_cb, object_id) open_alert.show()
def __activate_game_cb(self, menu, i): self._game_selected_index = i if self.activity.game.model.is_demo: self.activity.get_canvas().hide() def momentary_blank_timeout_cb(): self._change_game() self.activity.get_canvas().show() GLib.timeout_add(100, momentary_blank_timeout_cb) else: alert = Alert() alert.props.title = _('Discard your modified game?') icon = Icon(icon_name='dialog-ok') alert.add_button(1, _('Discard'), icon) icon = Icon(icon_name='dialog-cancel') alert.add_button(0, _('Do not discard'), icon) alert.connect('response', self._change_game_alert_cb) self.activity.add_alert(alert)
def _incompatible(self): ''' Display abbreviated activity user interface with alert ''' toolbox = ToolbarBox() stop = StopButton(self) toolbox.toolbar.add(stop) self.set_toolbar_box(toolbox) title = _('Activity not compatible with this system.') msg = _('Please erase the activity.') alert = Alert(title=title, msg=msg) alert.add_button(0, 'Stop', Icon(icon_name='activity-stop')) self.add_alert(alert) label = Gtk.Label(_('You do not have an accelerometer.')) self.set_canvas(label) alert.connect('response', self.__incompatible_response_cb) stop.connect('clicked', self.__incompatible_stop_clicked_cb, alert) self.show_all()
def __erase_activated_cb(self, tree_view, bundle_id): registry = bundleregistry.get_registry() activity_info = registry.get_bundle(bundle_id) alert = Alert() alert.props.title = _('Confirm erase') alert.props.msg = \ _('Confirm erase: Do you want to permanently erase %s?') \ % activity_info.get_name() cancel_icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Keep'), cancel_icon) erase_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('Erase'), erase_icon) alert.connect('response', self.__erase_confirmation_dialog_response_cb, bundle_id) self.add_alert(alert)
def _erase_comment_cb(self, widget, event): alert = Alert() entry = self.get_selection().get_selected()[1] erase_string = _('Erase') alert.props.title = erase_string alert.props.msg = _('Do you want to permanently erase \"%s\"?') \ % self._store[entry][self.COMMENT_MESSAGE] icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel'), icon) icon.show() ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, erase_string, ok_icon) ok_icon.show() alert.connect('response', self._erase_alert_response_cb, entry) journalwindow.get_journal_window().add_alert(alert) alert.show()
def _incompatible(self): ''' Display abbreviated activity user interface with alert ''' toolbox = ToolbarBox() stop = StopButton(self) toolbox.toolbar.add(stop) self.set_toolbar_box(toolbox) title = _('Activity not compatible with this system.') msg = _('Please downgrade activity and try again.') alert = Alert(title=title, msg=msg) alert.add_button(0, 'Stop', Icon(icon_name='activity-stop')) self.add_alert(alert) label = Gtk.Label(_('Uh oh, GStreamer is too old.')) self.set_canvas(label) alert.connect('response', self.__incompatible_response_cb) stop.connect('clicked', self.__incompatible_stop_clicked_cb, alert) self.show_all()
def _create_alert(name, scrolled): title = G.TEXT_SAVE_CHANGES_QUESTION.replace("****", name) msg = G.TEXT_IF_NOT_SAVE no = Gtk.Image.new_from_icon_name("activity-stop", Gtk.IconSize.MENU) save = Gtk.Image.new_from_icon_name("filesave", Gtk.IconSize.MENU) alert = Alert() alert.props.title = title alert.props.msg = msg alert.add_button(Gtk.ResponseType.NO, _("No save"), icon=no) alert.add_button(Gtk.ResponseType.YES, _("Save"), icon=save) alert.connect("response", _alert_response, scrolled) self.vbox.pack_start(alert, False, False, 0) self.vbox.reorder_child(alert, 0) self.vbox.show_all()
def _show_journal_alert(self, title, msg): _stop_alert = Alert() _stop_alert.props.title = title _stop_alert.props.msg = msg if _HAS_BUNDLE_LAUNCHER: bundle = get_bundle(object_id=self._object_id) if bundle is not None: icon = Icon(file=bundle.get_icon()) label = _('Open with %s') % bundle.get_name() _stop_alert.add_button(Gtk.ResponseType.ACCEPT, label, icon) else: icon = Icon(icon_name='zoom-activity') label = _('Show in Journal') _stop_alert.add_button(Gtk.ResponseType.APPLY, label, icon) icon.show() ok_icon = Icon(icon_name='dialog-ok') _stop_alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) ok_icon.show() # Remove other alerts for alert in self._alerts: self.remove_alert(alert) self.add_alert(_stop_alert) _stop_alert.connect('response', self.__stop_response_cb) _stop_alert.show()
def __accept_clicked_cb(self, widget): if hasattr(self._section_view, "apply"): self._section_view.apply() if self._section_view.needs_restart: self._section_toolbar.accept_button.set_sensitive(False) self._section_toolbar.cancel_button.set_sensitive(False) alert = Alert() alert.props.title = _('Warning') alert.props.msg = _('Changes require restart') if self._section_view.props.is_cancellable: icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel changes'), icon) icon.show() if self._section_view.props.is_deferrable: icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.ACCEPT, _('Later'), icon) icon.show() icon = Icon(icon_name='system-restart') alert.add_button(Gtk.ResponseType.APPLY, _('Restart now'), icon) icon.show() self.add_alert(alert) alert.connect('response', self.__response_cb) alert.show() else: self._show_main_view()
def __accept_clicked_cb(self, widget): if hasattr(self._section_view, "apply"): self._section_view.apply() if self._section_view.needs_restart: self._section_toolbar.accept_button.set_sensitive(False) self._section_toolbar.cancel_button.set_sensitive(False) alert = Alert() alert.props.title = _('Warning') alert.props.msg = _('Changes require restart') if self._section_view.props.is_cancellable: icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel changes'), icon) icon.show() if self._current_option not in ('aboutme', 'backup'): icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.ACCEPT, _('Later'), icon) icon.show() icon = Icon(icon_name='system-restart') alert.add_button(Gtk.ResponseType.APPLY, _('Restart now'), icon) icon.show() self._vbox.pack_start(alert, False, False, 0) self._vbox.reorder_child(alert, 2) alert.connect('response', self.__response_cb) alert.show() else: self._show_main_view()
def __accept_clicked_cb(self, widget): if hasattr(self._section_view, "apply"): self._section_view.apply() if self._section_view.needs_restart: self._section_toolbar.accept_button.set_sensitive(False) self._section_toolbar.cancel_button.set_sensitive(False) alert = Alert() alert.props.title = _("Warning") alert.props.msg = _("Changes require restart") if self._section_view.props.is_cancellable: icon = Icon(icon_name="dialog-cancel") alert.add_button(Gtk.ResponseType.CANCEL, _("Cancel changes"), icon) icon.show() if self._current_option not in ("aboutme", "backup"): icon = Icon(icon_name="dialog-ok") alert.add_button(Gtk.ResponseType.ACCEPT, _("Later"), icon) icon.show() icon = Icon(icon_name="system-restart") alert.add_button(Gtk.ResponseType.APPLY, _("Restart now"), icon) icon.show() self._vbox.pack_start(alert, False, False, 0) self._vbox.reorder_child(alert, 2) alert.connect("response", self.__response_cb) alert.show() else: self._show_main_view()
def __accept_clicked_cb(self, widget): if self._section_view.needs_restart: self._section_toolbar.accept_button.set_sensitive(False) self._section_toolbar.cancel_button.set_sensitive(False) alert = Alert() alert.props.title = _('Warning') alert.props.msg = _('Changes require restart') icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel changes'), icon) icon.show() if self._current_option != 'aboutme': icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.ACCEPT, _('Later'), icon) icon.show() icon = Icon(icon_name='system-restart') alert.add_button(Gtk.ResponseType.APPLY, _('Restart now'), icon) icon.show() self._vbox.pack_start(alert, False, False, 0) self._vbox.reorder_child(alert, 2) alert.connect('response', self.__response_cb) alert.show() else: self._show_main_view()
def __create_new_folder(self, entry): if entry.get_text(): try: path = os.path.join(self.folder, entry.get_text()) os.mkdir(path) self.folder = path except OSError as msg: alert = Alert() alert.props.title = _('Error creating the folder.') alert.props.msg = msg image = Gtk.Image.new_from_stock(Gtk.STOCK_OK, Gtk.IconSize.MENU) alert.add_button(Gtk.ResponseType.NO, _('Ok'), icon=image) alert.connect('response', self.__alert_response) self.vbox.pack_start(alert, False, False, 0) self.vbox.reorder_child(alert, 1) item = entry.get_parent() self.toolbar.remove(item) self.button_new_folder.set_sensitive(True)
def _create_alert(name, scrolled): title = _('Save changes to document "%s" before closing?' % name) msg = _('If you do not save, changes will be lost forever.') no = Gtk.Image.new_from_icon_name('activity-stop', Gtk.IconSize.MENU) save = Gtk.Image.new_from_icon_name('filesave', Gtk.IconSize.MENU) alert = Alert() alert.props.title = title alert.props.msg = msg button1 = alert.add_button(Gtk.ResponseType.NO, _('No save'), icon=no) button2 = alert.add_button(Gtk.ResponseType.YES, _('Save'), icon=save) alert.connect('response', _alert_response, scrolled) self.vbox.pack_start(alert, False, False, 0) self.vbox.reorder_child(alert, 0) self.vbox.show_all()
def __create_restart_alert_cb(self, widget=None, event=None): alert = Alert() alert.props.title = _("Warning") alert.props.msg = self._section_view.restart_msg if self._section_view.props.is_cancellable: icon = Icon(icon_name="dialog-cancel") alert.add_button(Gtk.ResponseType.CANCEL, _("Cancel changes"), icon) icon.show() if self._section_view.props.is_deferrable: icon = Icon(icon_name="dialog-ok") alert.add_button(Gtk.ResponseType.ACCEPT, _("Later"), icon) icon.show() icon = Icon(icon_name="system-restart") alert.add_button(Gtk.ResponseType.APPLY, _("Restart now"), icon) icon.show() self.add_alert(alert) alert.connect("response", self.__response_cb) alert.show()
def __create_restart_alert_cb(self, widget=None, event=None): alert = Alert() alert.props.title = _('Warning') alert.props.msg = self._section_view.restart_msg if self._section_view.props.is_cancellable: icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel changes'), icon) icon.show() if self._section_view.props.is_deferrable: icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.ACCEPT, _('Later'), icon) icon.show() icon = Icon(icon_name='system-restart') alert.add_button(Gtk.ResponseType.APPLY, _('Restart now'), icon) icon.show() self.add_alert(alert) alert.connect('response', self.__response_cb) alert.show()