Skip to content

Commit

Permalink
Merge pull request #281 from gnarlyquack/paths-to-resources
Browse files Browse the repository at this point in the history
Replace paths with resources
  • Loading branch information
cydanil authored Nov 5, 2020
2 parents 86664b2 + e64112f commit c884791
Show file tree
Hide file tree
Showing 35 changed files with 864 additions and 644 deletions.
29 changes: 13 additions & 16 deletions src/gourmet/GourmetRecipeManager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import os.path
from pkgutil import get_data as _get_data
import re
import threading
from gettext import gettext as _
Expand All @@ -15,8 +14,7 @@
from gourmet.exporters.exportManager import ExportManager
from gourmet.exporters.printer import PrintManager
from gourmet.gdebug import debug
from gourmet.gglobals import (DEFAULT_HIDDEN_COLUMNS, REC_ATTRS, doc_base,
icondir, uibase)
from gourmet.gglobals import DEFAULT_HIDDEN_COLUMNS, REC_ATTRS
from gourmet.gtk_extras import WidgetSaver
from gourmet.gtk_extras import dialog_extras as de
from gourmet.gtk_extras import (fix_action_group_importance, mnemonic_manager,
Expand All @@ -28,6 +26,9 @@
get_thread_manager_gui)
from gourmet.timer import show_timer

from .image_utils import load_pixbuf_from_resource as _load_pixbuf_from_resource


UNDO = 1
SHOW_TRASH = 2

Expand Down Expand Up @@ -347,15 +348,11 @@ def show_about (self, *args):
else:
translator = defaults.CREDITS

logo=GdkPixbuf.Pixbuf.new_from_file(os.path.join(icondir,"gourmet.png"))
logo = _load_pixbuf_from_resource('gourmet.svg')

# load LICENSE text file
try:
license_text = open(os.path.join(doc_base,'LICENSE'),'r').read()
except IOError as err:
print("IO Error %s" % err)
except:
print("Unexpexted error")
license_text = _get_data('gourmet', 'data/LICENSE').decode()
assert license_text

paypal_link = """https://www.paypal.com/cgi-bin/webscr?cmd=_donations
&business=Thomas_Hinkle%40alumni%2ebrown%2eedu
Expand All @@ -364,7 +361,7 @@ def show_about (self, *args):
gratipay_link = "https://gratipay.com/on/github/thinkle/"
flattr_link = "http://flattr.com/profile/Thomas_Hinkle/things"

about = Gtk.AboutDialog()
about = Gtk.AboutDialog(parent=self.window)
about.set_artists(version.artists)
about.set_authors(version.authors)
about.set_comments(version.description)
Expand Down Expand Up @@ -404,7 +401,7 @@ def show_about (self, *args):
about.destroy()

def show_help (self, *args):
de.show_faq(os.path.join(doc_base,'FAQ'))
de.show_faq(parent=self.window)

def save (self, file=None, db=None, xml=None):
debug("save (self, file=None, db=None, xml=None):",5)
Expand Down Expand Up @@ -504,7 +501,7 @@ def __init__ (self, rg):
self.rg = rg
self.rmodel = self.rg.rmodel
self.ui=Gtk.Builder()
self.ui.add_from_file(os.path.join(uibase,'recipe_index.ui'))
self.ui.add_from_string(_get_data('gourmet', 'ui/recipe_index.ui').decode())
RecIndex.__init__(self, self.ui, self.rg.rd, self.rg)
self.setup_main_window()

Expand Down Expand Up @@ -871,7 +868,7 @@ def __init__(self):
self.setup_index_columns()
self.setup_hacks()
self.ui=Gtk.Builder()
self.ui.add_from_file(os.path.join(uibase,'recipe_index.ui'))
self.ui.add_from_string(_get_data('gourmet', 'ui/recipe_index.ui').decode())
self.setup_actions()
RecIndex.__init__(self,
ui=self.ui,
Expand Down Expand Up @@ -955,7 +952,7 @@ def selection_changed (self, selected=False):

def setup_main_window(self):
self.window = self.app = Gtk.Window()
self.window.set_icon_from_file(os.path.join(icondir, 'gourmet.png'))
self.window.set_icon(_load_pixbuf_from_resource('gourmet.svg'))
saver = WidgetSaver.WindowSaver(
self.window,
self.prefs.get('app_window', {'window_size': (800, 600)})
Expand Down
4 changes: 2 additions & 2 deletions src/gourmet/backends/DatabaseChooser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os.path
from gettext import gettext as _
from pkgutil import get_data as _get_data

from gi.repository import Gtk

Expand All @@ -20,9 +21,8 @@ def __init__ (self, okcb=lambda x: debug(x,0), modal=True):
self.default_file_directory = gglobals.gourmetdir
self.default_files = {'sqlite':'recipes.db'
}
uifile = os.path.join(gglobals.uibase,'databaseChooser.ui')
self.ui = Gtk.Builder()
self.ui.add_from_file(uifile)
self.ui.add_from_string(_get_data('gourmet', 'ui/databaseChooser.ui').decode())
self.connection_widgets = ['hostEntry','userEntry','pwEntry','dbEntry',
'hostLabel','userLabel','pwLabel','dbLabel',
'pwCheckButton']
Expand Down
4 changes: 2 additions & 2 deletions src/gourmet/batchEditor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from pkgutil import get_data as _get_data

from gi.repository import Gtk

Expand All @@ -14,7 +14,7 @@ def __init__ (self, rg):

def setup_ui (self):
self.ui = Gtk.Builder()
self.ui.add_from_file(os.path.join(gglobals.uibase,'batchEditor.ui'))
self.ui.add_from_string(_get_data('gourmet', 'ui/batchEditor.ui').decode())
self.dialog = self.ui.get_object('batchEditorDialog')
self.setFieldWhereBlankButton = self.ui.get_object('setFieldWhereBlankButton')
self.setup_boxes()
Expand Down
Loading

0 comments on commit c884791

Please sign in to comment.