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