]> git.sesse.net Git - vlc/blob - modules/gui/pda/pda_support.c
99fcb57eaa2d47b406659ae1109ccbd81d7f2991
[vlc] / modules / gui / pda / pda_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
14 #include <gtk/gtk.h>
15
16 #include "pda_support.h"
17
18 GtkWidget*
19 lookup_widget                          (GtkWidget       *widget,
20                                         const gchar     *widget_name)
21 {
22   GtkWidget *parent, *found_widget;
23
24   for (;;)
25     {
26       if (GTK_IS_MENU (widget))
27         parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
28       else
29         parent = widget->parent;
30       if (!parent)
31         parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
32       if (parent == NULL)
33         break;
34       widget = parent;
35     }
36
37   found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
38                                                  widget_name);
39   if (!found_widget)
40     g_warning ("Widget not found: %s", widget_name);
41   return found_widget;
42 }
43
44 static GList *pixmaps_directories = NULL;
45
46 /* Use this function to set the directory containing installed pixmaps. */
47 void
48 add_pixmap_directory                   (const gchar     *directory)
49 {
50   pixmaps_directories = g_list_prepend (pixmaps_directories,
51                                         g_strdup (directory));
52 }
53
54 /* This is an internally used function to find pixmap files. */
55 static gchar*
56 find_pixmap_file                       (const gchar     *filename)
57 {
58   GList *elem;
59
60   /* We step through each of the pixmaps directory to find it. */
61   elem = pixmaps_directories;
62   while (elem)
63     {
64       gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
65                                          G_DIR_SEPARATOR_S, filename);
66       if (g_file_test (pathname, G_FILE_TEST_EXISTS))
67         return pathname;
68       g_free (pathname);
69       elem = elem->next;
70     }
71   return NULL;
72 }
73
74 /* This is an internally used function to create pixmaps. */
75 GtkWidget*
76 create_pixmap                          (GtkWidget       *widget,
77                                         const gchar     *filename)
78 {
79   (void) widget;
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*
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
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