Project Homepage | Sourceforge Page | CVS Repository | Freshmeat.net Page | Download project | Author's Homepage |
Definition in file support.c.
#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 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 |
|
Use this function to set the directory containing installed pixmaps. Definition at line 102 of file support.c. References pixmaps_directories.
00103 { 00104 pixmaps_directories = g_list_prepend (pixmaps_directories, 00105 g_strdup (directory)); 00106 } |
|
Definition at line 163 of file support.c. Referenced by create_pixmap().
00165 { 00166 gchar *full_filename; 00167 struct stat s; 00168 gint status; 00169 00170 full_filename = (gchar*) g_malloc (strlen (directory) + 1 00171 + strlen (filename) + 1); 00172 strcpy (full_filename, directory); 00173 strcat (full_filename, G_DIR_SEPARATOR_S); 00174 strcat (full_filename, filename); 00175 00176 status = stat (full_filename, &s); 00177 if (status == 0 && S_ISREG (s.st_mode)) 00178 return full_filename; 00179 g_free (full_filename); 00180 return NULL; 00181 } |
|
Definition at line 80 of file support.c. References dummy_pixmap_xpm. Referenced by create_pixmap().
00081 { 00082 GdkColormap *colormap; 00083 GdkPixmap *gdkpixmap; 00084 GdkBitmap *mask; 00085 GtkWidget *pixmap; 00086 00087 colormap = gtk_widget_get_colormap (widget); 00088 gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, 00089 NULL, dummy_pixmap_xpm); 00090 if (gdkpixmap == NULL) 00091 g_error ("Couldn't create replacement pixmap."); 00092 pixmap = gtk_pixmap_new (gdkpixmap, mask); 00093 gdk_pixmap_unref (gdkpixmap); 00094 gdk_bitmap_unref (mask); 00095 return pixmap; 00096 } |
|
This is used to create the pixmaps in the interface. Definition at line 110 of file support.c. References check_file_exists(), create_dummy_pixmap(), and pixmaps_directories.
00112 { 00113 gchar *found_filename = NULL; 00114 GdkColormap *colormap; 00115 GdkPixmap *gdkpixmap; 00116 GdkBitmap *mask; 00117 GtkWidget *pixmap; 00118 GList *elem; 00119 00120 if (!filename || !filename[0]) 00121 return create_dummy_pixmap (widget); 00122 00123 /* We first try any pixmaps directories set by the application. */ 00124 elem = pixmaps_directories; 00125 while (elem) 00126 { 00127 found_filename = check_file_exists ((gchar*)elem->data, filename); 00128 if (found_filename) 00129 break; 00130 elem = elem->next; 00131 } 00132 00133 /* If we haven't found the pixmap, try the source directory. */ 00134 if (!found_filename) 00135 { 00136 found_filename = check_file_exists ("../pixmaps", filename); 00137 } 00138 00139 if (!found_filename) 00140 { 00141 g_warning ("Couldn't find pixmap file: %s", filename); 00142 return create_dummy_pixmap (widget); 00143 } 00144 00145 colormap = gtk_widget_get_colormap (widget); 00146 gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, 00147 NULL, found_filename); 00148 if (gdkpixmap == NULL) 00149 { 00150 g_warning ("Error loading pixmap file: %s", found_filename); 00151 g_free (found_filename); 00152 return create_dummy_pixmap (widget); 00153 } 00154 g_free (found_filename); 00155 pixmap = gtk_pixmap_new (gdkpixmap, mask); 00156 gdk_pixmap_unref (gdkpixmap); 00157 gdk_bitmap_unref (mask); 00158 return pixmap; 00159 } |
Here is the call graph for this function:
|
This function returns a widget in a component created by Glade. Call it with the toplevel widget in the component (i.e. a window/dialog), or alternatively any widget in the component, and the name of the widget you want returned. Definition at line 46 of file support.c.
00048 { 00049 GtkWidget *parent, *found_widget; 00050 00051 for (;;) 00052 { 00053 if (GTK_IS_MENU (widget)) 00054 parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); 00055 else 00056 parent = widget->parent; 00057 if (parent == NULL) 00058 break; 00059 widget = parent; 00060 } 00061 00062 found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget), 00063 widget_name); 00064 if (!found_widget) 00065 g_warning ("Widget not found: %s", widget_name); 00066 return found_widget; 00067 } |
|
Initial value: { "1 1 1 1", " c None", " " } Definition at line 70 of file support.c. Referenced by create_dummy_pixmap(). |
|
Definition at line 98 of file support.c. Referenced by add_pixmap_directory(), and create_pixmap(). |