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 <gtk/gtk.h>
16 
17 #include "support.h"
18 
19 GtkWidget*
lookup_widget(GtkWidget * widget,const gchar * widget_name)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 = gtk_widget_get_parent (widget);
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 static GList *pixmaps_directories = NULL;
46 
47 /* Use this function to set the directory containing installed pixmaps. */
48 void
add_pixmap_directory(const gchar * directory)49 add_pixmap_directory                   (const gchar     *directory)
50 {
51   pixmaps_directories = g_list_prepend (pixmaps_directories,
52                                         g_strdup (directory));
53 }
54 
55 /* This is an internally used function to find pixmap files. */
56 static gchar*
find_pixmap_file(const gchar * filename)57 find_pixmap_file                       (const gchar     *filename)
58 {
59   GList *elem;
60 
61   /* We step through each of the pixmaps directory to find it. */
62   elem = pixmaps_directories;
63   while (elem)
64     {
65       gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
66                                          G_DIR_SEPARATOR_S, filename);
67       if (g_file_test (pathname, G_FILE_TEST_EXISTS))
68         return pathname;
69       g_free (pathname);
70       elem = elem->next;
71     }
72   return NULL;
73 }
74 
75 /* This is an internally used function to create pixmaps. */
76 GtkWidget*
create_pixmap(GtkWidget * widget,const gchar * filename)77 create_pixmap                          (GtkWidget       *widget,
78                                         const gchar     *filename)
79 {
80   gchar *pathname = NULL;
81   GtkWidget *pixmap;
82 
83   if (!filename || !filename[0])
84       return gtk_image_new ();
85 
86   pathname = find_pixmap_file (filename);
87 
88   if (!pathname)
89     {
90       g_warning (_("Couldn't find pixmap file: %s"), filename);
91       return gtk_image_new ();
92     }
93 
94   pixmap = gtk_image_new_from_file (pathname);
95   g_free (pathname);
96   return pixmap;
97 }
98 
99 /* This is an internally used function to create pixmaps. */
100 GdkPixbuf*
create_pixbuf(const gchar * filename)101 create_pixbuf                          (const gchar     *filename)
102 {
103   gchar *pathname = NULL;
104   GdkPixbuf *pixbuf;
105   GError *error = NULL;
106 
107   if (!filename || !filename[0])
108       return NULL;
109 
110   pathname = find_pixmap_file (filename);
111 
112   if (!pathname)
113     {
114       g_warning (_("Couldn't find pixmap file: %s"), filename);
115       return NULL;
116     }
117 
118   pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
119   if (!pixbuf)
120     {
121       fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
122                pathname, error->message);
123       g_error_free (error);
124     }
125   g_free (pathname);
126   return pixbuf;
127 }
128 
129 /* This is used to set ATK action descriptions. */
130 void
glade_set_atk_action_description(AtkAction * action,const gchar * action_name,const gchar * description)131 glade_set_atk_action_description       (AtkAction       *action,
132                                         const gchar     *action_name,
133                                         const gchar     *description)
134 {
135   gint n_actions, i;
136 
137   n_actions = atk_action_get_n_actions (action);
138   for (i = 0; i < n_actions; i++)
139     {
140       if (!strcmp (atk_action_get_name (action, i), action_name))
141         atk_action_set_description (action, i, description);
142     }
143 }
144 
145 #if GTK_CHECK_VERSION(3,0,0)
146 GtkWidget *
gtk_combo_box_entry_new_text(void)147 gtk_combo_box_entry_new_text(void) {
148     return gtk_combo_box_text_new_with_entry ();
149 }
150 
151 void
gtk_dialog_set_has_separator(GtkDialog * dlg,gboolean has)152 gtk_dialog_set_has_separator (GtkDialog *dlg, gboolean has) {
153 }
154 #endif
155 
156 #if !GTK_CHECK_VERSION(2,22,0)
157 GdkDragAction
gdk_drag_context_get_selected_action(GdkDragContext * context)158 gdk_drag_context_get_selected_action (GdkDragContext *context) {
159     return context->action;
160 }
161 GList *
gdk_drag_context_list_targets(GdkDragContext * context)162 gdk_drag_context_list_targets (GdkDragContext *context) {
163     return context->targets;
164 }
165 #endif
166 
167 #if !GTK_CHECK_VERSION(2,24,0)
168 #define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
169 GtkWidget *
gtk_combo_box_text_new()170 gtk_combo_box_text_new () {
171     return gtk_combo_box_new_text ();
172 }
173 
174 GtkWidget *
gtk_combo_box_text_new_with_entry(void)175 gtk_combo_box_text_new_with_entry   (void) {
176     return gtk_combo_box_entry_new ();
177 }
178 
179 void
gtk_combo_box_text_append_text(GtkComboBoxText * combo_box,const gchar * text)180 gtk_combo_box_text_append_text (GtkComboBoxText *combo_box, const gchar *text) {
181     gtk_combo_box_append_text (combo_box, text);
182 }
183 
184 void
gtk_combo_box_text_insert_text(GtkComboBoxText * combo_box,gint position,const gchar * text)185 gtk_combo_box_text_insert_text (GtkComboBoxText *combo_box, gint position, const gchar *text) {
186     gtk_combo_box_insert_text (combo_box, position, text);
187 }
188 
189 void
gtk_combo_box_text_prepend_text(GtkComboBoxText * combo_box,const gchar * text)190 gtk_combo_box_text_prepend_text (GtkComboBoxText *combo_box, const gchar *text) {
191     gtk_combo_box_prepend_text (combo_box, text);
192 }
193 gchar *
gtk_combo_box_text_get_active_text(GtkComboBoxText * combo_box)194 gtk_combo_box_text_get_active_text  (GtkComboBoxText *combo_box) {
195     return gtk_combo_box_get_active_text (combo_box);
196 }
197 
198 #endif
199 
200 #if !GTK_CHECK_VERSION(2,18,0)
201 void
gtk_widget_set_allocation(GtkWidget * widget,const GtkAllocation * allocation)202 gtk_widget_set_allocation (GtkWidget *widget, const GtkAllocation *allocation) {
203     widget->allocation.x = (allocation)->x;
204     widget->allocation.y = (allocation)->y;
205     widget->allocation.width = (allocation)->width;
206     widget->allocation.height = (allocation)->height;
207 }
208 
209 void
gtk_widget_get_allocation(GtkWidget * widget,GtkAllocation * allocation)210 gtk_widget_get_allocation (GtkWidget *widget, GtkAllocation *allocation) {
211     (allocation)->x = widget->allocation.x;
212     (allocation)->y = widget->allocation.y;
213     (allocation)->width = widget->allocation.width;
214     (allocation)->height = widget->allocation.height;
215 }
216 
217 void
gtk_widget_set_window(GtkWidget * widget,GdkWindow * window)218 gtk_widget_set_window(GtkWidget *widget, GdkWindow *window) {
219     widget->window = window;
220 }
221 #endif
222