00001
00002
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 #include <stdio.h>
00014
00015 #include <gnome.h>
00016
00017 #include "support.h"
00018
00019
00020 GtkWidget*
00021 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 = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
00034 if (parent == NULL)
00035 break;
00036 widget = parent;
00037 }
00038
00039 found_widget = (GtkWidget*) g_object_get_data (G_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
00047 GtkWidget*
00048 create_pixmap (GtkWidget *widget,
00049 const gchar *filename)
00050 {
00051 GtkWidget *pixmap;
00052 gchar *pathname;
00053
00054 if (!filename || !filename[0])
00055 return gtk_image_new ();
00056
00057 pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
00058 filename, TRUE, NULL);
00059 if (!pathname)
00060 {
00061 g_warning (_("Couldn't find pixmap file: %s"), filename);
00062 return gtk_image_new ();
00063 }
00064
00065 pixmap = gtk_image_new_from_file (pathname);
00066 g_free (pathname);
00067 return pixmap;
00068 }
00069
00070
00071 GdkPixbuf*
00072 create_pixbuf (const gchar *filename)
00073 {
00074 gchar *pathname = NULL;
00075 GdkPixbuf *pixbuf;
00076 GError *error = NULL;
00077
00078 if (!filename || !filename[0])
00079 return NULL;
00080
00081 pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
00082 filename, TRUE, NULL);
00083
00084 if (!pathname)
00085 {
00086 g_warning (_("Couldn't find pixmap file: %s"), filename);
00087 return NULL;
00088 }
00089
00090 pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
00091 if (!pixbuf)
00092 {
00093 fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
00094 pathname, error->message);
00095 g_error_free (error);
00096 }
00097 g_free (pathname);
00098 return pixbuf;
00099 }
00100
00101
00102 void
00103 glade_set_atk_action_description (AtkAction *action,
00104 const gchar *action_name,
00105 const gchar *description)
00106 {
00107 gint n_actions, i;
00108
00109 n_actions = atk_action_get_n_actions (action);
00110 for (i = 0; i < n_actions; i++)
00111 {
00112 if (!strcmp (atk_action_get_name (action, i), action_name))
00113 atk_action_set_description (action, i, description);
00114 }
00115 }
00116