Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
model.append((None, None)) # Separator
i += 1
if self.allow_globals:
for f in menus:
key = f.get_basename()
name = key
if name.startswith("."): continue
if "." in name:
name = _("%s (global)" % (name.split(".")[0]))
model.append((name, key))
if self._current_menu == key:
current_index = i
i += 1
if i > 0:
model.append((None, None)) # Separator
model.append(( _("New Menu..."), "" ))
self._recursing = True
cb.set_active(current_index)
self._recursing = False
name = self.get_selected_menu()
if name:
self.builder.get_object("btEditMenu").set_sensitive(name not in MenuEditor.OPEN)
ae.show(self.window)
elif id in STICKS:
ae = self._choose_editor(self.current.stick,
_("Stick"))
ae.set_stick(self.current.stick)
ae.show(self.window)
elif id in GYROS:
ae = self._choose_editor(self.current.gyro,
_("Gyro"))
ae.set_gyro(self.current.gyro)
ae.show(self.window)
elif id in PADS:
data = NoAction()
if id == "LPAD":
data = self.current.pads[Profile.LEFT]
ae = self._choose_editor(data, _("Left Pad"))
else:
data = self.current.pads[Profile.RIGHT]
ae = self._choose_editor(data, _("Right Pad"))
ae.set_pad(id, data)
ae.show(self.window)
def _choose_editor(self, action, cb):
from scc.gui.ring_editor import RingEditor # Cannot be imported @ top
if isinstance(action, Macro):
from scc.gui.macro_editor import MacroEditor # Cannot be imported @ top
e = MacroEditor(self.app, cb)
e.set_title(_("Edit Macro"))
elif RingEditor.is_ring_action(action):
e = RingEditor(self.app, cb)
else:
from scc.gui.action_editor import ActionEditor # Cannot be imported @ top
e = ActionEditor(self.app, cb)
e.set_title(_("Edit Action"))
e.hide_modeshift()
return e
def describe(self):
if self.label:
return _("----[ %s ]----") % (self.label,)
else:
return _("---- Separator ----")
def shell_import_confirmed(self):
grSccImportFinished = self.builder.get_object("grSccImportFinished")
lblSccImportFinished = self.builder.get_object("lblSccImportFinished")
txName2 = self.builder.get_object("txName2")
files = self.builder.get_object("lstImportPackage")
vbImportPackage = self.builder.get_object("vbImportPackage")
enabled, trash, name, trash, obj = files[0]
lblSccImportFinished.set_text(_("Profile sucessfully imported"))
txName2.set_text(name)
vbImportPackage.set_visible(len(files) > 1)
self.next_page(grSccImportFinished)
self.on_txName2_changed()
btDefault = self.builder.get_object("btDefault")
lblPressAlone = self.builder.get_object("lblPressAlone")
cbHoldFeedback = self.builder.get_object("cbHoldFeedback")
sclHoldFeedback = self.builder.get_object("sclHoldFeedback")
self.id = id
self._fill_button_chooser()
if id in STICKS:
lblPressAlone.set_label(_("(no button pressed)"))
self.mode = mode = mode or Action.AC_STICK
elif id in PADS:
lblPressAlone.set_label(_("(no button pressed)"))
self.mode = mode = mode or Action.AC_PAD
else:
lblPressAlone.set_label(_("(pressed alone)"))
self.mode = mode = mode or Action.AC_BUTTON
self.set_title("Modeshift for %s" % (nameof(id) if id in SCButtons else str(id),))
if isinstance(action, FeedbackModifier):
cbHoldFeedback.set_active(True)
sclHoldFeedback.set_value(action.haptic.get_amplitude())
action = action.action
else:
cbHoldFeedback.set_active(False)
sclHoldFeedback.set_value(512)
if isinstance(action, ModeModifier):
self._load_modemod(0, action)
self._set_nomod_button(0, action.default)
self._set_nomod_button(1, NoAction())
def on_device_open_failed(self, *a):
"""
Called when all (or user-selected) driver fails
to communicate with controller.
Shoudln't be really possible, but something
_has_ to happen in such case.
"""
d = Gtk.MessageDialog(parent=self.window,
flags = Gtk.DialogFlags.MODAL,
type = Gtk.MessageType.ERROR,
buttons = Gtk.ButtonsType.OK,
message_format = _("Failed to open device")
)
d.run()
d.destroy()
self.window.destroy()
def setup_widgets(self):
self.builder = Gtk.Builder()
self.builder.add_from_file(os.path.join(self.gladepath, "app.glade"))
self.builder.connect_signals(self)
self.window = self.builder.get_object("window")
self.add_window(self.window)
self.window.set_title(_("SC Controller"))
self.window.set_wmclass("SC Controller", "SC Controller")
self.ribar = None
for b in BUTTONS:
self.button_widgets[b] = ControllerButton(self, b, self.builder.get_object("bt" + b.name))
for b in TRIGGERS:
self.button_widgets[b] = ControllerTrigger(self, b, self.builder.get_object("btTrigger" + b))
for b in PADS:
self.button_widgets[b] = ControllerPad(self, b, self.builder.get_object("bt" + b))
for b in STICKS:
self.button_widgets[b] = ControllerStick(self, b, self.builder.get_object("bt" + b))
for b in GYROS:
self.button_widgets[b] = ControllerGyro(self, b, self.builder.get_object("bt" + b))
self.builder.get_object("cbProfile").set_row_separator_func(
lambda model, iter : model.get_value(iter, 1) is None and model.get_value(iter, 0) == "-" )
def on_actionb_clicked(self, button, i, action_data):
""" Handler clicking on action name """
def on_chosen(id, action):
readd = [ x.action for x in self.actions ]
readd[i] = action
self._refill_grid(readd)
self.update_action_field()
from scc.gui.action_editor import ActionEditor # Cannot be imported @ top
ae = ActionEditor(self.app, on_chosen)
ae.set_title(_("Edit Action"))
ae.set_input(self.id, action_data.action, mode=self.mode)
ae.hide_modeshift()
ae.hide_macro()
ae.hide_name()
ae.show(self.window)
def _bad_id_duplicate(self, *a):
self.builder.get_object("lblNope").set_label(_('Invalid Menu ID: Menu with same ID already exists.'))
self.builder.get_object("rvInvalidID").set_reveal_child(True)
self.builder.get_object("btSave").set_sensitive(False)