Page principale | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de classe | Membres de fichier | Pages associées

support.c

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 #ifdef HAVE_UNISTD_H
00012 #include <unistd.h>
00013 #endif
00014 #include <string.h>
00015 #include <stdio.h>
00016 
00017 #include <gtk/gtk.h>
00018 
00019 #include "support.h"
00020 
00021 GtkWidget *lookup_widget(GtkWidget * widget,
00022                          const gchar * widget_name)
00023 {
00024     GtkWidget *parent, *found_widget;
00025 
00026     for (;;)
00027     {
00028         if (GTK_IS_MENU(widget))
00029             parent = gtk_menu_get_attach_widget(GTK_MENU(widget));
00030         else
00031             parent = widget->parent;
00032         if (!parent)
00033             parent =
00034                 (GtkWidget *) g_object_get_data(G_OBJECT(widget),
00035                                                 "GladeParentKey");
00036         if (parent == NULL)
00037             break;
00038         widget = parent;
00039     }
00040 
00041     found_widget =
00042         (GtkWidget *) g_object_get_data(G_OBJECT(widget), widget_name);
00043     if (!found_widget)
00044         g_warning("Widget not found: %s", widget_name);
00045     return found_widget;
00046 }
00047 
00048 static GList *pixmaps_directories = NULL;
00049 
00050 /* Use this function to set the directory containing installed pixmaps. */
00051 void add_pixmap_directory(const gchar * directory)
00052 {
00053     pixmaps_directories =
00054         g_list_prepend(pixmaps_directories, g_strdup(directory));
00055 }
00056 
00057 /* This is an internally used function to find pixmap files. */
00058 static gchar *find_pixmap_file(const gchar * filename)
00059 {
00060     GList *elem;
00061 
00062     /* We step through each of the pixmaps directory to find it. */
00063     elem = pixmaps_directories;
00064     while (elem)
00065     {
00066         gchar *pathname = g_strdup_printf("%s%s%s", (gchar *) elem->data,
00067                                           G_DIR_SEPARATOR_S, filename);
00068 
00069         if (g_file_test(pathname, G_FILE_TEST_EXISTS))
00070             return pathname;
00071         g_free(pathname);
00072         elem = elem->next;
00073     }
00074     return NULL;
00075 }
00076 
00077 /* This is an internally used function to create pixmaps. */
00078 GtkWidget *create_pixmap(GtkWidget * widget,
00079                          const gchar * filename)
00080 {
00081     gchar *pathname = NULL;
00082     GtkWidget *pixmap;
00083 
00084     if (!filename || !filename[0])
00085         return gtk_image_new();
00086 
00087     pathname = find_pixmap_file(filename);
00088 
00089     if (!pathname)
00090     {
00091         g_warning(_("Couldn't find pixmap file: %s"), filename);
00092         return gtk_image_new();
00093     }
00094 
00095     pixmap = gtk_image_new_from_file(pathname);
00096     g_free(pathname);
00097     return pixmap;
00098 }
00099 
00100 /* This is an internally used function to create pixmaps. */
00101 GdkPixbuf *create_pixbuf(const gchar * filename)
00102 {
00103     gchar *pathname = NULL;
00104     GdkPixbuf *pixbuf;
00105     GError *error = NULL;
00106 
00107     if (!filename || !filename[0])
00108         return NULL;
00109 
00110     pathname = find_pixmap_file(filename);
00111 
00112     if (!pathname)
00113     {
00114         g_warning(_("Couldn't find pixmap file: %s"), filename);
00115         return NULL;
00116     }
00117 
00118     pixbuf = gdk_pixbuf_new_from_file(pathname, &error);
00119     if (!pixbuf)
00120     {
00121         fprintf(stderr, "Failed to load pixbuf file: %s: %s\n", pathname,
00122                 error->message);
00123         g_error_free(error);
00124     }
00125     g_free(pathname);
00126     return pixbuf;
00127 }
00128 
00129 /* This is used to set ATK action descriptions. */
00130 void glade_set_atk_action_description(AtkAction * action,
00131                                       const gchar * action_name,
00132                                       const gchar * description)
00133 {
00134     gint n_actions, i;
00135 
00136     n_actions = atk_action_get_n_actions(action);
00137     for (i = 0; i < n_actions; i++)
00138     {
00139         if (!strcmp(atk_action_get_name(action, i), action_name))
00140             atk_action_set_description(action, i, description);
00141     }
00142 }

Généré le Sat Aug 27 11:57:20 2005 pour GestionAsso par  doxygen 1.3.9.1