annotate gui/mplayer/widgets.c @ 33551:5d5f66b52c62

Add a warning message for unavailable or unusable icons. This is a preparation for differently sized icons to come.
author ib
date Fri, 17 Jun 2011 18:59:03 +0000
parents 107084241b00
children c5a19bbeac2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26458
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
1 /*
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
2 * This file is part of MPlayer.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
3 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
5 * it under the terms of the GNU General Public License as published by
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
7 * (at your option) any later version.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
8 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
12 * GNU General Public License for more details.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
13 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
14 * You should have received a copy of the GNU General Public License along
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
17 */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
18
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
19 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
20 #include <stdio.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
21
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
22 #include <sys/types.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23 #include <sys/stat.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 #include <sys/wait.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 #include <unistd.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27 #include <signal.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
29 #include <gdk/gdkprivate.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
30 #include <gdk/gdkkeysyms.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
31 #include <gdk/gdkx.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
32 #include <gdk/gdk.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
33 #include <gtk/gtk.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
34
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
35 #include "config.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
36 #include "help_mp.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
37 #include "mp_msg.h"
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
38 #include "libavutil/intreadwrite.h"
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
39 #include "libvo/x11_common.h"
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
40
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
41 #include "widgets.h"
26365
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 26203
diff changeset
42 #include "gui/app.h"
33466
45d8bfbd27bc Define "gmplayer" as symbolic constant.
ib
parents: 33465
diff changeset
43 #include "gui/interface.h"
26365
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 26203
diff changeset
44 #include "gui/wm/ws.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
45
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
46 #include "play.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47 #include "gtk/fs.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
48
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
49 GtkWidget *PopUpMenu = NULL;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
51 GtkWidget *WarningPixmap;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
52 GtkWidget *ErrorPixmap;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
53
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
54 int gtkPopupMenu = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
55 int gtkPopupMenuParam = 0;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
56 int gtkInitialized = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
57
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
58 #include "gtk/sb.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
59 #include "gtk/pl.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
60 #include "gtk/fs.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
61 #include "gtk/mb.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
62 #include "gtk/about.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63 #include "gtk/opts.h"
30531
704903d34069 Rename gui/mplayer/gtk/menu.[ch] --> gui/mplayer/gtk/gtkmenu.[ch].
diego
parents: 29263
diff changeset
64 #include "gtk/gtk_menu.h"
26137
02a08fffb1dc Rename url.c/url.h to the less generic gtk_url.c/gtk_url.h.
diego
parents: 25962
diff changeset
65 #include "gtk/gtk_url.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66 #include "gtk/eq.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67
33484
4f940d7917f0 Provide a desktop icon of reasonable size (48x48) and quality.
ib
parents: 33466
diff changeset
68 #include "pixmaps/mplayer.xpm"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
70 #define THRESHOLD 128 // transparency values equal to or above this will become
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
71 // opaque, all values below this will become transparent
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
72
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73 // --- init & close gtk
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
74
33529
276eef06fb3d Store icon data in a struct variable.
ib
parents: 33528
diff changeset
75 guiIcon_t guiIcon;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
77 void gtkInit(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
78 {
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
79 int argc = 0, i;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
80 char *arg[3], **argv = arg;
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
81 GdkPixbuf *pixbuf;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
82 GdkPixmap *gdkIcon;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
83 GdkBitmap *gdkIconMask;
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
84 guchar *data;
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
85
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
86 mp_msg(MSGT_GPLAYER, MSGL_V, "GTK init.\n");
33528
6f20f2a42b76 Do some gtkInit() cleanup.
ib
parents: 33527
diff changeset
87
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
88 arg[argc++] = GMPlayer;
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
89
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
90 if (mDisplayName) { // MPlayer option '-display' was given
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
91 arg[argc++] = "--display"; // Pass corresponding command line arguments to GTK,
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
92 arg[argc++] = mDisplayName; // to open the requested display for the GUI, too.
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
93 }
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
94
27343
5fe6a8adf569 Rename two GUI-related preprocessor directives:
diego
parents: 26458
diff changeset
95 #ifdef CONFIG_GTK2
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
96 gtk_disable_setlocale();
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
97 #endif
33528
6f20f2a42b76 Do some gtkInit() cleanup.
ib
parents: 33527
diff changeset
98
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
99 gtk_init(&argc, &argv);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
100
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
101 pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)mplayer_xpm);
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
102
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
103 gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, gdk_colormap_get_system(), &gdkIcon, &gdkIconMask, THRESHOLD);
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
104
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
105 if (gdk_pixbuf_get_colorspace(pixbuf) == GDK_COLORSPACE_RGB &&
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
106 gdk_pixbuf_get_n_channels(pixbuf) == 4 &&
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
107 gdk_pixbuf_get_bits_per_sample(pixbuf) == 8) {
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
108 guiIcon.collection_size = 2 + gdk_pixbuf_get_width(pixbuf) * gdk_pixbuf_get_height(pixbuf);
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
109
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
110 guiIcon.collection = malloc(guiIcon.collection_size * sizeof(*guiIcon.collection));
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
111
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
112 if (guiIcon.collection) {
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
113 guiIcon.collection[0] = gdk_pixbuf_get_width(pixbuf);
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
114 guiIcon.collection[1] = gdk_pixbuf_get_height(pixbuf);
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
115
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
116 data = gdk_pixbuf_get_pixels(pixbuf);
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
117
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
118 for (i = 2; i < guiIcon.collection_size; data += 4, i++)
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
119 guiIcon.collection[i] = (data[3] << 24) | AV_RB24(data); // RGBA -> ARGB
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
120 }
33551
5d5f66b52c62 Add a warning message for unavailable or unusable icons.
ib
parents: 33542
diff changeset
121 } else
5d5f66b52c62 Add a warning message for unavailable or unusable icons.
ib
parents: 33542
diff changeset
122 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_ICONERROR, "mplayer");
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
124 // start up GTK which realizes the pixmaps
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
125 gtk_main_iteration_do(FALSE);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
126
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
127 guiIcon.normal = GDK_PIXMAP_XID(gdkIcon);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
128 guiIcon.normal_mask = GDK_PIXMAP_XID(gdkIconMask);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
130 gtkInitialized = 1;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
131 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
132
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
133 void gtkAddIcon(GtkWidget *window)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
134 {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
135 wsSetIcon(gdk_display, GDK_WINDOW_XWINDOW(window->window), &guiIcon);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
136 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
138 void gtkClearList(GtkWidget *list)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
139 {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
140 gtk_clist_clear(GTK_CLIST(list));
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
143 int gtkFindCList(GtkWidget *list, char *item)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
144 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
145 gint j;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
146 gchar *tmpstr;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
147
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
148 for (j = 0; j < GTK_CLIST(list)->rows; j++) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
149 gtk_clist_get_text(GTK_CLIST(list), j, 0, &tmpstr);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
150
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
151 if (!strcmp(tmpstr, item))
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
152 return j;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
153 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
154
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
155 return -1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
156 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
157
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
158 void gtkSetDefaultToCList(GtkWidget *list, char *item)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
160 gint i;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
161
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
162 if ((i = gtkFindCList(list, item)) > -1)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
163 gtk_clist_select_row(GTK_CLIST(list), i, 0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
164 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
165
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
166 void gtkEventHandling(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
168 int i;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
169
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
170 for (i = 0; i < 25; i++)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
171 gtk_main_iteration_do(0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
172 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
173
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
174 // --- funcs
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
175
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
176 void gtkMessageBox(int type, const gchar *str)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
177 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
178 if (!gtkInitialized)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
179 return;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
180
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
181 ShowMessageBox(str);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
182 gtk_label_set_text(GTK_LABEL(gtkMessageBoxText), str);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
183
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
184 /* enable linewrapping by alex */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
185 // GTK_LABEL(gtkMessageBoxText)->max_width = 80;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
186 if (strlen(str) > 80)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
187 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
188 else
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
189 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
190
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
191 switch (type) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
192 case GTK_MB_FATAL:
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
193 gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_MSGBOX_LABEL_FatalError);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
194 gtk_widget_hide(WarningPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
195 gtk_widget_show(ErrorPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
196 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
197
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
198 case GTK_MB_ERROR:
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
199 gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_MSGBOX_LABEL_Error);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
200 gtk_widget_hide(WarningPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
201 gtk_widget_show(ErrorPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
202 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
203
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
204 case GTK_MB_WARNING:
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
205 gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_MSGBOX_LABEL_Warning);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
206 gtk_widget_show(WarningPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
207 gtk_widget_hide(ErrorPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
208 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
209 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
210
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
211 gtk_widget_show(MessageBox);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
212 gtkSetLayer(MessageBox);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
213
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
214 if (type == GTK_MB_FATAL)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
215 while (MessageBox)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
216 gtk_main_iteration_do(0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
217 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
218
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
219 void gtkSetLayer(GtkWidget *wdg)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27343
diff changeset
220 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
221 wsSetLayer(gdk_display, GDK_WINDOW_XWINDOW(wdg->window), appMPlayer.subWindow.isFullScreen);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
222 gtkActive(wdg);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
223 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
224
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
225 void gtkActive(GtkWidget *wdg)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
226 {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
227 wsMoveTopWindow(gdk_display, GDK_WINDOW_XWINDOW(wdg->window));
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
228 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
229
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
230 void gtkShow(int type, char *param)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
231 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
232 switch (type) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
233 case evEqualizer:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
234 ShowEqualizer();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
235 gtkSetLayer(Equalizer);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
236 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
237
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
238 case evSkinBrowser:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
239 ShowSkinBrowser();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
240
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
241 // gtkClearList( SkinList );
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
242 if (gtkFillSkinList(sbMPlayerPrefixDir) &&
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
243 gtkFillSkinList(sbMPlayerDirInHome)) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
244 gtkSetDefaultToCList(SkinList, param);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
245 gtk_clist_sort(GTK_CLIST(SkinList));
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
246 gtk_widget_show(SkinBrowser);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
247 gtkSetLayer(SkinBrowser);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
248 } else {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
249 gtk_widget_destroy(SkinBrowser);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
250 gtkMessageBox(GTK_MB_ERROR, "Skin dirs not found ... Please install skins.");
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
251 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
252
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
253 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
254
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
255 case evPreferences:
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
256 ShowPreferences();
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
257 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
258
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
259 case evPlayList:
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
260 ShowPlayList();
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
261 gtkSetLayer(PlayList);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
262 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
263
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
264 case evLoad:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
265 ShowFileSelect(fsVideoSelector, 0);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
266 gtkSetLayer(fsFileSelect);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
267 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
268
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
269 case evFirstLoad:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
270 ShowFileSelect(fsVideoSelector, 0);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
271 gtkSetLayer(fsFileSelect);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
272 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
273
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
274 case evLoadSubtitle:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
275 ShowFileSelect(fsSubtitleSelector, 0);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
276 gtkSetLayer(fsFileSelect);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
277 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
278
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
279 case evLoadAudioFile:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
280 ShowFileSelect(fsAudioSelector, 0);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
281 gtkSetLayer(fsFileSelect);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
282 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
283
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
284 case evAbout:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
285 ShowAboutBox();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
286 gtkSetLayer(About);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
287 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
288
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
289 case evShowPopUpMenu:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
290 gtkPopupMenu = evNone;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
291 gtkPopupMenuParam = 0;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
292
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
293 if (PopUpMenu) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
294 gtk_widget_hide(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
295 gtk_widget_destroy(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
296 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
297
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
298 PopUpMenu = create_PopUpMenu();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
299 gtk_menu_popup(GTK_MENU(PopUpMenu), NULL, NULL, NULL, NULL, 0, 0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
300 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
301
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
302 case evHidePopUpMenu:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
303
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
304 if (PopUpMenu) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
305 gtk_widget_hide(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
306 gtk_widget_destroy(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
307 PopUpMenu = NULL;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
308 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
309
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
310 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
311
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
312 case evPlayNetwork:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
313 ShowURLDialogBox();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
314 gtkSetLayer(URL);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
315 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
316 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
317 }