Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-16-2004, 11:19 AM
|
#1
|
|
Member
Registered: May 2004
Location: Romania; Arad
Distribution: Archlinux
Posts: 91
Rep:
|
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?
|
|
|
|
01-12-2006, 02:44 AM
|
#2
|
|
Member
Registered: Nov 2005
Location: India
Posts: 42
Rep:
|
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
|
|
|
|
02-03-2006, 08:28 AM
|
#3
|
|
Member
Registered: May 2004
Location: Romania; Arad
Distribution: Archlinux
Posts: 91
Original Poster
Rep:
|
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 
|
|
|
|
03-13-2006, 05:30 PM
|
#4
|
|
LQ Newbie
Registered: Mar 2006
Location: mn woods
Posts: 6
Rep:
|
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  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
|
|
|
|
03-13-2006, 10:03 PM
|
#5
|
|
Member
Registered: Jul 2004
Distribution: Fedora
Posts: 241
Rep:
|
How are you loading the file... gdk_pixbuf_new_from_file()?
|
|
|
|
03-14-2006, 01:16 AM
|
#6
|
|
LQ Newbie
Registered: Mar 2006
Location: mn woods
Posts: 6
Rep:
|
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
|
|
|
|
03-14-2006, 01:38 PM
|
#7
|
|
Member
Registered: Jul 2004
Distribution: Fedora
Posts: 241
Rep:
|
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.
|
|
|
|
03-14-2006, 06:16 PM
|
#8
|
|
LQ Newbie
Registered: Mar 2006
Location: mn woods
Posts: 6
Rep:
|
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
|
|
|
|
03-14-2006, 06:56 PM
|
#9
|
|
Member
Registered: Jul 2004
Distribution: Fedora
Posts: 241
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:36 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|