Icon / mime association..
Magnus Bergman
magnus.bergman at observer.net
Wed Oct 18 12:07:27 EEST 2006
On Tue, 17 Oct 2006 20:27:47 +0300
Kustaa Nyholm <feedback2 at sparetimelabs.com> wrote:
> Magnus Bergman wrote:
> >
> > Using GTK+ it can look something like this:
> >
> > #include <gtk/gtk.h>
> >
> > int main(int argc,char** argv){
> > GtkWidget* window;
> > GtkIconTheme* theme;
> > GdkPixbuf* icon;
> >
> > gtk_init(&argc,&argv);
> >
> > window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> > g_signal_connect(window,"destroy",gtk_main_quit,NULL);
> >
> > theme = gtk_icon_theme_get_default();
> > icon = gtk_icon_theme_load_icon(theme,"my_application",48,0,NULL);
> > if(icon){
> > gtk_window_set_icon(GTK_WINDOW(window),icon);
> > g_object_unref(icon);
> > }
> >
> > gtk_widget_show(window);
> > gtk_main();
> > }
> >
> > Note that gtk_icon_theme_get_default() means "get the theme from the
> > default display", and not get the default theme (hicolor). If you
> > use some other toolkit there probably some function similar to
> > gtk_theme_load_icon(). If not, there is some pseudo code [1] in the
> > icon theme spec you can use.
> >
>
> Ok, now I understand what you meant when you said "modify your
> application". However, I'm still not following, call me slow, but are
> we talking about the same thing here?
>
> My application is Java, though I read/write C fluently. Not familiar
> with GTK+ but I take it the code sample you provided gets the icon
> from the theme and sets the icon for the *WINDOW* that the
> application is opening up. Correct?
Correct.
> Assuming that's what it does, my problem is different:
>
> I have a file called 'jDraft-Linux' which is the application
> executable file. This file on Gnome / KDE desktop shows up as an
> executable text/shell script, with the default icon for such files.
> Not suprisingly, as it is indeed a 'sh' script with the Java jar file
> embedded in it. Now my question is can I change the icon for *that*
> file and if possible, how to do that programmatically?
Ah, it was me who misunderstood. No, it's not possible. This is the
problem that the desktop-files are used to solve basically.
> I've create a jDraft.desktop file which specifies the icon and indeed
> the jDraft.deskop file shows the correct icon I specified, however,
> the actual executable file jDraft-Linux does not.
The idea is that the users are not exposed to the executable files,
only to the desktop files.
> Thanks again for putting up with me!
>
> cheers Kusti
More information about the xdg
mailing list