Commit 7139f4f7 authored by Alexandru Băluț's avatar Alexandru Băluț Committed by Thibault Saunier

Stop using UIManager because it's obsolete

Refactored the management of the timeline actions. Now they are not
disabled when the timeline loses focus, because they are made available
only to the layers representation layout and the timeline toolbar. This
guarantees that the accelerators will trigger only if the focus is
the (PitiviTimeline's) layout widget. For details see
TimelineContainer._createActions.

A nice result is that the toolbar buttons don't flicker because the
actions are enabled or disabled too many times.

Fixes https://phabricator.freedesktop.org/T3416
Fixes https://phabricator.freedesktop.org/T3477Reviewed-by: Thibault Saunier's avatarThibault Saunier <tsaunier@gnome.org>
Differential Revision: https://phabricator.freedesktop.org/D546
parent 85fb9c68
......@@ -14,7 +14,7 @@ ui_DATA = \
renderingdialog.ui \
renderingprogress.ui \
startupwizard.ui \
timelinecontainer.xml \
timelinetoolbar.ui \
titleeditor.ui \
$(NULL)
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.1 -->
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkToolbar" id="medialibrary_toolbar">
......@@ -11,7 +11,6 @@
<object class="GtkToolButton" id="media_import_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">Add media files to your project</property>
<property name="is_important">True</property>
<property name="label" translatable="yes">Import</property>
......@@ -32,15 +31,12 @@
<child>
<object class="GtkToolButton" id="media_remove_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">Remove selected clips from the project</property>
<property name="tooltip_text" translatable="yes">Remove selected clips from the project</property>
<property name="action_name">medialibrary.remove_assets</property>
<property name="label" translatable="yes">_Remove from Project</property>
<property name="use_underline">True</property>
<property name="icon_name">list-remove-symbolic</property>
<signal name="clicked" handler="_removeClickedCb" swapped="no"/>
<child internal-child="accessible">
<object class="AtkObject" id="media_remove_button-atkobject">
<property name="AtkObject::accessible-name">media_remove_button</property>
......@@ -55,11 +51,8 @@
<child>
<object class="GtkToolButton" id="media_props_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">Clip Properties...</property>
<property name="tooltip_text" translatable="yes">Clip Properties...</property>
<property name="tooltip_text" translatable="yes">Clip properties...</property>
<property name="use_underline">True</property>
<property name="icon_name">document-properties-symbolic</property>
<signal name="clicked" handler="_clipPropertiesCb" swapped="no"/>
......@@ -77,15 +70,12 @@
<child>
<object class="GtkToolButton" id="media_insert_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">Insert the selected clips at the end of the timeline</property>
<property name="tooltip_text" translatable="yes">Insert the selected clips at the end of the timeline</property>
<property name="action_name">medialibrary.insert_assets_at_end</property>
<property name="label" translatable="yes">Insert at _End of Timeline</property>
<property name="use_underline">True</property>
<property name="icon_name">insert-object-symbolic</property>
<signal name="clicked" handler="_insertEndCb" swapped="no"/>
<child internal-child="accessible">
<object class="AtkObject" id="media_insert_button-atkobject">
<property name="AtkObject::accessible-name">media_insert_button</property>
......@@ -125,7 +115,6 @@
<object class="GtkEntry" id="media_search_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
<property name="margin_start">3</property>
<property name="invisible_char"></property>
<property name="primary_icon_name">starred-symbolic</property>
......@@ -185,7 +174,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="has_tooltip">True</property>
<property name="tooltip_text" translatable="yes">Close this message</property>
<signal name="clicked" handler="_warningInfoBarDismissedCb" swapped="no"/>
</object>
......@@ -215,8 +203,8 @@
<object class="GtkLabel" id="warning_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -267,9 +255,9 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Add media to your project by dragging files and folders here or by using the "Import" button.</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......
<ui>
<toolbar name="TimelineToolBar">
<placeholder name="Timeline">
<separator />
<toolitem action="Split" />
<toolitem action="DeleteObj" />
<toolitem action="GroupObj" />
<toolitem action="UngroupObj" />
<toolitem action="Copy" />
<toolitem action="Paste" />
<!-- <toolitem action="AlignObj" /> -->
</placeholder>
</toolbar>
<accelerator action="ZoomIn" />
<accelerator action="ZoomOut" />
<accelerator action="ZoomFit" />
<accelerator action="ControlEqualAccel" />
<accelerator action="ControlKPAddAccel" />
<accelerator action="ControlKPSubtractAccel" />
<accelerator action="DeleteObj" />
<accelerator action="UngroupObj" />
<accelerator action="GroupObj" />
<accelerator action="Copy" />
<accelerator action="Paste" />
<!-- <accelerator action="AlignObj" /> -->
<accelerator action="PlayPause" />
<accelerator action="Split" />
<accelerator action="Keyframe" />
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkToolbar" id="timeline_toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="orientation">vertical</property>
<property name="toolbar_style">icons</property>
<child>
<object class="GtkToolButton" id="toolbutton1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Split clips at playhead position</property>
<property name="action_name">timeline.split_clips</property>
<property name="label" translatable="yes">Split</property>
<property name="use_underline">True</property>
<property name="stock_id">pitivi-split</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Delete clips</property>
<property name="action_name">timeline.delete_selected_clips</property>
<property name="label" translatable="yes">Delete</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-delete</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Group clips</property>
<property name="action_name">timeline.group_selected_clips</property>
<property name="label" translatable="yes">Group</property>
<property name="use_underline">True</property>
<property name="stock_id">pitivi-group</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Ungroup clips</property>
<property name="action_name">timeline.ungroup_selected_clips</property>
<property name="label" translatable="yes">Ungroup</property>
<property name="use_underline">True</property>
<property name="stock_id">pitivi-ungroup</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Copy clips</property>
<property name="action_name">timeline.copy_selected_clips</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-copy</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Paste clips</property>
<property name="action_name">timeline.paste_clips</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-paste</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Align clips based on their soundtracks</property>
<property name="visible_horizontal">False</property>
<property name="visible_vertical">False</property>
<property name="action_name">timeline.align_selected_clips</property>
<property name="label" translatable="yes">Align</property>
<property name="use_underline">True</property>
<property name="stock_id">pitivi-align</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToggleToolButton" id="gapless_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Toggle gapless mode
When enabled, adjacent clips automatically move to fill gaps.</property>
<property name="action_name">timeline.toggle_gapless_mode</property>
<property name="label" translatable="yes">Gapless mode</property>
<property name="use_underline">True</property>
<property name="stock_id">pitivi-gapless</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
</interface>
......@@ -287,7 +287,7 @@ class EffectListWidget(Gtk.Box, Loggable):
""" Widget for listing effects """
def __init__(self, instance, unused_uiman):
def __init__(self, instance):
Gtk.Box.__init__(self)
Loggable.__init__(self)
......
......@@ -136,11 +136,9 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
self.connect("destroy", self._destroyedCb)
self.uimanager = Gtk.UIManager()
self.setupCss()
self.builder_handler_ids = []
self.builder = Gtk.Builder()
self.add_accel_group(self.uimanager.get_accel_group())
self._createUi()
self.recent_manager = Gtk.RecentManager()
......@@ -292,8 +290,8 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
# First set of tabs
self.main_tabs = BaseTabs(self.app)
self.medialibrary = MediaLibraryWidget(self.app, self.uimanager)
self.effectlist = EffectListWidget(self.app, self.uimanager)
self.medialibrary = MediaLibraryWidget(self.app)
self.effectlist = EffectListWidget(self.app)
self.main_tabs.append_page(
self.medialibrary, Gtk.Label(label=_("Media Library")))
self.main_tabs.append_page(
......@@ -330,7 +328,7 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
self.mainhpaned.pack2(self.viewer, resize=True, shrink=False)
# Now, the lower part: the timeline
self.timeline_ui = TimelineContainer(self, self.app, self.uimanager)
self.timeline_ui = TimelineContainer(self, self.app)
self.timeline_ui.setProjectManager(self.app.project_manager)
self.vpaned.pack2(self.timeline_ui, resize=True, shrink=False)
......@@ -373,7 +371,7 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
self.connect("configure-event", self._configureCb)
# Focus the timeline by default!
self.timeline_ui.grab_focus()
self.focusTimeline()
self.updateTitle()
def _setDefaultPositions(self):
......@@ -435,7 +433,10 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
self.context_tabs.set_current_page(page)
def focusTimeline(self):
self.timeline_ui.grab_focus()
layers_representation = self.timeline_ui.timeline.layout
# Check whether it has focus already, grab_focus always emits an event.
if not layers_representation.props.is_focus:
layers_representation.grab_focus()
def _create_headerbar_buttons(self):
undo_button = Gtk.Button.new_from_icon_name(
......@@ -479,15 +480,6 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
self._headerbar.pack_start(self.render_button)
def _set_keyboard_shortcuts(self):
"""
You can't rely on Glade/GTKBuilder to set accelerators properly
on menu items or buttons, it just doesn't work.
GAction and GActionGroup are overkill and a massive PITA.
This code keeps things *really* simple, and it actually works.
Bonus points: the accelerators disable themselves when buttons or
menu items are set_sensitive(False), which is exactly what we want.
"""
self.save_action = Gio.SimpleAction.new("save", None)
self.save_action.connect("activate", self._saveProjectCb)
self.add_action(self.save_action)
......@@ -1323,11 +1315,11 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
def __titleTypeCb(self, widget, event, project):
if event.keyval == Gdk.KEY_Return:
self.timeline_ui.grab_focus()
self.focusTimeline()
return True
elif event.keyval == Gdk.KEY_Escape:
widget.set_text(project.name)
self.timeline_ui.grab_focus()
self.focusTimeline()
return True
return False
......
......@@ -85,13 +85,6 @@ STORE_MODEL_STRUCTURE = (
COL_LENGTH,
COL_SEARCH_TEXT) = list(range(len(STORE_MODEL_STRUCTURE)))
ui = '''
<ui>
<accelerator action="RemoveSources" />
<accelerator action="InsertEnd" />
</ui>
'''
# This whitelist is made from personal knowledge of file extensions in the wild,
# from gst-inspect |grep demux,
# http://en.wikipedia.org/wiki/Comparison_of_container_formats and
......@@ -116,7 +109,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
'play': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_PYOBJECT,))}
def __init__(self, app, uiman):
def __init__(self, app):
Gtk.Box.__init__(self)
Loggable.__init__(self)
......@@ -129,6 +122,8 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
self._draggedPaths = None
self.dragged = False
self.clip_view = self.app.settings.lastClipView
if self.clip_view not in (SHOW_TREEVIEW, SHOW_ICONVIEW):
self.clip_view = SHOW_ICONVIEW
self.import_start_time = time.time()
self._last_imported_uris = []
......@@ -150,9 +145,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
toolbar = builder.get_object("medialibrary_toolbar")
toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR)
self._import_button = builder.get_object("media_import_button")
self._remove_button = builder.get_object("media_remove_button")
self._clipprops_button = builder.get_object("media_props_button")
self._insert_button = builder.get_object("media_insert_button")
self._listview_button = builder.get_object("media_listview_button")
searchEntry = builder.get_object("media_search_entry")
......@@ -289,19 +282,20 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
# Hack so that the views have the same method as self
self.treeview.getSelectedItems = self.getSelectedItems
# Keyboard shortcuts for some items in the gtkbuilder file
selection_actions = (
("RemoveSources", Gtk.STOCK_DELETE, _("_Remove from Project"),
"<Control>Delete", None, self._removeSourcesCb),
actions_group = Gio.SimpleActionGroup()
self.insert_action_group("medialibrary", actions_group)
self.remove_assets_action = Gio.SimpleAction.new("remove_assets", None)
self.remove_assets_action.connect("activate", self._removeAssetsCb)
actions_group.add_action(self.remove_assets_action)
self.app.add_accelerator("<Control>Delete", "medialibrary.remove_assets", None)
self.insert_at_end_action = Gio.SimpleAction.new("insert_assets_at_end", None)
self.insert_at_end_action.connect("activate", self._insertEndCb)
actions_group.add_action(self.insert_at_end_action)
self.app.add_accelerator("Insert", "medialibrary.insert_assets_at_end", None)
("InsertEnd", Gtk.STOCK_COPY, _("Insert at _End of Timeline"),
"Insert", None, self._insertEndCb),
)
self.selection_actions = Gtk.ActionGroup(name="medialibraryselection")
self.selection_actions.add_actions(selection_actions)
self.selection_actions.set_sensitive(False)
uiman.insert_action_group(self.selection_actions, 0)
uiman.add_ui_from_string(ui)
self._updateActions()
# Set the state of the view mode toggle button.
self._listview_button.set_active(self.clip_view == SHOW_TREEVIEW)
......@@ -350,10 +344,10 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
info = asset.get_info()
asset_uri = info.get_uri()
if asset_uri == uri:
self.debug("Found asset: %s for uri: %s" % (asset, uri))
self.debug("Found asset: %s for uri: %s", asset, uri)
return asset
self.warning("Did not find any asser for uri: %s" % (uri))
self.warning("Did not find any asset for uri: %s", uri)
def _setupViewAsDragAndDropSource(self, view):
view.drag_source_set(0, [], Gdk.DragAction.COPY)
......@@ -367,10 +361,27 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
def _importSourcesCb(self, unused_action):
self._showImportSourcesDialog()
def _removeSourcesCb(self, unused_action):
self._removeSources()
def _removeAssetsCb(self, unused_action, unused_parameter):
"""
Determine which clips are selected in the icon or list view,
and ask MediaLibrary to remove them from the project.
"""
model = self.treeview.get_model()
paths = self.getSelectedPaths()
if not paths:
return
# use row references so we don't have to care if a path has been
# removed
rows = [Gtk.TreeRowReference.new(model, path)
for path in paths]
def _insertEndCb(self, unused_action):
self.app.action_log.begin("remove asset from media library")
for row in rows:
asset = model[row.get_path()][COL_ASSET]
self.app.project_manager.current_project.remove_asset(asset)
self.app.action_log.commit()
def _insertEndCb(self, unused_action, unused_parameter):
self.app.gui.timeline_ui.insertAssets(self.getSelectedAssets(), -1)
def _searchEntryChangedCb(self, entry):
......@@ -386,6 +397,11 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
entry.set_text("")
elif icon_pos == Gtk.EntryIconPosition.PRIMARY:
self._selectUnusedSources()
# Focus the container so the user can use Ctrl+Delete, for example.
if self.clip_view == SHOW_TREEVIEW:
self.treeview.grab_focus()
elif self.clip_view == SHOW_ICONVIEW:
self.iconview.grab_focus()
def _setRowVisible(self, model, iter, data):
"""
......@@ -792,28 +808,6 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
dialogbox.destroy()
self._importDialog = None
def _removeSources(self):
"""
Determine which clips are selected in the icon or list view,
and ask MediaLibrary to remove them from the project.
"""
model = self.treeview.get_model()
paths = self.getSelectedPaths()
if not paths:
return
# use row references so we don't have to care if a path has been
# removed
rows = []
for path in paths:
row = Gtk.TreeRowReference.new(model, path)
rows.append(row)
self.app.action_log.begin("remove clip from source list")
for row in rows:
asset = model[row.get_path()][COL_ASSET]
self.app.project_manager.current_project.remove_asset(asset)
self.app.action_log.commit()
def _sourceIsUsed(self, asset):
"""Check if a given URI is present in the timeline"""
layers = self.app.project_manager.current_project.timeline.get_layers()
......@@ -825,7 +819,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
def _selectUnusedSources(self):
"""
Select, in the media library, unused sources in the project.
Select the assets not used by any clip in the project's timeline.
"""
project = self.app.project_manager.current_project
unused_sources_uris = []
......@@ -858,10 +852,6 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
self.app.gui.showProjectSettingsDialog()
infobar.hide()
def _removeClickedCb(self, unused_widget=None):
""" Called when a user clicks on the remove button """
self._removeSources()
def _clipPropertiesCb(self, unused_widget=None):
"""
Show the clip properties (resolution, framerate, audio channels...)
......@@ -1005,20 +995,14 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
ts.select_path(path[0])
def _viewSelectionChangedCb(self, unused):
selected_items = len(self.getSelectedPaths())
if selected_items:
self.selection_actions.set_sensitive(True)
self._remove_button.set_sensitive(True)
self._insert_button.set_sensitive(True)
# Some actions can only be done on a single item at a time:
self._clipprops_button.set_sensitive(False)
if selected_items == 1:
self._clipprops_button.set_sensitive(True)
else:
self.selection_actions.set_sensitive(False)
self._remove_button.set_sensitive(False)
self._insert_button.set_sensitive(False)
self._clipprops_button.set_sensitive(False)
self._updateActions()
def _updateActions(self):
selected_count = len(self.getSelectedPaths())
self.remove_assets_action.set_enabled(selected_count)
self.insert_at_end_action.set_enabled(selected_count)
# Some actions can only be done on a single item at a time:
self._clipprops_button.set_sensitive(selected_count == 1)
def _itemOrRowActivatedCb(self, unused_view, path, *unused_column):
"""
......
......@@ -99,19 +99,19 @@ class PresetManager(GObject.Object, Loggable):
action = Gio.SimpleAction.new("new", None)
action.connect("activate", self._addPresetCb)
action_group.insert(action)
action_group.add_action(action)
menu_model.append(_("New"), "preset.%s" % action.get_name())
self.action_new = action
action = Gio.SimpleAction.new("remove", None)
action.connect("activate", self._removePresetCb)
action_group.insert(action)
action_group.add_action(action)
menu_model.append(_("Remove"), "preset.%s" % action.get_name())
self.action_remove = action
action = Gio.SimpleAction.new("save", None)
action.connect("activate", self._savePresetCb)
action_group.insert(action)
action_group.add_action(action)
menu_model.append(_("Save"), "preset.%s" % action.get_name())
self.action_save = action
......
......@@ -225,31 +225,31 @@ class LayerControls(Gtk.EventBox, Loggable):
self.__move_layer_top_action = Gio.SimpleAction.new("move_layer_to_top", None)
action = self.__move_layer_top_action
action.connect("activate", self._moveLayerCb, -2)
action_group.insert(action)
action_group.add_action(action)
menu_model.append(_("Move layer to top"), "layer.%s" % action.get_name().replace(" ", "."))
self.__move_layer_up_action = Gio.SimpleAction.new("move_layer_up", None)
action = self.__move_layer_up_action
action.connect("activate", self._moveLayerCb, -1)
action_group.insert(action)
action_group.add_action(action)
menu_model.append(_("Move layer up"), "layer.%s" % action.get_name().replace(" ", "."))
self.__move_layer_down_action = Gio.SimpleAction.new("move_layer_down", None)
action = self.__move_layer_down_action
action.connect("activate", self._moveLayerCb, 1)
action_group.insert(action)
action_group.add_action(action)
menu_model.append(_("Move layer down"), "layer.%s" % action.get_name().replace(" ", "."))
self.__move_layer_bottom_action = Gio.SimpleAction.new("move_layer_to_bottom", None)
action = self.__move_layer_bottom_action
action.connect("activate", self._moveLayerCb, 2)
action_group.insert(action)
action_group.add_action(action)
menu_model.append(_("Move layer to bottom"), "layer.%s" % action.get_name().replace(" ", "."))
self.__delete_layer_action = Gio.SimpleAction.new("delete_layer", None)
action = self.__delete_layer_action
action.connect("activate", self._deleteLayerCb)
action_group.insert(action)
action_group.add_action(action)
menu_model.append(_("Delete layer"), "layer.%s" % action.get_name())
return menu_model, action_group
......
......@@ -72,11 +72,6 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
Loggable.__init__(self)
self.log("Creating new ScaleRuler")
# Allows stealing focus from other GTK widgets, prevent accidents:
self.props.can_focus = True
self.connect("focus-in-event", self._focusInCb)
self.connect("focus-out-event", self._focusOutCb)
self.timeline = timeline
self._background_color = timeline.get_style_context().lookup_color(
'theme_bg_color')[1]
......@@ -113,14 +108,6 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
self.scales = SCALES
def _focusInCb(self, unused_widget, unused_arg):
self.log("Ruler has grabbed focus")
self.timeline.setActionsSensitivity(True)
def _focusOutCb(self, unused_widget, unused_arg):
self.log("Ruler has lost focus")
self.timeline.setActionsSensitivity(False)
def _hadjValueChangedCb(self, unused_arg):
self.pixbuf_offset = self.hadj.get_value()
self.queue_draw()
......@@ -182,7 +169,7 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
def do_button_release_event(self, event):
self.debug("button released at x:%d", event.x)
self.grab_focus() # Prevent other widgets from being confused
self.app.gui.focusTimeline()
return False
def do_motion_notify_event(self, event):
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment