GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 02, 2014 2:00 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Problem findin pixmaps, error: Couldn't find pixmap file:
PostPosted: Mon Jan 15, 2007 10:13 am 
Offline

Joined: Mon Jan 15, 2007 10:06 am
Posts: 4
I made some simple application (window, picture in it) with glade designer. Glade designer produce this code (I paste part of it):

Code:
  image1 = create_pixmap (window1, "logo.gif");
  gtk_widget_show (image1);
  gtk_table_attach (GTK_TABLE (table1), image1, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);



And this is located in file interface.c
In file main.c is pixmaps folder definision:

Code:
add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");


And when I compile and start there is no picture, and I see this WARNING: ** (project5:10919): WARNING **: Couldn't find pixmap file: logo.gif.

I have same problem when I try to add Icon to window, it tells me It cannot find icon.

So, does somebody maybe know what is problem ?

And is it possible to comiple source so the picture be in exe file ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 15, 2007 4:27 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
You can use either absolute or relative image paths. In this example, you are assuming that logo.gif is in the same directory as your executable. You should build the path out of the provided components & then give an absolute path.

Also, Glade's source code generation is depreciated (in fact, it's completely removed from Glade 3)! You should just load the .glade file with GladeXML (libglade) so that it is dynamically created during runtime.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 15, 2007 11:43 pm 
Offline

Joined: Mon Jan 15, 2007 10:06 am
Posts: 4
Hmmm...Maybe you are right, but when I put logo.gif in the same folder where is source code it still wont display gif picture.

And if that glade 3 doesn not generate source code, how I can modifie source code of designed GTK+ apps ?
Is there anyway to generate GTK code from that .glade file ?


Last edited by kunalagon on Tue Jan 16, 2007 12:05 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 15, 2007 11:52 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
How you are supposed to use Glade is to design your graphical application and then save it as a .glade file. Then, in the code that you write, use GladeXML to load the user interface and connect signals. There's a simple tutorial at: http://www.jamesh.id.au/software/libglade/ and http://www.micahcarrick.com/v2/content/view/29/20/. There's also a whole chapter in my book, which will be out in April.

In any case, what is the actual code that you have?

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 12:13 am 
Offline

Joined: Mon Jan 15, 2007 10:06 am
Posts: 4
I have some simple code (just window and one picture which is button like - can be clicked). And I want source code so I can change and modify that source (add some my function to button etc...) and I dont know how to do it if I use Glade 3 which generates just .glade (xml file) ???


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 12:41 am 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Open you .glade file in a text editor and paste the contents here and I'll show you.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 12:50 am 
Offline

Joined: Mon Jan 15, 2007 10:06 am
Posts: 4
here it is:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.1.2 on Tue Jan 16 02:00:11 2007 by sorg@euforia-->
<glade-interface>
<widget class="GtkWindow" id="window1">
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
</widget>
</child>
</widget>
</glade-interface>


I read on glade official site that there is some tool or plugin to generate source code...
I AM JUST LEARNING GKT , and it is much easier for me to have source code...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 1:24 am 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Well, I would really recommend that you lean using libglade and not auto-generated code as you'd be learning a lot of obsolete code. Start with something simple, a tutorial, and then build from there.

In you glade file, I have added a signal handler to the window's "destroy" event which will call gtk_main_quit when you destroy the window (clicking the 'x' in the titlebar). This is how you will handle events in your application. You will define "handlers" for "signals" in Glade and then write code to do whatever you want.

In your example, using Glade 3, I click on the window and then click the 'Signals" tab of the 'Properties" pane and add 'gtk_main_quit' as the handler for the "destroy" event. The new glade file looks like this:

example.glade
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.1.2 on Tue Jan 16 02:00:11 2007 by sorg@euforia-->
<glade-interface>
  <widget class="GtkWindow" id="window1">
  <signal name="destroy" handler="gtk_main_quit" last_modification_time="Sun, 14 Jan 2007 01:56:55 GMT"/>
    <child>
      <widget class="GtkImage" id="image1">
        <property name="visible">True</property>
        <property name="stock">gtk-missing-image</property>
      </widget>
    </child>
  </widget>
</glade-interface>


I then wrote a simple C file to read the .glade file and set the image to /usr/share/gtk-2.0/demo/gnome-foot.png before showing the window.

example.c
Code:
#include <gtk/gtk.h>
#include <glade/glade.h>

#define GLADE_FILE "example.glade"
#define IMAGE_FILE "/usr/share/gtk-2.0/demo/gnome-foot.png"

int
main (int argc, char *argv[])
{
    GladeXML        *gxml = NULL;
    GtkWidget       *window = NULL;
    GtkWidget       *image = NULL;
   
    /* initialize GTK+ libraries */
    gtk_init (&argc, &argv);
   
    /* build from Glade XML object from the .glade file */
    gxml = glade_xml_new (GLADE_FILE, NULL, NULL);
   
    /* get widgets from Glade XML object */
    window = glade_xml_get_widget (gxml, "window1");
    image = glade_xml_get_widget (gxml, "image1");
       
    /* auto-connect signal callbacks specified in the .glade file */
    glade_xml_signal_autoconnect (gxml);

    /* free Glade XML object now that we're done with it */
    g_object_unref (G_OBJECT (gxml));
   
    /* set the image from a filename */   
    gtk_image_set_from_file (GTK_IMAGE (image), IMAGE_FILE);
   
    /* show the main window */
    gtk_widget_show_all (window);
   
    /* begin GTK+ main loop */                   
    gtk_main ();

    return 0;
}


Which you can compile using:
Code:
gcc -Wall -g `pkg-config --cflags --libs gtk+-2.0` `pkg-config --cflags --libs libglade-2.0` -export-dynamic -o example example.c

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group