X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=driver%2Fdemo-Gtk-support.c;fp=driver%2Fdemo-Gtk-support.c;h=0000000000000000000000000000000000000000;hp=881129c4f11ca1ebd8cd66e6771b1997dbd139dd;hb=dba664f31aa87285db4d76cf8c5e66335299703a;hpb=8afc01a67be4fbf3f1cc0fce9adf01b5289a21c6 diff --git a/driver/demo-Gtk-support.c b/driver/demo-Gtk-support.c deleted file mode 100644 index 881129c4..00000000 --- a/driver/demo-Gtk-support.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * DO NOT EDIT THIS FILE - it is generated by Glade. - WARNING: I did edit this file! Be careful! -jwz - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include - -#include - -#include "demo-Gtk-support.h" - -/* jwz -- dumbass Glade1 doesn't emit code that can read PNGs. this does. */ -#ifdef HAVE_GDK_PIXBUF -# ifdef HAVE_GTK2 -# include -# else /* !HAVE_GTK2 */ -# include -# endif /* !HAVE_GTK2 */ -#endif /* HAVE_GDK_PIXBUF */ - - -/* This is an internally used function to check if a pixmap file exists. */ -static gchar* check_file_exists (const gchar *directory, - const gchar *filename); - -/* This is an internally used function to create pixmaps. */ -static GtkWidget* create_dummy_pixmap (GtkWidget *widget); - -GtkWidget* -lookup_widget (GtkWidget *widget, - const gchar *widget_name) -{ - GtkWidget *parent, *found_widget; - - for (;;) - { - if (GTK_IS_MENU (widget)) - parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); - else - parent = widget->parent; - if (parent == NULL) - break; - widget = parent; - } - - found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget), - widget_name); - if (!found_widget) - g_warning ("Widget not found: %s", widget_name); - return found_widget; -} - -/* This is a dummy pixmap we use when a pixmap can't be found. */ -static char *dummy_pixmap_xpm[] = { -/* columns rows colors chars-per-pixel */ -"1 1 1 1", -" c None", -/* pixels */ -" " -}; - -/* This is an internally used function to create pixmaps. */ -static GtkWidget* -create_dummy_pixmap (GtkWidget *widget) -{ - GdkColormap *colormap; - GdkPixmap *gdkpixmap; - GdkBitmap *mask; - GtkWidget *pixmap; - - colormap = gtk_widget_get_colormap (widget); - gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, - NULL, dummy_pixmap_xpm); - if (gdkpixmap == NULL) - g_error ("Couldn't create replacement pixmap."); - pixmap = gtk_pixmap_new (gdkpixmap, mask); - gdk_pixmap_unref (gdkpixmap); - gdk_bitmap_unref (mask); - return pixmap; -} - -static GList *pixmaps_directories = NULL; - -/* Use this function to set the directory containing installed pixmaps. */ -void -add_pixmap_directory (const gchar *directory) -{ - pixmaps_directories = g_list_prepend (pixmaps_directories, - g_strdup (directory)); -} - -/* This is an internally used function to create pixmaps. */ -/* #### Warning: this version of this function hacked by jwz to - support PNGs. Don't let Glade1 overwrite this! - */ -GtkWidget* -create_pixmap (GtkWidget *widget, - const gchar *filename) -{ - gchar *found_filename = NULL; - GdkColormap *colormap = 0; - GdkPixmap *gdkpixmap = 0; - GdkBitmap *mask = 0; - GtkWidget *pixmap = 0; - GList *elem = 0; - - if (!filename || !filename[0]) - return create_dummy_pixmap (widget); - - /* We first try any pixmaps directories set by the application. */ - elem = pixmaps_directories; - while (elem) - { - found_filename = check_file_exists ((gchar*)elem->data, filename); - if (found_filename) - break; - elem = elem->next; - } - - /* If we haven't found the pixmap, try the source directory. */ - if (!found_filename) - { - found_filename = check_file_exists ("../utils/images", filename); - } - - if (!found_filename) - { - g_warning (_("Couldn't find pixmap file: %s"), filename); - return create_dummy_pixmap (widget); - } - - colormap = gtk_widget_get_colormap (widget); - -# ifndef HAVE_GDK_PIXBUF - - gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, - NULL, found_filename); - if (gdkpixmap == NULL) - { - g_warning (_("Error loading pixmap file: %s"), found_filename); - g_free (found_filename); - return create_dummy_pixmap (widget); - } - -# else /* HAVE_GDK_PIXBUF */ - - /* jwz -- dumbass Glade1 doesn't emit code that can read PNGs. - This code does... */ - - /* #### Danger: we aren't using `colormap'... */ - - { - GdkPixbuf *pb; -# ifdef HAVE_GTK2 - GError *gerr = 0; -# endif /* HAVE_GTK2 */ - - pb = gdk_pixbuf_new_from_file (found_filename -# ifdef HAVE_GTK2 - , &gerr -# endif /* HAVE_GTK2 */ - ); - - if (pb) - { - gdkpixmap = 0; - mask = 0; - gdk_pixbuf_render_pixmap_and_mask (pb, &gdkpixmap, &mask, 128); - } - else - { - g_warning (_("Error loading pixmap file: %s"), found_filename); -# ifdef HAVE_GTK2 - if (gerr && gerr->message && *gerr->message) - g_warning (_("reason: %s\n"), gerr->message); -# endif /* HAVE_GTK2 */ - - return create_dummy_pixmap (widget); - } - } -# endif /* HAVE_GDK_PIXBUF */ - - g_free (found_filename); - pixmap = gtk_pixmap_new (gdkpixmap, mask); - gdk_pixmap_unref (gdkpixmap); - gdk_bitmap_unref (mask); - - return pixmap; -} - -/* This is an internally used function to check if a pixmap file exists. */ -static gchar* -check_file_exists (const gchar *directory, - const gchar *filename) -{ - gchar *full_filename; - struct stat s; - gint status; - - full_filename = (gchar*) g_malloc (strlen (directory) + 1 - + strlen (filename) + 1); - strcpy (full_filename, directory); - strcat (full_filename, G_DIR_SEPARATOR_S); - strcat (full_filename, filename); - - status = stat (full_filename, &s); - if (status == 0 && S_ISREG (s.st_mode)) - return full_filename; - g_free (full_filename); - return NULL; -} -