+'captive-install-acquire'
[captive.git] / src / install / acquire / ui-gnome-support.c
1 /*
2  * DO NOT EDIT THIS FILE - it is generated by Glade.
3  */
4
5 #ifdef HAVE_CONFIG_H
6 #  include <config.h>
7 #endif
8
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <unistd.h>
12 #include <string.h>
13 #include <stdio.h>
14
15 #include <gnome.h>
16
17 #include "ui-gnome-support.h"
18
19 GtkWidget*
20 lookup_widget                          (GtkWidget       *widget,
21                                         const gchar     *widget_name)
22 {
23   GtkWidget *parent, *found_widget;
24
25   for (;;)
26     {
27       if (GTK_IS_MENU (widget))
28         parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
29       else
30         parent = widget->parent;
31       if (!parent)
32         parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
33       if (parent == NULL)
34         break;
35       widget = parent;
36     }
37
38   found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
39                                                  widget_name);
40   if (!found_widget)
41     g_warning ("Widget not found: %s", widget_name);
42   return found_widget;
43 }
44
45 /* This is an internally used function to create pixmaps. */
46 GtkWidget*
47 create_pixmap                          (GtkWidget       *widget,
48                                         const gchar     *filename)
49 {
50   GtkWidget *pixmap;
51   gchar *pathname;
52
53   if (!filename || !filename[0])
54       return gtk_image_new ();
55
56   pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
57                                         filename, TRUE, NULL);
58   if (!pathname)
59     {
60       g_warning (_("Couldn't find pixmap file: %s"), filename);
61       return gtk_image_new ();
62     }
63
64   pixmap = gtk_image_new_from_file (pathname);
65   g_free (pathname);
66   return pixmap;
67 }
68
69 /* This is an internally used function to create pixmaps. */
70 GdkPixbuf*
71 create_pixbuf                          (const gchar     *filename)
72 {
73   gchar *pathname = NULL;
74   GdkPixbuf *pixbuf;
75   GError *error = NULL;
76
77   if (!filename || !filename[0])
78       return NULL;
79
80   pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
81                                         filename, TRUE, NULL);
82
83   if (!pathname)
84     {
85       g_warning (_("Couldn't find pixmap file: %s"), filename);
86       return NULL;
87     }
88
89   pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
90   if (!pixbuf)
91     {
92       fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
93                pathname, error->message);
94       g_error_free (error);
95     }
96   g_free (pathname);
97   return pixbuf;
98 }
99
100 /* This is used to set ATK action descriptions. */
101 void
102 glade_set_atk_action_description       (AtkAction       *action,
103                                         const gchar     *action_name,
104                                         const gchar     *description)
105 {
106   gint n_actions, i;
107
108   n_actions = atk_action_get_n_actions (action);
109   for (i = 0; i < n_actions; i++)
110     {
111       if (!strcmp (atk_action_get_name (action, i), action_name))
112         atk_action_set_description (action, i, description);
113     }
114 }
115