Icon / mime association..
Kustaa Nyholm
feedback2 at sparetimelabs.com
Tue Oct 17 20:27:47 EEST 2006
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?
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?
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.
Thanks again for putting up with me!
cheers Kusti
More information about the xdg
mailing list