]> git.sesse.net Git - vlc/blob - plugins/gnome/gnome_support.c
f65d7698bf8e90d545ff76f2045bc8b444dc1584
[vlc] / plugins / gnome / 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
14 #include <gnome.h>
15
16 #include "gnome_support.h"
17
18 /* This is an internally used function to create pixmaps. */
19 static GtkWidget* create_dummy_pixmap  (GtkWidget       *widget,
20                                         gboolean         gnome_pixmap);
21
22 GtkWidget*
23 lookup_widget                          (GtkWidget       *widget,
24                                         const gchar     *widget_name)
25 {
26   GtkWidget *parent, *found_widget;
27
28   for (;;)
29     {
30       if (GTK_IS_MENU (widget))
31         parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
32       else
33         parent = widget->parent;
34       if (parent == NULL)
35         break;
36       widget = parent;
37     }
38
39   found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget),
40                                                    widget_name);
41   if (!found_widget)
42     g_warning ("Widget not found: %s", widget_name);
43   return found_widget;
44 }
45
46 /* This is a dummy pixmap we use when a pixmap can't be found. */
47 static char *dummy_pixmap_xpm[] = {
48 /* columns rows colors chars-per-pixel */
49 "1 1 1 1",
50 "  c None",
51 /* pixels */
52 " ",
53 " "
54 };
55
56 /* This is an internally used function to create pixmaps. */
57 static GtkWidget*
58 create_dummy_pixmap                    (GtkWidget       *widget,
59                                         gboolean         gnome_pixmap)
60 {
61   GdkColormap *colormap;
62   GdkPixmap *gdkpixmap;
63   GdkBitmap *mask;
64   GtkWidget *pixmap;
65
66   if (gnome_pixmap)
67     {
68       return gnome_pixmap_new_from_xpm_d (dummy_pixmap_xpm);
69     }
70
71   colormap = gtk_widget_get_colormap (widget);
72   gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask,
73                                                      NULL, dummy_pixmap_xpm);
74   if (gdkpixmap == NULL)
75     g_error ("Couldn't create replacement pixmap.");
76   pixmap = gtk_pixmap_new (gdkpixmap, mask);
77   gdk_pixmap_unref (gdkpixmap);
78   gdk_bitmap_unref (mask);
79   return pixmap;
80 }
81
82 /* This is an internally used function to create pixmaps. */
83 GtkWidget*
84 create_pixmap                          (GtkWidget       *widget,
85                                         const gchar     *filename,
86                                         gboolean         gnome_pixmap)
87 {
88   GtkWidget *pixmap;
89   GdkColormap *colormap;
90   GdkPixmap *gdkpixmap;
91   GdkBitmap *mask;
92   gchar *pathname;
93
94   pathname = gnome_pixmap_file (filename);
95   if (!pathname)
96     {
97       g_warning (_("Couldn't find pixmap file: %s"), filename);
98       return create_dummy_pixmap (widget, gnome_pixmap);
99     }
100
101   if (gnome_pixmap)
102     {
103       pixmap = gnome_pixmap_new_from_file (pathname);
104       g_free (pathname);
105       return pixmap;
106     }
107
108   colormap = gtk_widget_get_colormap (widget);
109   gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask,
110                                                    NULL, pathname);
111   if (gdkpixmap == NULL)
112     {
113       g_warning (_("Couldn't create pixmap from file: %s"), pathname);
114       g_free (pathname);
115       return create_dummy_pixmap (widget, gnome_pixmap);
116     }
117   g_free (pathname);
118
119   pixmap = gtk_pixmap_new (gdkpixmap, mask);
120   gdk_pixmap_unref (gdkpixmap);
121   gdk_bitmap_unref (mask);
122   return pixmap;
123 }
124
125 /* This is an internally used function to create imlib images. */
126 GdkImlibImage*
127 create_image                           (const gchar     *filename)
128 {
129   GdkImlibImage *image;
130   gchar *pathname;
131
132   pathname = gnome_pixmap_file (filename);
133   if (!pathname)
134     {
135       g_warning (_("Couldn't find pixmap file: %s"), filename);
136       return NULL;
137     }
138
139   image = gdk_imlib_load_image (pathname);
140   g_free (pathname);
141   return image;
142 }
143