LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   GTK GtkImage Widget (https://www.linuxquestions.org/questions/programming-9/gtk-gtkimage-widget-182066/)

Rajahuroman 05-16-2004 11:19 AM

GTK GtkImage Widget
 
I used Glade to design an interface and there I selected a GtkImage widget. also loaded an image there, using Glade. But when the program starts there is no image seen. Why? Must I load it at runtime as well as at design time? The tutorial at www.gnome.org isn't explicit enough. I tried using gtk_image_set_from_file() but it still doesn't load. I placed it in the on_window1_activate_default signal.

And another thing:
Can you tell me some website where I can find all the signals and their time of response, a description of all GTK+ signals?

santhosh.linux 01-12-2006 02:44 AM

Same problem also faced by me there is one good and temparary solutions for it.
In main.c file there is one line add_pixdirectory some thing..If u pass desire directory there then u will get images..

or it will search for default dir of /usr/share/pixmaps------something like this
If u read Makefile then u can get that information
ok

Rajahuroman 02-03-2006 08:28 AM

Tank you, as soon as i'll get home, i'll try it. After almost 2 years I almost forgot I asked this question but I still couldn't find an answer. All of my GTK projects suffered from this little bug. Many, many thanks. If you ever come to Romania there's a beer for you in my account :)

jfilse 03-13-2006 05:30 PM

GtkImage - glade
 
Hi, I'm fairly new with Glade 2.10.0, have taken it through some paces, delighted. Am still having problems getting any image to come up with GtkImage:scratch: I've tried making sure that a .jpg is available in the /myproject/pixmap directory, even tried .xpm and .png no good.
I tried working around it and simply having a GtkImage and setting the icon to a .jpg file, no go too (at least in that case the terminal window gave the file not found message.
In all cases there seems to be a problem finding it.
santhosh, I read your response of 11/05 but couldn't locate anything similar in main.c
Anyone else had this problem? suggestions? I've spent probably three days in the tutorials and manuals but the solution won't come to me.
thanks,
John

MicahCarrick 03-13-2006 10:03 PM

How are you loading the file... gdk_pixbuf_new_from_file()?

jfilse 03-14-2006 01:16 AM

the window I want it to be in is named image1 as a GtkImage by Glade.
I have a separate button with a callback funcion which includes only this (hoping it will load and refresh image1)

GtkImage *image1;
gtk_image_set_from_file (image1,"mypic.jpg");
gtk_widget_show(image1);

I get error:

assertion GTK_IS_IMAGE(image) failed

thanks, John

MicahCarrick 03-14-2006 01:38 PM

Code:

GtkImage *image1;
gtk_image_set_from_file (image1,"mypic.jpg");
gtk_widget_show(image1);

You have the image declared but not assigned. Assuming gxml has already been referenced something like:

Code:

gxml = glade_xml_new ("whatever.glade", NULL, NULL);
You can then access your "image1" assuming that's what it's named in the glade file:

Code:

GtkWidget *image1;
image1 = glade_xml_get_widget (gxml, "image1");
gtk_image_set_from_file (GTK_IMAGE(image1),"mypic.jpg");

You can then show the parent window which will also show the image. Note however, that you can't do much errorchecking with gtk_image_set_from_file(), gdk_pixbuf* may be a better way to go if you need to perform checks.

If you're still having problems, post more of you code so we can see what you're doing with your glade file.

jfilse 03-14-2006 06:16 PM

Micah, thanks for your help.
Your reference to
gxml = glade_xml_new("whatever.glade"NULL,NULL);
has me a bit confused and curious. I just went back and searched high and low, in main,interface,support,callbacks and makefile and couldn't find any reference to anyting xml except a reference in Makefile to dependency on various flavors of libxml. I've never seen reference to it in any turorials or glade docs although I assumed it was involved somehow waaay in the background. NO, PLEASE don't tell me I need to learn another language ;)
A thought I had this afternoon while finally out walking was that I set up glade to run on C not C++ would this have any effect on what I am trying to do?
John

MicahCarrick 03-14-2006 06:56 PM

I appoligize... I though you were using libglade which is different than glade generating the C code. My bad. In any case, you still don't have image1 pointing to anything. Can you post your main.c file?

The code:
Code:

GtkImage *image1;
gtk_image_set_from_file (image1,"mypic.jpg");
gtk_widget_show(image1);

Does not make sense as it is because although image1 is declared as a poitner to a GtkImage, it has not been assigned to a GtkImage. You say you have an image in glade, so when glade generated the C code there may be reference to it-- but you may also have to look it up. I'm not sure as I typically use libglade.

Alternately, you could use gtk_image_new_from_file instead, however, then you're not using the GtkImage you defined in the glade file but are instead creating a new one.

Again, post your main.c and we'll let you know.

- Micah


All times are GMT -5. The time now is 03:32 AM.