def __init__(self, application): self.application = application self.application.window.set_sensitive(False) gladefile = "/usr/share/linuxmint/mintupdate/kernels.ui" self.builder = Gtk.Builder() self.builder.set_translation_domain("mintupdate") self.builder.add_from_file(gladefile) self.window = self.builder.get_object("window1") self.window.set_title(_("Kernels")) main_box = self.builder.get_object("main_vbox") info_box = self.builder.get_object("intro_box") self.main_stack = Gtk.Stack() self.main_stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE) self.window.add(self.main_stack) # status_refreshing page self.main_stack.add_named(self.builder.get_object("status_refreshing"), "status_refreshing") self.status_refreshing_spinner = self.builder.get_object( "status_refreshing_spinner") # Setup the kernel warning page self.main_stack.add_named(info_box, "info_box") self.builder.get_object("button_continue").connect( "clicked", self.on_continue_clicked, main_box) self.builder.get_object("button_help").connect("clicked", self.show_help) self.builder.get_object("checkbutton1").connect( "toggled", self.on_info_checkbox_toggled) # Setup the main kernel page self.stack = Gtk.Stack() self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP_DOWN) stack_switcher = Gtk.StackSidebar() stack_switcher.set_stack(self.stack) scrolled_series = self.builder.get_object("box7") scrolled_series.pack_start(stack_switcher, True, True, 0) kernel_stack_box = self.builder.get_object("box1") kernel_stack_box.pack_start(self.stack, True, True, 0) self.builder.get_object("button_close").connect( "clicked", self.destroy_window) self.window.connect("destroy", self.destroy_window) self.current_label = self.builder.get_object("current_label") # Set up the kernel mass operation confirmation window and associated buttons self.confirmation_dialog = self.builder.get_object( "confirmation_window") self.confirmation_dialog.connect("destroy", self.on_cancel_clicked) self.confirmation_dialog.connect("delete-event", self.on_cancel_clicked) self.builder.get_object("b_confirmation_confirm").connect( "clicked", self.on_confirm_clicked) self.builder.get_object("b_confirmation_cancel").connect( "clicked", self.on_cancel_clicked) self.confirmation_listbox = self.builder.get_object( "confirmation_listbox") self.confirmation_listbox.set_sort_func(self.confirmation_listbox_sort) self.remove_kernels_listbox = [] self.queued_kernels_listbox = [] self.queued_kernels = [] self.button_massremove = self.builder.get_object("button_massremove") self.button_massremove.connect("clicked", self.show_confirmation_dialog, _("Remove Kernels"), self.remove_kernels_listbox) self.button_do_queue = self.builder.get_object("button_do_queue") self.button_do_queue.connect("clicked", self.show_confirmation_dialog, _("Perform Queued Actions"), self.queued_kernels_listbox) # Get distro release dates for support duration calculation self.release_dates = get_release_dates() self.allow_kernel_type_selection = False self.initially_configured_kernel_type = CONFIGURED_KERNEL_TYPE if not self.allow_kernel_type_selection and \ self.application.settings.get_boolean("allow-kernel-type-selection"): self.allow_kernel_type_selection = True if self.allow_kernel_type_selection: # Set up the kernel type selection dropdown self.kernel_type_selector = self.builder.get_object( "cb_kernel_type") for index, kernel_type in enumerate(SUPPORTED_KERNEL_TYPES): self.kernel_type_selector.append_text(kernel_type[1:]) if kernel_type[1:] == CONFIGURED_KERNEL_TYPE[1:]: self.kernel_type_selector.set_active(index) # Refresh window on kernel type selection change def on_kernel_type_selector_changed(widget): global CONFIGURED_KERNEL_TYPE CONFIGURED_KERNEL_TYPE = "-" + widget.get_active_text() self.application.settings.set_string("selected-kernel-type", CONFIGURED_KERNEL_TYPE) self.refresh_kernels_list() self.kernel_type_selector.connect("changed", on_kernel_type_selector_changed) self.main_stack.add_named(main_box, "main_box") # Center on main window window_size = self.window.get_size() parent_size = self.application.window.get_size() parent_position = self.application.window.get_position() parent_center_x = parent_position.root_x + parent_size.width / 2 parent_center_y = parent_position.root_y + parent_size.height / 2 self.window.move(parent_center_x - window_size.width / 2, parent_center_y - window_size.height / 2) self.window.show_all() self.builder.get_object("cb_label").set_visible( self.allow_kernel_type_selection) self.builder.get_object("cb_kernel_type").set_visible( self.allow_kernel_type_selection) if self.application.settings.get_boolean("hide-kernel-update-warning"): self.refresh_kernels_list() else: self.main_stack.set_visible_child(info_box)
origin = 1 else: origin = 2 archive = pkg_data.origins[0].archive # get support duration supported_tag = pkg_data.record.get("Supported") if not supported_tag and origin == 1 and not "-proposed" in pkg_data.origins[0].archive: # Workaround for Ubuntu releasing kernels by copying straight from # -proposed and only adding the Supported tag shortly after. # To avoid user confusion in the time in-between we just assume # that all Ubuntu kernels in all pockets but -proposed are supported # and generate the supported tag based on the distro support duration if not release_dates: release_dates = get_release_dates() distro = pkg.candidate.origins[0].archive.split("-")[0] if distro in release_dates: distro_lifetime = (release_dates[distro][1].year - release_dates[distro][0].year) * 12 +\ release_dates[distro][1].month - release_dates[distro][0].month if distro_lifetime >= 12: supported_tag = f"{distro_lifetime // 12}y" else: supported_tag = f"{distro_lifetime}m" if supported_tag: if pkg_data.record["Supported"].endswith("y"): # override support duration for HWE kernels in LTS releases, # these will be handled by the kernel window if "-hwe" in pkg_data.source_name: support_duration = -1 else:
else: origin = 2 archive = pkg_data.origins[0].archive # get support duration supported_tag = pkg_data.record.get("Supported") if not supported_tag and origin == 1 and not "-proposed" in pkg_data.origins[ 0].archive: # Workaround for Ubuntu releasing kernels by copying straight from # -proposed and only adding the Supported tag shortly after. # To avoid user confusion in the time in-between we just assume # that all Ubuntu kernels in all pockets but -proposed are supported # and generate the supported tag based on the distro support duration if not release_dates: release_dates = get_release_dates() distro = pkg.candidate.origins[0].archive.split("-")[0] if distro in release_dates: distro_lifetime = (release_dates[distro][1].year - release_dates[distro][0].year) * 12 +\ release_dates[distro][1].month - release_dates[distro][0].month if distro_lifetime >= 12: supported_tag = f"{distro_lifetime // 12}y" else: supported_tag = f"{distro_lifetime}m" if supported_tag: if pkg_data.record["Supported"].endswith("y"): # override support duration for HWE kernels in LTS releases, # these will be handled by the kernel window if "-hwe" in pkg_data.source_name: support_duration = -1 else:
def __init__(self, application): self.application = application self.application.window.set_sensitive(False) gladefile = "/usr/share/linuxmint/mintupdate/kernels.ui" self.builder = Gtk.Builder() self.builder.set_translation_domain("mintupdate") self.builder.add_from_file(gladefile) self.window = self.builder.get_object("window1") self.window.set_title(_("Kernels")) main_box = self.builder.get_object("main_vbox") info_box = self.builder.get_object("intro_box") self.main_stack = Gtk.Stack() self.main_stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE) self.window.add(self.main_stack) # Setup the kernel warning page self.main_stack.add_named(info_box, "info_box") self.builder.get_object("button_continue").connect("clicked", self.on_continue_clicked, main_box) self.builder.get_object("button_help").connect("clicked", self.show_help) self.builder.get_object("checkbutton1").connect("toggled", self.on_info_checkbox_toggled) # Setup the main kernel page self.stack = Gtk.Stack() self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP_DOWN) stack_switcher = Gtk.StackSidebar() stack_switcher.set_stack(self.stack) scrolled_series = self.builder.get_object("box7") scrolled_series.pack_start(stack_switcher, True, True, 0) kernel_stack_box = self.builder.get_object("box1") kernel_stack_box.pack_start(self.stack, True, True, 0) self.builder.get_object("button_close").connect("clicked", self.destroy_window) self.window.connect("destroy", self.destroy_window) self.current_label = self.builder.get_object("current_label") # Set up the kernel mass operation confirmation window and associated buttons self.confirmation_dialog = self.builder.get_object("confirmation_window") self.confirmation_dialog.connect("destroy", self.on_cancel_clicked) self.confirmation_dialog.connect("delete-event", self.on_cancel_clicked) self.builder.get_object("b_confirmation_confirm").connect("clicked", self.on_confirm_clicked) self.builder.get_object("b_confirmation_cancel").connect("clicked", self.on_cancel_clicked) self.confirmation_listbox = self.builder.get_object("confirmation_listbox") self.confirmation_listbox.set_sort_func(self.confirmation_listbox_sort) self.remove_kernels_listbox = [] self.queued_kernels_listbox = [] self.queued_kernels = [] self.button_massremove = self.builder.get_object("button_massremove") self.button_massremove.connect("clicked", self.show_confirmation_dialog, _("Remove Kernels"), self.remove_kernels_listbox) self.button_do_queue = self.builder.get_object("button_do_queue") self.button_do_queue.connect("clicked", self.show_confirmation_dialog, _("Perform Queued Actions"), self.queued_kernels_listbox) # Get distro release dates for support duration calculation self.release_dates = get_release_dates() # Build kernels list self.allow_kernel_type_selection = False self.build_kernels_list() self.initially_configured_kernel_type = CONFIGURED_KERNEL_TYPE if not self.allow_kernel_type_selection and \ self.application.settings.get_boolean("allow-kernel-type-selection"): self.allow_kernel_type_selection = True if self.allow_kernel_type_selection: # Set up the kernel type selection dropdown self.kernel_type_selector = self.builder.get_object("cb_kernel_type") for index, kernel_type in enumerate(SUPPORTED_KERNEL_TYPES): self.kernel_type_selector.append_text(kernel_type[1:]) if kernel_type[1:] == CONFIGURED_KERNEL_TYPE[1:]: self.kernel_type_selector.set_active(index) # Refresh window on kernel type selection change def on_kernel_type_selector_changed(widget): global CONFIGURED_KERNEL_TYPE CONFIGURED_KERNEL_TYPE = "-" + widget.get_active_text() self.application.settings.set_string("selected-kernel-type", CONFIGURED_KERNEL_TYPE) for child in self.stack.get_children(): child.destroy() self.remove_kernels_listbox = [] self.build_kernels_list() self.stack.show_all() self.kernel_type_selector.connect("changed", on_kernel_type_selector_changed) self.main_stack.add_named(main_box, "main_box") if self.application.settings.get_boolean("hide-kernel-update-warning"): self.main_stack.set_visible_child(main_box) else: self.main_stack.set_visible_child(info_box) # Center on main window window_size = self.window.get_size() parent_size = self.application.window.get_size() parent_position = self.application.window.get_position() parent_center_x = parent_position.root_x + parent_size.width / 2 parent_center_y = parent_position.root_y + parent_size.height / 2 self.window.move(parent_center_x - window_size.width / 2, parent_center_y - window_size.height / 2) self.window.show_all() self.builder.get_object("cb_label").set_visible(self.allow_kernel_type_selection) self.builder.get_object("cb_kernel_type").set_visible(self.allow_kernel_type_selection)