[pitivi/1.0] project: Remove project title functionality
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/1.0] project: Remove project title functionality
- Date: Sat, 29 Sep 2018 02:15:22 +0000 (UTC)
commit 89761fe1aceecd32ff661a2baf75849f697c9d7b
Author: HarishFulara07 <harish14143 iiitd ac in>
Date: Sat Jun 23 16:20:49 2018 +0530
project: Remove project title functionality
data/ui/projectsettings.ui | 36 ++++-------------------
pitivi/mainwindow.py | 73 +++++-----------------------------------------
pitivi/project.py | 28 +++++-------------
tests/test_project.py | 1 +
tests/test_undo_project.py | 13 ++++-----
5 files changed, 27 insertions(+), 124 deletions(-)
---
diff --git a/data/ui/projectsettings.ui b/data/ui/projectsettings.ui
index 723d7240..45c6ee87 100644
--- a/data/ui/projectsettings.ui
+++ b/data/ui/projectsettings.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.1 -->
+<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkAdjustment" id="adjustment1">
@@ -215,7 +215,7 @@
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="no">x</property>
+ <property name="label">x</property>
</object>
<packing>
<property name="expand">False</property>
@@ -557,25 +557,13 @@
<object class="GtkEntry" id="author_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="invisible_char">●</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="title_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="margin_right">10</property>
<property name="hexpand">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">3</property>
</packing>
</child>
<child>
@@ -585,18 +573,6 @@
<property name="halign">start</property>
<property name="label" translatable="yes">Author:</property>
</object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label24">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">Project title:</property>
- </object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
@@ -611,7 +587,7 @@
</object>
<packing>
<property name="left_attach">2</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">0</property>
</packing>
</child>
<child>
@@ -621,14 +597,14 @@
<property name="halign">start</property>
<property name="max_length">4</property>
<property name="invisible_char">●</property>
- <property name="text" translatable="no">1900</property>
+ <property name="text">1900</property>
<property name="adjustment">adjustment3</property>
<property name="numeric">True</property>
<property name="value">1900</property>
</object>
<packing>
<property name="left_attach">3</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">0</property>
</packing>
</child>
</object>
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 00e25df5..c9d326c3 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -312,7 +312,6 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
# Focus the timeline by default!
self.focusTimeline()
- self.updateTitle()
def _setDefaultPositions(self):
window_width = self.get_size()[0]
@@ -752,9 +751,6 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
if uri:
self.recent_manager.add_item(uri)
- if project.uri is None:
- project.uri = uri
-
def _projectManagerClosingProjectCb(self, project_manager, project):
"""Investigates whether it's possible to close the specified project.
@@ -862,7 +858,6 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
project.pipeline.deactivatePositionListener()
self.info("Project closed")
- self.updateTitle()
if project.loaded:
self._disconnectFromProject(project)
self.timeline_ui.setProject(None)
@@ -1094,12 +1089,8 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
asset = GES.Formatter.get_default()
asset_extension = asset.get_meta(GES.META_FORMATTER_EXTENSION)
- if not project.name:
- chooser.set_current_name(
- _("Untitled") + "." + asset_extension + "_tar")
- else:
- chooser.set_current_name(
- project.name + "." + asset_extension + "_tar")
+ chooser.set_current_name(
+ project.name + "." + asset_extension + "_tar")
filt = Gtk.FileFilter()
filt.set_name(_("Tar archive"))
@@ -1217,61 +1208,11 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
def updateTitle(self):
project = self.app.project_manager.current_project
- if project:
- if project.name:
- name = project.name
- else:
- name = _("Untitled")
- unsaved_mark = ""
- if project.hasUnsavedModifications():
- unsaved_mark = "*"
- title = "%s%s — %s" % (unsaved_mark, name, APPNAME)
- else:
- title = APPNAME
- event_box = Gtk.EventBox()
- label = Gtk.Label()
- clear_styles(label)
- label.set_text(title)
- event_box.add(label)
- event_box.show_all()
- event_box.connect("button-press-event", self.__titleClickCb, project)
- self._headerbar.set_custom_title(event_box)
- self.set_title(title)
-
- def __titleClickCb(self, unused_widget, unused_event, project):
- entry = Gtk.Entry()
- entry.set_width_chars(100)
- entry.set_margin_left(SPACING)
- entry.set_margin_right(SPACING)
- entry.show()
- entry.set_text(project.name)
- self._headerbar.set_custom_title(entry)
- if project.hasDefaultName():
- entry.grab_focus()
- else:
- entry.grab_focus_without_selecting()
- entry.connect("focus-out-event", self.__titleChangedCb, project)
- entry.connect("key_release_event", self.__titleTypeCb, project)
-
- def __titleChangedCb(self, widget, event, project):
- if not event.window:
- # Workaround https://bugzilla.gnome.org/show_bug.cgi?id=757036
- return
- name = widget.get_text()
- if project.name == name:
- self.updateTitle()
- else:
- project.name = name
-
- def __titleTypeCb(self, widget, event, project):
- if event.keyval == Gdk.KEY_Return:
- self.focusTimeline()
- return True
- elif event.keyval == Gdk.KEY_Escape:
- widget.set_text(project.name)
- self.focusTimeline()
- return True
- return False
+ unsaved_mark = ""
+ if project.hasUnsavedModifications():
+ unsaved_mark = "*"
+ title = "%s%s — %s" % (unsaved_mark, project.name, APPNAME)
+ self._headerbar.set_title(title)
class PreviewAssetWindow(Gtk.Window):
diff --git a/pitivi/project.py b/pitivi/project.py
index a39d3d7c..3477478b 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -60,7 +60,7 @@ from pitivi.utils.validate import has_validate
from pitivi.utils.widgets import FractionWidget
-DEFAULT_NAME = _("New Project")
+DEFAULT_NAME = _("Untitled")
ALL_RAW_VIDEO_FORMATS = []
# Starting at 2 as 0 is UNKNOWN and 1 is ENCODED.
@@ -379,13 +379,13 @@ class ProjectManager(GObject.Object, Loggable):
if not backup:
# Do not emit the signal when autosaving a backup file
self.current_project.setModificationState(False)
- self.emit("project-saved", self.current_project, uri)
self.debug('Saved project: %s', uri)
# Update the project instance's uri,
# otherwise, subsequent saves will be to the old uri.
self.info("Setting the project instance's URI to: %s", uri)
self.current_project.uri = uri
self.disable_save = False
+ self.emit("project-saved", self.current_project, uri)
else:
self.debug('Saved backup: %s', uri)
@@ -516,7 +516,7 @@ class ProjectManager(GObject.Object, Loggable):
return False
self.__start_loading_time = time.time()
- project = Project(self.app, name=DEFAULT_NAME)
+ project = Project(self.app)
self.emit("new-project-loading", project)
# setting default values for project metadata
@@ -630,7 +630,6 @@ class Project(Loggable, GES.Project):
loaded (bool): Whether the project is fully loaded.
Args:
- name (Optional[str]): The name of the new empty project.
uri (Optional[str]): The URI of the file where the project should
be loaded from.
@@ -654,10 +653,10 @@ class Project(Loggable, GES.Project):
"video-size-changed": (GObject.SignalFlags.RUN_LAST, None, ()),
}
- def __init__(self, app, name="", uri=None, scenario=None, **unused_kwargs):
+ def __init__(self, app, uri=None, scenario=None, **unused_kwargs):
Loggable.__init__(self)
GES.Project.__init__(self, uri=uri, extractable_type=GES.Timeline)
- self.log("name:%s, uri:%s", name, uri)
+ self.log("uri:%s", uri)
self.pipeline = None
self.ges_timeline = None
self.uri = uri
@@ -698,7 +697,6 @@ class Project(Loggable, GES.Project):
self.__awaited_deleted_proxy_targets = set()
# Project property default values
- self.register_meta(GES.MetaFlag.READWRITE, "name", name)
self.register_meta(GES.MetaFlag.READWRITE, "author", "")
# The rendering settings.
@@ -761,13 +759,9 @@ class Project(Loggable, GES.Project):
# Project specific properties
@property
def name(self):
- return self.get_meta("name")
-
- @name.setter
- def name(self, name):
- if name == self.name:
- return
- self.set_meta("name", name)
+ if not self.uri:
+ return DEFAULT_NAME
+ return os.path.splitext(os.path.basename(self.uri))[0]
@property
def year(self):
@@ -1423,9 +1417,6 @@ class Project(Loggable, GES.Project):
# The asset is an original which is not being proxied.
self.app.proxy_manager.cancel_job(asset)
- def hasDefaultName(self):
- return DEFAULT_NAME == self.name
-
def _commit(self):
"""Logs the operation and commits.
@@ -1851,7 +1842,6 @@ class ProjectSettingsDialog(object):
self.video_presets_combo = getObj("video_presets_combo")
self.constrain_sar_button = getObj("constrain_sar_button")
self.select_dar_radiobutton = getObj("select_dar_radiobutton")
- self.title_entry = getObj("title_entry")
self.author_entry = getObj("author_entry")
self.year_spinbutton = getObj("year_spinbutton")
@@ -2005,7 +1995,6 @@ class ProjectSettingsDialog(object):
self.audio_presets_combo.set_active_id(matching_audio_preset)
# Metadata
- self.title_entry.set_text(self.project.name)
self.author_entry.set_text(self.project.author)
if self.project.year:
year = int(self.project.year)
@@ -2016,7 +2005,6 @@ class ProjectSettingsDialog(object):
def updateProject(self):
with self.app.action_log.started("change project settings",
toplevel=True):
- self.project.name = self.title_entry.get_text()
self.project.author = self.author_entry.get_text()
self.project.year = str(self.year_spinbutton.get_value_as_int())
diff --git a/tests/test_project.py b/tests/test_project.py
index 38c24e39..7e99ee8f 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -656,6 +656,7 @@ class TestProjectSettings(common.TestCase):
def testLoad(self):
project = Project(uri="fake.xges", app=common.create_pitivi_mock())
+ self.assertEqual(project.name, "fake")
self.assertFalse(project._has_default_video_settings)
self.assertFalse(project._has_default_audio_settings)
diff --git a/tests/test_undo_project.py b/tests/test_undo_project.py
index 6f15a226..3a2688a4 100644
--- a/tests/test_undo_project.py
+++ b/tests/test_undo_project.py
@@ -126,25 +126,22 @@ class TestProjectUndo(common.TestCase):
project=self.project,
app=self.app)
- def assert_meta(title, author, year):
- self.assertEqual(self.project.name, title)
+ def assert_meta(author, year):
self.assertEqual(self.project.author, author)
self.assertEqual(self.project.year, year)
- dialog.title_entry.set_text("t1")
dialog.author_entry.set_text("a1")
dialog.year_spinbutton.set_value(2001)
dialog.updateProject()
- assert_meta("t1", "a1", "2001")
+ assert_meta("a1", "2001")
- dialog.title_entry.set_text("t2")
dialog.author_entry.set_text("a2")
dialog.year_spinbutton.set_value(2002)
dialog.updateProject()
- assert_meta("t2", "a2", "2002")
+ assert_meta("a2", "2002")
self.action_log.undo()
- assert_meta("t1", "a1", "2001")
+ assert_meta("a1", "2001")
self.action_log.redo()
- assert_meta("t2", "a2", "2002")
+ assert_meta("a2", "2002")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]