Back to Evolution Project page
00001 /* 00002 * DO NOT EDIT THIS FILE - it is generated by Glade. 00003 */ 00004 00005 #ifdef HAVE_CONFIG_H 00006 # include <config.h> 00007 #endif 00008 00009 #include <sys/types.h> 00010 #include <sys/stat.h> 00011 #include <unistd.h> 00012 #include <string.h> 00013 00014 #include <gnome.h> 00015 00016 #include "support.h" 00017 00018 /* This is an internally used function to create pixmaps. */ 00019 static GtkWidget* create_dummy_pixmap (GtkWidget *widget, 00020 gboolean gnome_pixmap); 00021 00022 GtkWidget* 00023 lookup_widget (GtkWidget *widget, 00024 const gchar *widget_name) 00025 { 00026 GtkWidget *parent, *found_widget; 00027 00028 for (;;) 00029 { 00030 if (GTK_IS_MENU (widget)) 00031 parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); 00032 else 00033 parent = widget->parent; 00034 if (parent == NULL) 00035 break; 00036 widget = parent; 00037 } 00038 00039 found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget), 00040 widget_name); 00041 if (!found_widget) 00042 g_warning ("Widget not found: %s", widget_name); 00043 return found_widget; 00044 } 00045 00046 /* This is a dummy pixmap we use when a pixmap can't be found. */ 00047 static char *dummy_pixmap_xpm[] = { 00048 /* columns rows colors chars-per-pixel */ 00049 "1 1 1 1", 00050 " c None", 00051 /* pixels */ 00052 " ", 00053 " " 00054 }; 00055 00056 /* This is an internally used function to create pixmaps. */ 00057 static GtkWidget* 00058 create_dummy_pixmap (GtkWidget *widget, 00059 gboolean gnome_pixmap) 00060 { 00061 GdkColormap *colormap; 00062 GdkPixmap *gdkpixmap; 00063 GdkBitmap *mask; 00064 GtkWidget *pixmap; 00065 00066 if (gnome_pixmap) 00067 { 00068 return gnome_pixmap_new_from_xpm_d (dummy_pixmap_xpm); 00069 } 00070 00071 colormap = gtk_widget_get_colormap (widget); 00072 gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, 00073 NULL, dummy_pixmap_xpm); 00074 if (gdkpixmap == NULL) 00075 g_error ("Couldn't create replacement pixmap."); 00076 pixmap = gtk_pixmap_new (gdkpixmap, mask); 00077 gdk_pixmap_unref (gdkpixmap); 00078 gdk_bitmap_unref (mask); 00079 return pixmap; 00080 } 00081 00082 /* This is an internally used function to create pixmaps. */ 00083 GtkWidget* 00084 create_pixmap (GtkWidget *widget, 00085 const gchar *filename, 00086 gboolean gnome_pixmap) 00087 { 00088 GtkWidget *pixmap; 00089 GdkColormap *colormap; 00090 GdkPixmap *gdkpixmap; 00091 GdkBitmap *mask; 00092 gchar *pathname; 00093 00094 if (!filename || !filename[0]) 00095 return create_dummy_pixmap (widget, gnome_pixmap); 00096 00097 pathname = gnome_pixmap_file (filename); 00098 if (!pathname) 00099 { 00100 g_warning (_("Couldn't find pixmap file: %s"), filename); 00101 return create_dummy_pixmap (widget, gnome_pixmap); 00102 } 00103 00104 if (gnome_pixmap) 00105 { 00106 pixmap = gnome_pixmap_new_from_file (pathname); 00107 g_free (pathname); 00108 return pixmap; 00109 } 00110 00111 colormap = gtk_widget_get_colormap (widget); 00112 gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, 00113 NULL, pathname); 00114 if (gdkpixmap == NULL) 00115 { 00116 g_warning (_("Couldn't create pixmap from file: %s"), pathname); 00117 g_free (pathname); 00118 return create_dummy_pixmap (widget, gnome_pixmap); 00119 } 00120 g_free (pathname); 00121 00122 pixmap = gtk_pixmap_new (gdkpixmap, mask); 00123 gdk_pixmap_unref (gdkpixmap); 00124 gdk_bitmap_unref (mask); 00125 return pixmap; 00126 } 00127 00128 /* This is an internally used function to create imlib images. */ 00129 GdkImlibImage* 00130 create_image (const gchar *filename) 00131 { 00132 GdkImlibImage *image; 00133 gchar *pathname; 00134 00135 pathname = gnome_pixmap_file (filename); 00136 if (!pathname) 00137 { 00138 g_warning (_("Couldn't find pixmap file: %s"), filename); 00139 return NULL; 00140 } 00141 00142 image = gdk_imlib_load_image (pathname); 00143 g_free (pathname); 00144 return image; 00145 } 00146