Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

support.h File Reference

#include <gtk/gtk.h>

Include dependency graph for support.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define get_widget   lookup_widget

Functions

GtkWidget * lookup_widget (GtkWidget *widget, const gchar *widget_name)
void add_pixmap_directory (const gchar *directory)
GtkWidget * create_pixmap (GtkWidget *widget, const gchar *filename)


Define Documentation

#define get_widget   lookup_widget
 

Definition at line 25 of file support.h.


Function Documentation

void add_pixmap_directory const gchar *    directory
 

Definition at line 82 of file support.c.

Referenced by main().

00083 {
00084   pixmaps_directories = g_list_prepend (pixmaps_directories,
00085                                         g_strdup (directory));
00086 }

GtkWidget* create_pixmap GtkWidget *    widget,
const gchar *    filename
 

Definition at line 90 of file 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 }

GtkWidget* lookup_widget GtkWidget *    widget,
const gchar *    widget_name
 

Definition at line 26 of file support.c.

Referenced by main(), and set_torque_units().

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 }


Generated on Sun Dec 2 15:28:32 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001