mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-12 17:02:36 +12:00
Added quote of the day
This commit is contained in:
parent
8029522563
commit
336e9b672e
21
manuskript/quoteOfTheDay.py
Normal file
21
manuskript/quoteOfTheDay.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
import random
|
||||
import datetime
|
||||
|
||||
# Get seed
|
||||
today = datetime.date.today()
|
||||
split_date = str(today).split("-")
|
||||
seed = split_date[0]+split_date[1]+split_date[2]
|
||||
int(seed)
|
||||
|
||||
random.seed(seed)
|
||||
|
||||
quote_file = "./resources/quotes/Quotes_English.txt" # TODO translations
|
||||
def load_quotes():
|
||||
file = open(quote_file, "r")
|
||||
text = file.read()
|
||||
quotes = text.split("\n")
|
||||
return quotes
|
||||
|
||||
quotes = load_quotes()
|
||||
def get_quote():
|
||||
return random.choice(quotes)
|
|
@ -8,7 +8,7 @@ from gi.repository import Gtk
|
|||
|
||||
from manuskript.data import Info
|
||||
from manuskript.util import validString, invalidString
|
||||
|
||||
from manuskript.quoteOfTheDay import get_quote
|
||||
|
||||
class GeneralView:
|
||||
|
||||
|
@ -28,6 +28,8 @@ class GeneralView:
|
|||
self.licenseBuffer = builder.get_object("license")
|
||||
self.nameBuffer = builder.get_object("name")
|
||||
self.emailBuffer = builder.get_object("email")
|
||||
|
||||
self.quoteLabel = builder.get_object("quote-label")
|
||||
|
||||
self.titleBuffer.set_text(validString(self.info.title), -1)
|
||||
self.subtitleBuffer.set_text(validString(self.info.subtitle), -1)
|
||||
|
@ -54,6 +56,9 @@ class GeneralView:
|
|||
self.nameBuffer.connect("inserted-text", self._nameInsertedText)
|
||||
self.emailBuffer.connect("deleted-text", self._emailDeletedText)
|
||||
self.emailBuffer.connect("inserted-text", self._emailInsertedText)
|
||||
|
||||
self.quoteLabel.set_markup(get_quote())
|
||||
|
||||
|
||||
def __titleChanged(self, buffer: Gtk.EntryBuffer):
|
||||
self.info.title = invalidString(buffer.get_text())
|
||||
|
|
3
resources/quotes/Quotes_English.txt
Normal file
3
resources/quotes/Quotes_English.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
"Don't say it was “delightful”; make us say “delightful” when we’ve read the description. You see all those words (horrifying, wonderful, hideous, exquisite) are only like saying to your readers, “Please will you give my job for me?”" -- C.S. Lewis
|
||||
"Don’t use words too big for the subject. Don’t say “infinitely” when you mean “very”; otherwise you’ll have no word left when you want to talk about something really infinite" -– C.S. Lewis
|
||||
“I’m not in a mood for writing; I must write on until I am.” -- Jane Austen
|
1
resources/quotes/Rules For Quotes.txt
Normal file
1
resources/quotes/Rules For Quotes.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Please make sure all quotes are clean (No language) and make sure they are pertaining to writing.
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2
|
||||
<!-- Generated with glade 3.40.0
|
||||
|
||||
Copyright (C) 2015-2021 Olivier Keshavjee et al.
|
||||
|
||||
|
@ -429,6 +429,50 @@ along with Manuskript. If not, see <http://www.gnu.org/licenses/>.
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Quote of The Day</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="quote-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="wrap">True</property>
|
||||
<attributes>
|
||||
<attribute name="style" value="normal"/>
|
||||
<attribute name="scale" value="2"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
Loading…
Reference in a new issue