From 4eff488d044da0dcbd126efdf1881445797cd4ae Mon Sep 17 00:00:00 2001 From: glasseyes Date: Thu, 30 Aug 2018 13:18:56 +0700 Subject: [PATCH] move images to icons dir and be able to locate them it local non-installed dir --- linux/keyman-config/MANIFEST.in | 2 +- .../{ => keyman/icons}/cross20.png | Bin .../{ => keyman/icons}/defaultpackage.gif | Bin .../{ => keyman/icons}/expand20.png | Bin .../{ => keyman/icons}/help20.png | Bin .../{ => keyman/icons}/icon_kmp.png | Bin linux/keyman-config/keyman/install_window.py | 9 ++++- linux/keyman-config/keyman/view_installed.py | 33 ++++++++++++++++-- linux/keyman-config/setup.py | 12 ++----- 9 files changed, 42 insertions(+), 14 deletions(-) rename linux/keyman-config/{ => keyman/icons}/cross20.png (100%) rename linux/keyman-config/{ => keyman/icons}/defaultpackage.gif (100%) rename linux/keyman-config/{ => keyman/icons}/expand20.png (100%) rename linux/keyman-config/{ => keyman/icons}/help20.png (100%) rename linux/keyman-config/{ => keyman/icons}/icon_kmp.png (100%) diff --git a/linux/keyman-config/MANIFEST.in b/linux/keyman-config/MANIFEST.in index 804d5c14ed..c9212752cd 100644 --- a/linux/keyman-config/MANIFEST.in +++ b/linux/keyman-config/MANIFEST.in @@ -1 +1 @@ -include *.gif *.png +recursive-include keyman/icons * diff --git a/linux/keyman-config/cross20.png b/linux/keyman-config/keyman/icons/cross20.png similarity index 100% rename from linux/keyman-config/cross20.png rename to linux/keyman-config/keyman/icons/cross20.png diff --git a/linux/keyman-config/defaultpackage.gif b/linux/keyman-config/keyman/icons/defaultpackage.gif similarity index 100% rename from linux/keyman-config/defaultpackage.gif rename to linux/keyman-config/keyman/icons/defaultpackage.gif diff --git a/linux/keyman-config/expand20.png b/linux/keyman-config/keyman/icons/expand20.png similarity index 100% rename from linux/keyman-config/expand20.png rename to linux/keyman-config/keyman/icons/expand20.png diff --git a/linux/keyman-config/help20.png b/linux/keyman-config/keyman/icons/help20.png similarity index 100% rename from linux/keyman-config/help20.png rename to linux/keyman-config/keyman/icons/help20.png diff --git a/linux/keyman-config/icon_kmp.png b/linux/keyman-config/keyman/icons/icon_kmp.png similarity index 100% rename from linux/keyman-config/icon_kmp.png rename to linux/keyman-config/keyman/icons/icon_kmp.png diff --git a/linux/keyman-config/keyman/install_window.py b/linux/keyman-config/keyman/install_window.py index 5daeccb0f4..8798dc9e79 100755 --- a/linux/keyman-config/keyman/install_window.py +++ b/linux/keyman-config/keyman/install_window.py @@ -93,7 +93,14 @@ class InstallKmpWindow(Gtk.Window): if options and "graphicFile" in options: image.set_from_file(os.path.join(tmpdirname, options['graphicFile'])) else: - image.set_from_file("defaultpackage.gif") + img_default = "/usr/share/keyman/icons/defaultpackage.gif" + if not os.path.isfile(img_default): + img_default = "keyman/icons/defaultpackage.gif" + if not os.path.isfile(img_default): + img_default = "defaultpackage.gif" + if not os.path.isfile(img_default): + img_default = "icons/defaultpackage.gif" + image.set_from_file(img_default) mainhbox.pack_start(image, False, False, 0) diff --git a/linux/keyman-config/keyman/view_installed.py b/linux/keyman-config/keyman/view_installed.py index f44b6e215c..2091c3c6cf 100755 --- a/linux/keyman-config/keyman/view_installed.py +++ b/linux/keyman-config/keyman/view_installed.py @@ -22,8 +22,14 @@ class KeyboardBox(Gtk.Box): #print(kmp) self.kmp = kmp icofile = os.path.join("/usr/local/share/keyman", self.kmp["id"], self.kmp["id"] + ".ico.bmp") + if not os.path.isfile(icofile): + icofile = "/usr/share/keyman/icons/icon_kmp.png" + if not os.path.isfile(icofile): + icofile = "keyman/icons/icon_kmp.png" if not os.path.isfile(icofile): icofile = "icon_kmp.png" + if not os.path.isfile(icofile): + icofile = "icons/icon_kmp.png" self.image = Gtk.Image.new_from_file(icofile) #image.set_from_pixbuf(pics[0]) #grid.add(image) @@ -36,16 +42,30 @@ class KeyboardBox(Gtk.Box): #grid.attach_next_to(label1, image, Gtk.PositionType.RIGHT, 1, 1) self.pack_start(self.label1, False, False, 10) + img_expand = "/usr/share/keyman/icons/expand20.png" + if not os.path.isfile(img_expand): + img_expand = "keyman/icons/expand20.png" + if not os.path.isfile(img_expand): + img_expand = "expand20.png" + if not os.path.isfile(img_expand): + img_expand = "icons/expand20.png" self.expandbutton = Gtk.Button() - self.expandimage = Gtk.Image.new_from_file("expand20.png") + self.expandimage = Gtk.Image.new_from_file(img_expand) self.expandbutton.set_image(self.expandimage) self.expandbutton.set_tooltip_text("More information about " + kmp["name"]) #grid.attach_next_to(expandbutton, helpbutton, Gtk.PositionType.RIGHT, 1, 1) self.expandbutton.connect("clicked", self.on_expand_clicked) self.pack_end(self.expandbutton, False, False, 0) + img_cross = "/usr/share/keyman/icons/cross20.png" + if not os.path.isfile(img_cross): + img_cross = "keyman/icons/cross20.png" + if not os.path.isfile(img_cross): + img_cross = "cross20.png" + if not os.path.isfile(img_cross): + img_cross = "icons/cross20.png" self.uninstallbutton = Gtk.Button() - self.uninstallimage = Gtk.Image.new_from_file("cross20.png") + self.uninstallimage = Gtk.Image.new_from_file(img_cross) self.uninstallbutton.set_image(self.uninstallimage) self.uninstallbutton.set_tooltip_text("Uninstall " + kmp["name"] + " (" + kmp["id"] + ")") #grid.attach_next_to(uninstallbutton, expandbutton, Gtk.PositionType.RIGHT, 1, 1) @@ -54,8 +74,15 @@ class KeyboardBox(Gtk.Box): welcome_file = os.path.join("/usr/local/share/doc/keyman", self.kmp["id"], "welcome.htm") if os.path.isfile(welcome_file): + img_help = "/usr/share/keyman/icons/help20.png" + if not os.path.isfile(img_help): + img_help = "keyman/icons/help20.png" + if not os.path.isfile(img_help): + img_help = "help20.png" + if not os.path.isfile(img_help): + img_help = "icons/help20.png" self.helpbutton = Gtk.Button() - self.helpimage = Gtk.Image.new_from_file("help20.png") + self.helpimage = Gtk.Image.new_from_file(img_help) self.helpbutton.set_image(self.helpimage) self.helpbutton.set_tooltip_text("Help for " + kmp["name"]) #grid.attach_next_to(helpbutton, label1, Gtk.PositionType.RIGHT, 1, 1) diff --git a/linux/keyman-config/setup.py b/linux/keyman-config/setup.py index 0c4df92c17..02d96ad96f 100644 --- a/linux/keyman-config/setup.py +++ b/linux/keyman-config/setup.py @@ -9,9 +9,6 @@ setup( 'install_kmp', 'kvk2ldml', 'uninstall_kmp', 'list_installed_kmp', ], - package_data={ - '': ['*.png', '*.gif'], - }, install_requires=[ 'lxml', 'gi', 'numpy', 'PIL', 'requests', 'requests_cached', @@ -28,9 +25,6 @@ setup( project_urls={ "Bug Tracker": "https://github.com/keymanapp/issues", "Source Code": "https://github.com/keymanapp/keyman/linux/tree/master/linux/keyman-config", - } -) - -#accelerators.py downloadkeyboard.py install_window.py kvk2ldml.py uninstall_kmp.py -#check_mime_type.py get_kmp.py keyboard_details.py list_installed_kmp.py view_installed.py -#convertico.py install_kmp.py kmpmetadata.py setup.py welcome.py + }, + include_package_data=True, +) \ No newline at end of file