#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <gtk/gtk.h>
#include "support.h"
Include dependency graph for sc_support.c:
Go to the source code of this file.
Functions | |
gchar * | check_file_exists (const gchar *directory, const gchar *filename) |
GtkWidget * | create_dummy_pixmap (GtkWidget *widget) |
GtkWidget * | lookup_widget (GtkWidget *widget, const gchar *widget_name) |
void | add_pixmap_directory (const gchar *directory) |
GtkWidget * | create_pixmap (GtkWidget *widget, const gchar *filename) |
Variables | |
char * | dummy_pixmap_xpm [] |
GList * | pixmaps_directories = NULL |
|
Definition at line 82 of file sc_support.c. 00083 { 00084 pixmaps_directories = g_list_prepend (pixmaps_directories, 00085 g_strdup (directory)); 00086 } |
|
Definition at line 140 of file sc_support.c. 00142 { 00143 gchar *full_filename; 00144 struct stat s; 00145 gint status; 00146 00147 full_filename = (gchar*) g_malloc (strlen (directory) + 1 00148 + strlen (filename) + 1); 00149 strcpy (full_filename, directory); 00150 strcat (full_filename, G_DIR_SEPARATOR_S); 00151 strcat (full_filename, filename); 00152 00153 status = stat (full_filename, &s); 00154 if (status == 0 && S_ISREG (s.st_mode)) 00155 return full_filename; 00156 g_free (full_filename); 00157 return NULL; 00158 } |
|
Definition at line 60 of file sc_support.c. 00061 { 00062 GdkColormap *colormap; 00063 GdkPixmap *gdkpixmap; 00064 GdkBitmap *mask; 00065 GtkWidget *pixmap; 00066 00067 colormap = gtk_widget_get_colormap (widget); 00068 gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, 00069 NULL, dummy_pixmap_xpm); 00070 if (gdkpixmap == NULL) 00071 g_error ("Couldn't create replacement pixmap."); 00072 pixmap = gtk_pixmap_new (gdkpixmap, mask); 00073 gdk_pixmap_unref (gdkpixmap); 00074 gdk_bitmap_unref (mask); 00075 return pixmap; 00076 } |
|
Definition at line 90 of file sc_support.c. 00092 { 00093 gchar *found_filename = NULL; 00094 GdkColormap *colormap; 00095 GdkPixmap *gdkpixmap; 00096 GdkBitmap *mask; 00097 GtkWidget *pixmap; 00098 GList *elem; 00099 00100 /* We first try any pixmaps directories set by the application. */ 00101 elem = pixmaps_directories; 00102 while (elem) 00103 { 00104 found_filename = check_file_exists ((gchar*)elem->data, filename); 00105 if (found_filename) 00106 break; 00107 elem = elem->next; 00108 } 00109 00110 /* If we haven't found the pixmap, try the source directory. */ 00111 if (!found_filename) 00112 { 00113 found_filename = check_file_exists ("", filename); 00114 } 00115 00116 if (!found_filename) 00117 { 00118 g_warning ("Couldn't find pixmap file: %s", filename); 00119 return create_dummy_pixmap (widget); 00120 } 00121 00122 colormap = gtk_widget_get_colormap (widget); 00123 gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, 00124 NULL, found_filename); 00125 if (gdkpixmap == NULL) 00126 { 00127 g_warning ("Error loading pixmap file: %s", found_filename); 00128 g_free (found_filename); 00129 return create_dummy_pixmap (widget); 00130 } 00131 g_free (found_filename); 00132 pixmap = gtk_pixmap_new (gdkpixmap, mask); 00133 gdk_pixmap_unref (gdkpixmap); 00134 gdk_bitmap_unref (mask); 00135 return pixmap; 00136 } |
|
Definition at line 26 of file sc_support.c. 00028 { 00029 GtkWidget *parent, *found_widget; 00030 00031 for (;;) 00032 { 00033 if (GTK_IS_MENU (widget)) 00034 parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); 00035 else 00036 parent = widget->parent; 00037 if (parent == NULL) 00038 break; 00039 widget = parent; 00040 } 00041 00042 found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget), 00043 widget_name); 00044 if (!found_widget) 00045 g_warning ("Widget not found: %s", widget_name); 00046 return found_widget; 00047 } |
|
Initial value: { "1 1 1 1", " c None", " " } Definition at line 50 of file sc_support.c. |
|
Definition at line 78 of file sc_support.c. |