Problems with GTK+ .99.8 and Imlib 1.1
- From: Derek Simkowiak <dereks animal blarg net>
- To: gtk-list redhat com
- cc: gnome-components-list gnome org
- Subject: Problems with GTK+ .99.8 and Imlib 1.1
- Date: Mon, 23 Mar 1998 15:51:29 -0800 (PST)
Hello,
First, a quick note before I forget: doing a "make install" with
GTK+ .99.8 did not copy the file glibconfig.h into /usr/local/include/, I
had to do it myself. I just thought that was weird.
Anyhow, on to the real problem(s): I am trying to learn GTK+ and
Imlib, so I wrote the attached imageviewer program (it's crappy, but it's
only meant for me as a learning tool, and not for general use). I can
get it to compile, but I have the following problem:
Imlib loads the image just fine, but about 50% of the time that
I run the program it displays a blank, grey window instead of the JPG (or
GIF, or whatever) I loaded. It seems almost random in when it works and
when it doesn't.
This is probably some sort of buffer problem (I feel like a newbie
trying to figure out getc() ) but I'd really like to understand what's
going on.
The second issue may be a bug in .99.8, because it works just fine
when compiled using .99.5. Clicking the "close" button from my window
manager no longer exits the program, I have to kill it. It worked just
fine in .99.5. See the code below for details (I think I'm catching all
the right signals...).
Anyhow, I think GNOME (with GTK) is the greatest thing since
sliced bread, and I really want to understand what I'm doing wrong.
Please take a minute to compile this program, reproduce the errors, and
look at the code (because there might be a problem with GTK or Imlib,
although it's probably just a crappy programming job on my part).
Thank You,
Derek Simkowiak
dereks@blarg.net
play.c is attached as MIME, and also listed below for quick viewing:
--------------------------------------------------------------------
#include <gtk/gtk.h>
#include <gdk_imlib.h>
/* When the button is pushed, a file selection box appears, gets the
desired filename, and then that particular file is displayed by
Imlib. */
void
file_selection_ok (GtkWidget *w,
GtkFileSelection *fs)
{
GdkPixmap *pixmap /*, *mask*/; /* I'm just ignoring the mask for now */
GdkImlibImage *image;
gint width, height;
GtkWidget *event_box; /* an event window for the pixmap */
GtkWidget *window; /* a window widget for the event_box */
GtkWidget *gtk_pixmap; /* our gtk-level pixmap */
g_print ("%s was selected, attempting to load...\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)));
/* The image loading seems to go successfully */
image = gdk_imlib_load_image(gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)));
width = image->rgb_width; height = image -> rgb_height;
gdk_imlib_render(image, width, height);
pixmap = gdk_imlib_move_image(image);
event_box = gtk_event_box_new();
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
/* I'm just ignoring the Mask for now. */
gtk_pixmap = gtk_pixmap_new(pixmap, NULL);
gtk_window_set_title (GTK_WINDOW (window), "Here's your damned file:");
gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT(window));
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT(window));
gtk_container_add (GTK_CONTAINER(event_box), gtk_pixmap);
gtk_container_add (GTK_CONTAINER(window), event_box);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (event_box);
/* I don't know what "gtk_widget_realize" does, but I thought
I'd see if it would fix the problem. It doesn't. */
gtk_widget_realize (gtk_pixmap);
gtk_widget_realize (event_box);
gtk_widget_realize (window);
/* Now show our image */
gtk_widget_show(window);
/* This just deletes the file selection window */
gtk_widget_destroy (GTK_WIDGET (fs));
}
void button_pushed(GtkWidget *widget)
{
GtkWidget *filew; /* this is our new File Selection widget that
gets created when we click the button */
filew = gtk_file_selection_new ("Select a freakin' file");
gtk_signal_connect (GTK_OBJECT (filew), "destroy",
(GtkSignalFunc) gtk_widget_destroy, &filew);
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button),
"clicked", (GtkSignalFunc) gtk_widget_destroy,
GTK_OBJECT (filew));
/* set a cool default filename */
gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew),
"penguin.png");
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),
"clicked", GTK_SIGNAL_FUNC (file_selection_ok), GTK_FILE_SELECTION(filew) );
gtk_widget_show(filew);
}
gint delete_event (GtkWidget *widget)
{
return TRUE;
}
int main(int argc, char *argv[])
{
GtkWidget *window; /* Our main application window */
GtkWidget *button; /* the only widget in the whole main window */
GtkWidget *box; /* Not really necessary, just used it anyway */
gtk_init(&argc, &argv);
/* Imlib initialization fxns */
gdk_imlib_init();
gtk_widget_push_visual(gdk_imlib_get_visual());
gtk_widget_push_colormap(gdk_imlib_get_colormap());
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
/* These next two lines quit working when I went from GTK+.99.5 to .99.8,
and I don't know why. Anyone have any ideas? */
gtk_signal_connect(GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL);
gtk_signal_connect(GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
box = gtk_vbox_new(FALSE,0); /* again, not really necessary */
gtk_container_add(GTK_CONTAINER(window), box);
gtk_container_border_width(GTK_CONTAINER(window), 5);
button = gtk_button_new_with_label("Open File");
gtk_signal_connect(GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC(button_pushed), NULL);
/* Now we PACK the button into the box */
gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
gtk_widget_show(button);
gtk_widget_show(box);
gtk_widget_show(window);
gtk_main();
return 0;
}
#include <gtk/gtk.h>
#include <gdk_imlib.h>
/* When the button is pushed, a file selection box appears, gets the
desired filename, and then that particular file is displayed by
Imlib. */
void
file_selection_ok (GtkWidget *w,
GtkFileSelection *fs)
{
GdkPixmap *pixmap /*, *mask*/; /* I'm just ignoring the mask for now */
GdkImlibImage *image;
gint width, height;
GtkWidget *event_box; /* an event window for the pixmap */
GtkWidget *window; /* a window widget for the event_box */
GtkWidget *gtk_pixmap; /* our gtk-level pixmap */
g_print ("%s was selected, attempting to load...\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)));
/* The image loading seems to go successfully */
image = gdk_imlib_load_image(gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)));
width = image->rgb_width; height = image -> rgb_height;
gdk_imlib_render(image, width, height);
pixmap = gdk_imlib_move_image(image);
event_box = gtk_event_box_new();
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
/* I'm just ignoring the Mask for now. */
gtk_pixmap = gtk_pixmap_new(pixmap, NULL);
gtk_window_set_title (GTK_WINDOW (window), "Here's your damned file:");
gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT(window));
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT(window));
gtk_container_add (GTK_CONTAINER(event_box), gtk_pixmap);
gtk_container_add (GTK_CONTAINER(window), event_box);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (event_box);
/* I don't know what "gtk_widget_realize" does, but I thought
I'd see if it would fix the problem. It doesn't. */
gtk_widget_realize (gtk_pixmap);
gtk_widget_realize (event_box);
gtk_widget_realize (window);
/* Now show our image */
gtk_widget_show(window);
/* This just deletes the file selection window */
gtk_widget_destroy (GTK_WIDGET (fs));
}
void button_pushed(GtkWidget *widget)
{
GtkWidget *filew; /* this is our new File Selection widget that
gets created when we click the button */
filew = gtk_file_selection_new ("Select a freakin' file");
gtk_signal_connect (GTK_OBJECT (filew), "destroy",
(GtkSignalFunc) gtk_widget_destroy, &filew);
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button),
"clicked", (GtkSignalFunc) gtk_widget_destroy,
GTK_OBJECT (filew));
/* set a cool default filename */
gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew),
"penguin.png");
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),
"clicked", GTK_SIGNAL_FUNC (file_selection_ok), GTK_FILE_SELECTION(filew) );
gtk_widget_show(filew);
}
gint delete_event (GtkWidget *widget)
{
return TRUE;
}
int main(int argc, char *argv[])
{
GtkWidget *window; /* Our main application window */
GtkWidget *button; /* the only widget in the whole main window */
GtkWidget *box; /* Not really necessary, just used it anyway */
gtk_init(&argc, &argv);
/* Imlib initialization fxns */
gdk_imlib_init();
gtk_widget_push_visual(gdk_imlib_get_visual());
gtk_widget_push_colormap(gdk_imlib_get_colormap());
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
/* These next two lines quit working when I went from GTK+.99.5 to .99.8,
and I don't know why. Anyone have any ideas? */
gtk_signal_connect(GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL);
gtk_signal_connect(GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
box = gtk_vbox_new(FALSE,0); /* again, not really necessary */
gtk_container_add(GTK_CONTAINER(window), box);
gtk_container_border_width(GTK_CONTAINER(window), 5);
button = gtk_button_new_with_label("Open File");
gtk_signal_connect(GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC(button_pushed), NULL);
/* Now we PACK the button into the box */
gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
gtk_widget_show(button);
gtk_widget_show(box);
gtk_widget_show(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]