 |
GTK+ Forums Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
|
|
|
| Author |
Message |
|
|
kunalagon
Joined: 15 Jan 2007 Posts: 4
|
Posted: Mon Jan 15, 2007 10:13 am Post subject: Problem findin pixmaps, error: Couldn't find pixmap file: |
|
|
I made some simple application (window, picture in it) with glade designer. Glade designer produce this code (I paste part of it):
| Code: (Plaintext) | 1 2 3 4 5
| 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: (Plaintext) | 1
| 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 ? |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 387 Location: Fairfax, Virginia
|
Posted: Mon Jan 15, 2007 4:27 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
kunalagon
Joined: 15 Jan 2007 Posts: 4
|
Posted: Mon Jan 15, 2007 11:43 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 387 Location: Fairfax, Virginia
|
Posted: Mon Jan 15, 2007 11:52 pm Post subject: |
|
|
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? |
|
| Back to top |
|
 |
kunalagon
Joined: 15 Jan 2007 Posts: 4
|
Posted: Tue Jan 16, 2007 12:13 am Post subject: |
|
|
| 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) ??? |
|
| Back to top |
|
 |
Micah Carrick Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 505 Location: Portland, OR USA
|
Posted: Tue Jan 16, 2007 12:41 am Post subject: |
|
|
| Open you .glade file in a text editor and paste the contents here and I'll show you. |
|
| Back to top |
|
 |
kunalagon
Joined: 15 Jan 2007 Posts: 4
|
Posted: Tue Jan 16, 2007 12:50 am Post subject: |
|
|
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... |
|
| Back to top |
|
 |
Micah Carrick Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 505 Location: Portland, OR USA
|
Posted: Tue Jan 16, 2007 1:24 am Post subject: |
|
|
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: (Plaintext) | 1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <?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: (Plaintext) | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #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: (Plaintext) | 1 2
| gcc -Wall -g `pkg-config --cflags --libs gtk+-2.0` `pkg-config --cflags --libs libglade-2.0` -export-dynamic -o example example.c
| |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group CodeBB 1.0 Beta 2
|