def __init__(self, entropy_client, avc, updates_len, security_updates_len): self._entropy = entropy_client self._avc = avc msg = ngettext("There is <b>%d</b> update", "There are <b>%d</b> updates", updates_len) msg = msg % (updates_len, ) if security_updates_len > 0: sec_msg = ", " + ngettext("and <b>%d</b> security update", "and <b>%d</b> security updates", security_updates_len) sec_msg = sec_msg % (security_updates_len, ) msg += sec_msg msg += ". " + _("What to do?") NotificationBox.__init__( self, prepare_markup(msg), tooltip=prepare_markup( _("Updates available, how about installing them?")), message_type=Gtk.MessageType.WARNING, context_id="UpdatesNotificationBox") self.add_button(_("_Update"), self._update) self.add_button(_("_Show"), self._show) self.add_destroy_button(_("_Ignore")) self.add_destroy_button(_("Srsly, ignore!"), callback=UpdatesNotificationBox.snooze)
def __init__(self, entropy_client, avc, updates_len, security_updates_len): self._entropy = entropy_client self._avc = avc msg = ngettext("There is <b>%d</b> update", "There are <b>%d</b> updates", updates_len) msg = msg % (updates_len,) if security_updates_len > 0: sec_msg = ", " + ngettext("and <b>%d</b> security update", "and <b>%d</b> security updates", security_updates_len) sec_msg = sec_msg % (security_updates_len,) msg += sec_msg msg += ". " + _("What to do?") NotificationBox.__init__(self, prepare_markup(msg), tooltip=prepare_markup( _("Updates available, how about installing them?")), message_type=Gtk.MessageType.WARNING, context_id="UpdatesNotificationBox") self.add_button(_("_Update"), self._update) self.add_button(_("_Show"), self._show) self.add_destroy_button(_("_Ignore")) self.add_destroy_button(_("Srsly, ignore!"), callback=UpdatesNotificationBox.snooze)
def _rename(self, button): """ Try to login to Entropy Web Services. """ repository_id = self._repo_entry.get_text() valid = entropy.tools.validate_repository_id(repository_id) if not valid: self._repo_message.show() self._repo_message.set_markup( prepare_markup( _("<b>Invalid</b> Repository name!"))) return from_repository_id = self._repo.repository() renamed = self._service.rename_repository( from_repository_id, repository_id) if not renamed: self._repo_message.show() self._repo_message.set_markup( prepare_markup( _("Repository rename <b>not allowed</b>!"))) return self.destroy() self.emit("renamed")
def __init__(self, app, entropy_client, license_map): """ LicensesNotificationBox constructor. @param entropy_client: Entropy Client object @param license_map: mapping composed by license id as key and list of Application objects as value. """ self._app = app self._entropy = entropy_client self._licenses = license_map licenses = sorted(license_map.keys(), key=lambda x: x.lower()) lic_txts = [] for lic in licenses: lic_txt = "<a href=\"%s\">%s</a>" % ( lic, lic, ) lic_txts.append(lic_txt) if app is None: msg = _("You are required to <b>review</b> and <b>accept</b>" " the following licenses before continuing: %s") msg = msg % (", ".join(lic_txts), ) msg = prepare_markup(msg) else: msg = _("<b>%s</b> Application or one of its " "dependencies is distributed with the following" " licenses: %s") msg = msg % ( self._app.name, ", ".join(lic_txts), ) msg = prepare_markup(msg) label = Gtk.Label() label.set_markup(prepare_markup(msg)) label.set_line_wrap_mode(Pango.WrapMode.WORD) label.set_line_wrap(True) label.set_property("expand", True) label.set_alignment(0.02, 0.50) label.connect("activate-link", self._on_license_activate) NotificationBox.__init__( self, None, message_widget=label, tooltip=prepare_markup(_("Make sure to review all the licenses")), message_type=Gtk.MessageType.WARNING, context_id="LicensesNotificationBox") self.add_button(_("Accept"), self._on_accept) self.add_button(_("Accept forever"), self._on_accept_forever) self.add_button(_("Decline"), self._on_decline)
def __init__(self, app, entropy_client, license_map): """ LicensesNotificationBox constructor. @param entropy_client: Entropy Client object @param license_map: mapping composed by license id as key and list of Application objects as value. """ self._app = app self._entropy = entropy_client self._licenses = license_map licenses = sorted(license_map.keys(), key = lambda x: x.lower()) lic_txts = [] for lic in licenses: lic_txt = "<a href=\"%s\">%s</a>" % (lic, lic,) lic_txts.append(lic_txt) if app is None: msg = _("You are required to <b>review</b> and <b>accept</b>" " the following licenses before continuing: %s") msg = msg % (", ".join(lic_txts),) msg = prepare_markup(msg) else: msg = _("<b>%s</b> Application or one of its " "dependencies is distributed with the following" " licenses: %s") msg = msg % (self._app.name, ", ".join(lic_txts),) msg = prepare_markup(msg) label = Gtk.Label() label.set_markup(prepare_markup(msg)) label.set_line_wrap_mode(Pango.WrapMode.WORD) label.set_line_wrap(True) label.set_property("expand", True) label.set_alignment(0.02, 0.50) label.connect("activate-link", self._on_license_activate) NotificationBox.__init__( self, None, message_widget=label, tooltip=prepare_markup( _("Make sure to review all the licenses")), message_type=Gtk.MessageType.WARNING, context_id="LicensesNotificationBox") self.add_button(_("Accept"), self._on_accept) self.add_button(_("Accept forever"), self._on_accept_forever) self.add_button(_("Decline"), self._on_decline)
def _update_countdown(self, seconds): """ Update Countdown message. """ msg = prepare_markup( ngettext("<b>%s</b> Application Action will start " "in <big><b>%d</b></big> second", "<b>%s</b> Application Action will start " "in <big><b>%d</b></big> seconds", seconds)) msg = msg % (self._app.name, seconds,) self._action_label.set_markup(prepare_markup(msg))
def __init__(self, apc, avc, app, entropy_client, entropy_ws, rigo_service, install, _message=None): """ InstallNotificationBox constructor. @param entropy_client: Entropy Client object @param install: Application Install queue """ self._apc = apc self._avc = avc self._app = app self._entropy_ws = entropy_ws self._entropy = entropy_client self._service = rigo_service self._install = sorted( install, key = lambda x: x.name) if _message is None: msg = prepare_markup( _("<b>%s</b> Application requires the installation " "of the following Applications: %s")) else: msg = _message if len(self._install) <= 20: app_txts = [] for _app in self._install: _pkg_id, _repo_id = _app.get_details().pkg app_txt = "<a href=\"%d|%s\">%s</a>" % ( _pkg_id, _repo_id, _app.name,) app_txts.append(app_txt) txt = ", ".join(app_txts) else: txt = "<a href=\"%s\">%s</a>" % ( "full", _("Show full list")) msg = msg % (self._app.name, prepare_markup(txt),) label = Gtk.Label() label.set_markup(msg) label.set_line_wrap_mode(Pango.WrapMode.WORD) label.set_line_wrap(True) label.set_property("expand", True) label.set_alignment(0.02, 0.50) label.connect("activate-link", self._on_app_activate) NotificationBox.__init__( self, None, message_widget=label, message_type=Gtk.MessageType.WARNING, context_id="InstallNotificationBox") self.add_button(_("Accept"), self._on_accept) self.add_button(_("Decline"), self._on_decline)
def _update_countdown(self, seconds): """ Update Countdown message. """ msg = prepare_markup( ngettext( "<b>%s</b> Application Action will start " "in <big><b>%d</b></big> second", "<b>%s</b> Application Action will start " "in <big><b>%d</b></big> seconds", seconds)) msg = msg % ( self._app.name, seconds, ) self._action_label.set_markup(prepare_markup(msg))
def get_markup(self): """ Return ConfigurationUpdate markup text. """ categories = self.categories() max_cat = 4 max_cat_str = "" if len(categories) > max_cat: max_cat_str = " ..." cat_str = ", ".join(["<b>%s</b>" % x for x in categories[:max_cat]]) msg = "<b>%s</b>\n<small><i>%s</i>\n%s%s</small>" msg = msg % (escape_markup( self.name()), escape_markup(self.description()), prepare_markup(cat_str), prepare_markup(max_cat_str)) return prepare_markup(msg)
def __init__(self, avc, entropy_ws, app, context_id=None): self._avc = avc self._entropy_ws = entropy_ws self._app = app self._repository_id = app.get_details().channelname if context_id is None: context_id = "LoginNotificationBox" NotificationBox.__init__( self, None, message_widget=self._make_login_box(), tooltip=prepare_markup( _("You need to login to Entropy Web Services")), message_type=Gtk.MessageType.WARNING, context_id=context_id) self.add_button(_("_Login"), self._login) self.add_button(_("Register"), self._register) def _destroy(*args): self.emit("login-failed", self._app) self.destroy() self.add_button(_("_Cancel"), _destroy)
def _setup_not_found_box(self, search_text): """ Setup "not found" message label and layout """ nf_box = self._not_found_box with self._entropy.rwsem().reader(): # now self._not_found_label is available meant_packages = self._entropy.get_meant_packages(search_text) text = escape_markup(search_text) msg = "%s <b>%s</b>" % ( escape_markup(_("Nothing found for")), text, ) if meant_packages: first_entry = meant_packages[0] app = Application(self._entropy, self._entropy_ws, self._service, first_entry) name = app.name msg += ", %s" % ( prepare_markup(_("did you mean <a href=\"%s\">%s</a>?")) % ( escape_markup(name), escape_markup(name), ), ) self._not_found_label.set_markup(msg)
def _notify(): msg = _("Application <b>%s</b> not found") msg = msg % (dependency, ) box = NotificationBox(prepare_markup(msg), message_type=Gtk.MessageType.ERROR, context_id="AppRemoveNotFoundContextId") self._nc.append(box, timeout=10)
def update_queue_information(self, queue_len): """ Update Action Queue related info. """ daemon_action = self._last_daemon_action msg = None if daemon_action == DaemonAppActions.INSTALL: msg = _("Installing") elif daemon_action == DaemonAppActions.REMOVE: msg = _("Removing") if msg is not None: more_msg = "" queue_len -= 1 queue_len = max(0, queue_len) if queue_len: more_msg = ngettext( ", and <b>%d</b> <i>more in queue</i>", ", and <b>%d</b> <i>more in queue</i>", queue_len) more_msg = prepare_markup(more_msg % (queue_len,)) self._action_label.set_markup( "<big><b>%s</b>%s</big>" % ( escape_markup(msg), more_msg,))
def update_queue_information(self, queue_len): """ Update Action Queue related info. """ daemon_action = self._last_daemon_action msg = None if daemon_action == DaemonAppActions.INSTALL: msg = _("Installing") elif daemon_action == DaemonAppActions.REMOVE: msg = _("Removing") if msg is not None: more_msg = "" queue_len -= 1 queue_len = max(0, queue_len) if queue_len: more_msg = ngettext(", and <b>%d</b> <i>more in queue</i>", ", and <b>%d</b> <i>more in queue</i>", queue_len) more_msg = prepare_markup(more_msg % (queue_len, )) self._action_label.set_markup("<big><b>%s</b>%s</big>" % ( escape_markup(msg), more_msg, ))
def _setup_terminal_area(self): """ Setup TerminalWidget area (including ScrollBar). """ terminal_align = Gtk.Alignment() terminal_align.set_padding(10, 0, 0, 0) self._terminal_expander = Gtk.Expander.new( prepare_markup( _("<i>Show <b>Application Management</b> Progress</i>"))) self._terminal_expander.set_use_markup(True) hbox = Gtk.HBox() self._terminal = TerminalWidget() self._terminal.connect( "button-press-event", self._on_terminal_click) self._terminal.reset() self._terminal.autoscroll(self._autoscroll_mode) hbox.pack_start(self._terminal, True, True, 0) scrollbar = Gtk.VScrollbar.new(self._terminal.get_property("vadjustment")) hbox.pack_start(scrollbar, False, False, 0) self._terminal_expander.add(hbox) terminal_align.add(self._terminal_expander) terminal_align.show_all() return terminal_align
def get_markup(self): """ Return Preference markup text. """ msg = "<b>%s</b>\n\n<small>%s</small>" msg = msg % (self._title, self._description) return prepare_markup(msg)
def _setup_terminal_area(self): """ Setup TerminalWidget area (including ScrollBar). """ terminal_align = Gtk.Alignment() terminal_align.set_padding(10, 0, 0, 0) self._terminal_expander = Gtk.Expander.new( prepare_markup( _("<i>Show <b>Application Management</b> Progress</i>"))) self._terminal_expander.set_use_markup(True) hbox = Gtk.HBox() self._terminal = TerminalWidget() self._terminal.connect("button-press-event", self._on_terminal_click) self._terminal.reset() self._terminal.autoscroll(self._autoscroll_mode) hbox.pack_start(self._terminal, True, True, 0) scrollbar = Gtk.VScrollbar.new( self._terminal.get_property("vadjustment")) hbox.pack_start(scrollbar, False, False, 0) self._terminal_expander.add(hbox) terminal_align.add(self._terminal_expander) terminal_align.show_all() return terminal_align
def __init__(self, apc, avc, app, entropy_client, entropy_ws, rigo_service, removal): message = prepare_markup( _("<b>%s</b> Application requires the removal " "of the following Applications: %s")) InstallNotificationBox.__init__( self, apc, avc, app, entropy_client, entropy_ws, rigo_service, removal, _message=message)
def get_markup(self): """ Return ConfigurationUpdate markup text. """ categories = self.categories() max_cat = 4 max_cat_str = "" if len(categories) > max_cat: max_cat_str = " ..." cat_str = ", ".join( ["<b>%s</b>" % x for x in categories[:max_cat]]) msg = "<b>%s</b>\n<small><i>%s</i>\n%s%s</small>" msg = msg % ( escape_markup(self.name()), escape_markup(self.description()), prepare_markup(cat_str), prepare_markup(max_cat_str)) return prepare_markup(msg)
def _notify_error(self, message): """ Notify a generic configuration management action error. """ box = NotificationBox( prepare_markup(message), message_type=Gtk.MessageType.ERROR, context_id="ConfigUpdateErrorContextId") self._nc.append(box, timeout=10)
def __init__(self, message, context_id): NotificationBox.__init__(self, message, tooltip=prepare_markup(_("A watched pot never boils")), message_type=Gtk.MessageType.INFO, context_id=context_id) self._spinner = Gtk.Spinner() self._spinner.set_size_request(StockEms.XXLARGE, StockEms.XXLARGE) self.add_widget(self._spinner)
def get_markup(self): """ Return ConfigurationUpdate markup text. """ msg = "<b>%s</b>\n<small><b>%s</b>, " + \ "<i>%s</i>\n<u>%s</u></small>" msg = msg % (escape_markup( self.title()), escape_markup(self.repository()), escape_markup(self.date()), escape_markup(self.link())) return prepare_markup(msg)
def __init__(self, preserved): preserved_len = len(preserved) msg = ngettext("There is <b>%d</b> preserved library on the system", "There are <b>%d</b> preserved libraries on the system", preserved_len) msg = msg % (preserved_len,) msg += ". " + _("What to do?") NotificationBox.__init__( self, prepare_markup(msg), tooltip=prepare_markup( _("Preserved libraries detected on the system.")), message_type=Gtk.MessageType.WARNING, context_id="PreservedLibsNotificationBox") self.add_button(_("_Update system now"), self._update) self.add_destroy_button(_("_Ignore"))
def __init__(self): msg = _("Cannot connect to Entropy Web Services, " "are you connected to the <b>interweb</b>?") NotificationBox.__init__(self, msg, tooltip=prepare_markup(_("Don't ask me...")), message_type=Gtk.MessageType.ERROR, context_id="ConnectivityNotificationBox") self.add_destroy_button(_("_Of course not"))
def _build_app_str_list(self, apps): app_lst = [] for app in apps: app_name = escape_markup(app.name) pkg_id, pkg_repo = app.get_details().pkg app_str = "<b><a href=\"%d|%s\">%s</a></b>" % (pkg_id, pkg_repo, app_name) app_lst.append(app_str) return prepare_markup("<small>" + \ ", ".join(app_lst) + "</small>")
def _build_app_str_list(self, apps): app_lst = [] for app in apps: app_name = escape_markup(app.name) pkg_id, pkg_repo = app.get_details().pkg app_str = "<b><a href=\"%d|%s\">%s</a></b>" % ( pkg_id, pkg_repo, app_name) app_lst.append(app_str) return prepare_markup("<small>" + \ ", ".join(app_lst) + "</small>")
def __init__(self, message, context_id): NotificationBox.__init__(self, message, tooltip=prepare_markup( _("A watched pot never boils")), message_type=Gtk.MessageType.INFO, context_id=context_id) self._spinner = Gtk.Spinner() self._spinner.set_size_request(StockEms.XXLARGE, StockEms.XXLARGE) self.add_widget(self._spinner)
def __show_no_comments(self): """ Create "No comments for this Application" message. """ label = Gtk.Label() label.set_markup( prepare_markup( _("<i>No <b>comments</b> for this Application, yet!</i>"))) # place in app_my, this way it will get cleared out # once a new comment is inserted self._app_my_comments_box.pack_start(label, False, False, 1) self._app_my_comments_box.show_all()
def get_markup(self): """ Return ConfigurationUpdate markup text. """ msg = "<b>%s</b>\n<small><b>%s</b>, " + \ "<i>%s</i>\n<u>%s</u></small>" msg = msg % ( escape_markup(self.title()), escape_markup(self.repository()), escape_markup(self.date()), escape_markup(self.link())) return prepare_markup(msg)
def __init__(self, preserved): preserved_len = len(preserved) msg = ngettext( "There is <b>%d</b> preserved library on the system", "There are <b>%d</b> preserved libraries on the system", preserved_len) msg = msg % (preserved_len, ) msg += ". " + _("What to do?") NotificationBox.__init__( self, prepare_markup(msg), tooltip=prepare_markup( _("Preserved libraries detected on the system.")), message_type=Gtk.MessageType.WARNING, context_id="PreservedLibsNotificationBox") self.add_button(_("_Update system now"), self._update) self.add_destroy_button(_("_Ignore"))
def _setup_label(self, label): """ Setup message Label content. """ msg = prepare_markup( _("Several <b>Applications</b>, no longer maintained by this " "distribution, have been found on your <b>System</b>. " "Some of them might require <b>manual review</b> before " "being uninstalled. Click on the Apps to expand.")) msg += "\n" if self._manual_apps: msg += "\n%s: %s" % ( prepare_markup(_("Manual review")), self._build_app_str_list(self._manual_apps),) if self._apps: msg += "\n%s: %s" % ( prepare_markup(_("Safe to drop")), self._build_app_str_list(self._apps),) label.set_markup(prepare_markup(msg))
def get_markup(self): """ Return Repository markup text. """ msg = "<b>%s</b>\n<small><i>%s</i>\n<b>%s</b></small>" if self.enabled(): enabled_msg = _("Enabled") else: enabled_msg = _("Disabled") msg = msg % (escape_markup( self.repository()), escape_markup( self.description()), escape_markup(enabled_msg)) return prepare_markup(msg)
def feed_child(self, txt): # Workaround vte.Terminal bug not passing to .feed proper message RAW # size. feed() supports UTF-8 but then, string length is wrongly passed # by python, because it does not consider the fact that UTF-8 chars can # be 16bits long. raw_txt_len = len(txt) if const_isunicode(txt): raw_txt_len = len(txt.encode(etpConst['conf_encoding'])) try: return Vte.Terminal.feed(self, txt, raw_txt_len) except TypeError: # Vte.Terminal 0.32.x return Vte.Terminal.feed(self, prepare_markup(txt))
def _setup_label(self, label): """ Setup message Label content. """ msg = prepare_markup( _("Several <b>Applications</b>, no longer maintained by this " "distribution, have been found on your <b>System</b>. " "Some of them might require <b>manual review</b> before " "being uninstalled. Click on the Apps to expand.")) msg += "\n" if self._manual_apps: msg += "\n%s: %s" % ( prepare_markup(_("Manual review")), self._build_app_str_list(self._manual_apps), ) if self._apps: msg += "\n%s: %s" % ( prepare_markup(_("Safe to drop")), self._build_app_str_list(self._apps), ) label.set_markup(prepare_markup(msg))
def __init__(self, apc, avc, app, entropy_client, entropy_ws, rigo_service, removal): message = prepare_markup( _("<b>%s</b> Application requires the removal " "of the following Applications: %s")) InstallNotificationBox.__init__(self, apc, avc, app, entropy_client, entropy_ws, rigo_service, removal, _message=message)
def _rename(self, button): """ Try to login to Entropy Web Services. """ repository_id = self._repo_entry.get_text() valid = entropy.tools.validate_repository_id(repository_id) if not valid: self._repo_message.show() self._repo_message.set_markup( prepare_markup(_("<b>Invalid</b> Repository name!"))) return from_repository_id = self._repo.repository() renamed = self._service.rename_repository(from_repository_id, repository_id) if not renamed: self._repo_message.show() self._repo_message.set_markup( prepare_markup(_("Repository rename <b>not allowed</b>!"))) return self.destroy() self.emit("renamed")
def get_markup(self): """ Return ConfigurationUpdate markup text. """ source = escape_markup(self.root() + self.source()) dest = escape_markup(self.root() + self.destination()) apps = self.apps() msg = "<b>%s</b>\n<small><u>%s</u>: <i>%s</i></small>" % ( source, _("Destination"), dest) if apps: apps_msg = "\n<small><u>%s</u>: %s</small>" % ( _("Applications"), ", ".join(["<i>" + x.name + "</i>" for x in apps]),) msg += apps_msg return prepare_markup(msg)
def __init__(self, entropy_client, avc, unavailable=None): self._entropy = entropy_client self._avc = avc if unavailable is None: msg = _("The list of available Applications is old" ", <b>update now</b>?") else: msg = _("Repositories should be downloaded, <b>update now</b>?") NotificationBox.__init__(self, msg, tooltip=prepare_markup(_("I dunno dude, I'd say Yes")), message_type=Gtk.MessageType.ERROR, context_id="RepositoriesUpdateNotificationBox") self.add_button(_("_Yes, why not?"), self._update) self.add_destroy_button(_("_No, thanks"))
def _append_images(self, downloader, app, images, has_more): """ Append given Entropy WebService Document objects to the images area. """ self.__clean_non_image_boxes() if not images: label = Gtk.Label() label.set_markup( prepare_markup( _("<i>No <b>images</b> for this Application, yet!</i>"))) self._app_images_box.pack_start(label, False, False, 1) label.show() return if has_more: button_box = Gtk.HButtonBox() button = Gtk.Button() button.set_label(_("Older images")) button.set_alignment(0.5, 0.5) def _enqueue_download(widget): widget.get_parent().destroy() spinner = Gtk.Spinner() spinner.set_size_request(24, 24) spinner.set_tooltip_text(_("Loading older images...")) spinner.set_name("image-box-spinner") self._app_images_box.pack_end(spinner, False, False, 3) spinner.show() spinner.start() downloader.enqueue_download() button.connect("clicked", _enqueue_download) button_box.pack_start(button, False, False, 0) self._app_images_box.pack_start(button_box, False, False, 1) button_box.show_all() idx = 0 length = len(images) for doc in images: idx += 1 box = ImageBox(doc, is_last=(not has_more and (idx == length))) box.render() self._app_images_box.pack_end(box, False, False, 2) box.show()
def get_markup(self): """ Return ConfigurationUpdate markup text. """ source = escape_markup(self.root() + self.source()) dest = escape_markup(self.root() + self.destination()) apps = self.apps() msg = "<b>%s</b>\n<small><u>%s</u>: <i>%s</i></small>" % ( source, _("Destination"), dest) if apps: apps_msg = "\n<small><u>%s</u>: %s</small>" % ( _("Applications"), ", ".join(["<i>" + x.name + "</i>" for x in apps]), ) msg += apps_msg return prepare_markup(msg)
def __init__(self, repo_object, rigo_service): self._repo = repo_object self._service = rigo_service context_id = "RenameRepositoryNotificationBox" NotificationBox.__init__(self, None, message_widget=self._make_rename_box(), tooltip=prepare_markup( _("You are about to rename a Repository")), message_type=Gtk.MessageType.INFO, context_id=context_id) self.add_button(_("_Rename"), self._rename) def _destroy(*args): self.emit("cancelled") self.destroy() self.add_button(_("_Cancel"), _destroy)
def __init__(self, entropy_client, avc, unavailable=None): self._entropy = entropy_client self._avc = avc if unavailable is None: msg = _("The list of available Applications is old" ", <b>update now</b>?") else: msg = _("Repositories should be downloaded, <b>update now</b>?") NotificationBox.__init__( self, msg, tooltip=prepare_markup(_("I dunno dude, I'd say Yes")), message_type=Gtk.MessageType.ERROR, context_id="RepositoriesUpdateNotificationBox") self.add_button(_("_Yes, why not?"), self._update) self.add_destroy_button(_("_No, thanks"))
def __init__(self, repo_object, rigo_service): self._repo = repo_object self._service = rigo_service context_id = "RenameRepositoryNotificationBox" NotificationBox.__init__( self, None, message_widget=self._make_rename_box(), tooltip=prepare_markup(_("You are about to rename a Repository")), message_type=Gtk.MessageType.INFO, context_id=context_id) self.add_button(_("_Rename"), self._rename) def _destroy(*args): self.emit("cancelled") self.destroy() self.add_button(_("_Cancel"), _destroy)
def __init__(self, avc, notices_len): msg = ngettext("There is <b>%d</b> notice from a repository", "There are <b>%d</b> notices from repositories", notices_len) msg = msg % (notices_len, ) msg += ".\n\n<small>" msg += _("It is <b>extremely</b> important to" " always read them.") msg += "</small>" context_id = "NoticeBoardNotificationContextId" NotificationBox.__init__(self, prepare_markup(msg), message_type=Gtk.MessageType.INFO, context_id=context_id) self.add_button(_("Let me see"), self._on_let_me_see) self.add_button(_("Stop annoying me"), self._on_stop_annoying) self.add_destroy_button(_("Close"))
def __init__(self, avc, notices_len): msg = ngettext("There is <b>%d</b> notice from a repository", "There are <b>%d</b> notices from repositories", notices_len) msg = msg % (notices_len,) msg += ".\n\n<small>" msg += _("It is <b>extremely</b> important to" " always read them.") msg += "</small>" context_id = "NoticeBoardNotificationContextId" NotificationBox.__init__( self, prepare_markup(msg), message_type=Gtk.MessageType.INFO, context_id=context_id) self.add_button(_("Let me see"), self._on_let_me_see) self.add_button(_("Stop annoying me"), self._on_stop_annoying) self.add_destroy_button(_("Close"))
def __init__(self, avc, entropy_ws, app, context_id=None): self._avc = avc self._entropy_ws = entropy_ws self._app = app self._repository_id = app.get_details().channelname if context_id is None: context_id = "LoginNotificationBox" NotificationBox.__init__(self, None, message_widget=self._make_login_box(), tooltip=prepare_markup( _("You need to login to Entropy Web Services")), message_type=Gtk.MessageType.WARNING, context_id=context_id) self.add_button(_("_Login"), self._login) self.add_button(_("Register"), self._register) def _destroy(*args): self.emit("login-failed", self._app) self.destroy() self.add_button(_("_Cancel"), _destroy)
def _on_repository_toggle(self, widget, path, repo): """ Enable/Disable Repository event from View """ enabled = repo.enabled() repository = repo.repository() if enabled: outcome = self._service.disable_repository(repository) else: outcome = self._service.enable_repository(repository) if not outcome and self._nc is not None: if enabled: msg = _("Cannot disable <b>%s</b>. Sorry!") else: msg = _("Cannot enable <b>%s</b>. Sorry!") box = NotificationBox( prepare_markup(msg % (repository,)), message_type=Gtk.MessageType.WARNING, context_id=self._service.REPOSITORY_SETTINGS_CONTEXT_ID) box.add_destroy_button(_("_Ok")) self._nc.append(box)
def _on_repository_toggle(self, widget, path, repo): """ Enable/Disable Repository event from View """ enabled = repo.enabled() repository = repo.repository() if enabled: outcome = self._service.disable_repository(repository) else: outcome = self._service.enable_repository(repository) if not outcome and self._nc is not None: if enabled: msg = _("Cannot disable <b>%s</b>. Sorry!") else: msg = _("Cannot enable <b>%s</b>. Sorry!") box = NotificationBox( prepare_markup(msg % (repository, )), message_type=Gtk.MessageType.WARNING, context_id=self._service.REPOSITORY_SETTINGS_CONTEXT_ID) box.add_destroy_button(_("_Ok")) self._nc.append(box)
def __init__(self, entropy_client, avc, updates_len): self._entropy = entropy_client self._avc = avc msg = ngettext("There is <b>%d</b> configuration file update", "There are <b>%d</b> configuration file updates", updates_len) msg = msg % (updates_len,) msg += ".\n\n<small>" msg += _("It is <b>extremely</b> important to" " update these configuration files before" " <b>rebooting</b> the System.") msg += "</small>" context_id = "ConfigUpdatesNotificationContextId" NotificationBox.__init__( self, prepare_markup(msg), message_type=Gtk.MessageType.WARNING, context_id=context_id) self.add_button(_("Let me see"), self._on_show_me) self.add_destroy_button(_("Happily ignore"))
def __init__(self, entropy_client, avc, updates_len): self._entropy = entropy_client self._avc = avc msg = ngettext("There is <b>%d</b> configuration file update", "There are <b>%d</b> configuration file updates", updates_len) msg = msg % (updates_len, ) msg += ".\n\n<small>" msg += _("It is <b>extremely</b> important to" " update these configuration files before" " <b>rebooting</b> the System.") msg += "</small>" context_id = "ConfigUpdatesNotificationContextId" NotificationBox.__init__(self, prepare_markup(msg), message_type=Gtk.MessageType.WARNING, context_id=context_id) self.add_button(_("Let me see"), self._on_show_me) self.add_destroy_button(_("Happily ignore"))
def __init__(self, apc, avc, app, entropy_client, entropy_ws, rigo_service, install, _message=None): """ InstallNotificationBox constructor. @param entropy_client: Entropy Client object @param install: Application Install queue """ self._apc = apc self._avc = avc self._app = app self._entropy_ws = entropy_ws self._entropy = entropy_client self._service = rigo_service self._install = sorted(install, key=lambda x: x.name) if _message is None: msg = prepare_markup( _("<b>%s</b> Application requires the installation " "of the following Applications: %s")) else: msg = _message if len(self._install) <= 20: app_txts = [] for _app in self._install: _pkg_id, _repo_id = _app.get_details().pkg app_txt = "<a href=\"%d|%s\">%s</a>" % ( _pkg_id, _repo_id, _app.name, ) app_txts.append(app_txt) txt = ", ".join(app_txts) else: txt = "<a href=\"%s\">%s</a>" % ("full", _("Show full list")) msg = msg % ( self._app.name, prepare_markup(txt), ) label = Gtk.Label() label.set_markup(msg) label.set_line_wrap_mode(Pango.WrapMode.WORD) label.set_line_wrap(True) label.set_property("expand", True) label.set_alignment(0.02, 0.50) label.connect("activate-link", self._on_app_activate) NotificationBox.__init__(self, None, message_widget=label, message_type=Gtk.MessageType.WARNING, context_id="InstallNotificationBox") self.add_button(_("Accept"), self._on_accept) self.add_button(_("Decline"), self._on_decline)
def _login_error(): self._login_message.show() self._login_message.set_markup( prepare_markup(_("Login <b>error</b>!")))
def _login_error(): self._login_message.show() self._login_message.set_markup( prepare_markup( _("Login <b>error</b>!")))