Hello all,
I'm trying to cross-compile GTK+ for Windows on Linux (Debian) using MXE (http:/mxe.cc/). My goal is to produce a statically linked executable that just runs without having to install anything else (libraries, themes, etc.). I saw that in a previous thread someone said that GTK+ can't be statically linked, but that isn't true, it actually works fine (at least on Windows).
There is only one thing that doesn't work: the icons that are part of the standard interface (for example, the "+" and "-" that appear on the buttons of a GtkSpinButton) aren't displayed. When I run it, the program prints a warning saying that it can't find the "hicolor" theme, and all icons are replaced by a "missing icon" symbol.
I suppose that if I installed the theme on the target system, it would work (although I'm not sure in which directories GTK+ looks for it). But as I wrote above, I want the icons to be embedded in the executable, so that one can just download the file and run it. That is definitely possible with GTK+ 2, I compiled several programs and they all work without issues. But I haven't been able to make it work with GTK+ 3, so I'm asking for your help.
The problem is demonstrated by the attached screenshots:
- a window containing a GtkSpinButton (spinbutton-gtk3.png)
- a window containing a GtkToolbar with two buttons (toolbar-gtk3.png)
- the latter program rewritten for GTK+ 2 (toolbar-gtk2.png). As you can see, here the icons are displayed correctly.
I'm also attaching the source code of those examples.
I've tried to dig into the GTK+ sources to find where the icons are generated, but got lost. I found that there's a program called gtk-update-icon-cache that I guess might have to do with that, but I didn't understand how it's supposed to be used and where it's called during the build process (if it's called at all).
To reproduce what I did, go to http:/mxe.cc/ and follow the instructions. The GTK+ 3 library is configured with the following options (specified in the src/gtk3.mk file in the MXE source tree):
--disable-glibtest --disable-cups --disable-test-print-backend --disable-gtk-doc --disable-man --with-included-immodules --enable-win32-backend
MXE also applies a few patches to the GTK+ sources (file src/gtk3-1-fixes.patch).
Thank you in advance for any help that you can provide.
Gerardo
Attachment:
spinbutton-gtk3.png
Description: PNG image
Attachment:
toolbar-gtk3.png
Description: PNG image
Attachment:
toolbar-gtk2.png
Description: PNG image
#include <gtk/gtk.h> void activate(GtkApplication *app, gpointer user_data) { GtkWidget *window, *spinbutton; GtkAdjustment *adjustment; window = gtk_application_window_new(app); adjustment = gtk_adjustment_new(5, 0, 10, 1, 1, 0); spinbutton = gtk_spin_button_new(adjustment, 1, 0); gtk_container_add(GTK_CONTAINER(window), spinbutton); gtk_widget_show_all(window); } int main(int argc, char *argv[]) { GtkApplication *app; int status; app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE); g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); status = g_application_run(G_APPLICATION(app), argc, argv); g_object_unref(app); return status; }
#include <gtk/gtk.h> void print_hello(GtkWidget *widget, gpointer data) { g_print("Hello World\n"); } void activate(GtkApplication *app, gpointer user_data) { GtkWidget *window, *box, *toolbar; GtkWidget *icon_new, *icon_quit; GtkToolItem *tool_new, *tool_quit; window = gtk_application_window_new(app); gtk_window_set_default_size(GTK_WINDOW(window), 200, 200); box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_container_add(GTK_CONTAINER(window), box); toolbar = gtk_toolbar_new(); gtk_box_pack_start(GTK_BOX(box), toolbar, FALSE, FALSE, 0); icon_new = gtk_image_new_from_icon_name("document-new", GTK_ICON_SIZE_LARGE_TOOLBAR); tool_new = gtk_tool_button_new(icon_new, NULL); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_new, -1); g_signal_connect(tool_new, "clicked", G_CALLBACK(print_hello), NULL); icon_quit = gtk_image_new_from_icon_name("application-exit", GTK_ICON_SIZE_LARGE_TOOLBAR); tool_quit = gtk_tool_button_new(icon_quit, NULL); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_quit, -1); g_signal_connect_swapped(tool_quit, "clicked", G_CALLBACK(gtk_widget_destroy), window); gtk_widget_show_all(window); } int main(int argc, char *argv[]) { GtkApplication *app; int status; app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE); g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); status = g_application_run(G_APPLICATION(app), argc, argv); g_object_unref(app); return status; }
#include <gtk/gtk.h> void print_hello(GtkWidget *widget, gpointer data) { g_print("Hello World\n"); } int main(int argc, char *argv[]) { GtkWidget *window, *vbox, *toolbar; GtkToolItem *tool_new, *tool_quit; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), 200, 200); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); toolbar = gtk_toolbar_new(); gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); tool_new = gtk_tool_button_new_from_stock(GTK_STOCK_NEW); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_new, -1); g_signal_connect(tool_new, "clicked", G_CALLBACK(print_hello), NULL); tool_quit = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_quit, -1); g_signal_connect_swapped(tool_quit, "clicked", G_CALLBACK(gtk_widget_destroy), window); gtk_widget_show_all(window); gtk_main(); return 0; }
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx https://mail.gnome.org/mailman/listinfo/gtk-list