Skip to content

Commit

Permalink
Move 'Show tray icon' to Preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
strycore committed Oct 19, 2020
1 parent 8ae4e16 commit 7c8865d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 76 deletions.
2 changes: 1 addition & 1 deletion lutris/gui/application.py
Expand Up @@ -607,7 +607,7 @@ def do_shutdown(self): # pylint: disable=arguments-differ

def set_tray_icon(self):
"""Creates or destroys a tray icon for the application"""
active = settings.read_setting("show_tray_icon", default="false") == "true"
active = settings.read_setting("show_tray_icon", default="false").lower() == "true"
if active and not self.tray:
self.tray = LutrisStatusIcon(application=self)
if self.tray:
Expand Down
36 changes: 14 additions & 22 deletions lutris/gui/config/common.py
Expand Up @@ -99,8 +99,13 @@ def _build_info_tab(self):

def _build_prefs_tab(self):
prefs_box = VBox()
prefs_box.pack_start(self._get_hide_on_game_launch_box(), False, False, 6)
prefs_box.pack_start(self._get_hide_text_under_icons(), False, False, 6)
settings_options = {
"hide_client_on_game_start": _("Minimize client when a game is launched"),
"hide_text_under_icons": _("Hide text under icons"),
"show_tray_icon": _("Show Tray Icon"),
}
for setting_key, label in settings_options.items():
prefs_box.pack_start(self._get_setting_box(setting_key, label), False, False, 6)
info_sw = self.build_scrolled_window(prefs_box)
self._add_notebook_tab(info_sw, _("Lutris preferences"))

Expand All @@ -126,31 +131,18 @@ def _build_sysinfo_tab(self):
def _copy_text(self, widget): # pylint: disable=unused-argument
self.clipboard.set_text(self._clipboard_buffer, -1)

def _get_hide_on_game_launch_box(self):
def _get_setting_box(self, setting_key, label):
box = Gtk.Box(spacing=12, margin_right=12, margin_left=12)
checkbox = Gtk.CheckButton(label=_("Minimize client when a game is launched"))
if settings.read_setting("hide_client_on_game_start") == "True":
checkbox = Gtk.CheckButton(label=label)
if settings.read_setting(setting_key).lower() == "true":
checkbox.set_active(True)
checkbox.connect("toggled", self._on_hide_client_change)
checkbox.connect("toggled", self._on_setting_change, setting_key)
box.pack_start(checkbox, True, True, 0)
return box

def _on_hide_client_change(self, widget):
"""Save setting for hiding the game on game launch"""
settings.write_setting("hide_client_on_game_start", widget.get_active())

def _get_hide_text_under_icons(self):
box = Gtk.Box(spacing=12, margin_right=12, margin_left=12)
checkbox = Gtk.CheckButton(label=_("Hide text under icons"))
if settings.read_setting("hide_text_under_icons") == "True":
checkbox.set_active(True)
checkbox.connect("toggled", self._on_hide_text_change)
box.pack_start(checkbox, True, True, 0)
return box

def _on_hide_text_change(self, widget):
"""Save setting for hiding the game on game launch"""
settings.write_setting("hide_text_under_icons", widget.get_active())
def _on_setting_change(self, widget, setting_key):
"""Save a setting when an option is toggled"""
settings.write_setting(setting_key, widget.get_active())

def _get_name_box(self):
box = Gtk.Box(spacing=12, margin_right=12, margin_left=12)
Expand Down
7 changes: 0 additions & 7 deletions lutris/gui/lutriswindow.py
Expand Up @@ -147,7 +147,6 @@ def _init_actions(self):
default=self.view_sorting_ascending,
),
"use-dark-theme": Action(self.on_dark_theme_state_change, type="b", default=self.use_dark_theme),
"show-tray-icon": Action(self.on_tray_icon_toggle, type="b", default=self.show_tray_icon),
"show-left-side-panel": Action(
self.on_left_side_panel_state_change,
type="b",
Expand Down Expand Up @@ -239,12 +238,6 @@ def use_dark_theme(self):
"""Return whether to use the dark theme variant (if the theme provides one)"""
return settings.read_setting("dark_theme", default="false").lower() == "true"

def on_tray_icon_toggle(self, action, value):
"""Callback for handling tray icon toggle"""
action.set_state(value)
settings.write_setting('show_tray_icon', value)
self.application.set_tray_icon()

@property
def show_tray_icon(self):
"""Setting to hide or show status icon"""
Expand Down
67 changes: 21 additions & 46 deletions share/lutris/ui/lutris-window.ui
Expand Up @@ -79,7 +79,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">3</property>
</packing>
</child>
<child>
Expand All @@ -90,49 +90,35 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="action_name">win.open-forums</property>
<property name="text" translatable="yes">Lutris forums</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="action_name">win.open-discord</property>
<property name="text" translatable="yes">Discord</property>
<property name="action_name">win.preferences</property>
<property name="text" translatable="yes">Preferences</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="action_name">win.donate</property>
<property name="text" translatable="yes">Support Lutris!</property>
<property name="action_name">win.manage-runners</property>
<property name="text" translatable="yes">Manage runners</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
<property name="position">6</property>
</packing>
</child>
<child>
Expand All @@ -143,74 +129,63 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">10</property>
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="action_name">win.manage-runners</property>
<property name="text" translatable="yes">Manage runners</property>
<property name="action_name">win.open-discord</property>
<property name="text" translatable="yes">Discord</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">11</property>
<property name="position">8</property>
</packing>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="action_name">win.preferences</property>
<property name="text" translatable="yes">Preferences</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">12</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="action_name">win.open-forums</property>
<property name="text" translatable="yes">Lutris forums</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">13</property>
<property name="position">9</property>
</packing>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="action_name">win.about</property>
<property name="text" translatable="yes">About Lutris</property>
<property name="action_name">win.donate</property>
<property name="text" translatable="yes">Make a donation</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">14</property>
<property name="position">10</property>
</packing>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="action_name">win.show-tray-icon</property>
<property name="text" translatable="yes">Show _Tray Icon</property>
<property name="action_name">win.about</property>
<property name="text" translatable="yes">About Lutris</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">15</property>
<property name="position">11</property>
</packing>
</child>
</object>
Expand Down

0 comments on commit 7c8865d

Please sign in to comment.