Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize port to Python 3 / Gtk 3 #1022

Open
wants to merge 157 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
65ffca7
GitHub Actions: build and test on every push
gnarlyquack Oct 29, 2020
781a722
setup.py: Automatically find packages
gnarlyquack Oct 29, 2020
ed3f42a
Move tests out of the source directory
gnarlyquack Oct 29, 2020
ee87fc3
setup.py: Don't import ourselves
gnarlyquack Oct 30, 2020
4e6a5b7
Move gourmet source into a 'src' directory
gnarlyquack Oct 30, 2020
2d59622
setup.py: Use MANIFEST.in to specify package data
gnarlyquack Oct 30, 2020
022b041
Move requirements into setup.py
gnarlyquack Oct 30, 2020
889ecfd
Simpify installing a development environment
gnarlyquack Oct 30, 2020
56df257
Update contributing documentation
gnarlyquack Oct 31, 2020
fc82a00
GitHub Actions: don't build and test on every push
gnarlyquack Nov 1, 2020
9083d9b
Update contributing documentation
gnarlyquack Nov 1, 2020
9649677
development.in: use long option name
gnarlyquack Nov 1, 2020
052fa7a
Merge pull request #279 from gnarlyquack/reorganize
cydanil Nov 1, 2020
0a13665
Fix schema.org based importers
cydanil Nov 1, 2020
42912d9
Fix recipe removal and change of image
cydanil Nov 1, 2020
c0efbfd
Flake setup.py
cydanil Nov 1, 2020
57d5ddd
Prepare changes for upstream
cydanil Nov 2, 2020
3ab60a0
Clean readme
cydanil Nov 2, 2020
da5a792
Fix scrolled window in message dialog
cydanil Nov 2, 2020
41572a3
Clean imports
cydanil Nov 3, 2020
4b69155
Remove ipython shell plugin
cydanil Nov 3, 2020
86664b2
Make use of opus sound files
cydanil Nov 4, 2020
cac3252
Replace doc_base with resources
gnarlyquack Nov 2, 2020
7f26805
Replace icondir/icon_base with resources
gnarlyquack Nov 2, 2020
fe997b7
Remove obsolete html_plugin_dir
gnarlyquack Nov 2, 2020
499d18e
Replace style_dir with resources
gnarlyquack Nov 2, 2020
0c56611
Replace imagedir with resources
gnarlyquack Nov 2, 2020
01c48f2
Replace data_dir with resources
gnarlyquack Nov 3, 2020
ea68849
Replace uibase with resources
gnarlyquack Nov 4, 2020
79cee79
Remove obsolete plugin search paths
gnarlyquack Nov 4, 2020
005d4a8
Cleanup setting and use of gourmetdir
gnarlyquack Nov 4, 2020
c194e92
Remove lib_dir global variable
gnarlyquack Nov 4, 2020
0923959
Remove obsolete settings file
gnarlyquack Nov 4, 2020
e64112f
Use '.opus' as the audio file extension
gnarlyquack Nov 5, 2020
c884791
Merge pull request #281 from gnarlyquack/paths-to-resources
cydanil Nov 5, 2020
4365015
Fix imports
cydanil Nov 5, 2020
ee35a46
Fix timer formatting
cydanil Nov 5, 2020
c344bda
Fix timer input validation
cydanil Nov 5, 2020
76e7aab
Merge pull request #289 from cydanil/fix/285
cydanil Nov 5, 2020
c94fc42
Remove web plugin
gnarlyquack Nov 6, 2020
c05ef12
Handle unset rating in MCB imports
cydanil Nov 6, 2020
9470d40
Fix broken cycling imports in plugin_loader
cydanil Nov 6, 2020
43d823e
Update GLib.idle_add api call
cydanil Nov 6, 2020
bca9556
Fix import from files test suit
cydanil Nov 6, 2020
0fa8205
Merge pull request #292 from cydanil/fix/1014
cydanil Nov 6, 2020
7e33639
Fix the nutrition plugin
gnarlyquack Nov 6, 2020
570dc2a
Sort imports on PR Github Action
cydanil Nov 7, 2020
6228294
Fix sort imports on PR Github Action
cydanil Nov 7, 2020
484b7a6
Move isort test to test CI
cydanil Nov 7, 2020
eb8db0e
Correctly sort imports
cydanil Nov 7, 2020
9dde7b7
Move isort test to test CI
cydanil Nov 7, 2020
b4aeb2f
Restore interactive importer tests
cydanil Nov 9, 2020
e286deb
Fix html exporter
cydanil Nov 9, 2020
988cc47
Delete unused test data
cydanil Nov 9, 2020
33bcedf
Fix dialog extra formatting
cydanil Nov 9, 2020
6bb99a2
Fix image export in gourmet format
cydanil Nov 9, 2020
b510953
Fix export to gourmet format
cydanil Nov 9, 2020
00b8269
Source version info from src/gourmet/version.py
cydanil Nov 9, 2020
d691152
Update database version check
cydanil Nov 9, 2020
36fe98e
Merge Update version number to 1.0.0
cydanil Nov 9, 2020
ba4006c
Add Windows 10 installation instructions
cydanil Nov 9, 2020
d3bda0f
Fix rating to text in recipe browser
cydanil Nov 10, 2020
9adb5e7
Fix path generation in recipe browser
cydanil Nov 10, 2020
5329de6
Fix alphabetical ordering of recipes in browser
cydanil Nov 10, 2020
0caaf07
Fix KeyEditor plugin
cydanil Nov 10, 2020
a0b5197
Make RecData.format_amount_string_from_amount a staticmethod
cydanil Nov 12, 2020
1b50cce
Specify Pillow 7.0.0 or greater
cydanil Nov 16, 2020
6e8fed2
Re-add nutritionDruid.ui to POTFILES.in
gnarlyquack Nov 18, 2020
5d442e7
Split i18n into build and update commands
gnarlyquack Nov 18, 2020
20e66f0
Remove intltool cache files after build
gnarlyquack Nov 18, 2020
b7d8133
Automatically build i18n files
gnarlyquack Nov 18, 2020
00deef9
Reorganize l10n/i18n files
gnarlyquack Nov 18, 2020
d576378
Ensure sdists and wheels have correct package data
gnarlyquack Nov 18, 2020
482c1a1
Fix creating/updating PO templates
gnarlyquack Nov 18, 2020
cb7c1a1
setup.py: minor cleanup
gnarlyquack Nov 19, 2020
41f98d4
Update documentation
gnarlyquack Nov 20, 2020
a5310fe
Update build scripts
gnarlyquack Nov 20, 2020
6bcf33e
Remove gourmet.pot from .gitignore
gnarlyquack Nov 20, 2020
619adeb
version.py: Remove unused variable
gnarlyquack Nov 20, 2020
60e1ac8
Fix switching windows with the 'Go' menu
takluyver Nov 21, 2020
ed1013b
Merge pull request #322 from takluyver/fix-go-menu
cydanil Nov 21, 2020
fb2601e
Fix index error when updating ingredient key
cydanil Dec 22, 2020
b701f62
Update calls to Gtk API in KeyEditor plugins
cydanil Dec 23, 2020
1f35b7a
Remove dependency on argcomplete
cydanil Dec 23, 2020
d1a9f55
Clean dead code
cydanil Dec 23, 2020
e9b78c5
Return False instead of raising in getBoolean
cydanil Dec 26, 2020
9d5afb9
Pin SQLAlchemy version to 1.3.22
cydanil May 2, 2021
5d0c61b
Update Flatpak Gnome runtime to 40
cydanil May 2, 2021
1731c8e
Update Flatpak Gnome runtime to 40
cydanil May 2, 2021
b37f8f2
Update line slicing in MasterCook importer
cydanil May 2, 2021
3b75b23
Flake MasterCook file importer
cydanil May 2, 2021
b26cd8b
Remove broken MasterCook test
cydanil May 2, 2021
15abafa
Merge pull request #334 from cydanil/fix/328
cydanil May 2, 2021
f631002
Add annotations
cydanil May 2, 2021
7b556a8
Rebase from master
cydanil May 2, 2021
95907ab
Flatpak: Gnome runtime 40
cydanil May 2, 2021
57e97a5
Merge pull request #324 from cydanil/fix/315
cydanil May 3, 2021
79ccc02
Fix nutrition information exporter
cydanil May 6, 2021
0778bde
Pin dependencies versions
cydanil May 6, 2021
b6d9aea
Merge pull request #320 from gnarlyquack/i18n
cydanil May 6, 2021
e94f834
Update Gtk API calls retrieving chosen filetype in file export selector
cydanil May 10, 2021
f2177ea
Fix Preferences issues introduced when refactoring
cydanil May 10, 2021
ead0036
Fix nutritionGrabberGui
cydanil May 10, 2021
b411f9e
Merge branch 'master' into fix/nutritional_infos_export
cydanil May 10, 2021
37adfc1
Fix nutritional infos export
cydanil May 10, 2021
bbb67e2
Load plugins from namespaces
cydanil May 13, 2021
8d7e653
Add Copy recipe to context menu
cydanil Jun 12, 2021
8e70cf5
Update deprecated Gtk widgets
cydanil Jun 12, 2021
4fc0282
Add support for copying selected recipes to clipboard
cydanil Jun 13, 2021
6ac46c8
Add TODO to check for dead code
cydanil Jun 13, 2021
7ec3a62
Merge pull request #341 from cydanil/feat/plugin_namespace
cydanil Jun 13, 2021
8380567
Add ingredients to clipboard-exported recipes
cydanil Jun 15, 2021
cb604da
Add CI runner for creating AppImages (#343)
cydanil Jun 16, 2021
9fac119
Update INSTALL.md with rc2 infos
cydanil Jun 16, 2021
c8a509a
Prepare PR to upstream
cydanil Jun 16, 2021
98fae3c
Fix file chooser dialog on recipe export
cydanil Jun 24, 2021
fc8518f
Adapt FileSelectorDialog to work with images
cydanil Jun 24, 2021
3ecf55e
Remove unused is_extension_legal function
cydanil Jun 24, 2021
fcb65db
Adapt FileSelectorDialog to work with file imports
cydanil Jun 24, 2021
7fc6e59
Fix FileSelectorDialog behaviour (#347)
cydanil Jun 24, 2021
4f98bdf
Reinstate mastercook_plaintext_importer.Tester (#348)
cydanil Jun 24, 2021
f46b5c0
Add comments
cydanil Jun 26, 2021
dbb736b
Remove unused Gtk dialog code
cydanil Jun 26, 2021
baa1c05
Refactor mastercook text file check
cydanil Jun 26, 2021
6b5c119
Refactor mastercook text file check (#349)
cydanil Jun 26, 2021
01fc39d
Update recipe tree upon save
cydanil Jun 26, 2021
797cafa
Fix refreshing of recipe tree upon new recipe (#350)
cydanil Jun 26, 2021
f927789
Correctly handle cancel when prompted to save modified recipe before …
cydanil Jun 26, 2021
18d1363
Update reccard tests
cydanil Jun 26, 2021
f21b9a5
Fix saving modified recipe when prompted before export
cydanil Jun 26, 2021
dce85c8
Handle invalid image uri in web imports
cydanil Jun 26, 2021
e33dd20
Retrieve web recipe images in a cancellable background thread
cydanil Jun 27, 2021
40a888a
Make ImageBrowser scrollable
cydanil Jun 27, 2021
ab2c4cf
merge Improve ImageBrowserDialog (#352)
cydanil Jun 27, 2021
a66b89d
Fix plugin_loader refactor gone wrong (#353)
cydanil Jun 28, 2021
cc36d73
Add log message in pdf plugin when poppler not available (#354)
cydanil Jun 29, 2021
c4a20d5
Use OS locale (#345)
cydanil Jun 29, 2021
1c35745
Do small refactor in undo.py (#355)
cydanil Jun 30, 2021
9fe8d1d
Prepare release 1.0.0 (#356)
cydanil Jul 1, 2021
cda64c0
Prepare PR to upstream
cydanil Jul 1, 2021
38307bd
Remove deprecated argument from pdf recipe export (#360)
cydanil Jul 4, 2021
bc5b546
Do small ImageBox refactor
cydanil Jul 4, 2021
387d313
Create ImageBox thumbnail when initializing self.image
cydanil Jul 4, 2021
e8110e3
Create ImageBox.thumbnail when ImageBox.image is being set (#361)
cydanil Jul 4, 2021
b07509c
Fix pdf export when a locale is set
cydanil Jul 11, 2021
93bd237
Clarify variable names
cydanil Jul 11, 2021
8762b0c
Store PDF export settings in locale-agnostic format
cydanil Jul 12, 2021
a951f9c
Remove not needed self.prefs attribute of PdfPrefGetter
cydanil Jul 12, 2021
5b495b7
Remove PdfPrefGetter.make_reverse_dicts function
cydanil Jul 12, 2021
57c4e7b
Flake PdfPrefGetter attributes definitions
cydanil Jul 12, 2021
a1546f4
Add test for locale-agnostic PDF preferences
cydanil Jul 12, 2021
ca4ad62
Make PDF export preferences locale-agnostic (#363)
cydanil Jul 12, 2021
7e34b52
Hardcode maximum columns in PDF exports
cydanil Jul 12, 2021
778c4d7
Remove deprecated Gtk.ComboText.remove_text call
cydanil Jul 12, 2021
0133f98
Only apply scaling of attribute if attribute available for reportlab …
cydanil Jul 12, 2021
a617327
Only scale available reportlab attributes (#365)
cydanil Jul 12, 2021
6d7d585
Prepare PR to upstream
cydanil Jul 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 34 additions & 44 deletions src/gourmet/gtk_extras/dialog_extras.py
Original file line number Diff line number Diff line change
@@ -880,7 +880,7 @@ def show_message(*args, **kwargs):

def select_file(title,
filename=None,
filters=[],
filters=None,
# filters are lists of a name, a list of mime types and a list of
# patterns ['Plain Text', ['text/plain'], '*txt']
action=Gtk.FileChooserAction.OPEN,
@@ -889,6 +889,8 @@ def select_file(title,
buttons=None,
parent=None
):
if filters is None:
filters = []
sfd = FileSelectorDialog(title,
filename=filename,
filters=filters,
@@ -917,14 +919,11 @@ def saveas_file(title: str,
buttons=buttons,
show_filetype=show_filetype,
parent=parent)
# Get the filename, and the extension of the chosen filetype menu
filename, *extension = sfd.run()
extension = ''.join(extension)

# TODO: it would be cleaner to return the extension, rather than the
# output file type description
export_type = sfd.ext_to_filter[extension].get_name()
return filename, export_type
try:
filename, export_type = sfd.run()
return filename, export_type
except TypeError:
return None, None


def get_type_for_filters(fname, filters):
@@ -941,10 +940,18 @@ def get_type_for_filters(fname, filters):
def select_image(title,
filename=None,
action=Gtk.FileChooserAction.OPEN,
buttons=None):
buttons=None) -> Optional[Path]:
sfd = ImageSelectorDialog(title, filename=filename,
action=action, buttons=buttons)
return sfd.run()
filename = sfd.run()
if not filename:
return

filename = Path(filename[-1])
if not filename.is_file():
return

return filename


class FileSelectorDialog:
@@ -1081,42 +1088,25 @@ def change_file_extension(self, fsd, data: GObject.GParamSpec):
else:
self.fsd.set_current_name(stem)

def is_extension_legal(self, filenames: List[str]) -> bool:
if filenames:
for extension in self.extensions:
if not extension:
extension = ""
if fnmatch.fnmatch(filenames[0], extension):
return True
return False
def run(self) -> Optional[List[str]]:
"""Return a list of filenames.

def run(self) -> List[str]:
"""Run our dialog and return the filename(s)"""
If saving files, the file type is also returned as the last entry in
the list.
In that case, it is assumed that all file are of the same type.
"""
response = self.fsd.run()

if response == Gtk.ResponseType.OK:
if self.multiple:
fn = self.fsd.get_filenames()
else:
fn = [self.fsd.get_filename()]
if not fn:
show_message(label=_('No file selected'),
sublabel=_(
'No file was selected, so the action has been cancelled')
)
return []
if self.action == Gtk.FileChooserAction.SAVE:
# add the extension if need be...
if self.do_saveas and not self.is_extension_legal(fn):
if self.fsd.get_filter().get_name() in self.name_to_ext:
add_ext = self.name_to_ext[self.fsd.get_filter(
).get_name()]
if add_ext:
fn += add_ext
self.quit()
return fn
else:
self.quit()
return []
filenames = self.fsd.get_filenames()
if self.action == Gtk.FileChooserAction.SAVE and self.do_saveas:
export_type = self.fsd.get_filter().get_name()
filenames.append(export_type)
else: # response == Gtk.ResponseType.CANCEL:
filenames = None

self.quit()
return filenames

def quit(self, *args):
if hasattr(self, 'timeout'):
2 changes: 1 addition & 1 deletion src/gourmet/importers/importManager.py
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ def offer_import(self, parent: Optional[Gtk.Window] = None):
filters=self.get_filters(),
parent=parent,
select_multiple=True)
if not filenames:
if filenames is None:
return
self.import_filenames(filenames)

8 changes: 3 additions & 5 deletions src/gourmet/reccard.py
Original file line number Diff line number Diff line change
@@ -1550,12 +1550,10 @@ def set_from_file (self, filename: str):
self.draw_image()

def set_from_fileCB(self, widget: Gtk.Button):
filenames = de.select_image("Select Image",
filename = de.select_image("Select Image",
action=Gtk.FileChooserAction.OPEN)
if filenames:
fname, *_ = filenames
fname = Path(fname)
Undo.UndoableObject(lambda *args: self.set_from_file(fname),
if filename is not None:
Undo.UndoableObject(lambda *args: self.set_from_file(filename),
lambda *args: self.remove_image(),
self.rc.history,
widget=self.imageW).perform()