Skip to content

Commit

Permalink
Only use NAME variable
Browse files Browse the repository at this point in the history
  • Loading branch information
sidevesh authored Mar 4, 2024
1 parent 4eb0833 commit 9ac6e44
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 27 deletions.
3 changes: 1 addition & 2 deletions lib/solaar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import subprocess as _subprocess
import sys as _sys

NAME = "solaar"
DISPLAY_NAME = "Solaar"
NAME = "Solaar"

try:
__version__ = (
Expand Down
4 changes: 2 additions & 2 deletions lib/solaar/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _receivers(dev_path=None):
yield r
except Exception as e:
logger.exception("opening " + str(dev_info))
_sys.exit("%s: error: %s" % (NAME, str(e)))
_sys.exit("%s: error: %s" % (NAME.lower(), str(e)))


def _receivers_and_devices(dev_path=None):
Expand All @@ -136,7 +136,7 @@ def _receivers_and_devices(dev_path=None):
yield d
except Exception as e:
logger.exception("opening " + str(dev_info))
_sys.exit("%s: error: %s" % (NAME, str(e)))
_sys.exit("%s: error: %s" % (NAME.lower(), str(e)))


def _find_receiver(receivers, name):
Expand Down
2 changes: 1 addition & 1 deletion lib/solaar/cli/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def run(devices, args, find_receiver, find_device):
assert devices
assert args.device

print("%s version %s" % (NAME, __version__))
print("%s version %s" % (NAME.lower(), __version__))
print("")

device_name = args.device.lower()
Expand Down
2 changes: 1 addition & 1 deletion lib/solaar/gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _require(module, os_package, gi=None, gi_package=None, gi_version=None):
gi.require_version(gi_package, gi_version)
return importlib.import_module(module)
except (ImportError, ValueError):
sys.exit("%s: missing required system package %s" % (NAME, os_package))
sys.exit("%s: missing required system package %s" % (NAME.lower(), os_package))


battery_icons_style = "regular"
Expand Down
6 changes: 3 additions & 3 deletions lib/solaar/ui/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from gi.repository import Gtk

from solaar import DISPLAY_NAME, NAME, __version__
from solaar import NAME, __version__
from solaar.i18n import _

#
Expand All @@ -32,7 +32,7 @@
def _create():
about = Gtk.AboutDialog()

about.set_program_name(DISPLAY_NAME)
about.set_program_name(NAME)
about.set_version(__version__)
about.set_comments(_("Manages Logitech receivers,\nkeyboards, mice, and tablets."))
about.set_icon_name(NAME.lower())
Expand Down Expand Up @@ -83,7 +83,7 @@ def _create():
)

about.set_website("https://pwr-solaar.github.io/Solaar")
about.set_website_label(DISPLAY_NAME)
about.set_website_label(NAME)

about.connect("response", lambda x, y: x.hide())

Expand Down
8 changes: 4 additions & 4 deletions lib/solaar/ui/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def init():
if logger.isEnabledFor(logging.INFO):
logger.info("starting desktop notifications")
try:
return Notify.init(NAME)
return Notify.init(NAME.lower())
except Exception:
logger.exception("initializing desktop notifications")
available = False
Expand All @@ -80,15 +80,15 @@ def alert(reason, icon=None):
assert reason

if available and Notify.is_initted():
n = _notifications.get(NAME)
n = _notifications.get(NAME.lower())
if n is None:
n = _notifications[NAME] = Notify.Notification()
n = _notifications[NAME.lower()] = Notify.Notification()

# we need to use the filename here because the notifications daemon
# is an external application that does not know about our icon sets
icon_file = _icons.icon_file(NAME.lower()) if icon is None else _icons.icon_file(icon)

n.update(NAME, reason, icon_file)
n.update(NAME.lower(), reason, icon_file)
n.set_urgency(Notify.Urgency.NORMAL)
n.set_hint("desktop-entry", GLib.Variant("s", NAME.lower()))

Expand Down
18 changes: 9 additions & 9 deletions lib/solaar/ui/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import solaar.gtk as gtk

from solaar import DISPLAY_NAME, NAME
from solaar import NAME
from solaar.i18n import _

from . import icons as _icons
Expand Down Expand Up @@ -61,10 +61,10 @@ def _create_menu(quit_handler):
menu.append(Gtk.SeparatorMenuItem.new())

