diff --git a/manuskript/ui/mainWindow.py b/manuskript/ui/mainWindow.py index 104f7ffa..87756323 100644 --- a/manuskript/ui/mainWindow.py +++ b/manuskript/ui/mainWindow.py @@ -69,7 +69,7 @@ class MainWindow: self.plotView = MainWindow.packViewIntoSlot(builder, "plot_slot", PlotView, self.project.plots) self.worldView = MainWindow.packViewIntoSlot(builder, "world_slot", WorldView, self.project.world) self.outlineView = MainWindow.packViewIntoSlot(builder, "outline_slot", OutlineView, self.project.outline) - self.editorView = MainWindow.packViewIntoSlot(builder, "editor_slot", EditorView) + self.editorView = MainWindow.packViewIntoSlot(builder, "editor_slot", EditorView, self.project) self.startupWindow = StartupWindow(self) self.aboutDialog = AboutDialog(self) @@ -144,5 +144,5 @@ class MainWindow: self.window.destroy() - def _notifyProperty(self, window, property): - print(property.name) + def _notify(self, obj: GObject.Object, pspec: GObject.ParamSpec): + print(pspec.name + " = " + str(obj.get_property(pspec.name))) diff --git a/manuskript/ui/views/editorView.py b/manuskript/ui/views/editorView.py index 40a71244..079435a6 100644 --- a/manuskript/ui/views/editorView.py +++ b/manuskript/ui/views/editorView.py @@ -6,14 +6,89 @@ import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk +from manuskript.data import Project, Outline, OutlineFolder, OutlineText, OutlineItem, OutlineState, Plots, PlotLine, Characters, Character, Importance, Goal +from manuskript.ui.util import rgbaFromColor, pixbufFromColor +from manuskript.util import validString, invalidString, validInt, invalidInt, CounterKind, countText + class EditorView: - def __init__(self): + def __init__(self, project: Project): + self.project = project + builder = Gtk.Builder() builder.add_from_file("ui/editor.glade") self.widget = builder.get_object("editor_view") + self.labelStore = builder.get_object("label_store") + self.refreshLabelStore() + + self.statusStore = builder.get_object("status_store") + self.refreshStatusStore() + + self.outlineStore = builder.get_object("outline_store") + self.refreshOutlineStore() + + def refreshLabelStore(self): + self.labelStore.clear() + + for label in self.project.labels: + tree_iter = self.labelStore.append() + + if tree_iter is None: + continue + + self.labelStore.set_value(tree_iter, 0, validString(label.name)) + self.labelStore.set_value(tree_iter, 1, pixbufFromColor(label.color)) + + def refreshStatusStore(self): + self.statusStore.clear() + + for status in self.project.statuses: + tree_iter = self.statusStore.append() + + if tree_iter is None: + continue + + self.statusStore.set_value(tree_iter, 0, validString(status.name)) + + def __appendOutlineItem(self, outlineItem: OutlineItem, parent_iter=None): + tree_iter = self.outlineStore.append(parent_iter) + + if tree_iter is None: + return + + if outlineItem.state != OutlineState.COMPLETE: + outlineItem.load(False) + + if type(outlineItem) is OutlineFolder: + for item in outlineItem: + self.__appendOutlineItem(item, tree_iter) + + wordCount = validInt(outlineItem.textCount()) + goal = validInt(outlineItem.goalCount()) + progress = 0 + + if goal > wordCount: + progress = 100 * wordCount / goal + elif goal > 0: + progress = 100 + + self.outlineStore.set_value(tree_iter, 0, outlineItem.UID.value) + self.outlineStore.set_value(tree_iter, 1, validString(outlineItem.title)) + self.outlineStore.set_value(tree_iter, 2, validString(outlineItem.label)) + self.outlineStore.set_value(tree_iter, 3, validString(outlineItem.status)) + self.outlineStore.set_value(tree_iter, 4, outlineItem.compile) + self.outlineStore.set_value(tree_iter, 5, wordCount) + self.outlineStore.set_value(tree_iter, 6, goal) + self.outlineStore.set_value(tree_iter, 7, progress) + + def refreshOutlineStore(self): + self.outlineStore.clear() + + for item in self.project.outline.items: + self.__appendOutlineItem(item) + def show(self): self.widget.show_all() diff --git a/ui/editor.glade b/ui/editor.glade index 9b466c11..8c083771 100644 --- a/ui/editor.glade +++ b/ui/editor.glade @@ -1,5 +1,5 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + True True @@ -39,18 +67,452 @@ along with Manuskript. If not, see . True False - + True - False + True + True + 200 True False vertical - + + True + True + in + + + True + False + + + True + True + outline_store + False + + + + + + + + + + + + 1 + + + + + 0.90 + 300 + + + 5 + + + + + + + + + + + True + True + 0 + + + + True False + 2 + 2 + 2 + 2 + 4 + + + True + True + True + + + True + False + folder-new-symbolic + + + + + False + True + 0 + + + + + True + True + True + + + True + False + document-new-symbolic + + + + + False + True + 1 + + + + + True + True + True + + + True + False + list-remove-symbolic + + + + + False + True + 2 + + + + + False + True + end + 1 + + + + + True + True + + + + + True + False + + + True + False + vertical + + + True + False + + + True + True + in + + + True + False + + + True + True + + + + + + + page0 + page0 + view-continuous-symbolic + + + + + True + True + in + + + True + False + + + True + False + + + + + + + page1 + page1 + view-grid-symbolic + 1 + + + + + True + True + in + + + True + False + + + True + True + outline_store + + + + + + True + 50 + Title + True + + + True + + + 1 + + + + + + + True + 50 + Label + + + True + label_store + 0 + + + 2 + + + + + + + True + 50 + Status + + + True + status_store + 0 + + + 3 + + + + + + + True + 50 + Compile + + + + 4 + + + + + + + True + 50 + Word count + + + True + + + 5 + + + + + + + True + 50 + Goal + + + True + + + 6 + + + + + + + 50 + % + + + + 7 + + + + + + + + + + + page2 + page2 + view-list-symbolic + 2 + + + + + True + True + 0 + + + + + True + False + 2 + 2 + 2 + 2 + 4 + + + True + False + 8 + 8 + 0 words / 0 + + + False + True + end + -1 + + + + + True + True + True + + + True + False + go-up-symbolic + + + + + False + True + 0 + + + + + True + False + editor_stack + + + False + True + 1 + + + + + True + False + center + + + False + True + end + 2 + + + + + 300 + True + True + editor_scale_adjustment + 100 + False + + + False + True + 3 + + + + + False + True + end + 1 + + + + + page0 + page0 + + + + + True + False + vertical True @@ -70,315 +532,77 @@ along with Manuskript. If not, see . - page0 - page0 - view-continuous-symbolic - - - - - True - True - in - - - True - False - - - True - False - - - - - - - page1 - page1 - view-grid-symbolic - 1 - - - - - True - True - in - - - True - False - - - True - True - 0 - both - - - - - - Title - - - - 0 - - - - - - - Label - - - - 1 - - - - - - - Status - - - - 2 - - - - - - - Compile - - - - 3 - - - - - - - Word count - - - - 4 - - - - - - - Goal - - - - 5 - - - - - - - % - - - - 4 - - - - - - - - - - - page2 - page2 - view-list-symbolic - 2 - - - - - True - True - 0 - - - - - True - False - 2 - 2 - 2 - 2 - 4 - - - True - False - 8 - 8 - 0 words / 0 - - - False - True - end - -1 - - - - - True - True - True - - - True - False - go-up-symbolic - - - - - False + True True 0 - - True - False - editor_stack - - - False - True - 1 - - - - - True - False - center - - - False - True - end - 2 - - - - - 300 - True - True - editor_scale_adjustment - 100 - False - - - False - True - 3 - - - - - False - True - end - 1 - - - - - page0 - page0 - - - - - True - False - vertical - - - True - True - in - - + True False + 2 + 2 + 2 + 2 + 2 + 2 + 4 - + True True + True + + + True + False + go-up-symbolic + + + + False + True + 0 + - - - - - True - True - 0 - - - - - True - False - 2 - 2 - 2 - 2 - 4 - - - True - True - True - + + True + True + True + + + True + False + view-fullscreen-symbolic + + + + + False + True + end + 1 + + + + True False - go-up-symbolic - - - - - False - True - 0 - - - - - True - True - True - - - True - False - view-fullscreen-symbolic + 8 + 8 + 8 + 8 + 0 words + + False + True + end + 2 + @@ -388,34 +612,17 @@ along with Manuskript. If not, see . 1 - - - True - False - 8 - 8 - 0 words - - - False - True - end - 2 - - - False - True - end + page1 + page1 1 - page1 - page1 - 1 + True + True @@ -423,4 +630,10 @@ along with Manuskript. If not, see . + + + + + + diff --git a/ui/main.glade b/ui/main.glade index ad5268d7..32d9a619 100644 --- a/ui/main.glade +++ b/ui/main.glade @@ -664,7 +664,7 @@ along with Manuskript. If not, see . True False - paned1 + paned 200 @@ -677,20 +677,127 @@ along with Manuskript. If not, see . - + 300 True True True True - - 20 + + 50 True False - vertical - + + True + False + vertical + + + + + + page_overview + General + view-dual-symbolic + + + + + True + False + vertical + + + + + + page_summary + Summary + emblem-documents-symbolic + 1 + + + + + True + False + vertical + + + + + + page_characters + Characters + system-users-symbolic + 2 + + + + + True + False + vertical + + + + + + page_plot + Plot + network-wired-symbolic + 3 + + + + + True + False + vertical + + + + + + page_world + World + weather-few-clouds-symbolic + 4 + + + + + True + False + vertical + + + + + + page_outline + Outline + view-list-symbolic + 5 + + + + + True + False + vertical + + + + + + page_editor + Editor + document-edit-symbolic + 6 + @@ -702,164 +809,31 @@ along with Manuskript. If not, see . True True + vertical + 300 + True True - - 50 + True False + vertical - - True - False - vertical - - - - - - page_overview - General - view-dual-symbolic - - - - - True - False - vertical - - - - - - page_summary - Summary - emblem-documents-symbolic - 1 - - - - - True - False - vertical - - - - - - page_characters - Characters - system-users-symbolic - 2 - - - - - True - False - vertical - - - - - - page_plot - Plot - network-wired-symbolic - 3 - - - - - True - False - vertical - - - - - - page_world - World - weather-few-clouds-symbolic - 4 - - - - - True - False - vertical - - - - - - page_outline - Outline - view-list-symbolic - 5 - - - - - True - False - vertical - - - - - - page_editor - Editor - document-edit-symbolic - 6 - + True - False + True - + True - True + False vertical - 300 - True - True - - True - False - vertical - - - - - - True - True - - - - - True - False - vertical - - - - - - True - True - +