Where GTK finds icon names to use with gtk_image_new_from_icon_name()? - gtk

GTK can construct images by name of the "icon from current icon theme". For example:
#!/usr/bin/env python
import gtk; wnd=gtk.Window(); img=gtk.Image();
img.set_from_icon_name( "go-jump", gtk.ICON_SIZE_BUTTON );
wnd.add( img ); img.show(); wnd.show(); gtk.main()
This will display a window with a pretty arrow inside it. But - only on ubuntu. On Windows or OSX it will display window with a "no image" icon inside :(. So my questions is - where GTK keeps icon names like "go-jump"? Is it some list or specification available like for stock icons? Maybe it's some GTK API i can use to list such icons?

The names are in the Icon Naming Specification. If this doesn't work on Windows or OSX, then report it as a bug - GTK needs at least one icon theme installed in order to work properly.

Better late than never !
Here are two little Python scripts showing all existing icons sorted by their name:
http://dl.0xdeadc0de.fr/misc/gtkiconview_freedesktop.py for those in the Icon Naming Specification.
http://dl.0xdeadc0de.fr/misc/gtkiconview_local.py for those included in packages such as 'gnome-icon-theme-symbolic'.

Developing on Debian but wanting cross-platform support, I've recently installed gtkmm and co on both Windows and OS X, via MSYS2 and Homebrew respectively. As an aside, gtkmm, MSYS2, and Homebrew are excellent projects and well worth a look (I have no affiliation blah blah).
In that time, I think I've gained a decent understanding of why this happens and how to 'fix' it.
Why
This is not a bug in GTK+, as the accepted answer suggests. It's a fact of life when using a library tailored to Linux on another platform, via an environment that creates a Linux-like picture.
On Linux, you have a single environment with a standardised filesystem - via the FHS and FreeDesktop specs - with icons always in /usr/share/icons.
In contrast, on other platforms, you install Linux-like environments for compilation and sometimes runtime, each with its own virtual filesystem - which is difficult to track by other programs, without doing dangerous things to the end-user's PATH, especially if you're trying multiple such environments... You get the idea. The end result is that your program, by default, doesn't necessary have any awareness of where your environment's virtual root resides.
How
The solution, I've found, is to copy all required resources to the same folder as your executable - i.e. the directory you'll eventually redistribute, or if you're writing OSS, do this in your makefile or such. This is because, as far as I can tell, a program - looking for GTK+ resources, DLLs, etc. - checks its own directory before the (probably not helpful) PATH. A little opposite to how shells do things, but handy!
So, you copy the relevant icon themes, as installed by your package manager, into a new folder within said directory. At a minimum, do this for the standard theme: copy it to $YOURDIR/share/icons/Adwaita. Then restart your program. If you're anything like me, now all the icons work perfectly.
The same applies for pretty much any other resource that you need to redistribute with your application.
Notably, I'd suggest doing the same thing with all DLLs needed by your binary. These may or may not work for you out-of-the-box and depending on how you invoke your binary - but you really can't afford to speculate about whether your end-users already have the right set of DLLs installed somewhere in their PATH, of the right version compiled by the right compiler.

Related

What are the prerequisite subjects related to program installers?

I never needed to add an installer to my programs but I always wondered about Microsoft Installer (.msi or .exe installers). What tasks do they do?
They make the life easier for the user, but that's not all to it. I know they also deal with the Operating System in several aspects.
But before learning about installers themselves. I feel there's a gap on my knowledge on some prerequisite subjects related to this.
So, which subjects would they be? And where can I learn them? (Books, articles, videos, courses, ...)
And to be clear I'm not asking about how to create an installer (I can do it with Visual Studio or tools like Install Shield). But I'm more concerned about the prerequisite subjects I need to learn to proper understand and handle installers. Specially in what areas do they deal with the Operating System?
Installers are nothing special. They give this impression because they do a bunch of weird things that don't seem accessible to other apps. The .msi and .exe installers will self extract (take a portion of the file itself and copy it to another file) or they will download other files from a server. The .exe and .msi files are thus normal executables that the OS recognizes due to their file extension as files that it should execute.
Each file extension has a default app to open them. When you open a file, its default app is started and the path to that file is passed as a string to the main function of the app. That way, the app can parse the file and show the content of it to you (similarly to compiling a program).
Other things like creating desktop icons are available with some dlls native to Windows and some other libraries that call in those dlls for higher level languages like C#. Quite simply, you create an average window like any other, you extract the app being installed from the same file to Program Files and you're good minus some other minor details. The apps available are really just to make your life easier.

Is there any text editor for Mac that can be configured to have, or already has, autocomplete for Lua?

I know TextWrangler shows the option, but it doesn't actually do anything. So what I want is autocomplete, either with a key combination, or while I type.
Syntax coloring/highlighting is a requirement as well, though I know Xcode and TextWrangler have that.
You might want to use Lua Development Tools for this purpose. It has syntax coloring, plus it is doing smart autocomplete, depending on what your actual context is (required modules, ...)
It is an Eclipse Technology project, and it is Open Source! (EPL license).
Project web page - http://www.eclipse.org/koneki/ldt
Installation via Eclipse Marketplace - http://marketplace.eclipse.org/content/lua-development-tools-koneki
I don't know if you have seen this page, but it seems a good place to start:
http://lua-users.org/wiki/LuaEditorSupport
If I search for "completion" I get:
Decoda (Win)
LuaEdit (Win)
DForD (Win)
NsEditor (Win)
Visual Studio + LuaLite
Eclipse + LuaEclipse or LunarEclipse (java)
I personally use Vim + SuperTab (which only auto-fills with things that you have previously written).
There's a nice plugin for IntelliJ IDEA for Lua. IntelliJ IDEA is really nice, though kind of biggish.
Aside of that there is also TextAdept which is a lot smaller, and 100% configurable in Lua.
And probably a bunch of others.
If you want full (semantic) autocompletion, you should try lua-inspect (source code), which can be installed in the SciTE editor, and also into ViM using vim-lua-inspect.
It uses Metalua to fully parse the source code into AST and then performs code analysis. Apart from simple keyword-based syntax highlighters, it can:
differentiate between local/global variables, parameters and unused variables
jump to the definition of a variable/function
autocomplete table members
correctly rename variables/functions (not only definitions but also uses)
Even though it is not yet stable, and tends to hang on large scripts, it is very usable for standard Lua programs, mainly for it's intelligent autocompletion and renaming.

The Science of Installation

I have minimal exposure to RPM, Windows installer mechanics, and WIX. That said, I'm interested in making a cross-platform installer tool (Linux, Windows) that supports upgrading and downgrading (versiona and patches) of my own product. I don't believe this is a topic to be approached lightly; I would like to learn the science of the art (or the art of the science). If I succeed, and build a minimally successful installer tool, it would have these features:
does not depend on a platform-specific tool (such as Windows Installer).
reads XML or a declarative syntax to fulfill installation requirements.
attempts to minimize steps to upgrade or downgrade one of my products (rather than requiring a complete uninstall and re-install).
does not require knowledge of interim product versions, in order to jump versions (i.e. can upgrade one of my products from version 1 to version 3, without passing through version 2).
I'm convinced that "the key" to achieving this goal is by seeing versions as a "point A to point B" problem, which implies that A and B are described by two XML "version" documents that hold info about all the parts and actions (files, or platform specifics such as registry entries). My installer tool would "join" or compare the two documents and determine a minimal set of changes to transform A into B. To some extent, I believe this is precisely what Windows Installer does.
Of course there are further complexities, but that is the point of this post. Where is "the bible" of information on this topic? Remember, I want to make my own installer - not use a platform-specific one. For those who care, my products are usually written in C++ or C#.
Or perhaps I should study something like Steam which is cross-platform and has "automated game updates" as part of its capabilities. In my case, the problem of online deployment is already handled. It is just the final installation step I'm examining. Does Steam use native installers (such as an MSI)? If yes, then that is not what I'm looking for.
In short, what path should I pursue to become somewhat competent on the science of this topic?
I'm not an expert and others can give you better answers but...
Don't declaratively list steps required to install your product - You'll end up making assumptions which will eventually prove wrong. Instead, you should be looking at defining the final state of the installation and let the installer worry about how to make that happen.
Another consideration is that being downgradable may involve huge complications depending on your product - Would it have to down-grade database schemas / file formats / ??? In short, every version of your app will need to be both fully forwards- and backwards-compatible (or at least fail gracefully). Also consider the scenario where V1 of your app stores settings in a file. V2 comes along and adds more settings. You downgrade to V1 - What should it do when changing settings? preserve the V2 settings? dump them? Do some of the V2 settings change the impact/meaning of the V1 settings? Are these decisions to be made by your app or your installer?
Anyway, all that aside, I'd say you need at the least:
A central server/farm with complete files for every version of your App and some API/Web Service which allows the installer to retrieve files/filesets/??? as appropriate (You may be able to tie this into a source control system like svn)
Some way of specifying the desired post-install state of the system in an environment-agnostic way (Think install paths - /usr/??? - should the map to C:\Users\??? or C:\Program Files on windows? Also don't forget it might be a 64-bit machine so it could be C:\Program Files (x86).
A very clever installer written for multiple platforms with as much code re-use as possible (Java, Mono, ???)
The installer should do (simply):
Determine the desired version of the product.
Download/read the appropriate manifest.
Compare the desired situation with the current situation (NB: What is currently on the local system, NOT what should be on the system according to the current version's manifest)
Generate a list of steps to reconcile the two, taking into account any dependencies (can't set file permissions before you copy the file). You can make use of checksums/hashing/similar to compare existing files with desired files - thus only downloading the files actually required.
Possibly take complete backups
Download/unpack required files.
Download/unpack 3rd party dependencies - Later .Net Framework Version/Similar
Perform install steps in atomic a manner as possible (at the very least keeping a record of steps taken so they can be undone)
Potentially apply any version-jump specific changes (up/down-grade db, config files, etc.)
verify installation as much as possible (checksums again)
None of this addresses the question of what to do when the installer itself needs upgrading.
A technique I've used on Windows is that the installer executable itself is little more than a wrapper with some interfaces which loads the actual installer dynamically at runtime - thus I can move files about/unload/reload assemblies, etc... from within a fixed process that almost never changes.
As I said above, I am definitely not an expert, just a novice who's done some of this myself. I sure you can get more complete answers from others but I hope this helped a little

Is Perl a good option for writing platform independent desktop applications?

Is Perl a good option for writing (possibly and partially) platform independent desktop applications? I know there are interesting widget libraries like GTK2 Perl and wxWidgets but I'm not familiar with development on Windows.
Is it possible to write a good application with Perl and those tools, maybe embedding everything needed to avoid asking the user to install external (and probably non conventional for many) libraries? Are there examples of this kind of apps around?
Sort of. You can certainly write Perl scripts that provide a Tk GUI that will work on any platform, and you can even package the libraries they need to work with PAR to put together an application that will run anywhere with an appropriate version of perl installed without requiring the end use to install a bunch of stuff from CPAN to get it to work.
However, an application that will run anywhere without requiring an existing perl installation (and it's probably not safe to assume the average Windows user will have perl) isn't really viable. One solution would be to distribute an "everywhere but Windows" version that simply uses PAR to include the necessary libraries, and a PAR::Packer-built version for Windows, which would be a fully-functional .exe including the perl interpreter and the libraries.
EDIT: following daotoad's response, it does appear that ActiveState's PerlApp can build cross-platform binaries for for Windows, Mac OS X, Linux, Solaris, and AIX; I haven't tried this but if it works as advertised it would seem to meet your requirements.
My employer uses ActiveState's PerlApp to produce executable versions of our apps with great success.
We tested PAR and PerlApp before selecting our packaging method. At that time, PerlApp had faster load times. Several versions of each tool have come and gone since then, so I would recommend testing with each before selecting a tool.
Executable packaging has been very effective for us.
There are a few portability issues issues with Perl, but if you pay attention to perlport, it's easy to avoid most issues. Our biggest problems are always with Win32. From time to time, some simple thing will require stupid, bizarre work-arounds or digging into Win32 API for a platform specific hack.
We have used both Wx and Tk guis.
Frozen Bubble is a well known and widely available app you can look at.
Check out PAR (available via CPAN) with respect to your bundling requirement.
Consider having a look at Padre for an example of a complex application written in perl using Wx.
So yes. All of your requirements are achievable, including portability.
I am working on the module XUL::Gui on CPAN, which uses Firefox to display cross platform gui apps from Perl. It is under development, but stable, and may be complete enough for your needs. You can build your gui in HTML and/or XUL (the Mozilla gui language that Firefox itself is written in), and then style everything with CSS. Let me know if you have any feature requests.

Do you put your development/runtime tools in the repository?

Putting development tools (compilers, IDEs, editors, ...) and runtime environments (jre, .net framework, interpreters, ...) under the version control has a couple of nice reasons. First, you can easily compile/run your program just by checking out your repository. You don't have to have anything else. Second, the triple is surely version compatible as you once tested it. However, it has its own drawbacks. The main one is the big volume of large binary files that must be put under version control system. That may cause the VCS slower and the backup process harder. What's your idea?
Tools and dependencies actually used to compile and build the project, absolutely - it is very useful if you ever have to debug an issue or develop a fix for an older version and you've moved on to newer versions that aren't quite compatible with the old ones.
IDE's & editors no - ideally you're project should be buildable from a script so these would not be necessary. The generated output should still be the same regardless of what you used to edit the source.
I include a text (and thus easily diff-able) file in every project root called "How-to-get-this-project-running" that includes any and all things necessary, including the correct .net version and service packs.
Also for proprietry IDE's (e.g. Visual Studio), there can be licensing issues as this makes it difficult to manage who is using which pieces of software.
Edit:
We also used to store batch files that automatically checked out the source code automatically (and all dependencies) in source control. Developers just check out the "Setup" folder and run the batch scripts, instead of having to search the repository for appropriate bits and pieces.
What I find is very nice and common (in .Net projects I have experience with anyway) is including any "non-default install" dependencies in a lib or dependencies folder with source control. The runtime is provided by the GAC and kind of assumed.
First, you can easily compile/run your program just by checking out your repository.
Not true: it often isn't enough to just get/copy/check out a tool, instead the tool must also be installed on the workstation.
Personally I've seen libraries and 3rd-party components in the source version control system, but not the tools.
I keep all dependencies in a folder under source control named "3rdParty". I agree that this is very convinient and you can just pull down the source and get going. This really shouldnt affect the performance of the source control.
The only real draw back is that the initial size to pull down can be fairly large. In my situation anyone who pulls downt he code usually will run it also, so it is ok. But if you expect many people to pull down the source just to read then this can be annoying.
I've seen this done in more than one place where I worked. In all cases, I've found it to be pretty convenient.