How do I change the icon of my Shoes App?

与世无争的帅哥 提交于 2019-12-21 18:06:21

问题


I was wondering if it was possible to change the my Shoes app's icon? I imagine its style-oriented, but I haven't been able to find anything on it.

Is this possible?


回答1:


I don't believe this is possible from within Shoes. This is based on extensive searching, both online and in the source code.

However, there are a couple things external to Shoes that work. One is to simply change the file #{DIR}/static/shoes-icon.png, which is where the runtime pulls its icon from. The other is to change the hardcoded value in the file libshoes.so (or your OS's equivalent); you could use a hex editor, or any other editor that wouldn't mess the file up. Note that for the hardcoded editing to work without crashing, you have to replace the hardcoded string with something of the same length.




回答2:


You can do it in Green Shoes, but you have to go under the hood a bit. Here's some very simple code I wrote for SciRuby:

class Shoes
  class App
    def icon filename=nil
      filename.nil? ? win.icon : win.icon = filename
    end

    class << self
      def default_icon= filename
        Gtk::Window.set_default_icon(filename)
      end
    end
  end
end

The second method is optional; you can use it to set the icon for your whole app, I think. The first method sets the icon for the current window, and you would use it like so:

DIR = Pathname.new(__FILE__).realpath.dirname.to_s
ICON_PATH = File.join(DIR, '..', 'static', 'my-icon.png')

# ...

Shoes.app :title => "My App" do
  icon ICON_PATH
end

And for the default:

Shoes::App.default_icon = ICON_PATH

I use a 128x128 png file. I tried a 500x500 one and it didn't work properly. In the code above, ICON_PATH, from the root of your project directory, should be ./static/my-icon.png.

You may also need to require "gtk2" somewhere for the default_icon= method.




回答3:


Use IcoFx. _why himself suggested this utility on the mailing list. You will find the instruction in the tutorial section of the icoFX website.




回答4:


So far, I am not sure that this is actually possible. in OS X, I was able to modify the package contents to change what the plist is pointing to in terms of icons. However, when the application runs, it uses the Shoes' runtime icon.

I have no clue how you'd do this on Windows.



来源:https://stackoverflow.com/questions/426965/how-do-i-change-the-icon-of-my-shoes-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!