annotate gui/dialog/dialog.c @ 37176:2208a16cc562

Remove GTK+ and GLib versions 1 relatedness from the GUI. This isn't really a cut-back, because although it seemed that compiling with GTK+ and GLib versions 1 were possible, compiling actually hadn't been possible for quite some time.
author ib
date Mon, 08 Sep 2014 20:17:01 +0000
parents b28b632efeef
children
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
36040
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
19 #include <stdint.h>
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
20 #include <stdlib.h>
36040
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
21 #include <string.h>
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
22 #include <gdk/gdkx.h>
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23
36040
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
24 #include "dialog.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
25 #include "about.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
26 #include "equalizer.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
27 #include "fileselect.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
28 #include "menu.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
29 #include "msgbox.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
30 #include "playlist.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
31 #include "preferences.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
32 #include "skinbrowser.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
33 #include "tools.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
34 #include "url.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
35 #include "gui/interface.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
36 #include "gui/app/app.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
37 #include "gui/app/gui.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
38 #include "gui/util/string.h"
5ecbf382ff26 Group and sort #includes, remove unneeded ones.
ib
parents: 36037
diff changeset
39 #include "gui/wm/ws.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
40
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
41 #include "config.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
42 #include "help_mp.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
43 #include "mp_msg.h"
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
44 #include "libavutil/intreadwrite.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
45
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
46 #define THRESHOLD 128 // transparency values equal to or above this will become
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
47 // opaque, all values below this will become transparent
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
48
33529
276eef06fb3d Store icon data in a struct variable.
ib
parents: 33528
diff changeset
49 guiIcon_t guiIcon;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36048
diff changeset
51 static const char guiIconName[] = "mplayer";
36048
e3e9b31b1088 Cosmetic: Rearrange definitions.
ib
parents: 36044
diff changeset
52
e3e9b31b1088 Cosmetic: Rearrange definitions.
ib
parents: 36044
diff changeset
53 static GtkWidget *PopUpMenu;
e3e9b31b1088 Cosmetic: Rearrange definitions.
ib
parents: 36044
diff changeset
54
e3e9b31b1088 Cosmetic: Rearrange definitions.
ib
parents: 36044
diff changeset
55 static int gtkInitialized;
e3e9b31b1088 Cosmetic: Rearrange definitions.
ib
parents: 36044
diff changeset
56
35643
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
57 /**
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
58 * @brief Add an icon to the #guiIcon icon structure.
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
59 *
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
60 * @param theme theme to load the icon from
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
61 * @param size size of the icon to load
37065
b28b632efeef Cosmetic: Revise a few comments.
ib
parents: 36694
diff changeset
62 * @param gdkIcon memory location to store a pointer to the created pixmap
b28b632efeef Cosmetic: Revise a few comments.
ib
parents: 36694
diff changeset
63 * @param gdkIconMask memory location to store a pointer to the created mask
35643
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
64 *
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
65 * @return #True (ok) or #False (error)
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
66 */
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
67 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
68 {
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
69 GdkPixbuf *pixbuf;
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
70 guchar *data;
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
71 int csize, i;
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
72
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36048
diff changeset
73 pixbuf = gtk_icon_theme_load_icon(theme, guiIconName, size, 0, NULL);
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
74
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
75 if (pixbuf)
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
76 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
77
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
78 if (pixbuf &&
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
79 gdk_pixbuf_get_colorspace(pixbuf) == GDK_COLORSPACE_RGB &&
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
80 gdk_pixbuf_get_n_channels(pixbuf) == 4 &&
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
81 gdk_pixbuf_get_bits_per_sample(pixbuf) == 8) {
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
82 csize = guiIcon.collection_size;
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
83 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
84
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
85 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
86
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
87 if (guiIcon.collection) {
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
88 guiIcon.collection[csize++] = gdk_pixbuf_get_width(pixbuf);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
89 guiIcon.collection[csize++] = gdk_pixbuf_get_height(pixbuf);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
90
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
91 data = gdk_pixbuf_get_pixels(pixbuf);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
92
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
93 for (i = csize; i < guiIcon.collection_size; data += 4, i++)
35703
c0d48e21b9fc Cosmetic: Remove/adjust comments.
ib
parents: 35681
diff changeset
94 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
95 }
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
96
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
97 g_object_unref(pixbuf);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
98 } else
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36680
diff changeset
99 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_GUI_MSG_IconError, guiIconName, size);
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
100
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34596
diff changeset
101 /* start up GTK which realizes the pixmaps */
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
102 gtk_main_iteration_do(FALSE);
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
103
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
104 return (pixbuf != NULL);
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
105 }
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
106
35643
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
107 /**
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
108 * @brief Initialize the GTK user interface.
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
109 *
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
110 * @param display_name name of the X display to use or NULL (using the DISPLAY environment variable)
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
111 */
35629
365dc9336f0d Pass parameter instead of using global variable.
ib
parents: 35624
diff changeset
112 void gtkInit(char *display_name)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113 {
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
114 int argc = 0;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
115 char *arg[3], **argv = arg;
35873
65f7b2fdda46 Add a warning message about @locale in G_FILENAME_ENCODING.
ib
parents: 35703
diff changeset
116 char *env;
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
117 GtkIconTheme *theme;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
118 GdkPixmap *gdkIcon;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
119 GdkBitmap *gdkIconMask;
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
120
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
121 mp_msg(MSGT_GPLAYER, MSGL_V, "GTK init.\n");
33528
6f20f2a42b76 Do some gtkInit() cleanup.
ib
parents: 33527
diff changeset
122
36054
1562f350e8d2 Cosmetic: Rename GMPlayer definition gmplayer.
ib
parents: 36049
diff changeset
123 arg[argc++] = gmplayer;
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
124
35703
c0d48e21b9fc Cosmetic: Remove/adjust comments.
ib
parents: 35681
diff changeset
125 if (display_name) { // MPlayer option '-display' was given
c0d48e21b9fc Cosmetic: Remove/adjust comments.
ib
parents: 35681
diff changeset
126 arg[argc++] = "--display"; // Pass corresponding command line arguments to GTK,
35629
365dc9336f0d Pass parameter instead of using global variable.
ib
parents: 35624
diff changeset
127 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
128 }
33465
b0430e293333 Take notice of MPlayer option '-display'.
ib
parents: 33314
diff changeset
129
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
130 gtk_disable_setlocale();
35873
65f7b2fdda46 Add a warning message about @locale in G_FILENAME_ENCODING.
ib
parents: 35703
diff changeset
131
65f7b2fdda46 Add a warning message about @locale in G_FILENAME_ENCODING.
ib
parents: 35703
diff changeset
132 env = getenv("G_FILENAME_ENCODING");
65f7b2fdda46 Add a warning message about @locale in G_FILENAME_ENCODING.
ib
parents: 35703
diff changeset
133
65f7b2fdda46 Add a warning message about @locale in G_FILENAME_ENCODING.
ib
parents: 35703
diff changeset
134 if ((!env && getenv("G_BROKEN_FILENAMES")) || (gstrncmp(env, "@locale", 7) == 0))
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36680
diff changeset
135 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_GUI_MSG_LocaleEncoding);
33528
6f20f2a42b76 Do some gtkInit() cleanup.
ib
parents: 33527
diff changeset
136
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
137 gtk_init(&argc, &argv);
35703
c0d48e21b9fc Cosmetic: Remove/adjust comments.
ib
parents: 35681
diff changeset
138 wsSetErrorHandler(); // GDK has just set its own handler
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
139
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
140 theme = gtk_icon_theme_get_default();
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
141
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
142 if (gtkLoadIcon(theme, 16, &gdkIcon, &gdkIconMask)) {
34781
bdf54c7f4eb6 Cosmetic: Adjust indent.
ib
parents: 34780
diff changeset
143 guiIcon.small = GDK_PIXMAP_XID(gdkIcon);
bdf54c7f4eb6 Cosmetic: Adjust indent.
ib
parents: 34780
diff changeset
144 guiIcon.small_mask = GDK_PIXMAP_XID(gdkIconMask);
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
145 }
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33538
diff changeset
146
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
147 if (gtkLoadIcon(theme, 32, &gdkIcon, &gdkIconMask)) {
34781
bdf54c7f4eb6 Cosmetic: Adjust indent.
ib
parents: 34780
diff changeset
148 guiIcon.normal = GDK_PIXMAP_XID(gdkIcon);
bdf54c7f4eb6 Cosmetic: Adjust indent.
ib
parents: 34780
diff changeset
149 guiIcon.normal_mask = GDK_PIXMAP_XID(gdkIconMask);
34780
70d16eb7899e Fix crash with icon that has unsupported format.
ib
parents: 34697
diff changeset
150 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
151
34480
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
152 gtkLoadIcon(theme, 48, &gdkIcon, &gdkIconMask);
6c6fb701fa8e Add differently sized, new icons for the GUI.
ib
parents: 34333
diff changeset
153
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35361
diff changeset
154 gtkInitialized = True;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
155 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
156
35643
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
157 /**
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
158 * @brief Add the #guiIcon icons to a GTK window.
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
159 *
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
160 * @param window pointer to a GtkWindow widget
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
161 */
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
162 void gtkAddIcon(GtkWidget *window)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
163 {
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35643
diff changeset
164 wsWindowIcon(gdk_display, GDK_WINDOW_XWINDOW(window->window), &guiIcon);
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
165 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166
36071
989b5d955703 Revise gtkEvents().
ib
parents: 36070
diff changeset
167 /**
989b5d955703 Revise gtkEvents().
ib
parents: 36070
diff changeset
168 * @brief Process all pending events.
989b5d955703 Revise gtkEvents().
ib
parents: 36070
diff changeset
169 */
36070
6c3dc8fec01f Rename gtkEventHandling() gtkEvents().
ib
parents: 36054
diff changeset
170 void gtkEvents(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
171 {
36071
989b5d955703 Revise gtkEvents().
ib
parents: 36070
diff changeset
172 while (gtk_events_pending())
989b5d955703 Revise gtkEvents().
ib
parents: 36070
diff changeset
173 gtk_main_iteration();
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
174 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
175
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34596
diff changeset
176 /* funcs */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
177
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
178 void gtkMessageBox(int type, const gchar *str)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
179 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
180 if (!gtkInitialized)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
181 return;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
182
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
183 ShowMessageBox(str);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
184 gtk_label_set_text(GTK_LABEL(gtkMessageBoxText), str);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
185
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
186 /* enable linewrapping by alex */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
187 // GTK_LABEL(gtkMessageBoxText)->max_width = 80;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
188 if (strlen(str) > 80)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
189 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
190 else
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
191 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
192
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
193 switch (type) {
36036
2421356e2a03 Make #defines enums.
ib
parents: 36034
diff changeset
194 case MSGBOX_FATAL:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36680
diff changeset
195 gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_GUI_ErrorFatal);
36680
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36071
diff changeset
196 gtk_widget_hide(InformationPixmap);
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
197 gtk_widget_hide(WarningPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
198 gtk_widget_show(ErrorPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
199 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
200
36036
2421356e2a03 Make #defines enums.
ib
parents: 36034
diff changeset
201 case MSGBOX_ERROR:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36680
diff changeset
202 gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_GUI_Error);
36680
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36071
diff changeset
203 gtk_widget_hide(InformationPixmap);
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
204 gtk_widget_hide(WarningPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
205 gtk_widget_show(ErrorPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
206 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
207
36036
2421356e2a03 Make #defines enums.
ib
parents: 36034
diff changeset
208 case MSGBOX_WARNING:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36680
diff changeset
209 gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_GUI_Warning);
36680
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36071
diff changeset
210 gtk_widget_hide(InformationPixmap);
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
211 gtk_widget_show(WarningPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
212 gtk_widget_hide(ErrorPixmap);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
213 break;
36680
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36071
diff changeset
214
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36071
diff changeset
215 case MSGBOX_INFORMATION:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36680
diff changeset
216 gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_GUI_Information);
36680
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36071
diff changeset
217 gtk_widget_show(InformationPixmap);
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36071
diff changeset
218 gtk_widget_hide(WarningPixmap);
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36071
diff changeset
219 gtk_widget_hide(ErrorPixmap);
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36071
diff changeset
220 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
221 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
222
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
223 gtk_widget_show(MessageBox);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
224 gtkSetLayer(MessageBox);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
225
36036
2421356e2a03 Make #defines enums.
ib
parents: 36034
diff changeset
226 if (type == MSGBOX_FATAL)
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
227 while (MessageBox)
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
228 gtk_main_iteration_do(0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
229 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
230
35643
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
231 /**
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
232 * @brief Set the layer for a GTK window.
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
233 *
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
234 * @param window pointer to a GtkWindow widget
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
235 */
35638
78d9cfd68b34 Cosmetic: Use parameter name 'window' for a GtkWindow.
ib
parents: 35636
diff changeset
236 void gtkSetLayer(GtkWidget *window)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27343
diff changeset
237 {
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35643
diff changeset
238 wsWindowLayer(gdk_display, GDK_WINDOW_XWINDOW(window->window), guiApp.videoWindow.isFullScreen);
36019
d2d776c8e040 Cosmetic: Rename gtkActive() gtkRaise().
ib
parents: 35996
diff changeset
239 gtkRaise(window);
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
240 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
241
35643
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
242 /**
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
243 * @brief Activate a GTK window, i.e. raise it to the top.
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
244 *
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
245 * @param window pointer to a GtkWindow widget
f8eb470c25ea Add doxygen comments.
ib
parents: 35638
diff changeset
246 */
36019
d2d776c8e040 Cosmetic: Rename gtkActive() gtkRaise().
ib
parents: 35996
diff changeset
247 void gtkRaise(GtkWidget *window)
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
248 {
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35643
diff changeset
249 wsWindowRaiseTop(gdk_display, GDK_WINDOW_XWINDOW(window->window));
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
250 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
251
36022
bf5690e00dc6 Cosmetic: Relocate gtkSelectInCList().
ib
parents: 36021
diff changeset
252 static void gtkSelectInCList(GtkWidget *list, char *item)
bf5690e00dc6 Cosmetic: Relocate gtkSelectInCList().
ib
parents: 36021
diff changeset
253 {
bf5690e00dc6 Cosmetic: Relocate gtkSelectInCList().
ib
parents: 36021
diff changeset
254 gint i;
bf5690e00dc6 Cosmetic: Relocate gtkSelectInCList().
ib
parents: 36021
diff changeset
255
36024
a9e5f317d6e4 Move gtkFindCList() to tools.c.
ib
parents: 36022
diff changeset
256 if ((i = gtkFindInCList(list, item)) > -1)
36022
bf5690e00dc6 Cosmetic: Relocate gtkSelectInCList().
ib
parents: 36021
diff changeset
257 gtk_clist_select_row(GTK_CLIST(list), i, 0);
bf5690e00dc6 Cosmetic: Relocate gtkSelectInCList().
ib
parents: 36021
diff changeset
258 }
bf5690e00dc6 Cosmetic: Relocate gtkSelectInCList().
ib
parents: 36021
diff changeset
259
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
260 void gtkShow(int type, char *param)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
261 {
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
262 switch (type) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
263 case evEqualizer:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
264 ShowEqualizer();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
265 gtkSetLayer(Equalizer);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
266 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
267
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
268 case evSkinBrowser:
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
269 ShowSkinBrowser();
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
270
36020
ecf86ae01e4e Remove unused gtkClearList().
ib
parents: 36019
diff changeset
271 // gtk_clist_clear(GTK_CLIST(SkinList));
36044
7898b9b8ac51 Cosmetic: Switch conditions (for consistency).
ib
parents: 36043
diff changeset
272 if (FillSkinList(sbSkinDirInHome) &&
7898b9b8ac51 Cosmetic: Switch conditions (for consistency).
ib
parents: 36043
diff changeset
273 FillSkinList(sbSkinDirInData)) {
36021
bc1d68f48ca5 Make gtkSetDefaultToCList() static.
ib
parents: 36020
diff changeset
274 gtkSelectInCList(SkinList, param);
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
275 gtk_clist_sort(GTK_CLIST(SkinList));
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
276 gtk_widget_show(SkinBrowser);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
277 gtkSetLayer(SkinBrowser);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
278 } else {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
279 gtk_widget_destroy(SkinBrowser);
36036
2421356e2a03 Make #defines enums.
ib
parents: 36034
diff changeset
280 gtkMessageBox(MSGBOX_ERROR, "Skin dirs not found ... Please install skins.");
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
281 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
282
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
283 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
284
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
285 case evPreferences:
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
286 ShowPreferences();
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
287 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
288
34321
daebf766dea6 Cosmetic: Synchronize evPlaylist event and message names.
ib
parents: 33990
diff changeset
289 case evPlaylist:
35981
1d11ed014a53 Cosmetic: Rename ShowPlayList() ShowPlaylist().
ib
parents: 35978
diff changeset
290 ShowPlaylist();
1d11ed014a53 Cosmetic: Rename ShowPlayList() ShowPlaylist().
ib
parents: 35978
diff changeset
291 gtkSetLayer(Playlist);
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 evLoad:
35976
6eaf7941b762 Rename ShowFileSelect() ShowFileSelector().
ib
parents: 35975
diff changeset
295 ShowFileSelector(FILESELECT_VIDEO_AUDIO);
35975
16f60d1a3b7f Rename extern GTK widget fsFileSelect FileSelector.
ib
parents: 35974
diff changeset
296 gtkSetLayer(FileSelector);
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 evLoadSubtitle:
35976
6eaf7941b762 Rename ShowFileSelect() ShowFileSelector().
ib
parents: 35975
diff changeset
300 ShowFileSelector(FILESELECT_SUBTITLE);
35975
16f60d1a3b7f Rename extern GTK widget fsFileSelect FileSelector.
ib
parents: 35974
diff changeset
301 gtkSetLayer(FileSelector);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
302 break;
33538
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 evLoadAudioFile:
35976
6eaf7941b762 Rename ShowFileSelect() ShowFileSelector().
ib
parents: 35975
diff changeset
305 ShowFileSelector(FILESELECT_AUDIO);
35975
16f60d1a3b7f Rename extern GTK widget fsFileSelect FileSelector.
ib
parents: 35974
diff changeset
306 gtkSetLayer(FileSelector);
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
307 break;
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 case evAbout:
35977
3734172b4af6 Cosmetic: Rename ShowAboutBox() ShowAbout().
ib
parents: 35976
diff changeset
310 ShowAbout();
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
311 gtkSetLayer(About);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
312 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
313
34333
e8e4e6f9b7ac Change prefix for internal events from ev to iv.
ib
parents: 34331
diff changeset
314 case ivShowPopUpMenu:
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
315 gtkPopupMenu = evNone;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
316 gtkPopupMenuParam = 0;
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 if (PopUpMenu) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
319 gtk_widget_hide(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
320 gtk_widget_destroy(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
321 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
322
35996
6c891a0e3fea Cosmetic: Rename the functions creating the dialogs.
ib
parents: 35981
diff changeset
323 PopUpMenu = CreatePopUpMenu();
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
324 gtk_menu_popup(GTK_MENU(PopUpMenu), NULL, NULL, NULL, NULL, 0, 0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
325 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
326
34333
e8e4e6f9b7ac Change prefix for internal events from ev to iv.
ib
parents: 34331
diff changeset
327 case ivHidePopUpMenu:
33538
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 if (PopUpMenu) {
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
330 gtk_widget_hide(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
331 gtk_widget_destroy(PopUpMenu);
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
332 PopUpMenu = NULL;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
333 }
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
334
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
335 break;
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
336
34329
d7c8a3cee15e Replace evPlayNetwork by evLoadURL.
ib
parents: 34321
diff changeset
337 case evLoadURL:
35978
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35977
diff changeset
338 ShowURLDialog();
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35977
diff changeset
339 gtkSetLayer(URLDialog);
33538
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
340 break;
64e43eb13ebf Cosmetic: Format to MPlayer coding style.
ib
parents: 33530
diff changeset
341 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
342 }