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