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

Method __toggle_callback

bleachbit/GuiPreferences.py:248–290  ·  view source on GitHub ↗

Callback function to toggle option

(self, _cell, path)

Source from the content-addressed store, hash-verified

246 self.refresh_operations = True
247
248 def __toggle_callback(self, _cell, path):
249 """Callback function to toggle option"""
250 options.toggle(path)
251 if online_update_notification_enabled:
252 self.cb_beta.set_sensitive(options.get('check_online_updates'))
253 if 'nt' == os.name:
254 self.cb_winapp2.set_sensitive(
255 options.get('check_online_updates'))
256 if 'auto_hide' == path:
257 self.refresh_operations = True
258 if 'dark_mode' == path:
259 logger.debug("Toggling dark mode to %s", options.get('dark_mode'))
260 theme_widget = self.parent or self.dialog
261 before_dark = detect_dark_background(theme_widget)
262 if 'nt' == os.name and options.get('win10_theme'):
263 self.cb_set_windows10_theme()
264
265 settings = self.dialog.get_settings()
266 if settings:
267 settings.set_property(
268 'gtk-application-prefer-dark-theme', options.get('dark_mode'))
269 else:
270 logger.warning("Could not get GTK settings to apply dark mode")
271
272 flush_gtk_events()
273 after_dark = detect_dark_background(theme_widget)
274
275 if not os.name == 'nt' and should_show_dark_mode_warning(before_dark, after_dark):
276 self.show_infobar(
277 # TRANSLATORS: Notice shown in an infobar when toggling
278 # dark mode on Linux.
279 _("Some GTK themes do not support both light and dark modes."),
280 Gtk.MessageType.WARNING)
281 if 'win10_theme' == path:
282 self.cb_set_windows10_theme()
283 if 'debug' == path:
284 from bleachbit.Log import set_root_log_level
285 set_root_log_level(options.get('debug'))
286 if 'kde_shred_menu_option' == path:
287 from bleachbit.DesktopMenuOptions import install_kde_service_menu_file
288 install_kde_service_menu_file()
289 if 'use_fontconfig_backend' == path:
290 self.show_infobar(RESTART_APP_MSG, Gtk.MessageType.INFO)
291
292 def __reset_warning_preferences(self, _button):
293 """Reset saved warning confirmations."""

Callers 1

Calls 9

show_infobarMethod · 0.95
detect_dark_backgroundFunction · 0.90
flush_gtk_eventsFunction · 0.90
set_root_log_levelFunction · 0.90
toggleMethod · 0.80
set_sensitiveMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected