[pitivi] prefs: Remove the already-set label
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] prefs: Remove the already-set label
- Date: Tue, 27 Sep 2016 08:50:00 +0000 (UTC)
commit 1072e91f5987dc3ff40e47a7b35d2585de1a1dbe
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Fri Sep 16 18:02:11 2016 +0200
prefs: Remove the already-set label
The label was informing the user that the typed accelerator is already
set for the action. By getting rid of this label, the user will now be
able to apply the accelerator. The reason for the change is that it
simplifies the code.
Reviewed-by: Jakub Brindza <jakub brindza gmail com>
Differential Revision: https://phabricator.freedesktop.org/D1316
pitivi/dialogs/prefs.py | 23 +++--------------------
pitivi/shortcuts.py | 8 +++++---
2 files changed, 8 insertions(+), 23 deletions(-)
---
diff --git a/pitivi/dialogs/prefs.py b/pitivi/dialogs/prefs.py
index 35c7379..48016cc 100644
--- a/pitivi/dialogs/prefs.py
+++ b/pitivi/dialogs/prefs.py
@@ -464,10 +464,6 @@ class CustomShortcutDialog(Gtk.Dialog):
self.accelerator_label.set_markup("<span size='20000'><b>%s</b></span>"
% customised_item.get_accel())
self.accelerator_label.props.margin_bottom = PADDING
- self.currently_used = Gtk.Label()
- self.currently_used.set_text(_("This is the currently set accelerator"
- " for this shortcut.\n You may want to"
- " change it to something else."))
self.invalid_used = Gtk.Label()
self.invalid_used.set_text(_("The accelerator you are trying to set"
" might interfere with typing.\n"
@@ -479,11 +475,10 @@ class CustomShortcutDialog(Gtk.Dialog):
content_area.add(prompt_label)
content_area.add(self.accelerator_label)
content_area.add(self.conflict_label)
- content_area.add(self.currently_used)
content_area.add(self.invalid_used)
def do_key_press_event(self, event):
- """Decides if the pressed accel combination is valid and sets widget visibility."""
+ """Handles key press events and detects valid accelerators."""
keyval = event.keyval
mask = event.state
@@ -496,7 +491,6 @@ class CustomShortcutDialog(Gtk.Dialog):
accelerator = Gtk.accelerator_get_label(keyval, mask)
self.accelerator_label.set_markup("<span size='20000'><b>%s</b></span>"
% accelerator)
- equal_accelerators = self.check_equal_to_set(keyval, mask)
valid = Gtk.accelerator_valid(keyval, mask)
self.conflicting_action = self.app.shortcuts.get_conflicting_action(
@@ -510,21 +504,10 @@ class CustomShortcutDialog(Gtk.Dialog):
# Set visibility according to the booleans set above.
self.apply_button.set_visible(valid and not bool(self.conflicting_action))
self.accelerator_label.set_visible(valid)
- self.conflict_label.set_visible(valid and bool(self.conflicting_action) and
- not equal_accelerators)
- self.replace_button.set_visible(valid and bool(self.conflicting_action) and
- not equal_accelerators)
- self.currently_used.set_visible(equal_accelerators)
+ self.conflict_label.set_visible(valid and bool(self.conflicting_action))
+ self.replace_button.set_visible(valid and bool(self.conflicting_action))
self.invalid_used.set_visible(not valid)
- def check_equal_to_set(self, keyval, mask):
- """Checks if the customised accelerator is not already set for the action."""
- action = self.customised_item.action_name
- for accel in self.app.get_accels_for_action(action):
- if (keyval, mask) == Gtk.accelerator_parse(accel):
- return True
- return False
-
def do_response(self, response):
"""Handles the user's response."""
if response == Gtk.ResponseType.OK:
diff --git a/pitivi/shortcuts.py b/pitivi/shortcuts.py
index 6ecf282..3dabcf2 100644
--- a/pitivi/shortcuts.py
+++ b/pitivi/shortcuts.py
@@ -136,10 +136,12 @@ class ShortcutsManager(GObject.Object):
"""
group_name = action.split(".")[0]
for group in {group_name, "app", "win"}:
- for action, unused_title in self.group_actions[group]:
- for accel in self.app.get_accels_for_action(action):
+ for neighbor_action, unused_title in self.group_actions[group]:
+ if neighbor_action == action:
+ continue
+ for accel in self.app.get_accels_for_action(neighbor_action):
if (keyval, mask) == Gtk.accelerator_parse(accel):
- return action
+ return neighbor_action
return None
def register_group(self, action_prefix, title):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]