http://funplosion.com/free-assets.html
http://stackoverflow.com/questions/143050/
Here is what I have so far:
Code: Select all
#include <sys/inotify.h>
#include <gtk/gtk.h>
#define IMAGE "svgame.svg"
void refresh(gpointer si, gint fd, GdkInputCondition c){
char buffer[sizeof (struct inotify_event)];
read( fd, buffer, sizeof(buffer) ); /* just clearing, don't care the type */
gtk_image_set_from_file(si,IMAGE);} /* force redraw of image*/
int main(int argc, char *argv[]){
int watch, fd; GtkWidget *window, *image;
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
fd = inotify_init();
image = gtk_image_new_from_file(IMAGE);
gtk_container_add(GTK_CONTAINER(window), image);
watch = inotify_add_watch( fd, IMAGE, IN_MODIFY ); /* more events? */
gdk_input_add( fd, GDK_INPUT_READ, refresh, image ); /* refresh on inotify */
g_signal_connect((gpointer) window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show_all(window);
gtk_main ();}
TODO add a callback to printf key-presses and mouse-clicks (until then, control is decoupled)
EDIT: see my next post for the mouse/key actions
Just to give you an idea, you can do something like this:
Code: Select all
<svg width="640" height="480">
<image x="1" y="1" width="640" height="480"
xlink:href="/usr/share/backgrounds/default.jpg" />
<image x="1" y="1" width="64" height="48"
xlink:href="/usr/share/pixmaps/buddy.png" />
</svg>
Code: Select all
<svg width="640" height="480">
<image x="1" y="1" width="640" height="480"
xlink:href="/usr/share/backgrounds/default.jpg" />
<image x="65" y="49" width="64" height="48"
xlink:href="/usr/share/pixmaps/buddy.png" />
</svg>
(oops I accidently created a webcam viewer - use ffmpeg to generate images of the same name defined by IMAGE)
(oops2 ... can do a slideshow also)
(oops3 ... and presentations via svg)
(oops4 ... someone on IRC also suggested using svg to build a nicer widget/toolkit)
Eventually this could be shifted to using libtinysvg and cairo-xcb?? for a multithread capable 2d toolkit.
P.S. If Thunor is reading this, it would be nice to have a autorefresh="true" flag on images in gtkdialog to do the same thing I am doing here. I could help come up with a patch, but this was just a quick proof of concept, no frills adaptation of my simple icon tray.