MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / set_cleaner

Method set_cleaner

bleachbit/GuiTreeModels.py:69–111  ·  view source on GitHub ↗

Activate or deactivate option of cleaner.

(self, path, model, parent_window, value)

Source from the content-addressed store, hash-verified

67 return self.view
68
69 def set_cleaner(self, path, model, parent_window, value):
70 """Activate or deactivate option of cleaner."""
71 assert isinstance(value, bool)
72 assert isinstance(model, Gtk.TreeStore)
73 cleaner_id = None
74 i = path
75 if isinstance(i, str):
76 # type is either str or gtk.TreeIter
77 i = model.get_iter(path)
78 parent = model.iter_parent(i)
79 if parent:
80 # this is an option (child), not a cleaner (parent)
81 cleaner_id = model[parent][2]
82 option_id = model[path][2]
83 if cleaner_id and value:
84 # When enabling an option, present any warnings.
85 # (When disabling an option, there is no need to present warnings.)
86 warning = backends[cleaner_id].get_warning(option_id)
87 if warning and not options.get('expert_mode'):
88 if hasattr(parent_window, 'show_infobar'):
89 parent_window.show_infobar(
90 # TRANSLATORS: Warning shown in the infobar.
91 _("This option is protected. To bypass protection, enable expert mode."))
92 # Show an alert icon by the option name.
93 model[path][4] = "dialog-warning"
94 return
95 warning_key = 'cleaner:' + cleaner_id + ':' + option_id
96 if warning and not options.get_warning_preference(warning_key):
97 # TRANSLATORS: %(cleaner) may be Firefox, System, etc.
98 # %(option) may be cache, logs, cookies, etc.
99 option_name = _("%(cleaner)s - %(option)s") % {
100 'cleaner': model[parent][0],
101 'option': model[path][0],
102 }
103 confirmed, remember_choice = GuiBasic.warning_confirm_dialog(
104 parent_window, option_name, warning)
105 if not confirmed:
106 # user cancelled, so don't toggle option
107 return
108 if remember_choice:
109 options.remember_warning_preference(warning_key)
110 model[path][1] = value
111 model[path][4] = ""
112
113 def col1_toggled_cb(self, cell, path, model, parent_window):
114 """Callback for toggling cleaners"""

Callers 1

col1_toggled_cbMethod · 0.95

Calls 6

get_iterMethod · 0.80
get_warningMethod · 0.80
getMethod · 0.45
show_infobarMethod · 0.45

Tested by

no test coverage detected