[pitivi] Fix main menu
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Fix main menu
- Date: Wed, 9 Jan 2019 16:09:18 +0000 (UTC)
commit 3304e9aa093668356151d0805c6eef3d27f54765
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Tue Dec 18 00:21:40 2018 +0100
Fix main menu
The menu items connected to a signal were broken since
9c41985960c1355416cf680c48f9091df6e154c7 because they were not connected
anymore.
Later in 1c3ff4f0f7dbe418e1d61478d952fce740598b7a they would have broke
again, for some reason.
Fixed by converting all the menu items to use actions.
data/ui/mainmenubutton.ui | 13 +++++--------
pitivi/editorperspective.py | 38 ++++++++++++++++++++++----------------
pitivi/mainwindow.py | 8 ++++++++
3 files changed, 35 insertions(+), 24 deletions(-)
---
diff --git a/data/ui/mainmenubutton.ui b/data/ui/mainmenubutton.ui
index 04397407..079a132f 100644
--- a/data/ui/mainmenubutton.ui
+++ b/data/ui/mainmenubutton.ui
@@ -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>
diff --git a/pitivi/editorperspective.py b/pitivi/editorperspective.py
index 836db1d5..b1fb4d96 100644
--- a/pitivi/editorperspective.py
+++ b/pitivi/editorperspective.py
@@ -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:
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 3ca13dee..65ace502 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]