]> git.sesse.net Git - vlc/blob - plugins/gnome/gnome_support.c
* The pure Gnome part of the Gnome interface has been rewritten from
[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   if (!filename || !filename[0])
95       return create_dummy_pixmap (widget, gnome_pixmap);
96
97   pathname = gnome_pixmap_file (filename);
98   if (!pathname)
99     {
100       g_warning (_("Couldn't find pixmap file: %s"), filename);
101       return create_dummy_pixmap (widget, gnome_pixmap);
102     }
103
104   if (gnome_pixmap)
105     {
106       pixmap = gnome_pixmap_new_from_file (pathname);
107       g_free (pathname);
108       return pixmap;
109     }
110
111   colormap = gtk_widget_get_colormap (widget);
112   gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask,
113                                                    NULL, pathname);
114   if (gdkpixmap == NULL)
115     {
116       g_warning (_("Couldn't create pixmap from file: %s"), pathname);
117       g_free (pathname);
118       return create_dummy_pixmap (widget, gnome_pixmap);
119     }
120   g_free (pathname);
121
122   pixmap = gtk_pixmap_new (gdkpixmap, mask);
123   gdk_pixmap_unref (gdkpixmap);
124   gdk_bitmap_unref (mask);
125   return pixmap;
126 }
127
128 /* This is an internally used function to create imlib images. */
129 GdkImlibImage*
130 create_image                           (const gchar     *filename)
131 {
132   GdkImlibImage *image;
133   gchar *pathname;
134
135   pathname = gnome_pixmap_file (filename);
136   if (!pathname)
137     {
138       g_warning (_("Couldn't find pixmap file: %s"), filename);
139       return NULL;
140     }
141
142   image = gdk_imlib_load_image (pathname);
143   g_free (pathname);
144   return image;
145 }
146