]> git.sesse.net Git - vlc/blob - modules/gui/pda/pda_support.c
Remove most stray semi-colons in module descriptions
[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
13 #include <gtk/gtk.h>
14
15 #include "pda_support.h"
16
17 GtkWidget*
18 lookup_widget                          (GtkWidget       *widget,
19                                         const gchar     *widget_name)
20 {
21   GtkWidget *parent, *found_widget;
22
23   for (;;)
24     {
25       if (GTK_IS_MENU (widget))
26         parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
27       else
28         parent = widget->parent;
29       if (!parent)
30         parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
31       if (parent == NULL)
32         break;
33       widget = parent;
34     }
35
36   found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
37                                                  widget_name);
38   if (!found_widget)
39     g_warning ("Widget not found: %s", widget_name);
40   return found_widget;
41 }
42
43 static GList *pixmaps_directories = NULL;
44
45 /* Use this function to set the directory containing installed pixmaps. */
46 void
47 add_pixmap_directory                   (const gchar     *directory)
48 {
49   pixmaps_directories = g_list_prepend (pixmaps_directories,
50                                         g_strdup (directory));
51 }
52
53 /* This is an internally used function to find pixmap files. */
54 static gchar*
55 find_pixmap_file                       (const gchar     *filename)
56 {
57   GList *elem;
58
59   /* We step through each of the pixmaps directory to find it. */
60   elem = pixmaps_directories;
61   while (elem)
62     {
63       gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
64                                          G_DIR_SEPARATOR_S, filename);
65       if (g_file_test (pathname, G_FILE_TEST_EXISTS))
66         return pathname;
67       g_free (pathname);
68       elem = elem->next;
69     }
70   return NULL;
71 }
72
73 /* This is an internally used function to create pixmaps. */
74 GtkWidget*
75 create_pixmap                          (GtkWidget       *widget,
76                                         const gchar     *filename)
77 {
78   gchar *pathname = NULL;
79   GtkWidget *pixmap;
80
81   if (!filename || !filename[0])
82       return gtk_image_new ();
83
84   pathname = find_pixmap_file (filename);
85
86   if (!pathname)
87     {
88       g_warning (_("Couldn't find pixmap file: %s"), filename);
89       return gtk_image_new ();
90     }
91
92   pixmap = gtk_image_new_from_file (pathname);
93   g_free (pathname);
94   return pixmap;
95 }
96
97 /* This is an internally used function to create pixmaps. */
98 GdkPixbuf*
99 create_pixbuf                          (const gchar     *filename)
100 {
101   gchar *pathname = NULL;
102   GdkPixbuf *pixbuf;
103   GError *error = NULL;
104
105   if (!filename || !filename[0])
106       return NULL;
107
108   pathname = find_pixmap_file (filename);
109
110   if (!pathname)
111     {
112       g_warning (_("Couldn't find pixmap file: %s"), filename);
113       return NULL;
114     }
115
116   pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
117   if (!pixbuf)
118     {
119       fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
120                pathname, error->message);
121       g_error_free (error);
122     }
123   g_free (pathname);
124   return pixbuf;
125 }
126
127 /* This is used to set ATK action descriptions. */
128 void
129 glade_set_atk_action_description       (AtkAction       *action,
130                                         const gchar     *action_name,
131                                         const gchar     *description)
132 {
133   gint n_actions, i;
134
135   n_actions = atk_action_get_n_actions (action);
136   for (i = 0; i < n_actions; i++)
137     {
138       if (!strcmp (atk_action_get_name (action, i), action_name))
139         atk_action_set_description (action, i, description)
140     }
141 }
142