00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifdef HAVE_CONFIG_H
00023 # include <config.h>
00024 #endif
00025
00026 #include <sys/types.h>
00027 #include <sys/stat.h>
00028 #include <unistd.h>
00029 #include <string.h>
00030 #include <stdio.h>
00031
00032 #include <gnome.h>
00033
00034 #include "support.h"
00035
00036 GtkWidget*
00037 lookup_widget (GtkWidget *widget,
00038 const gchar *widget_name)
00039 {
00040 GtkWidget *parent, *found_widget;
00041
00042 for (;;)
00043 {
00044 if (GTK_IS_MENU (widget))
00045 parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
00046 else
00047 parent = widget->parent;
00048 if (!parent)
00049 parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
00050 if (parent == NULL)
00051 break;
00052 widget = parent;
00053 }
00054
00055 found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
00056 widget_name);
00057 if (!found_widget)
00058 g_warning ("Widget not found: %s", widget_name);
00059 return found_widget;
00060 }
00061
00062
00063 GtkWidget*
00064 create_pixmap (GtkWidget *widget,
00065 const gchar *filename)
00066 {
00067 GtkWidget *pixmap;
00068 gchar *pathname;
00069
00070 if (!filename || !filename[0])
00071 return gtk_image_new ();
00072
00073 pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
00074 filename, TRUE, NULL);
00075 if (!pathname)
00076 {
00077 g_warning (_("Couldn't find pixmap file: %s"), filename);
00078 return gtk_image_new ();
00079 }
00080
00081 pixmap = gtk_image_new_from_file (pathname);
00082 g_free (pathname);
00083 return pixmap;
00084 }
00085
00086
00087 GdkPixbuf*
00088 create_pixbuf (const gchar *filename)
00089 {
00090 gchar *pathname = NULL;
00091 GdkPixbuf *pixbuf;
00092 GError *error = NULL;
00093
00094 if (!filename || !filename[0])
00095 return NULL;
00096
00097 pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
00098 filename, TRUE, NULL);
00099
00100 if (!pathname)
00101 {
00102 g_warning (_("Couldn't find pixmap file: %s"), filename);
00103 return NULL;
00104 }
00105
00106 pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
00107 if (!pixbuf)
00108 {
00109 fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
00110 pathname, error->message);
00111 g_error_free (error);
00112 }
00113 g_free (pathname);
00114 return pixbuf;
00115 }
00116
00117
00118 void
00119 glade_set_atk_action_description (AtkAction *action,
00120 const gchar *action_name,
00121 const gchar *description)
00122 {
00123 gint n_actions, i;
00124
00125 n_actions = atk_action_get_n_actions (action);
00126 for (i = 0; i < n_actions; i++)
00127 {
00128 if (!strcmp (atk_action_get_name (action, i), action_name))
00129 atk_action_set_description (action, i, description);
00130 }
00131 }