annotate gui/dialog/dialog.c @ 35629:365dc9336f0d

Pass parameter instead of using global variable.
author ib
date Thu, 10 Jan 2013 11:20:18 +0000
parents ce4b3cbeb1d0
children 840e473ba4c0
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>
35361
3e8dcfa3ceef Prevent unintended sign extension from int to long on 64-bit machines.
ib
parents: 34781
diff changeset
21 #include <stdint.h>
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
22
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23 #include <sys/types.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 #include <sys/stat.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 #include <sys/wait.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26 #include <unistd.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28 #include <signal.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
29
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
30 #include <gdk/gdkprivate.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
31 #include <gdk/gdkkeysyms.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
32 #include <gdk/gdkx.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
33 #include <gdk/gdk.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
34 #include <gtk/gtk.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
35
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
36 #include "config.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
37 #include "help_mp.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
38 #include "mp_msg.h"
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
39 #include "libavutil/intreadwrite.h"
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
40 #include "libvo/x11_common.h"
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
41
35529
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
42 #include "dialog.h"
35525
e27855a45128 Rebuild GUI directory structure.
ib
parents: 35493
diff changeset
43 #include "gui/app/app.h"
e27855a45128 Rebuild GUI directory structure.
ib
parents: 35493
diff changeset
44 #include "gui/app/gui.h"
33466
45d8bfbd27bc Define "gmplayer" as symbolic constant.
ib
parents: 33465
diff changeset
45 #include "gui/interface.h"
26365
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 26203
diff changeset
46 #include "gui/wm/ws.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47
35529
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
48 #include "gui/ui/actions.h"
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
49 #include "fileselect.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50
35623
46b3d0bb76e0 Make variables static that are only used inside the file.
ib
parents: 35529
diff changeset
51 static GtkWidget *PopUpMenu;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
52
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
53 GtkWidget *WarningPixmap;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
54 GtkWidget *ErrorPixmap;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
55
35624
ce4b3cbeb1d0 Remove unnecessary initialization.
ib
parents: 35623
diff changeset
56 int gtkPopupMenu;
ce4b3cbeb1d0 Remove unnecessary initialization.
ib
parents: 35623
diff changeset
57 int gtkPopupMenuParam;
35623
46b3d0bb76e0 Make variables static that are only used inside the file.
ib
parents: 35529
diff changeset
58 static int gtkInitialized;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
59
35529
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
60 #include "skinbrowser.h"
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
61 #include "playlist.h"
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
62 #include "msgbox.h"
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
63 #include "about.h"
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
64 #include "preferences.h"
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
65 #include "menu.h"
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
66 #include "url.h"
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
67 #include "equalizer.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68
34596
04feb00f91be Prefer static const char arrays for string constants to #defines.
ib
parents: 34481
diff changeset
69 static const char gui_icon_name[] = "mplayer";
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
70
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
71 #define THRESHOLD 128 // transparency values equal to or above this will become
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
72 // opaque, all values below this will become transparent
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
73
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34596
diff changeset
74 /* init & close gtk */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75
33529
276eef06fb3d Store icon data in a struct variable.
ib
parents: 33528
diff changeset
76 guiIcon_t guiIcon;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
77
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
78 static int gtkLoadIcon(GtkIconTheme *theme, gint size, GdkPixmap **gdkIcon, GdkBitmap **gdkIconMask)
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
79 {
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
80 GdkPixbuf *pixbuf;
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
81 guchar *data;
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
82 int csize, i;
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
83
34596
04feb00f91be Prefer static const char arrays for string constants to #defines.
ib
parents: 34481
diff changeset
84 pixbuf = gtk_icon_theme_load_icon(theme, gui_icon_name, size, 0, NULL);
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
85
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
86 if (pixbuf)
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
87 gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, gdk_colormap_get_system(), gdkIcon, gdkIconMask, THRESHOLD);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
88
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
89 if (pixbuf &&
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
90 gdk_pixbuf_get_colorspace(pixbuf) == GDK_COLORSPACE_RGB &&
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
91 gdk_pixbuf_get_n_channels(pixbuf) == 4 &&
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
92 gdk_pixbuf_get_bits_per_sample(pixbuf) == 8) {
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
93 csize = guiIcon.collection_size;
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
94 guiIcon.collection_size += 2 + gdk_pixbuf_get_width(pixbuf) * gdk_pixbuf_get_height(pixbuf);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
95
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
96 guiIcon.collection = realloc(guiIcon.collection, guiIcon.collection_size * sizeof(*guiIcon.collection));
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
97
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
98 if (guiIcon.collection) {
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
99 guiIcon.collection[csize++] = gdk_pixbuf_get_width(pixbuf);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
100 guiIcon.collection[csize++] = gdk_pixbuf_get_height(pixbuf);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
101
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
102 data = gdk_pixbuf_get_pixels(pixbuf);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
103
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
104 for (i = csize; i < guiIcon.collection_size; data += 4, i++)
35361
3e8dcfa3ceef Prevent unintended sign extension from int to long on 64-bit machines.
ib
parents: 34781
diff changeset
105 guiIcon.collection[i] = (uint32_t)(data[3] << 24) | AV_RB24(data); // RGBA -> ARGB
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
106 }
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
107
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
108 g_object_unref(pixbuf);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
109 } else
34596
04feb00f91be Prefer static const char arrays for string constants to #defines.
ib
parents: 34481
diff changeset
110 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_ICONERROR, gui_icon_name, size);
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
111
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34596
diff changeset
112 /* start up GTK which realizes the pixmaps */
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
113 gtk_main_iteration_do(FALSE);
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
114
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
115 return (pixbuf != NULL);
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
116 }
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
117
35629
365dc9336f0d Pass parameter instead of using global variable.
ib
parents: 35624
diff changeset
118 void gtkInit(char *display_name)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119 {
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
120 int argc = 0;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
121 char *arg[3], **argv = arg;
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
122 GtkIconTheme *theme;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
123 GdkPixmap *gdkIcon;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
124 GdkBitmap *gdkIconMask;
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
125
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
126 mp_msg(MSGT_GPLAYER, MSGL_V, "GTK init.\n");
33528
6f20f2a42b76 Do some gtkInit() cleanup.
ib
parents: 33527
diff changeset
127
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
128 arg[argc++] = GMPlayer;
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
129
35629
365dc9336f0d Pass parameter instead of using global variable.
ib
parents: 35624
diff changeset
130 if (display_name) { // MPlayer option '-display' was given
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
131 arg[argc++] = "--display"; // Pass corresponding command line arguments to GTK,
35629
365dc9336f0d Pass parameter instead of using global variable.
ib
parents: 35624
diff changeset
132 arg[argc++] = display_name; // to open the requested display for the GUI, too.
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
133 }
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
134
27343
5fe6a8adf569 Rename two GUI-related preprocessor directives:
diego
parents: 26458
diff changeset
135 #ifdef CONFIG_GTK2
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
136 gtk_disable_setlocale();
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137 #endif
33528
6f20f2a42b76 Do some gtkInit() cleanup.
ib
parents: 33527
diff changeset
138
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
139 gtk_init(&argc, &argv);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
140
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
141 theme = gtk_icon_theme_get_default();
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
142
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
143 if (gtkLoadIcon(theme, 16, &gdkIcon, &gdkIconMask)) {
34781
bdf54c7f4eb6 Cosmetic: Adjust indent.
ib
parents: 34780
diff changeset
144 guiIcon.small = GDK_PIXMAP_XID(gdkIcon);
bdf54c7f4eb6 Cosmetic: Adjust indent.
ib
parents: 34780
diff changeset
145 guiIcon.small_mask = GDK_PIXMAP_XID(gdkIconMask);
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
146 }
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
147
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
148 if (gtkLoadIcon(theme, 32, &gdkIcon, &gdkIconMask)) {
34781
bdf54c7f4eb6 Cosmetic: Adjust indent.
ib
parents: 34780
diff changeset
149 guiIcon.normal = GDK_PIXMAP_XID(gdkIcon);
bdf54c7f4eb6 Cosmetic: Adjust indent.
ib
parents: 34780
diff changeset
150 guiIcon.normal_mask = GDK_PIXMAP_XID(gdkIconMask);
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
151 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
153 gtkLoadIcon(theme, 48, &gdkIcon, &gdkIconMask);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
154
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35361
diff changeset
155 gtkInitialized = True;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
156 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
157
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
158 void gtkAddIcon(GtkWidget *window)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
159 {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
160 wsSetIcon(gdk_display, GDK_WINDOW_XWINDOW(window->window), &guiIcon);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
161 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
162
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
163 void gtkClearList(GtkWidget *list)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
164 {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
165 gtk_clist_clear(GTK_CLIST(list));
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
168 int gtkFindCList(GtkWidget *list, char *item)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
169 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
170 gint j;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
171 gchar *tmpstr;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
172
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
173 for (j = 0; j < GTK_CLIST(list)->rows; j++) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
174 gtk_clist_get_text(GTK_CLIST(list), j, 0, &tmpstr);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
175
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
176 if (!strcmp(tmpstr, item))
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
177 return j;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
178 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
179
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
180 return -1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
181 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
182
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
183 void gtkSetDefaultToCList(GtkWidget *list, char *item)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
184 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
185 gint i;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
186
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
187 if ((i = gtkFindCList(list, item)) > -1)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
188 gtk_clist_select_row(GTK_CLIST(list), i, 0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
190
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
191 void gtkEventHandling(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
192 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
193 int i;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
194
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
195 for (i = 0; i < 25; i++)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
196 gtk_main_iteration_do(0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
197 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
198
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34596
diff changeset
199 /* funcs */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
200
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
201 void gtkMessageBox(int type, const gchar *str)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
202 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
203 if (!gtkInitialized)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
204 return;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
205
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
206 ShowMessageBox(str);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
207 gtk_label_set_text(GTK_LABEL(gtkMessageBoxText), str);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
208
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
209 /* enable linewrapping by alex */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
210 // GTK_LABEL(gtkMessageBoxText)->max_width = 80;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
211 if (strlen(str) > 80)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
212 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
213 else
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
214 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
215
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
216 switch (type) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
217 case GTK_MB_FATAL:
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
218 gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_MSGBOX_LABEL_FatalError);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
219 gtk_widget_hide(WarningPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
220 gtk_widget_show(ErrorPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
221 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
222
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
223 case GTK_MB_ERROR:
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
224 gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_MSGBOX_LABEL_Error);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
225 gtk_widget_hide(WarningPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
226 gtk_widget_show(ErrorPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
227 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
228
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
229 case GTK_MB_WARNING:
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
230 gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_MSGBOX_LABEL_Warning);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
231 gtk_widget_show(WarningPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
232 gtk_widget_hide(ErrorPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
233 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
234 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
235
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
236 gtk_widget_show(MessageBox);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
237 gtkSetLayer(MessageBox);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
238
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
239 if (type == GTK_MB_FATAL)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
240 while (MessageBox)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
241 gtk_main_iteration_do(0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
242 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
243
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
244 void gtkSetLayer(GtkWidget *wdg)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27343
diff changeset
245 {
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34684
diff changeset
246 wsSetLayer(gdk_display, GDK_WINDOW_XWINDOW(wdg->window), guiApp.videoWindow.isFullScreen);
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
247 gtkActive(wdg);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
248 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
249
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
250 void gtkActive(GtkWidget *wdg)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
251 {
33990
3a93b9227b01 Cosmetic: Rename wsMoveTopWindow() wsRaiseWindowTop().
ib
parents: 33572
diff changeset
252 wsRaiseWindowTop(gdk_display, GDK_WINDOW_XWINDOW(wdg->window));
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
253 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
254
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
255 void gtkShow(int type, char *param)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
256 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
257 switch (type) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
258 case evEqualizer:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
259 ShowEqualizer();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
260 gtkSetLayer(Equalizer);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
261 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
262
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
263 case evSkinBrowser:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
264 ShowSkinBrowser();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
265
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
266 // gtkClearList( SkinList );
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
267 if (gtkFillSkinList(sbMPlayerPrefixDir) &&
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
268 gtkFillSkinList(sbMPlayerDirInHome)) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
269 gtkSetDefaultToCList(SkinList, param);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
270 gtk_clist_sort(GTK_CLIST(SkinList));
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
271 gtk_widget_show(SkinBrowser);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
272 gtkSetLayer(SkinBrowser);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
273 } else {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
274 gtk_widget_destroy(SkinBrowser);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
275 gtkMessageBox(GTK_MB_ERROR, "Skin dirs not found ... Please install skins.");
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
276 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
277
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
278 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
279
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
280 case evPreferences:
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
281 ShowPreferences();
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
282 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
283
34321
daebf766dea6 Cosmetic: Synchronize evPlaylist event and message names.
ib
parents: 33990
diff changeset
284 case evPlaylist:
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
285 ShowPlayList();
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
286 gtkSetLayer(PlayList);
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 evLoad:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
290 ShowFileSelect(fsVideoSelector, 0);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
291 gtkSetLayer(fsFileSelect);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
292 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
293
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
294 case evLoadSubtitle:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
295 ShowFileSelect(fsSubtitleSelector, 0);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
296 gtkSetLayer(fsFileSelect);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
297 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
298
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
299 case evLoadAudioFile:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
300 ShowFileSelect(fsAudioSelector, 0);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
301 gtkSetLayer(fsFileSelect);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
302 break;
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 case evAbout:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
305 ShowAboutBox();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
306 gtkSetLayer(About);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
307 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
308
34333
e8e4e6f9b7ac Change prefix for internal events from ev to iv.
ib
parents: 34331
diff changeset
309 case ivShowPopUpMenu:
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
310 gtkPopupMenu = evNone;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
311 gtkPopupMenuParam = 0;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
312
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
313 if (PopUpMenu) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
314 gtk_widget_hide(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
315 gtk_widget_destroy(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
316 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
317
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
318 PopUpMenu = create_PopUpMenu();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
319 gtk_menu_popup(GTK_MENU(PopUpMenu), NULL, NULL, NULL, NULL, 0, 0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
320 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
321
34333
e8e4e6f9b7ac Change prefix for internal events from ev to iv.
ib
parents: 34331
diff changeset
322 case ivHidePopUpMenu:
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
323
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
324 if (PopUpMenu) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
325 gtk_widget_hide(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
326 gtk_widget_destroy(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
327 PopUpMenu = NULL;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
328 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
329
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
330 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
331
34329
d7c8a3cee15e Replace evPlayNetwork by evLoadURL.
ib
parents: 34321
diff changeset
332 case evLoadURL:
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
333 ShowURLDialogBox();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
334 gtkSetLayer(URL);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
335 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
336 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
337 }