From 2137c3c17e598b8e6069d2a9f89c621f5a4f2097 Mon Sep 17 00:00:00 2001 From: GabMus Date: Tue, 27 Sep 2016 22:57:02 +0200 Subject: [PATCH] app doesn't exit if no device is connected, shows informational label instead. Initial support for update devices button --- device.py | 1 + main.py | 45 +- ui.glade | 1387 +++++++++++++++++++++++++++-------------------------- 3 files changed, 748 insertions(+), 685 deletions(-) diff --git a/device.py b/device.py index 6c3bc94..0b811d8 100644 --- a/device.py +++ b/device.py @@ -241,6 +241,7 @@ def _hex2rgb(self, mhex): return tuple(int(mhex[i:i+2], 16) for i in (0, 2 ,4)) def assignMacro(self, key, command): + script_macro=self.device.macro.create_script_macro_item(command) self.device.macro.add_macro(key, script_macro) diff --git a/main.py b/main.py index 7c46f49..8314e48 100755 --- a/main.py +++ b/main.py @@ -20,6 +20,8 @@ universalApplyButton = builder.get_object('universalApplyButton') +refreshDevicesButton=builder.get_object('refreshDevicesButton') + universalApplyButton.modify_bg( Gtk.StateFlags.NORMAL, Gdk.Color.parse('#4884cb').color) @@ -32,12 +34,18 @@ devicesList = [] +mainBox=builder.get_object('mainBox') +noDevicesLabel=builder.get_object('noDevicesLabel') def initDevices(): for dev in device.devlist: newdev = device.Device(dev) devicesList.append(newdev) +def emptyDevicesList(): + for devindex in range(len(devicesList)): + popoverDevicesListBox.remove(popoverDevicesListBox.get_row_at_index(0)) + del devicesList[0] def fillDevicesList(): if len(devicesList) > 0: @@ -58,12 +66,25 @@ def fillDevicesList(): currentDeviceLabel.set_text( popoverDevicesListBox.get_row_at_index(0).value.name ) + else: + currentDeviceLabel.set_text('No devices') + +def updateDevicesConnected(): + if len(devicesList)>0: + mainBox.show_all() + noDevicesLabel.hide() else: print("no devices") - exit(1) + mainBox.hide() + noDevicesLabel.show() -initDevices() -fillDevicesList() +def refreshDevices(): + emptyDevicesList() + initDevices() + fillDevicesList() + updateDevicesConnected() + +refreshDevices() settings = Gtk.Settings.get_default() settings.set_property("gtk-application-prefer-dark-theme", True) @@ -138,6 +159,7 @@ def activateCb(self, app): app.set_app_menu(appMenu) window.show_all() keyboardBox.hide() + updateDevicesConnected() def on_about_activate(self, *agrs): builder.get_object("aboutdialog").show() @@ -145,7 +167,10 @@ def on_about_activate(self, *agrs): def on_quit_activate(self, *args): self.quit() -myrazerkb = devicesList[0] +if len(devicesList)>0: + myrazerkb = devicesList[0] +else: + myrazerkb = None gameModeIcon = builder.get_object("gameModeIcon") @@ -158,6 +183,8 @@ def on_quit_activate(self, *args): mainStackSwitcherButtons=builder.get_object('mainStackSwitcherButtons') def refreshFxList(): + if not myrazerkb: + return # empty list before (re)filling it while True: row = fxListBox.get_row_at_index(0) @@ -197,10 +224,11 @@ def refreshFxList(): gameModeIcon.hide() gameModeSwitch.hide() - if myrazerkb.device.type != 'tartarus': - mainStackSwitcherButtons.hide() - else: + # macro functionalities temporarely limited to tartarus + if myrazerkb.device.has('macro_logic') and myrazerkb.device.type=='tartarus': mainStackSwitcherButtons.show() + else: + mainStackSwitcherButtons.hide() refreshFxList() @@ -448,6 +476,9 @@ class Handler: def onDeleteWindow(self, *args): Gtk.main_quit(*args) + def on_refreshDevicesButton_clicked(self, button): + refreshDevices() + def on_tartarusKeyList_row_activated(self, list, row): # TODO: set shortcut entry to already existing shortcut tartarusShortcutDialogKeyNumber.set_text(str(row.value)) diff --git a/ui.glade b/ui.glade index 4beadb9..45b414e 100644 --- a/ui.glade +++ b/ui.glade @@ -8,6 +8,60 @@ 1 10 + + False + customProfilesButton + bottom + + + True + False + vertical + + + 150 + 250 + True + True + never + in + + + True + False + + + True + False + + + + + + + + True + True + 0 + + + + + Save profile + True + True + True + + + + False + True + 1 + + + + + 1 3 @@ -29,46 +83,38 @@ vertical 6 - - False - True - center - 6 - mainStack - - - False - True - 0 - - - - + True False - slide-right - True + vertical - - fxBox - True + False - 18 - 6 + True + center 6 - 6 - vertical + mainStack + + + False + True + 0 + + + + + True + False + slide-right + True - + + fxBox True False - 6 - 6 + 6 + 6 vertical - 6 - - - True @@ -76,216 +122,136 @@ vertical 6 - - True - False - start - Backlight Brightness - - - False - True - 0 - + True False + vertical + 6 - + True - True - brightnessAdjustment - True - 0 - 0 - right + False + start + Backlight Brightness - True + False True 0 + + + True + False + + + True + True + brightnessAdjustment + True + 0 + 0 + right + + + True + True + 0 + + + + + True + True + 1 + + - True + False True 1 - - - False - True - 1 - - - - - - - - True - False - vertical - 6 - - True - False - start - Light effects - - - False - True - 0 - + - + True False + vertical + 6 - + True - True - never - in - - - True - False - - - True - False - - - - - + False + start + Light effects - True + False True 0 - + True False - 6 - 6 - vertical - 6 - - False - True - 16 + + True + True + never + in - + True False - vertical - 6 - + True False - start - Breath mode - - - False - True - 0 - - - - - Random - True - True - False - start - True - True - + - - False - True - 1 - - - - - Single color - True - True - False - start - True - True - breathRandomRadio - - - - False - True - 2 - - - - - Double color - True - True - False - start - True - True - breathRandomRadio - - - - False - True - 3 - - - - - - False - True - 0 - + + + True + True + 0 + + + + + True + False + vertical + 6 - - True + False - vertical - 6 + True + 16 True False + vertical 6 True False start - Color 1 + Breath mode False @@ -294,13 +260,15 @@ - + + Random True - False True - True - Select color - rgb(255,255,255) + False + start + True + True + False @@ -308,6 +276,43 @@ 1 + + + Single color + True + True + False + start + True + breathRandomRadio + + + + False + True + 2 + + + + + Double color + True + True + False + start + True + breathRandomRadio + + + + False + True + 3 + + + + + False @@ -319,13 +324,41 @@ True False + vertical 6 - + True False - start - Color 2 + 6 + + + True + False + start + Color 1 + + + False + True + 0 + + + + + True + False + True + True + Select color + rgb(255,255,255) + + + False + True + 1 + + False @@ -334,13 +367,38 @@ - + True - False - True - True - Select color - rgb(255,255,255) + False + 6 + + + True + False + start + Color 2 + + + False + True + 0 + + + + + True + False + True + True + Select color + rgb(255,255,255) + + + False + True + 1 + + False @@ -357,303 +415,194 @@ - False - True - 1 - - - - - True - True - 0 - - - - - False - True - vertical - 6 - - - True - False - Wave mode - - - False - True - 0 - - - - - True - False - True - - - - - - - - - False - True - 1 - - - - - True - False - True - - - Left - True - True - True - - - - False - True - 0 - - - - - Right - True - True - True - True - - - - False - True - 1 - - - - - False - True - 2 - - - - - False - True - 1 - - - - - False - True - vertical - - - True - False - start - Static Mode - - - False + True True 0 - - True + False + True + vertical 6 True False - start - Color - - - True - True - 0 - - - - - True - True - True - Select color - rgb(255,255,255) + Wave mode False True - 1 - - - - - True - True - 1 - - - - - - - - False - True - 2 - - - - - False - True - vertical - 6 - - - True - False - 6 + 0 + + - + True False - start - Key lit time + True + + + + + + - True + False True - 0 + 1 - + True - True - reactiveTimeAdjustment - True + False + True + + + Left + True + True + True + + + + False + True + 0 + + + + + Right + True + True + True + True + + + + False + True + 1 + + False True - 1 + 2 False True - 0 + 1 - - True + False + True + vertical True False start - Color + Static Mode - True + False True 0 - + True - True - True - Select color - rgb(255,255,255) + False + 6 + + + True + False + start + Color + + + True + True + 0 + + + + + True + True + True + Select color + rgb(255,255,255) + + + False + True + 1 + + - False + True True 1 + + + False True - 1 + 2 - - - - - False - True - 3 - - - - - False - True - vertical - 6 - - - True + False + True + vertical 6 True False - vertical 6 - - Single color + True - True - False - True - True - + False + start + Key lit time - False + True True 0 - - Random + True True - False - True - True - rippleRadioColor + 1 + reactiveTimeAdjustment + True + 1 False @@ -672,22 +621,21 @@ True False - end - start True False - Color + start + Color - False + True True 0 - + True True True @@ -696,41 +644,152 @@ False - False + True 1 False - False - end + True 1 + + + False True - 0 + 3 - - - - + + False + True + vertical + 6 + + + True + False + 6 + + + True + False + vertical + 6 + + + Single color + True + True + False + True + True + + + + False + True + 0 + + + + + Random + True + True + False + True + rippleRadioColor + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + end + start + + + True + False + Color + + + False + True + 0 + + + + + True + True + True + Select color + rgb(255,255,255) + + + False + False + 1 + + + + + False + False + end + 1 + + + + + False + True + 0 + + + + + + + + + + + False + True + 4 + False True - 4 + 1 - False + True True 1 @@ -739,174 +798,174 @@ True True - 1 + 3 - - - True - True - 3 - - - - - True - False - center - center - vertical - + True False center center - 12 - 6 - - - True - False - 24 - Color: - - - False - True - 0 - - - - - True - True - True - Select color - rgb(255,255,255) - - - - False - True - 1 - - + vertical - + True False - 24 - Pipette: - - - False - True - 2 - - - - - True - True - True - + center + center + 12 + 6 - + True False - gtk-color-picker + Color: + + False + True + 0 + + + + + True + True + True + Select color + rgb(255,255,255) + + + + False + True + 1 + + + + + True + False + Pipette: + + + False + True + 2 + - - - False - True - 3 - - - - - True - False - 24 - Clear: - - - False - True - 4 - - - - - True - True - True - - + True - False - gtk-delete + True + True + + + + True + False + gtk-color-picker + + + + False + True + 3 + - - - False - True - 5 - - - - - True - True - True - none - - + True False + Clear: + + + False + True + 4 + + + + + True + True + True + - + True False - Profiles + gtk-delete - - False - True - 0 - + + + False + True + 5 + + + + + True + True + True + none + - + True False - down + + + True + False + Profiles + + + False + True + 0 + + + + + True + False + down + + + False + True + 1 + + - - False - True - 1 - + + False + True + 6 + False - True - 6 + False + 0 + + + False - False - 0 + True + 4 @@ -914,118 +973,127 @@ - False + True True - 4 + 1 - - - - True - True - 1 + Effects + Effects - - - Effects - Effects - - - - - True - False - vertical - + True False + vertical - + True False - gtk-missing-image - - - False - True - 0 - - - - - True - True - never - in - + True False + gtk-missing-image + + + False + True + 0 + + + + + True + True + never + in - + True False - - True - False - - - - False - True - 0 - - - - + True False - none + + + True + False + + + + False + True + 0 + + + + + True + False + none + + + True + True + 1 + + - - True - True - 1 - + + True + True + 1 + - True + False True - 1 + 0 + + + + + + - False - True - 0 + Macros + Macros + 1 - - - - - - - Macros - Macros + True + True 1 + + True + True + 0 + + + + + False + True + No devices connected + True True @@ -1124,6 +1192,23 @@ True False 6 + + + gtk-refresh + True + True + True + none + True + True + + + + False + True + 0 + + True @@ -1133,7 +1218,7 @@ False True - 0 + 1 @@ -1146,7 +1231,7 @@ False True - 1 + 2 @@ -1164,7 +1249,7 @@ dialog window razerCommander - 1.0.2 + 1.0.3 This project is not affiliated with Razer, Inc. (http://www.razerzone.com/) https://github.com/gabmus/razercommander Gabriele Musco aka GabMus (frontend) @@ -1221,60 +1306,6 @@ And special thanks to all the folks that have supported and helped with the deve - - False - customProfilesButton - bottom - - - True - False - vertical - - - 150 - 250 - True - True - never - in - - - True - False - - - True - False - - - - - - - - True - True - 0 - - - - - Save profile - True - True - True - - - - False - True - 1 - - - - - 350 False