Re: gtk_rc_parse and pixmap_path



I know It's bad form to answer your own posts.  Here is a working solution
to this problem I have found.


  - Create an rc file, for this example called .myrc, with this entry:
    pixmap_path: "/tmp"

  - Add this call immediately BEFORE gtk_init():
    gtk_rc_add_default_file("./.myrc");

  - Get a pointer to the GTK settings context:
    settings = gtk_settings_get_default();

  - Add this call to resolve the full path to the pixmap file:
    xpm_file = gtk_rc_find_pixmap_in_path(settings, NULL, "info.xpm");

  - Finally, use your pixmap file:
    image = gtk_image_new_from_file(xpm_file);
    gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 3);
    g_free(xpm_file);

Doing this works.  Given I'm still learning the details of GTK, there
are likely better solutions yet.  Adding any example of how to accomplish
this to the GTK examples would be extremely helpful.

Adam
---
Adam Bernstein   no6 pobox com   http://mpgedit.org/~number6
"Who are you?  The new Number 2.  Who is Number 1?  You are, Number 6.
I am not a number, I am a free man!  Aha ha ha ha ha..."
Key fingerprint =  DD 2B 08 4C 51 B6 2B FF  18 41 84 E8 93 8A 27 8D

On Tue, 24 Jun 2003 number6 mpgedit org wrote:

> [ Oops, I posted this question to the wrong list yesterday. Sorry for
> the duplicate post.]
> 
> I want my GTK application to find its pixmaps in the directory where
> they are installed, but configuring pixmap_path in an rc file seems to
> have no effect. 
> 
> In my efforts to debug why this is the case, this is what I have done. I
> modified examples/buttons/buttons.c from the GTK  distribution, adding
> the following line after the gtk_init() line:
> 
>     gtk_rc_parse("./.myrc");
> 
> I then created the file examples/buttons/.myrc with the following line:
> 
>     pixmap_path "/tmp"
> 
> I moved examples/buttons/info.xpm to /tmp.
> 
> After recompiling buttons.c, this example program is no longer able to
> find its pixmap.  




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]