menu.append(
_make("help-about", _("About %s") % DISPLAY_NAME, _show_about_window, stock_id="help-about").create_menu_item()
_make("help-about", _("About %s") % NAME, _show_about_window, stock_id="help-about").create_menu_item()
)
menu.append(
_make("application-exit", _("Quit %s") % DISPLAY_NAME, quit_handler, stock_id="application-exit").create_menu_item()
_make("application-exit", _("Quit %s") % NAME, quit_handler, stock_id="application-exit").create_menu_item()
)

menu.show_all()
Expand Down Expand Up @@ -183,10 +183,10 @@ def _create(menu):
ind = AppIndicator3.Indicator.new(
"indicator-solaar", _icon_file(_icons.TRAY_INIT), AppIndicator3.IndicatorCategory.HARDWARE
)
ind.set_title(DISPLAY_NAME)
ind.set_title(NAME)
ind.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
# ind.set_attention_icon_full(_icon_file(_icons.TRAY_ATTENTION), '') # works poorly for XFCE 16
# ind.set_label(NAME, NAME)
# ind.set_label(NAME.lower(), NAME.lower())

ind.set_menu(menu)
ind.connect("scroll-event", _scroll)
Expand Down Expand Up @@ -235,9 +235,9 @@ def attention(reason=None):

def _create(menu):
icon = Gtk.StatusIcon.new_from_icon_name(_icons.TRAY_INIT)
icon.set_name(NAME)
icon.set_title(DISPLAY_NAME)
icon.set_tooltip_text(DISPLAY_NAME)
icon.set_name(NAME.lower())
icon.set_title(NAME)
icon.set_tooltip_text(NAME)
icon.connect("activate", _window_toggle)
icon.connect("scroll-event", _scroll)
icon.connect("popup-menu", lambda icon, button, time: menu.popup(None, None, icon.position_menu, icon, button, time))
Expand Down Expand Up @@ -296,7 +296,7 @@ def attention(reason=None):

def _generate_tooltip_lines():
if not _devices_info:
yield "<b>%s</b>: " % DISPLAY_NAME + _("no receiver")
yield "<b>%s</b>: " % NAME + _("no receiver")
return

yield from _generate_description_lines()
Expand Down
10 changes: 5 additions & 5 deletions lib/solaar/ui/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from logitech_receiver.common import NamedInts as _NamedInts
from logitech_receiver.status import KEYS as _K

from solaar import DISPLAY_NAME, NAME
from solaar import NAME
from solaar.i18n import _, ngettext

from . import action as _action
Expand Down Expand Up @@ -315,9 +315,9 @@ def _create_window_layout():
bottom_buttons_box = Gtk.ButtonBox(Gtk.Orientation.HORIZONTAL)
bottom_buttons_box.set_layout(Gtk.ButtonBoxStyle.START)
bottom_buttons_box.set_spacing(20)
quit_button = _new_button(_("Quit %s") % DISPLAY_NAME, "application-exit", _SMALL_BUTTON_ICON_SIZE, clicked=destroy)
quit_button = _new_button(_("Quit %s") % NAME, "application-exit", _SMALL_BUTTON_ICON_SIZE, clicked=destroy)
bottom_buttons_box.add(quit_button)
about_button = _new_button(_("About %s") % DISPLAY_NAME, "help-about", _SMALL_BUTTON_ICON_SIZE, clicked=_show_about_window)
about_button = _new_button(_("About %s") % NAME, "help-about", _SMALL_BUTTON_ICON_SIZE, clicked=_show_about_window)
bottom_buttons_box.add(about_button)
diversion_button = _new_button(
_("Rule Editor"), "", _SMALL_BUTTON_ICON_SIZE, clicked=lambda *_trigger: _show_diversion_window(_model)
Expand All @@ -326,7 +326,7 @@ def _create_window_layout():
bottom_buttons_box.set_child_secondary(diversion_button, True)

# solaar_version = Gtk.Label()
# solaar_version.set_markup('<small>' + DISPLAY_NAME + ' v' + VERSION + '</small>')
# solaar_version.set_markup('<small>' + NAME + ' v' + VERSION + '</small>')
# bottom_buttons_box.add(solaar_version)
# bottom_buttons_box.set_child_secondary(solaar_version, True)

Expand All @@ -343,7 +343,7 @@ def _create_window_layout():

def _create(delete_action):
window = Gtk.Window()
window.set_title(DISPLAY_NAME)
window.set_title(NAME)
window.set_role("status-window")

# window.set_type_hint(Gdk.WindowTypeHint.UTILITY)
Expand Down

0 comments on commit 9ac6e44

Please sign in to comment.