LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 05-16-2004, 11:19 AM   #1
Rajahuroman
Member
 
Registered: May 2004
Location: Romania; Arad
Distribution: Archlinux
Posts: 91

Rep: Reputation: 15
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?
 
Old 01-12-2006, 02:44 AM   #2
santhosh.linux
Member
 
Registered: Nov 2005
Location: India
Posts: 42

Rep: Reputation: 15
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
 
Old 02-03-2006, 08:28 AM   #3
Rajahuroman
Member
 
Registered: May 2004
Location: Romania; Arad
Distribution: Archlinux
Posts: 91

Original Poster
Rep: Reputation: 15
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
 
Old 03-13-2006, 05:30 PM   #4
jfilse
LQ Newbie
 
Registered: Mar 2006
Location: mn woods
Posts: 6

Rep: Reputation: 0
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
 
Old 03-13-2006, 10:03 PM   #5
MicahCarrick
Member
 
Registered: Jul 2004
Distribution: Fedora
Posts: 241

Rep: Reputation: 31
How are you loading the file... gdk_pixbuf_new_from_file()?
 
Old 03-14-2006, 01:16 AM   #6
jfilse
LQ Newbie
 
Registered: Mar 2006
Location: mn woods
Posts: 6

Rep: Reputation: 0
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
 
Old 03-14-2006, 01:38 PM   #7
MicahCarrick
Member
 
Registered: Jul 2004
Distribution: Fedora
Posts: 241

Rep: Reputation: 31
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.
 
Old 03-14-2006, 06:16 PM   #8
jfilse
LQ Newbie
 
Registered: Mar 2006
Location: mn woods
Posts: 6

Rep: Reputation: 0
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
 
Old 03-14-2006, 06:56 PM   #9
MicahCarrick
Member
 
Registered: Jul 2004
Distribution: Fedora
Posts: 241

Rep: Reputation: 31
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GTK widget appearance neiljmac Linux - Software 1 12-25-2004 06:43 AM
Getting a widget GTK programming goelvish Programming 5 08-31-2004 05:30 AM
How to get Source code of Gtk File Selection Widget chaits Linux - General 0 04-14-2004 09:43 AM
Which GTK Widget to use? jpbarto Programming 0 11-20-2003 07:34 PM
what is a gtk-widget ? gladeiator Programming 3 10-30-2003 05:34 PM


All times are GMT -5. The time now is 06:29 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration