Commit 3304e9aa authored by Alexandru Băluț's avatar Alexandru Băluț Committed by Thibault Saunier

Fix main menu

The menu items connected to a signal were broken since
9c419859 because they were not connected
anymore.

Later in 1c3ff4f0 they would have broke
again, for some reason.

Fixed by converting all the menu items to use actions.
parent f9482403
Pipeline #50250 passed with stages
in 14 minutes and 15 seconds
......@@ -24,8 +24,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Reload the current project</property>
<property name="action_name">editor.revert-to-saved</property>
<property name="text" translatable="yes">Revert to saved version</property>
<signal name="activate" handler="_revertToSavedProjectCb" swapped="no"/>
</object>
</child>
<child>
......@@ -33,8 +33,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Export the current project and all its media in a .tar archive</property>
<property name="action_name">editor.export-project</property>
<property name="text" translatable="yes">Export as Archive...</property>
<signal name="activate" handler="_exportProjectAsTarCb" swapped="no"/>
</object>
</child>
<child>
......@@ -48,9 +48,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Export the frame at the current playhead position as an image file.</property>
<property name="action_name">editor.save-frame</property>
<property name="text" translatable="yes">Export current frame...</property>
<property name="use_underline">True</property>
<signal name="activate" handler="_screenshotCb" swapped="no"/>
</object>
</child>
<child>
......@@ -64,9 +63,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Edit the project settings</property>
<property name="action_name">editor.project-settings</property>
<property name="text" translatable="yes">Project Settings</property>
<property name="use_underline">True</property>
<signal name="activate" handler="_projectSettingsCb" swapped="no"/>
</object>
</child>
<child>
......@@ -79,8 +77,8 @@
<object class="GtkModelButton" id="menu_preferences">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="action_name">win.preferences</property>
<property name="text" translatable="yes">Preferences</property>
<signal name="activate" handler="_prefsCb" swapped="no"/>
</object>
</child>
<child>
......@@ -89,7 +87,6 @@
<property name="can_focus">True</property>
<property name="action_name">app.shortcuts_window</property>
<property name="text" translatable="yes">Keyboard Shortcuts</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
......
......@@ -30,7 +30,6 @@ from pitivi.clipproperties import ClipProperties
from pitivi.configure import APPNAME
from pitivi.configure import get_ui_dir
from pitivi.dialogs.missingasset import MissingAssetDialog
from pitivi.dialogs.prefs import PreferencesDialog
from pitivi.effects import EffectListWidget
from pitivi.mediafilespreviewer import PreviewWidget
from pitivi.medialibrary import MediaLibraryWidget
......@@ -44,7 +43,6 @@ from pitivi.transitions import TransitionsListWidget
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import path_from_uri
from pitivi.utils.ui import beautify_time_delta
from pitivi.utils.ui import clear_styles
from pitivi.utils.ui import info_name
from pitivi.utils.ui import PADDING
from pitivi.utils.ui import SPACING
......@@ -318,10 +316,6 @@ class EditorPerspective(Perspective, Loggable):
self.menu_button = self.builder.get_object("menubutton")
self._menubutton_items = {}
for widget in self.builder.get_object("menu_box").get_children():
self._menubutton_items[Gtk.Buildable.get_name(widget)] = widget
headerbar.pack_end(self.menu_button)
headerbar.pack_end(self.save_button)
headerbar.pack_end(self.render_button)
......@@ -347,21 +341,36 @@ class EditorPerspective(Perspective, Loggable):
self.app.shortcuts.add("editor.save-as", ["<Primary><Shift>s"],
_("Save the current project as"), group="win")
self.revert_to_saved_action = Gio.SimpleAction.new("revert-to-saved", None)
self.revert_to_saved_action.connect("activate", self.__revert_to_saved_cb)
group.add_action(self.revert_to_saved_action)
self.export_project_action = Gio.SimpleAction.new("export-project", None)
self.export_project_action.connect("activate", self.__export_project_cb)
group.add_action(self.export_project_action)
self.save_frame_action = Gio.SimpleAction.new("save-frame", None)
self.save_frame_action.connect("activate", self.__save_frame_cb)
group.add_action(self.save_frame_action)
self.project_settings_action = Gio.SimpleAction.new("project-settings", None)
self.project_settings_action.connect("activate", self.__project_settings_cb)
group.add_action(self.project_settings_action)
self.import_asset_action = Gio.SimpleAction.new("import-asset", None)
self.import_asset_action.connect("activate", self.__import_asset_cb)
group.add_action(self.import_asset_action)
self.app.shortcuts.add("editor.import-asset", ["<Primary>i"],
_("Add media files to your project"), group="win")
def __import_asset_cb(self, unusdaction, unusedparam):
def __import_asset_cb(self, unused_action, unused_param):
self.medialibrary.show_import_assets_dialog()
def showProjectStatus(self):
project = self.app.project_manager.current_project
dirty = project.hasUnsavedModifications()
self.save_action.set_enabled(dirty)
if project.uri:
self._menubutton_items["menu_revert_to_saved"].set_sensitive(dirty)
self.revert_to_saved_action.set_enabled(bool(project.uri) and dirty)
self.updateTitle()
# UI Callbacks
......@@ -403,10 +412,10 @@ class EditorPerspective(Perspective, Loggable):
else:
self.app.project_manager.saveProject()
def _revertToSavedProjectCb(self, unused_action):
def __revert_to_saved_cb(self, unused_action, unused_param):
return self.app.project_manager.revertToSavedProject()
def _exportProjectAsTarCb(self, unused_action):
def __export_project_cb(self, unused_action, unused_param):
uri = self._showExportDialog(self.app.project_manager.current_project)
result = None
if uri:
......@@ -417,7 +426,7 @@ class EditorPerspective(Perspective, Loggable):
self.log("Project couldn't be exported")
return result
def _projectSettingsCb(self, unused_action):
def __project_settings_cb(self, unused_action, unused_param):
self.showProjectSettingsDialog()
def showProjectSettingsDialog(self):
......@@ -426,9 +435,6 @@ class EditorPerspective(Perspective, Loggable):
dialog.window.run()
self.updateTitle()
def _prefsCb(self, unused_action):
PreferencesDialog(self.app).run()
# Project management callbacks
def _projectManagerNewProjectLoadedCb(self, project_manager, project):
......@@ -776,7 +782,7 @@ class EditorPerspective(Perspective, Loggable):
chooser.destroy()
return ret
def _screenshotCb(self, unused_action):
def __save_frame_cb(self, unused_action, unused_param):
"""Exports a snapshot of the current frame as an image file."""
foo = self._showSaveScreenshotDialog()
if foo:
......
......@@ -26,6 +26,7 @@ from gi.repository import Gtk
from pitivi.configure import get_pixmap_dir
from pitivi.dialogs.about import AboutDialog
from pitivi.dialogs.prefs import PreferencesDialog
from pitivi.editorperspective import EditorPerspective
from pitivi.greeterperspective import GreeterPerspective
from pitivi.settings import GlobalSettings
......@@ -170,6 +171,10 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
self.app.shortcuts.add("win.menu-button", ["F10"],
_("Show the menu button content"), group="app")
self.preferences_action = Gio.SimpleAction.new("preferences", None)
self.preferences_action.connect("activate", self.__preferences_cb)
self.add_action(self.preferences_action)
@staticmethod
def __user_manual_cb(unused_action, unused_param):
show_user_manual()
......@@ -182,6 +187,9 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
active = not self.__perspective.menu_button.get_active()
self.__perspective.menu_button.set_active(active)
def __preferences_cb(self, unused_action, unused_param):
PreferencesDialog(self.app).run()
def __configure_cb(self, unused_widget, unused_event):
"""Saves the main window position and size."""
# Takes window manager decorations into account.
......
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