Mercurial > audlegacy
annotate audacious/ui_playlist.c @ 1538:fe671cb74bf9 trunk
[svn] - fix geometry hinting so that it is ICCCM compliant. patch by whereami.
Also fixes: composite and xgl!
author | nenolod |
---|---|
date | Tue, 08 Aug 2006 23:43:33 -0700 |
parents | 705d4c089fce |
children | 06329cbf186a |
rev | line source |
---|---|
1068 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2006 Audacious development team. | |
3 * | |
4 * BMP - Cross-platform multimedia player | |
0 | 5 * Copyright (C) 2003-2004 BMP development team. |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
1459 | 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
0 | 23 */ |
24 | |
383 | 25 #include "ui_playlist.h" |
0 | 26 |
27 #include <glib.h> | |
28 #include <glib/gi18n.h> | |
29 #include <gdk/gdk.h> | |
30 #include <gdk/gdkkeysyms.h> | |
31 #include <gtk/gtk.h> | |
32 #include <string.h> | |
33 | |
34 #include <gdk/gdkx.h> | |
35 | |
36 #include <X11/Xlib.h> | |
37 #include <unistd.h> | |
38 #include <errno.h> | |
39 | |
40 #include "libaudacious/util.h" | |
41 | |
42 #include "dnd.h" | |
1064 | 43 #include "dock.h" |
0 | 44 #include "equalizer.h" |
45 #include "hints.h" | |
46 #include "input.h" | |
47 #include "main.h" | |
48 #include "mainwin.h" | |
538
e4e897d20791
[svn] remove libaudcore, we never did anything with it
nenolod
parents:
489
diff
changeset
|
49 #include "playback.h" |
0 | 50 #include "playlist.h" |
51 #include "playlist_list.h" | |
52 #include "playlist_slider.h" | |
53 #include "pbutton.h" | |
54 #include "sbutton.h" | |
55 #include "skin.h" | |
56 #include "textbox.h" | |
57 #include "util.h" | |
58 | |
59 #include "pixmaps.h" | |
120 | 60 #include "images/audacious_playlist.xpm" |
0 | 61 |
62 | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
63 #define ITEM_SEPARATOR {"/-", NULL, NULL, 0, "<Separator>", NULL} |
0 | 64 |
65 | |
66 enum { | |
67 ADD_URL, ADD_DIR, ADD_FILES, | |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
68 SUB_MISC, SUB_ALL, SUB_CROP, SUB_SELECTED, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
69 SUB_DUPLICATE_BYTITLE, SUB_DUPLICATE_BYFILENAME, SUB_DUPLICATE_BYPATH, |
0 | 70 SEL_INV, SEL_ZERO, SEL_ALL, |
71 MISC_SORT, MISC_FILEINFO, MISC_MISCOPTS, | |
72 PLIST_NEW, PLIST_SAVE_AS, PLIST_LOAD, | |
73 SEL_LOOKUP, CLOSE_PL_WINDOW, MOVE_UP, PLIST_SAVE, | |
74 MISC_QUEUE, PLIST_CQUEUE, PLIST_JTF, PLIST_JTT, | |
75 PLAYLISTWIN_REMOVE_DEAD_FILES, | |
1359
c60990f0bf2a
[svn] - add a menu item that toggles filepopup to the playlist popup menu.
yaz
parents:
1286
diff
changeset
|
76 PLAYLISTWIN_REFRESH, PLIST_DEFAULTSAVE, MISC_FILEPOPUP |
0 | 77 }; |
78 | |
79 enum { | |
80 PLAYLISTWIN_SORT_BYTITLE, PLAYLISTWIN_SORT_BYFILENAME, | |
81 PLAYLISTWIN_SORT_BYPATH, PLAYLISTWIN_SORT_BYDATE, | |
1251 | 82 PLAYLISTWIN_SORT_BYARTIST, PLAYLISTWIN_SORT_SEL_BYARTIST, |
0 | 83 PLAYLISTWIN_SORT_SEL_BYTITLE, PLAYLISTWIN_SORT_SEL_BYFILENAME, |
84 PLAYLISTWIN_SORT_SEL_BYPATH, PLAYLISTWIN_SORT_SEL_BYDATE, | |
1415 | 85 PLAYLISTWIN_SORT_RANDOMIZE, PLAYLISTWIN_SORT_REVERSE, |
1430
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
86 PLAYLISTWIN_SORT_BYTRACK, PLAYLISTWIN_SORT_SEL_BYTRACK, |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
87 PLAYLISTWIN_SORT_BYPLAYLIST, PLAYLISTWIN_SORT_SEL_BYPLAYLIST |
0 | 88 }; |
89 | |
90 GtkWidget *playlistwin; | |
91 | |
92 PlayList_List *playlistwin_list = NULL; | |
93 PButton *playlistwin_shade, *playlistwin_close; | |
94 | |
95 static gboolean playlistwin_resizing = FALSE; | |
96 | |
97 static GtkItemFactory *playlistwin_popup_menu; | |
98 static GtkItemFactory *pladd_menu, *pldel_menu; | |
99 static GtkItemFactory *plsel_menu, *plsort_menu; | |
100 static GtkItemFactory *pllist_menu; | |
101 | |
102 static GdkPixmap *playlistwin_bg; | |
103 static GdkBitmap *playlistwin_mask = NULL; | |
104 static GdkGC *playlistwin_gc; | |
105 | |
106 static GtkAccelGroup *playlistwin_accel; | |
107 | |
108 static gboolean playlistwin_hint_flag = FALSE; | |
109 | |
110 static PlaylistSlider *playlistwin_slider = NULL; | |
111 static TextBox *playlistwin_time_min, *playlistwin_time_sec; | |
112 static TextBox *playlistwin_info, *playlistwin_sinfo; | |
113 static SButton *playlistwin_srew, *playlistwin_splay; | |
114 static SButton *playlistwin_spause, *playlistwin_sstop; | |
115 static SButton *playlistwin_sfwd, *playlistwin_seject; | |
116 static SButton *playlistwin_sscroll_up, *playlistwin_sscroll_down; | |
117 | |
118 static GList *playlistwin_wlist = NULL; | |
119 | |
120 static void plsort_menu_callback(gpointer cb_data, guint action, | |
121 GtkWidget * w); | |
122 static void playlistwin_sub_menu_callback(gpointer cb_data, guint action, | |
123 GtkWidget * w); | |
124 static void playlistwin_popup_menu_callback(gpointer cb_data, guint action, | |
125 GtkWidget * w); | |
126 | |
127 static GtkItemFactoryEntry playlistwin_popup_menu_entries[] = { | |
128 {N_("/View Track Details"), NULL, | |
129 playlistwin_popup_menu_callback, | |
130 MISC_FILEINFO, "<ImageItem>", my_pixbuf}, | |
131 | |
1360
7e312e0c33e8
[svn] - now filepopup menu shows its state through checkbox.
yaz
parents:
1359
diff
changeset
|
132 {N_("/Show Popup Info"), NULL, |
1359
c60990f0bf2a
[svn] - add a menu item that toggles filepopup to the playlist popup menu.
yaz
parents:
1286
diff
changeset
|
133 playlistwin_popup_menu_callback, |
1360
7e312e0c33e8
[svn] - now filepopup menu shows its state through checkbox.
yaz
parents:
1359
diff
changeset
|
134 MISC_FILEPOPUP, "<ToggleItem>", NULL}, |
1359
c60990f0bf2a
[svn] - add a menu item that toggles filepopup to the playlist popup menu.
yaz
parents:
1286
diff
changeset
|
135 |
0 | 136 ITEM_SEPARATOR, |
137 | |
138 {N_("/Remove Selected"), "Delete", | |
139 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
140 SUB_SELECTED, "<StockItem>", GTK_STOCK_REMOVE}, |
0 | 141 |
142 {N_("/Remove Unselected"), NULL, | |
143 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
144 SUB_CROP, "<StockItem>", GTK_STOCK_REMOVE}, |
0 | 145 |
146 {N_("/Remove All"), NULL, | |
147 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
148 SUB_ALL, "<StockItem>", GTK_STOCK_CLEAR}, |
0 | 149 |
150 ITEM_SEPARATOR, | |
151 | |
152 {N_("/Queue Toggle"), "q", | |
153 playlistwin_popup_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
154 MISC_QUEUE, "<ImageItem>", queuetoggle_pixbuf}, |
0 | 155 }; |
156 | |
157 static GtkItemFactoryEntry pladd_menu_entries[] = { | |
158 {N_("/Add CD..."), "<shift>c", | |
159 mainwin_general_menu_callback, | |
160 MAINWIN_GENERAL_ADDCD, "<StockItem>", GTK_STOCK_CDROM}, | |
161 | |
162 {N_("/Add Internet Address..."), "<control>h", | |
163 mainwin_general_menu_callback, | |
164 MAINWIN_GENERAL_PLAYLOCATION, "<StockItem>", GTK_STOCK_NETWORK}, | |
165 | |
166 {N_("/Add Files..."), "f", | |
167 mainwin_general_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
168 MAINWIN_GENERAL_PLAYFILE, "<StockItem>", GTK_STOCK_ADD}, |
0 | 169 }; |
170 | |
171 static GtkItemFactoryEntry pldel_menu_entries[] = { | |
172 {N_("/Clear Queue"), "<shift>Q", | |
173 playlistwin_popup_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
174 PLIST_CQUEUE, "<StockItem>", GTK_STOCK_CANCEL}, |
0 | 175 |
176 ITEM_SEPARATOR, | |
177 | |
178 {N_("/Remove Unavailable Files"), NULL, | |
179 playlistwin_sub_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
180 PLAYLISTWIN_REMOVE_DEAD_FILES, "<ImageItem>", removeunavail_pixbuf}, |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
181 |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
182 {N_("/Remove Duplicates"), NULL, NULL, 0, "<Branch>", NULL}, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
183 {N_("/Remove Duplicates/By Title"), NULL, |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
184 playlistwin_sub_menu_callback, |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
185 SUB_DUPLICATE_BYTITLE, "<ImageItem>", removedups_pixbuf}, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
186 {N_("/Remove Duplicates/By Filename"), NULL, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
187 playlistwin_sub_menu_callback, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
188 SUB_DUPLICATE_BYFILENAME, "<ImageItem>", removedups_pixbuf}, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
189 {N_("/Remove Duplicates/By Path + Filename"), NULL, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
190 playlistwin_sub_menu_callback, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
191 SUB_DUPLICATE_BYPATH, "<ImageItem>", removedups_pixbuf}, |
0 | 192 |
193 ITEM_SEPARATOR, | |
194 | |
195 {N_("/Remove All"), NULL, | |
196 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
197 SUB_ALL, "<StockItem>", GTK_STOCK_CLEAR}, |
0 | 198 |
199 {N_("/Remove Unselected"), NULL, | |
200 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
201 SUB_CROP, "<StockItem>", GTK_STOCK_REMOVE}, |
0 | 202 |
203 {N_("/Remove Selected"), "Delete", | |
204 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
205 SUB_SELECTED, "<StockItem>", GTK_STOCK_REMOVE} |
0 | 206 }; |
207 | |
208 static GtkItemFactoryEntry pllist_menu_entries[] = { | |
1001
9189b80b6bea
[svn] Assign new shortcuts that no longer conflict. Patch by mokoshi, closes bug #478.
chainsaw
parents:
999
diff
changeset
|
209 {N_("/New List"), "<shift>N", |
0 | 210 playlistwin_sub_menu_callback, |
211 PLIST_NEW, "<StockItem>", GTK_STOCK_NEW}, | |
212 | |
213 ITEM_SEPARATOR, | |
214 | |
215 {N_("/Load List"), "o", | |
216 playlistwin_sub_menu_callback, | |
217 PLIST_LOAD, "<StockItem>", GTK_STOCK_OPEN}, | |
218 | |
1001
9189b80b6bea
[svn] Assign new shortcuts that no longer conflict. Patch by mokoshi, closes bug #478.
chainsaw
parents:
999
diff
changeset
|
219 {N_("/Save List"), "<shift>S", |
0 | 220 playlistwin_sub_menu_callback, |
221 PLIST_SAVE, "<StockItem>", GTK_STOCK_SAVE}, | |
222 | |
1062
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
223 {N_("/Save Default List"), "<alt>S", |
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
224 playlistwin_sub_menu_callback, |
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
225 PLIST_DEFAULTSAVE, "<StockItem>", GTK_STOCK_SAVE}, |
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
226 |
0 | 227 ITEM_SEPARATOR, |
228 | |
229 {N_("/Update View"), "F5", | |
230 playlistwin_sub_menu_callback, | |
231 PLAYLISTWIN_REFRESH, "<StockItem>", GTK_STOCK_REFRESH} | |
232 }; | |
233 | |
234 static GtkItemFactoryEntry plsel_menu_entries[] = { | |
235 {N_("/Invert Selection"), NULL, | |
236 playlistwin_sub_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
237 SEL_INV, "<ImageItem>", selectinvert_pixbuf}, |
0 | 238 |
239 ITEM_SEPARATOR, | |
240 | |
241 {N_("/Select None"),"<Ctrl><Shift>A", | |
242 playlistwin_sub_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
243 SEL_ZERO, "<ImageItem>", selectnone_pixbuf}, |
0 | 244 |
245 {N_("/Select All"), "<Ctrl>A", | |
246 playlistwin_sub_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
247 SEL_ALL, "<ImageItem>", selectall_pixbuf}, |
0 | 248 }; |
249 | |
250 static GtkItemFactoryEntry plsort_menu_entries[] = { | |
251 {N_("/Randomize List"), NULL, plsort_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
252 PLAYLISTWIN_SORT_RANDOMIZE, "<ImageItem>", randomizepl_pixbuf}, |
0 | 253 {N_("/Reverse List"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
254 PLAYLISTWIN_SORT_REVERSE, "<ImageItem>", invertpl_pixbuf}, |
0 | 255 ITEM_SEPARATOR, |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
256 {N_("/Sort List"), NULL, NULL, 0, "<Branch>", NULL}, |
0 | 257 {N_("/Sort List/By Title"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
258 PLAYLISTWIN_SORT_BYTITLE, "<ImageItem>", sortbytitle_pixbuf}, |
1251 | 259 {N_("/Sort List/By Artist"), NULL, plsort_menu_callback, |
260 PLAYLISTWIN_SORT_BYARTIST, "<ImageItem>", sortbytitle_pixbuf}, | |
0 | 261 {N_("/Sort List/By Filename"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
262 PLAYLISTWIN_SORT_BYFILENAME, "<ImageItem>", sortbyfilename_pixbuf}, |
0 | 263 {N_("/Sort List/By Path + Filename"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
264 PLAYLISTWIN_SORT_BYPATH, "<ImageItem>", sortbypathfile_pixbuf}, |
0 | 265 {N_("/Sort List/By Date"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
266 PLAYLISTWIN_SORT_BYDATE, "<ImageItem>", sortbydate_pixbuf}, |
1415 | 267 {N_("/Sort List/By Track Number"), NULL, plsort_menu_callback, |
268 PLAYLISTWIN_SORT_BYTRACK, "<ImageItem>", sortbytitle_pixbuf}, | |
1430
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
269 {N_("/Sort List/By Playlist Entry"), NULL, plsort_menu_callback, |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
270 PLAYLISTWIN_SORT_BYPLAYLIST, "<ImageItem>", sortbytitle_pixbuf}, |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
271 {N_("/Sort Selection"), NULL, NULL, 0, "<Branch>", NULL}, |
0 | 272 {N_("/Sort Selection/By Title"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
273 PLAYLISTWIN_SORT_SEL_BYTITLE, "<ImageItem>", sortbytitle_pixbuf}, |
1251 | 274 {N_("/Sort Selection/By Artist"), NULL, plsort_menu_callback, |
275 PLAYLISTWIN_SORT_SEL_BYARTIST, "<ImageItem>", sortbytitle_pixbuf}, | |
0 | 276 {N_("/Sort Selection/By Filename"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
277 PLAYLISTWIN_SORT_SEL_BYFILENAME, "<ImageItem>", sortbyfilename_pixbuf}, |
0 | 278 {N_("/Sort Selection/By Path + Filename"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
279 PLAYLISTWIN_SORT_SEL_BYPATH, "<ImageItem>", sortbypathfile_pixbuf}, |
0 | 280 {N_("/Sort Selection/By Date"), NULL, plsort_menu_callback, |
1415 | 281 PLAYLISTWIN_SORT_SEL_BYDATE, "<ImageItem>", sortbydate_pixbuf}, |
282 {N_("/Sort Selection/By Track Number"), NULL, plsort_menu_callback, | |
1430
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
283 PLAYLISTWIN_SORT_SEL_BYTRACK, "<ImageItem>", sortbytitle_pixbuf}, |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
284 {N_("/Sort Selection/By Playlist Entry"), NULL, plsort_menu_callback, |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
285 PLAYLISTWIN_SORT_SEL_BYPLAYLIST, "<ImageItem>", sortbytitle_pixbuf} |
0 | 286 }; |
287 | |
288 | |
289 static void playlistwin_draw_frame(void); | |
290 | |
291 | |
292 gboolean | |
293 playlistwin_is_shaded(void) | |
294 { | |
295 return cfg.playlist_shaded; | |
296 } | |
297 | |
298 gint | |
299 playlistwin_get_width(void) | |
300 { | |
1538
fe671cb74bf9
[svn] - fix geometry hinting so that it is ICCCM compliant. patch by whereami.
nenolod
parents:
1459
diff
changeset
|
301 cfg.playlist_width /= PLAYLISTWIN_WIDTH_SNAP; |
fe671cb74bf9
[svn] - fix geometry hinting so that it is ICCCM compliant. patch by whereami.
nenolod
parents:
1459
diff
changeset
|
302 cfg.playlist_width *= PLAYLISTWIN_WIDTH_SNAP; |
0 | 303 return cfg.playlist_width; |
304 } | |
305 | |
306 gint | |
307 playlistwin_get_height_unshaded(void) | |
308 { | |
1538
fe671cb74bf9
[svn] - fix geometry hinting so that it is ICCCM compliant. patch by whereami.
nenolod
parents:
1459
diff
changeset
|
309 cfg.playlist_height /= PLAYLISTWIN_HEIGHT_SNAP; |
fe671cb74bf9
[svn] - fix geometry hinting so that it is ICCCM compliant. patch by whereami.
nenolod
parents:
1459
diff
changeset
|
310 cfg.playlist_height *= PLAYLISTWIN_HEIGHT_SNAP; |
0 | 311 gint height = cfg.playlist_height; |
312 return height; | |
313 } | |
314 | |
315 gint | |
316 playlistwin_get_height_shaded(void) | |
317 { | |
318 return PLAYLISTWIN_SHADED_HEIGHT; | |
319 } | |
320 | |
321 gint | |
322 playlistwin_get_height(void) | |
323 { | |
324 if (playlistwin_is_shaded()) | |
325 return playlistwin_get_height_shaded(); | |
326 else | |
327 return playlistwin_get_height_unshaded(); | |
328 } | |
329 | |
330 void | |
331 playlistwin_get_size(gint * width, gint * height) | |
332 { | |
333 if (width) | |
334 *width = playlistwin_get_width(); | |
335 | |
336 if (height) | |
337 *height = playlistwin_get_height(); | |
338 } | |
339 | |
340 static void | |
341 playlistwin_update_info(void) | |
342 { | |
343 gchar *text, *sel_text, *tot_text; | |
344 gulong selection, total; | |
345 gboolean selection_more, total_more; | |
346 | |
347 playlist_get_total_time(&total, &selection, &total_more, &selection_more); | |
348 | |
349 if (selection > 0 || (selection == 0 && !selection_more)) { | |
350 if (selection > 3600) | |
351 sel_text = | |
352 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", selection / 3600, | |
353 (selection / 60) % 60, selection % 60, | |
354 (selection_more ? "+" : "")); | |
355 else | |
356 sel_text = | |
357 g_strdup_printf("%lu:%-2.2lu%s", selection / 60, | |
358 selection % 60, (selection_more ? "+" : "")); | |
359 } | |
360 else | |
361 sel_text = g_strdup("?"); | |
362 if (total > 0 || (total == 0 && !total_more)) { | |
363 if (total > 3600) | |
364 tot_text = | |
365 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", total / 3600, | |
366 (total / 60) % 60, total % 60, | |
367 total_more ? "+" : ""); | |
368 else | |
369 tot_text = | |
370 g_strdup_printf("%lu:%-2.2lu%s", total / 60, total % 60, | |
371 total_more ? "+" : ""); | |
372 } | |
373 else | |
374 tot_text = g_strdup("?"); | |
375 text = g_strconcat(sel_text, "/", tot_text, NULL); | |
376 textbox_set_text(playlistwin_info, text); | |
377 g_free(text); | |
378 g_free(tot_text); | |
379 g_free(sel_text); | |
380 } | |
381 | |
382 static void | |
383 playlistwin_update_sinfo(void) | |
384 { | |
385 gchar *posstr, *timestr, *title, *info, *dots; | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
386 gint pos, time; |
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
387 guint max_len; |
0 | 388 |
389 pos = playlist_get_position(); | |
390 title = playlist_get_songtitle(pos); | |
391 time = playlist_get_songtime(pos); | |
392 | |
393 if (!title) { | |
394 textbox_set_text(playlistwin_sinfo, ""); | |
395 return; | |
396 } | |
397 | |
398 if (cfg.show_numbers_in_pl) | |
399 posstr = g_strdup_printf("%d. ", pos + 1); | |
400 else | |
401 posstr = g_strdup(""); | |
402 | |
403 max_len = (playlistwin_get_width() - 35) / 5 - strlen(posstr); | |
404 | |
405 if (time != -1) { | |
406 timestr = g_strdup_printf(" %d:%-2.2d", time / 60000, | |
407 (time / 1000) % 60); | |
408 max_len -= strlen(timestr); | |
409 } | |
410 else | |
411 timestr = g_strdup(""); | |
412 | |
413 convert_title_text(title); | |
414 | |
415 if (strlen(title) > max_len) { | |
1222
09a96847fa53
[svn] - There's an ellipsis character in text.png. Let's use it like we should.
nhjm449
parents:
1085
diff
changeset
|
416 max_len -= 1; |
09a96847fa53
[svn] - There's an ellipsis character in text.png. Let's use it like we should.
nhjm449
parents:
1085
diff
changeset
|
417 dots = "\r"; |
09a96847fa53
[svn] - There's an ellipsis character in text.png. Let's use it like we should.
nhjm449
parents:
1085
diff
changeset
|
418 /* textbox.c interprets \r as the ellipsis character, as there |
09a96847fa53
[svn] - There's an ellipsis character in text.png. Let's use it like we should.
nhjm449
parents:
1085
diff
changeset
|
419 is none in ASCII. */ |
0 | 420 } |
421 else | |
422 dots = ""; | |
423 | |
424 info = g_strdup_printf("%s%-*.*s%s%s", posstr, max_len, max_len, | |
425 title, dots, timestr); | |
426 g_free(posstr); | |
427 g_free(title); | |
428 g_free(timestr); | |
429 | |
430 textbox_set_text(playlistwin_sinfo, info); | |
431 g_free(info); | |
432 } | |
433 | |
434 gboolean | |
435 playlistwin_item_visible(gint index) | |
436 { | |
437 if (index >= playlistwin_list->pl_first | |
438 && index < | |
439 (playlistwin_list->pl_first + playlistwin_list->pl_num_visible)) | |
440 return TRUE; | |
441 return FALSE; | |
442 } | |
443 | |
444 gint | |
445 playlistwin_get_toprow(void) | |
446 { | |
447 if (playlistwin_list) | |
448 return (playlistwin_list->pl_first); | |
449 return (-1); | |
450 } | |
451 | |
452 void | |
453 playlistwin_set_toprow(gint toprow) | |
454 { | |
455 if (playlistwin_list) | |
456 playlistwin_list->pl_first = toprow; | |
457 playlistwin_update_list(); | |
458 } | |
459 | |
460 void | |
461 playlistwin_update_list(void) | |
462 { | |
463 g_return_if_fail(playlistwin_list != NULL); | |
464 | |
239
ac4c3da7c263
[svn] Don't use widget_draw_quick() in playlistwin_update_list().
nenolod
parents:
238
diff
changeset
|
465 widget_draw(WIDGET(playlistwin_list)); |
ac4c3da7c263
[svn] Don't use widget_draw_quick() in playlistwin_update_list().
nenolod
parents:
238
diff
changeset
|
466 widget_draw(WIDGET(playlistwin_slider)); |
0 | 467 playlistwin_update_info(); |
468 playlistwin_update_sinfo(); | |
469 /* mainwin_update_jtf(); */ | |
470 } | |
471 | |
472 #if 0 | |
473 static void | |
474 playlistwin_redraw_list(void) | |
475 { | |
476 g_return_if_fail(playlistwin_list != NULL); | |
477 | |
478 draw_widget(playlistwin_list); | |
479 draw_widget(playlistwin_slider); | |
480 } | |
481 #endif | |
482 | |
483 static void | |
484 playlistwin_set_mask(void) | |
485 { | |
486 GdkGC *gc; | |
487 GdkColor pattern; | |
488 | |
489 if (playlistwin_mask) | |
490 g_object_unref(playlistwin_mask); | |
491 | |
492 playlistwin_mask = | |
493 gdk_pixmap_new(playlistwin->window, playlistwin_get_width(), | |
494 playlistwin_get_height(), 1); | |
495 gc = gdk_gc_new(playlistwin_mask); | |
496 pattern.pixel = 1; | |
497 gdk_gc_set_foreground(gc, &pattern); | |
498 gdk_draw_rectangle(playlistwin_mask, gc, TRUE, 0, 0, | |
499 playlistwin_get_width(), playlistwin_get_height()); | |
500 gdk_gc_destroy(gc); | |
501 | |
502 gtk_widget_shape_combine_mask(playlistwin, playlistwin_mask, 0, 0); | |
503 } | |
504 | |
505 static void | |
506 playlistwin_set_geometry_hints(gboolean shaded) | |
507 { | |
508 GdkGeometry geometry; | |
509 GdkWindowHints mask; | |
510 | |
511 geometry.min_width = PLAYLISTWIN_MIN_WIDTH; | |
512 geometry.max_width = G_MAXUINT16; | |
513 | |
514 geometry.width_inc = PLAYLISTWIN_WIDTH_SNAP; | |
515 geometry.height_inc = PLAYLISTWIN_HEIGHT_SNAP; | |
516 | |
517 if (shaded) { | |
518 geometry.min_height = PLAYLISTWIN_SHADED_HEIGHT; | |
519 geometry.max_height = PLAYLISTWIN_SHADED_HEIGHT; | |
520 geometry.base_height = PLAYLISTWIN_SHADED_HEIGHT; | |
521 } | |
522 else { | |
523 geometry.min_height = PLAYLISTWIN_MIN_HEIGHT; | |
524 geometry.max_height = G_MAXUINT16; | |
525 } | |
526 | |
1538
fe671cb74bf9
[svn] - fix geometry hinting so that it is ICCCM compliant. patch by whereami.
nenolod
parents:
1459
diff
changeset
|
527 mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_RESIZE_INC; |
0 | 528 |
529 gtk_window_set_geometry_hints(GTK_WINDOW(playlistwin), | |
530 playlistwin, &geometry, mask); | |
531 } | |
532 | |
533 void | |
534 playlistwin_set_shade(gboolean shaded) | |
535 { | |
536 cfg.playlist_shaded = shaded; | |
537 | |
538 if (shaded) { | |
539 widget_show(WIDGET(playlistwin_sinfo)); | |
540 playlistwin_shade->pb_nx = 128; | |
541 playlistwin_shade->pb_ny = 45; | |
542 playlistwin_shade->pb_px = 150; | |
543 playlistwin_shade->pb_py = 42; | |
544 playlistwin_close->pb_nx = 138; | |
545 playlistwin_close->pb_ny = 45; | |
546 } | |
547 else { | |
548 widget_hide(WIDGET(playlistwin_sinfo)); | |
549 playlistwin_shade->pb_nx = 157; | |
550 playlistwin_shade->pb_ny = 3; | |
551 playlistwin_shade->pb_px = 62; | |
552 playlistwin_shade->pb_py = 42; | |
553 playlistwin_close->pb_nx = 167; | |
554 playlistwin_close->pb_ny = 3; | |
555 } | |
556 | |
1064 | 557 dock_shade(dock_window_list, GTK_WINDOW(playlistwin), |
558 playlistwin_get_height()); | |
559 | |
0 | 560 playlistwin_set_geometry_hints(cfg.playlist_shaded); |
561 | |
562 gtk_window_resize(GTK_WINDOW(playlistwin), | |
1538
fe671cb74bf9
[svn] - fix geometry hinting so that it is ICCCM compliant. patch by whereami.
nenolod
parents:
1459
diff
changeset
|
563 playlistwin_get_width(), |
0 | 564 playlistwin_get_height()); |
565 | |
79
38ddde5b0f13
[svn] Fix #129 by using playlistwin_set_mask() in playlistwin_set_shade()
msameer
parents:
0
diff
changeset
|
566 playlistwin_set_mask(); |
237
02c17a5c99e3
[svn] - Implement widget_draw_quick(widget_t *) for doing an immediate draw
nenolod
parents:
236
diff
changeset
|
567 |
242 | 568 widget_draw(WIDGET(playlistwin_list)); |
569 widget_draw(WIDGET(playlistwin_slider)); | |
570 | |
0 | 571 draw_playlist_window(TRUE); |
572 } | |
573 | |
574 static void | |
575 playlistwin_set_shade_menu(gboolean shaded) | |
576 { | |
577 GtkWidget *item; | |
578 | |
579 item = gtk_item_factory_get_widget(mainwin_view_menu, | |
580 "/Roll up Playlist Editor"); | |
581 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), shaded); | |
582 | |
583 playlistwin_set_shade(shaded); | |
584 } | |
585 | |
586 void | |
587 playlistwin_shade_toggle(void) | |
588 { | |
589 playlistwin_set_shade_menu(!cfg.playlist_shaded); | |
590 } | |
591 | |
592 static void | |
593 playlistwin_release(GtkWidget * widget, | |
594 GdkEventButton * event, | |
595 gpointer callback_data) | |
596 { | |
597 if (event->button == 3) | |
598 return; | |
599 | |
600 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
601 playlistwin_resizing = FALSE; | |
602 gdk_flush(); | |
1068 | 603 |
604 if (dock_is_moving(GTK_WINDOW(playlistwin))) | |
605 { | |
606 dock_move_release(GTK_WINDOW(playlistwin)); | |
1047
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
1046
diff
changeset
|
607 |
1068 | 608 if (cfg.playlist_transparent) |
609 playlistwin_update_list(); | |
610 } | |
611 else | |
612 { | |
613 handle_release_cb(playlistwin_wlist, widget, event); | |
614 draw_playlist_window(FALSE); | |
615 } | |
0 | 616 } |
617 | |
618 void | |
619 playlistwin_scroll(gint num) | |
620 { | |
621 playlistwin_list->pl_first += num; | |
622 playlistwin_update_list(); | |
623 } | |
624 | |
625 void | |
626 playlistwin_scroll_up_pushed(void) | |
627 { | |
628 playlistwin_list->pl_first -= 3; | |
629 playlistwin_update_list(); | |
630 } | |
631 | |
632 void | |
633 playlistwin_scroll_down_pushed(void) | |
634 { | |
635 playlistwin_list->pl_first += 3; | |
636 playlistwin_update_list(); | |
637 } | |
638 | |
639 static void | |
640 playlistwin_select_all(void) | |
641 { | |
642 playlist_select_all(TRUE); | |
643 playlistwin_list->pl_prev_selected = 0; | |
644 playlistwin_list->pl_prev_min = 0; | |
645 playlistwin_list->pl_prev_max = playlist_get_length() - 1; | |
646 playlistwin_update_list(); | |
647 } | |
648 | |
649 static void | |
650 playlistwin_select_none(void) | |
651 { | |
652 playlist_select_all(FALSE); | |
653 playlistwin_list->pl_prev_selected = -1; | |
654 playlistwin_list->pl_prev_min = -1; | |
655 playlistwin_update_list(); | |
656 } | |
657 | |
658 static void | |
659 playlistwin_inverse_selection(void) | |
660 { | |
661 playlist_select_invert_all(); | |
662 playlistwin_list->pl_prev_selected = -1; | |
663 playlistwin_list->pl_prev_min = -1; | |
664 playlistwin_update_list(); | |
665 } | |
666 | |
667 static void | |
668 playlistwin_resize(gint width, gint height) | |
669 { | |
670 gboolean redraw; | |
671 | |
672 g_return_if_fail(width > 0 && height > 0); | |
673 | |
674 cfg.playlist_width = width; | |
675 | |
676 if (!cfg.playlist_shaded) | |
677 cfg.playlist_height = height; | |
678 else | |
679 height = cfg.playlist_height; | |
680 | |
681 /* FIXME: why the fsck are we doing this manually? */ | |
682 /* adjust widget positions and sizes */ | |
683 | |
684 widget_resize(WIDGET(playlistwin_list), width - 31, height - 58); | |
685 | |
686 widget_move(WIDGET(playlistwin_slider), width - 15, 20); | |
687 widget_resize(WIDGET(playlistwin_slider), 8, height - 58); | |
688 | |
689 widget_resize(WIDGET(playlistwin_sinfo), width - 35, 14); | |
690 playlistwin_update_sinfo(); | |
691 | |
692 widget_move(WIDGET(playlistwin_shade), width - 21, 3); | |
693 widget_move(WIDGET(playlistwin_close), width - 11, 3); | |
694 widget_move(WIDGET(playlistwin_time_min), width - 82, height - 15); | |
695 widget_move(WIDGET(playlistwin_time_sec), width - 64, height - 15); | |
696 widget_move(WIDGET(playlistwin_info), width - 143, height - 28); | |
697 widget_move(WIDGET(playlistwin_srew), width - 144, height - 16); | |
698 widget_move(WIDGET(playlistwin_splay), width - 138, height - 16); | |
699 widget_move(WIDGET(playlistwin_spause), width - 128, height - 16); | |
700 widget_move(WIDGET(playlistwin_sstop), width - 118, height - 16); | |
701 widget_move(WIDGET(playlistwin_sfwd), width - 109, height - 16); | |
702 widget_move(WIDGET(playlistwin_seject), width - 100, height - 16); | |
703 widget_move(WIDGET(playlistwin_sscroll_up), width - 14, height - 35); | |
704 widget_move(WIDGET(playlistwin_sscroll_down), width - 14, height - 30); | |
705 | |
706 g_object_unref(playlistwin_bg); | |
707 playlistwin_bg = gdk_pixmap_new(playlistwin->window, width, height, -1); | |
708 playlistwin_set_mask(); | |
709 | |
710 widget_list_lock(playlistwin_wlist); | |
711 | |
712 widget_list_change_pixmap(playlistwin_wlist, playlistwin_bg); | |
713 playlistwin_draw_frame(); | |
714 widget_list_draw(playlistwin_wlist, &redraw, TRUE); | |
715 widget_list_clear_redraw(playlistwin_wlist); | |
716 | |
717 widget_list_unlock(playlistwin_wlist); | |
718 | |
719 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
720 gdk_window_clear(playlistwin->window); | |
721 } | |
722 | |
723 | |
724 | |
725 static void | |
726 playlistwin_motion(GtkWidget * widget, | |
727 GdkEventMotion * event, | |
728 gpointer callback_data) | |
729 { | |
489
e0ee28a14570
[svn] Do not process redundant XEvents... just throw them away. Crude
nenolod
parents:
484
diff
changeset
|
730 GdkEvent *gevent; |
e0ee28a14570
[svn] Do not process redundant XEvents... just throw them away. Crude
nenolod
parents:
484
diff
changeset
|
731 |
1064 | 732 if (dock_is_moving(GTK_WINDOW(playlistwin))) { |
733 dock_move_motion(GTK_WINDOW(playlistwin), event); | |
734 } | |
735 else { | |
736 handle_motion_cb(playlistwin_wlist, widget, event); | |
737 draw_playlist_window(FALSE); | |
738 } | |
0 | 739 gdk_flush(); |
489
e0ee28a14570
[svn] Do not process redundant XEvents... just throw them away. Crude
nenolod
parents:
484
diff
changeset
|
740 |
e0ee28a14570
[svn] Do not process redundant XEvents... just throw them away. Crude
nenolod
parents:
484
diff
changeset
|
741 while ((gevent = gdk_event_get()) != NULL) gdk_event_free(gevent); |
0 | 742 } |
743 | |
744 static void | |
1286 | 745 playlistwin_enter(GtkWidget * widget, |
746 GdkEventMotion * event, | |
747 gpointer callback_data) | |
748 { | |
749 playlistwin_list->pl_tooltips = TRUE; | |
750 } | |
751 | |
752 static void | |
753 playlistwin_leave(GtkWidget * widget, | |
754 GdkEventMotion * event, | |
755 gpointer callback_data) | |
756 { | |
757 playlistwin_list->pl_tooltips = FALSE; | |
758 } | |
759 | |
760 static void | |
0 | 761 playlistwin_show_filebrowser(void) |
762 { | |
763 util_run_filebrowser(NO_PLAY_BUTTON); | |
764 } | |
765 | |
766 #if 0 | |
767 static void | |
768 playlistwin_add_dir_handler(const gchar * dir) | |
769 { | |
770 g_free(cfg.filesel_path); | |
771 cfg.filesel_path = g_strdup(dir); | |
772 playlist_add_dir(dir); | |
773 } | |
774 #endif | |
775 | |
776 static void | |
777 playlistwin_fileinfo(void) | |
778 { | |
779 /* Show the first selected file, or the current file if nothing is | |
780 * selected */ | |
781 GList *list = playlist_get_selected(); | |
782 if (list) { | |
783 playlist_fileinfo(GPOINTER_TO_INT(list->data)); | |
784 g_list_free(list); | |
785 } | |
786 else | |
787 playlist_fileinfo_current(); | |
788 } | |
789 | |
790 static void | |
791 menu_set_item_sensitive(GtkItemFactory * item_factory, | |
792 const gchar * path, | |
793 gboolean sensitive) | |
794 { | |
795 GtkWidget *item = gtk_item_factory_get_widget(item_factory, path); | |
796 gtk_widget_set_sensitive(item, sensitive); | |
797 } | |
798 | |
799 /* FIXME: broken */ | |
800 static void | |
801 playlistwin_set_sensitive_sortmenu(void) | |
802 { | |
803 gboolean set = playlist_get_num_selected() > 1; | |
804 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Title", set); | |
805 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Filename", set); | |
806 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Path + Filename", set); | |
807 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Date", set); | |
808 } | |
809 | |
810 static void | |
811 show_playlist_save_error(GtkWindow * parent, | |
812 const gchar * filename) | |
813 { | |
814 GtkWidget *dialog; | |
815 | |
816 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
817 g_return_if_fail(filename != NULL); | |
818 | |
819 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
820 GTK_DIALOG_DESTROY_WITH_PARENT, | |
821 GTK_MESSAGE_ERROR, | |
822 GTK_BUTTONS_OK, | |
823 _("Error writing playlist \"%s\": %s"), | |
824 filename, strerror(errno)); | |
825 | |
826 gtk_dialog_run(GTK_DIALOG(dialog)); | |
827 gtk_widget_destroy(dialog); | |
828 } | |
829 | |
830 static gboolean | |
831 show_playlist_overwrite_prompt(GtkWindow * parent, | |
832 const gchar * filename) | |
833 { | |
834 GtkWidget *dialog; | |
835 gint result; | |
836 | |
837 g_return_val_if_fail(GTK_IS_WINDOW(parent), FALSE); | |
838 g_return_val_if_fail(filename != NULL, FALSE); | |
839 | |
840 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
841 GTK_DIALOG_DESTROY_WITH_PARENT, | |
842 GTK_MESSAGE_QUESTION, | |
843 GTK_BUTTONS_YES_NO, | |
844 _("%s already exist. Continue?"), | |
845 filename); | |
846 | |
847 result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
848 gtk_widget_destroy(dialog); | |
849 | |
850 return (result == GTK_RESPONSE_YES); | |
851 } | |
852 | |
853 static void | |
854 show_playlist_save_format_error(GtkWindow * parent, | |
855 const gchar * filename) | |
856 { | |
857 const gchar *markup = | |
858 N_("<b><big>Unable to save playlist.</big></b>\n\n" | |
859 "Unknown file type for '%s'.\n"); | |
860 | |
861 GtkWidget *dialog; | |
862 | |
863 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
864 g_return_if_fail(filename != NULL); | |
865 | |
866 dialog = | |
867 gtk_message_dialog_new_with_markup(GTK_WINDOW(parent), | |
868 GTK_DIALOG_DESTROY_WITH_PARENT, | |
869 GTK_MESSAGE_ERROR, | |
870 GTK_BUTTONS_OK, | |
871 _(markup), | |
872 filename); | |
873 gtk_dialog_run(GTK_DIALOG(dialog)); | |
874 gtk_widget_destroy(dialog); | |
875 } | |
876 | |
877 static void | |
878 playlistwin_save_playlist(const gchar * filename) | |
879 { | |
880 PlaylistFormat format; | |
881 | |
882 format = playlist_format_get_from_name(filename); | |
883 if (format == PLAYLIST_FORMAT_UNKNOWN) { | |
884 show_playlist_save_format_error(GTK_WINDOW(playlistwin), filename); | |
885 return; | |
886 } | |
887 | |
888 str_replace_in(&cfg.playlist_path, g_path_get_dirname(filename)); | |
889 | |
890 if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) | |
891 if (!show_playlist_overwrite_prompt(GTK_WINDOW(playlistwin), filename)) | |
892 return; | |
893 | |
894 if (!playlist_save(filename, format)) | |
895 show_playlist_save_error(GTK_WINDOW(playlistwin), filename); | |
896 } | |
897 | |
898 #if 0 | |
899 static void | |
900 playlistwin_save_current(void) | |
901 { | |
902 const gchar *filename; | |
903 | |
904 if (!(filename = playlist_get_current_name())) | |
905 return; | |
906 | |
907 playlistwin_save_playlist(filename); | |
908 } | |
909 #endif | |
910 | |
911 static void | |
912 playlistwin_load_playlist(const gchar * filename) | |
913 { | |
914 g_return_if_fail(filename != NULL); | |
915 | |
916 str_replace_in(&cfg.playlist_path, g_strdup(filename)); | |
917 | |
918 playlist_clear(); | |
919 mainwin_clear_song_info(); | |
920 mainwin_set_info_text(); | |
921 | |
922 playlist_load(filename); | |
923 playlist_set_current_name(filename); | |
924 } | |
925 | |
926 static gchar * | |
927 playlist_file_selection(const gchar * title, | |
928 gboolean save, | |
929 const gchar * default_filename) | |
930 { | |
931 GtkWidget *dialog, *button; | |
932 gchar *filename; | |
933 | |
934 g_return_val_if_fail(title != NULL, NULL); | |
935 | |
936 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), | |
937 save ? GTK_FILE_CHOOSER_ACTION_SAVE : | |
376 | 938 GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL); |
0 | 939 if (default_filename) |
940 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | |
941 default_filename); | |
942 | |
943 button = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, | |
944 GTK_RESPONSE_REJECT); | |
945 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); | |
946 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
947 | |
948 button = gtk_dialog_add_button(GTK_DIALOG(dialog), | |
949 save ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, | |
950 GTK_RESPONSE_ACCEPT); | |
951 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); | |
952 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
953 | |
954 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
955 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
956 else | |
957 filename = NULL; | |
958 | |
959 gtk_widget_destroy(dialog); | |
960 | |
961 return filename; | |
962 } | |
963 | |
964 void | |
965 playlistwin_select_playlist_to_load(const gchar * default_filename) | |
966 { | |
967 gchar *filename = | |
968 playlist_file_selection(_("Load Playlist"), FALSE, default_filename); | |
969 | |
970 if (filename) { | |
971 playlistwin_load_playlist(filename); | |
972 g_free(filename); | |
973 } | |
974 } | |
975 | |
976 static void | |
977 playlistwin_select_playlist_to_save(const gchar * default_filename) | |
978 { | |
979 gchar *filename = | |
980 playlist_file_selection(_("Save Playlist"), TRUE, default_filename); | |
981 | |
982 if (filename) { | |
983 /* Default to M3U if no filename has extension */ | |
984 | |
985 /* NOTE: This doesn't work correctly for hidden files | |
986 - descender */ | |
987 if (!strchr(filename, '.')) { | |
988 gchar *tmpstr = filename; | |
989 filename = g_strconcat(filename, ".m3u", NULL); | |
990 g_free(tmpstr); | |
991 } | |
992 | |
993 playlistwin_save_playlist(filename); | |
994 g_free(filename); | |
995 } | |
996 } | |
997 | |
998 static gboolean | |
999 inside_sensitive_widgets(gint x, gint y) | |
1000 { | |
1001 return (widget_contains(WIDGET(playlistwin_list), x, y) || | |
1002 widget_contains(WIDGET(playlistwin_slider), x, y) || | |
1003 widget_contains(WIDGET(playlistwin_close), x, y) || | |
1004 widget_contains(WIDGET(playlistwin_shade), x, y) || | |
1005 widget_contains(WIDGET(playlistwin_time_min), x, y) || | |
1006 widget_contains(WIDGET(playlistwin_time_sec), x, y) || | |
1007 widget_contains(WIDGET(playlistwin_info), x, y) || | |
1008 widget_contains(WIDGET(playlistwin_srew), x, y) || | |
1009 widget_contains(WIDGET(playlistwin_splay), x, y) || | |
1010 widget_contains(WIDGET(playlistwin_spause), x, y) || | |
1011 widget_contains(WIDGET(playlistwin_sstop), x, y) || | |
1012 widget_contains(WIDGET(playlistwin_sfwd), x, y) || | |
1013 widget_contains(WIDGET(playlistwin_seject), x, y) || | |
1014 widget_contains(WIDGET(playlistwin_sscroll_up), x, y) || | |
1015 widget_contains(WIDGET(playlistwin_sscroll_down), x, y)); | |
1016 } | |
1017 | |
1018 #define REGION_L(x1,x2,y1,y2) \ | |
1019 (event->x >= (x1) && event->x < (x2) && \ | |
1020 event->y >= cfg.playlist_height - (y1) && \ | |
1021 event->y < cfg.playlist_height - (y2)) | |
1022 | |
1023 #define REGION_R(x1,x2,y1,y2) \ | |
1024 (event->x >= playlistwin_get_width() - (x1) && \ | |
1025 event->x < playlistwin_get_width() - (x2) && \ | |
1026 event->y >= cfg.playlist_height - (y1) && \ | |
1027 event->y < cfg.playlist_height - (y2)) | |
1028 | |
1029 static void | |
1030 playlistwin_scrolled(GtkWidget * widget, | |
1031 GdkEventScroll * event, | |
1032 gpointer callback_data) | |
1033 { | |
1034 | |
1035 if (event->direction == GDK_SCROLL_DOWN) | |
1036 playlistwin_scroll(cfg.scroll_pl_by); | |
1037 | |
1038 if (event->direction == GDK_SCROLL_UP) | |
1039 playlistwin_scroll(-cfg.scroll_pl_by); | |
1040 | |
1041 } | |
1042 | |
1043 | |
1044 | |
1045 | |
1046 static gboolean | |
1047 playlistwin_press(GtkWidget * widget, | |
1048 GdkEventButton * event, | |
1049 gpointer callback_data) | |
1050 { | |
1051 gboolean grab = TRUE; | |
1052 gint xpos, ypos; | |
1053 GtkWidget *_menu; | |
1054 GtkRequisition req; | |
1055 | |
1056 gtk_window_get_position(GTK_WINDOW(playlistwin), &xpos, &ypos); | |
1057 | |
1058 if (event->button == 1 && !cfg.show_wm_decorations && | |
1059 ((!cfg.playlist_shaded && | |
1060 event->x > playlistwin_get_width() - 20 && | |
1061 event->y > cfg.playlist_height - 20) || | |
1062 (cfg.playlist_shaded && | |
1063 event->x >= playlistwin_get_width() - 31 && | |
1064 event->x < playlistwin_get_width() - 22))) { | |
1065 | |
1066 /* NOTE: Workaround for bug #214 */ | |
1067 if (event->type != GDK_2BUTTON_PRESS && | |
1068 event->type != GDK_3BUTTON_PRESS) { | |
1069 /* resize area */ | |
1070 playlistwin_resizing = TRUE; | |
1071 gtk_window_begin_resize_drag(GTK_WINDOW(widget), | |
1072 GDK_WINDOW_EDGE_SOUTH_EAST, | |
1073 event->button, | |
1074 event->x + xpos, event->y + ypos, | |
1075 event->time); | |
1076 } | |
1077 grab = FALSE; | |
1078 } | |
1079 else if (event->button == 1 && REGION_L(12, 37, 29, 11)) { | |
1080 /* ADD button menu */ | |
1081 | |
1082 _menu = GTK_WIDGET(pladd_menu->widget); | |
1083 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1084 gtk_widget_size_request(_menu, &req); | |
1085 gtk_item_factory_popup_with_data(pladd_menu, | |
1086 NULL, NULL, | |
1087 xpos+12, | |
1088 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1089 grab = FALSE; | |
1090 } | |
1091 else if (event->button == 1 && REGION_L(41, 66, 29, 11)) { | |
1092 /* SUB button menu */ | |
1093 _menu = GTK_WIDGET(pldel_menu->widget); | |
1094 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1095 gtk_widget_size_request(_menu, &req); | |
1096 gtk_item_factory_popup_with_data(pldel_menu, | |
1097 NULL, NULL, | |
1098 xpos+40, | |
1099 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1100 grab = FALSE; | |
1101 } | |
1102 else if (event->button == 1 && REGION_L(70, 95, 29, 11)) { | |
1103 /* SEL button menu */ | |
1104 _menu = GTK_WIDGET(plsel_menu->widget); | |
1105 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1106 gtk_widget_size_request(_menu, &req); | |
1107 gtk_item_factory_popup_with_data(plsel_menu, | |
1108 NULL, NULL, | |
1109 xpos+68, | |
1110 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1111 | |
1112 grab = FALSE; | |
1113 } | |
1114 else if (event->button == 1 && REGION_L(99, 124, 29, 11)) { | |
1115 /* MISC button menu */ | |
1116 _menu = GTK_WIDGET(plsort_menu->widget); | |
1117 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1118 gtk_widget_size_request(_menu, &req); | |
1119 gtk_item_factory_popup_with_data(plsort_menu, | |
1120 NULL, NULL, | |
1121 xpos+100, | |
1122 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1123 grab = FALSE; | |
1124 } | |
1125 else if (event->button == 1 && REGION_R(46, 23, 29, 11)) { | |
1126 /* LIST button menu */ | |
1127 _menu = GTK_WIDGET(pllist_menu->widget); | |
1128 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1129 gtk_widget_size_request(_menu, &req); | |
1130 gtk_item_factory_popup_with_data(pllist_menu, | |
1131 NULL, NULL, | |
1132 xpos + playlistwin_get_width() - req.width - 12, | |
1133 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1134 grab = FALSE; | |
1135 } | |
1136 else if (event->button == 1 && REGION_R(82, 54, 15, 9)) { | |
1137 if (cfg.timer_mode == TIMER_ELAPSED) | |
1138 cfg.timer_mode = TIMER_REMAINING; | |
1139 else | |
1140 cfg.timer_mode = TIMER_ELAPSED; | |
1141 } | |
1142 else if (event->button == 2 && (event->type == GDK_BUTTON_PRESS) && | |
1143 widget_contains(WIDGET(playlistwin_list), event->x, event->y)) { | |
1144 gtk_selection_convert(widget, GDK_SELECTION_PRIMARY, | |
1145 GDK_TARGET_STRING, event->time); | |
1146 } | |
1147 else if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
1045 | 1148 !inside_sensitive_widgets(event->x, event->y) && event->y < 14) |
1149 { | |
1066 | 1150 dock_move_press(dock_window_list, GTK_WINDOW(playlistwin), event, |
1151 FALSE); | |
1045 | 1152 gtk_window_present(GTK_WINDOW(playlistwin)); |
0 | 1153 } |
1154 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1155 !inside_sensitive_widgets(event->x, event->y) | |
1156 && event->y < 14) { | |
1157 /* double click on title bar */ | |
1158 playlistwin_shade_toggle(); | |
1068 | 1159 if (dock_is_moving(GTK_WINDOW(playlistwin))) |
1160 dock_move_release(GTK_WINDOW(playlistwin)); | |
0 | 1161 return TRUE; |
1162 } | |
1163 else if (event->button == 3 && | |
1164 !(widget_contains(WIDGET(playlistwin_list), event->x, event->y) || | |
1165 (event->y >= cfg.playlist_height - 29 && | |
1166 event->y < cfg.playlist_height - 11 && | |
1167 ((event->x >= 12 && event->x < 37) || | |
1168 (event->x >= 41 && event->x < 66) || | |
1169 (event->x >= 70 && event->x < 95) || | |
1170 (event->x >= 99 && event->x < 124) || | |
1171 (event->x >= playlistwin_get_width() - 46 && | |
1172 event->x < playlistwin_get_width() - 23))))) { | |
1173 /* | |
1174 * Pop up the main menu a few pixels down to avoid | |
1175 * anything to be selected initially. | |
1176 */ | |
1177 util_item_factory_popup(mainwin_general_menu, event->x_root, | |
1178 event->y_root + 2, 3, event->time); | |
1179 grab = FALSE; | |
1180 } | |
1181 else if (event->button == 3 && | |
1182 widget_contains(WIDGET(playlistwin_list), event->x, event->y)) { | |
1183 /* popup menu */ | |
1184 playlistwin_set_sensitive_sortmenu(); | |
1360
7e312e0c33e8
[svn] - now filepopup menu shows its state through checkbox.
yaz
parents:
1359
diff
changeset
|
1185 { |
7e312e0c33e8
[svn] - now filepopup menu shows its state through checkbox.
yaz
parents:
1359
diff
changeset
|
1186 GtkWidget *item = gtk_item_factory_get_widget(playlistwin_popup_menu, "/Show Popup Info"); |
7e312e0c33e8
[svn] - now filepopup menu shows its state through checkbox.
yaz
parents:
1359
diff
changeset
|
1187 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), cfg.show_filepopup_for_tuple); |
7e312e0c33e8
[svn] - now filepopup menu shows its state through checkbox.
yaz
parents:
1359
diff
changeset
|
1188 } |
0 | 1189 gtk_item_factory_popup(playlistwin_popup_menu, |
1190 event->x_root, event->y_root + 5, | |
1191 3, event->time); | |
1192 grab = FALSE; | |
1193 } | |
1194 else { | |
1195 handle_press_cb(playlistwin_wlist, widget, event); | |
1196 draw_playlist_window(FALSE); | |
1197 } | |
1198 | |
1199 if (grab) | |
1200 gdk_pointer_grab(playlistwin->window, FALSE, | |
1201 GDK_BUTTON_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | | |
1202 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
1203 GDK_BUTTON1_MOTION_MASK, NULL, NULL, | |
1204 GDK_CURRENT_TIME); | |
1205 | |
1206 return FALSE; | |
1207 } | |
1208 | |
1209 static gboolean | |
1210 playlistwin_focus_in(GtkWidget * widget, GdkEvent * event, gpointer data) | |
1211 { | |
1212 playlistwin_close->pb_allow_draw = TRUE; | |
1213 playlistwin_shade->pb_allow_draw = TRUE; | |
1214 draw_playlist_window(TRUE); | |
1215 return FALSE; | |
1216 } | |
1217 | |
1218 static gboolean | |
1219 playlistwin_focus_out(GtkWidget * widget, | |
1220 GdkEventButton * event, gpointer data) | |
1221 { | |
1222 playlistwin_close->pb_allow_draw = FALSE; | |
1223 playlistwin_shade->pb_allow_draw = FALSE; | |
1224 draw_playlist_window(TRUE); | |
1225 return FALSE; | |
1226 } | |
1227 | |
1228 static gboolean | |
1229 playlistwin_configure(GtkWidget * window, | |
1230 GdkEventConfigure * event, gpointer data) | |
1231 { | |
1232 if (!GTK_WIDGET_VISIBLE(window)) | |
1233 return FALSE; | |
1234 | |
1235 cfg.playlist_x = event->x; | |
1236 cfg.playlist_y = event->y; | |
1237 | |
1238 if (playlistwin_resizing) { | |
1239 if (event->width != playlistwin_get_width() || | |
1240 event->height != playlistwin_get_height()) | |
1241 playlistwin_resize(event->width, event->height); | |
1242 } | |
1243 return TRUE; | |
1244 } | |
1245 | |
1246 void | |
1247 playlistwin_set_back_pixmap(void) | |
1248 { | |
1249 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
1250 gdk_window_clear(playlistwin->window); | |
1251 } | |
1252 | |
1253 static gboolean | |
1254 playlistwin_delete(GtkWidget * w, gpointer data) | |
1255 { | |
1256 playlistwin_hide(); | |
1257 return TRUE; | |
1258 } | |
1259 | |
1260 static void | |
1261 playlistwin_keypress_up_down_handler(PlayList_List * pl, | |
1262 gboolean up, guint state) | |
1263 { | |
1264 if ((state & GDK_MOD1_MASK) && (state & GDK_SHIFT_MASK)) | |
1265 return; | |
1266 if (!(state & GDK_MOD1_MASK)) | |
1267 playlist_select_all(FALSE); | |
1268 | |
1269 if (pl->pl_prev_selected == -1 || | |
1270 (!playlistwin_item_visible(pl->pl_prev_selected) && | |
1271 !(state & GDK_SHIFT_MASK && pl->pl_prev_min != -1))) { | |
1272 pl->pl_prev_selected = pl->pl_first; | |
1273 } | |
1274 else if (state & GDK_SHIFT_MASK) { | |
1275 if (pl->pl_prev_min == -1) { | |
1276 pl->pl_prev_max = pl->pl_prev_selected; | |
1277 pl->pl_prev_min = pl->pl_prev_selected; | |
1278 } | |
1279 pl->pl_prev_max += (up ? -1 : 1); | |
1280 pl->pl_prev_max = | |
1281 CLAMP(pl->pl_prev_max, 0, playlist_get_length() - 1); | |
1282 | |
1283 pl->pl_first = MIN(pl->pl_first, pl->pl_prev_max); | |
1284 pl->pl_first = MAX(pl->pl_first, pl->pl_prev_max - | |
1285 pl->pl_num_visible + 1); | |
1286 playlist_select_range(pl->pl_prev_min, pl->pl_prev_max, TRUE); | |
1287 return; | |
1288 } | |
1289 else if (state & GDK_MOD1_MASK) { | |
1290 if (up) | |
1291 playlist_list_move_up(pl); | |
1292 else | |
1293 playlist_list_move_down(pl); | |
1294 if (pl->pl_prev_min < pl->pl_first) | |
1295 pl->pl_first = pl->pl_prev_min; | |
1296 else if (pl->pl_prev_max >= (pl->pl_first + pl->pl_num_visible)) | |
1297 pl->pl_first = pl->pl_prev_max - pl->pl_num_visible + 1; | |
1298 return; | |
1299 } | |
1300 else if (up) | |
1301 pl->pl_prev_selected--; | |
1302 else | |
1303 pl->pl_prev_selected++; | |
1304 | |
1305 pl->pl_prev_selected = | |
1306 CLAMP(pl->pl_prev_selected, 0, playlist_get_length() - 1); | |
1307 | |
1308 if (pl->pl_prev_selected < pl->pl_first) | |
1309 pl->pl_first--; | |
1310 else if (pl->pl_prev_selected >= (pl->pl_first + pl->pl_num_visible)) | |
1311 pl->pl_first++; | |
1312 | |
1313 playlist_select_range(pl->pl_prev_selected, pl->pl_prev_selected, TRUE); | |
1314 pl->pl_prev_min = -1; | |
1315 | |
1316 } | |
1317 | |
1318 /* FIXME: Handle the keys through menu */ | |
1319 | |
1320 static gboolean | |
1321 playlistwin_keypress(GtkWidget * w, GdkEventKey * event, gpointer data) | |
1322 { | |
1323 guint keyval; | |
1324 gboolean refresh = FALSE; | |
1325 | |
1326 if (cfg.playlist_shaded) | |
1327 return FALSE; | |
1328 | |
1329 switch (keyval = event->keyval) { | |
1330 case GDK_KP_Up: | |
1331 case GDK_KP_Down: | |
1332 case GDK_Up: | |
1333 case GDK_Down: | |
1334 playlistwin_keypress_up_down_handler(playlistwin_list, | |
1335 keyval == GDK_Up | |
1336 || keyval == GDK_KP_Up, | |
1337 event->state); | |
1338 refresh = TRUE; | |
1339 break; | |
1340 case GDK_Page_Up: | |
1341 playlistwin_scroll(-playlistwin_list->pl_num_visible); | |
1342 refresh = TRUE; | |
1343 break; | |
1344 case GDK_Page_Down: | |
1345 playlistwin_scroll(playlistwin_list->pl_num_visible); | |
1346 refresh = TRUE; | |
1347 break; | |
1348 case GDK_Home: | |
1349 playlistwin_list->pl_first = 0; | |
1350 refresh = TRUE; | |
1351 break; | |
1352 case GDK_End: | |
1353 playlistwin_list->pl_first = | |
1354 playlist_get_length() - playlistwin_list->pl_num_visible; | |
1355 refresh = TRUE; | |
1356 break; | |
1357 case GDK_Return: | |
1358 if (playlistwin_list->pl_prev_selected > -1 | |
1359 && playlistwin_item_visible(playlistwin_list->pl_prev_selected)) { | |
1360 playlist_set_position(playlistwin_list->pl_prev_selected); | |
1361 if (!bmp_playback_get_playing()) | |
1362 bmp_playback_initiate(); | |
1363 } | |
1364 break; | |
1365 case GDK_3: | |
1366 if (event->state & GDK_CONTROL_MASK) | |
1367 playlistwin_fileinfo(); | |
1368 break; | |
1369 case GDK_Delete: | |
1370 if (event->state & GDK_CONTROL_MASK) | |
1371 playlist_delete(TRUE); | |
1372 else | |
1373 playlist_delete(FALSE); | |
1374 break; | |
1375 case GDK_Insert: | |
331
ac6389064cf9
[svn] Remove Add Directory option as it is broken. Patch by laci, closes bug #377.
chainsaw
parents:
284
diff
changeset
|
1376 if (event->state & GDK_MOD1_MASK) |
0 | 1377 mainwin_show_add_url_window(); |
1378 else | |
1379 playlistwin_show_filebrowser(); | |
1380 break; | |
226
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1381 case GDK_Left: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1382 case GDK_KP_Left: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1383 case GDK_KP_7: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1384 if (playlist_get_current_length() != -1) |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1385 bmp_playback_seek(CLAMP |
436 | 1386 (bmp_playback_get_time() - 1000, 0, |
226
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1387 playlist_get_current_length()) / 1000); |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1388 break; |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1389 case GDK_Right: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1390 case GDK_KP_Right: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1391 case GDK_KP_9: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1392 if (playlist_get_current_length() != -1) |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1393 bmp_playback_seek(CLAMP |
436 | 1394 (bmp_playback_get_time() + 1000, 0, |
226
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1395 playlist_get_current_length()) / 1000); |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1396 break; |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1397 |
0 | 1398 case GDK_Escape: |
1399 mainwin_minimize_cb(); | |
1400 break; | |
1401 default: | |
1402 return FALSE; | |
1403 } | |
1404 | |
1405 if (refresh) | |
1406 playlistwin_update_list(); | |
1407 | |
1408 return TRUE; | |
1409 } | |
1410 | |
1411 static void | |
1412 playlistwin_draw_frame(void) | |
1413 { | |
1414 gboolean focus = | |
1415 gtk_window_has_toplevel_focus(GTK_WINDOW(playlistwin)) || | |
1416 !cfg.dim_titlebar; | |
1417 | |
1418 if (cfg.playlist_shaded) { | |
1419 skin_draw_playlistwin_shaded(bmp_active_skin, | |
1420 playlistwin_bg, playlistwin_gc, | |
1421 playlistwin_get_width(), focus); | |
1422 } | |
1423 else { | |
1424 skin_draw_playlistwin_frame(bmp_active_skin, | |
1425 playlistwin_bg, playlistwin_gc, | |
1426 playlistwin_get_width(), | |
1427 cfg.playlist_height, focus); | |
1428 } | |
1429 } | |
1430 | |
1431 void | |
1432 draw_playlist_window(gboolean force) | |
1433 { | |
1434 gboolean redraw; | |
1435 GList *wl; | |
1436 Widget *w; | |
1437 | |
1438 if (force) | |
1439 playlistwin_draw_frame(); | |
1440 | |
1441 widget_list_lock(playlistwin_wlist); | |
1442 widget_list_draw(playlistwin_wlist, &redraw, force); | |
1443 | |
1444 if (redraw || force) { | |
1445 if (force) { | |
1446 gdk_window_clear(playlistwin->window); | |
1447 } | |
1448 else { | |
1449 for (wl = playlistwin_wlist; wl; wl = g_list_next(wl)) { | |
1450 w = WIDGET(wl->data); | |
1451 if (w->redraw && w->visible) { | |
1452 gdk_window_clear_area(playlistwin->window, w->x, w->y, | |
1453 w->width, w->height); | |
1454 w->redraw = FALSE; | |
1455 } | |
1456 } | |
1457 } | |
1458 | |
1459 gdk_flush(); | |
1460 } | |
1461 | |
1462 widget_list_unlock(playlistwin_wlist); | |
1463 } | |
1464 | |
1465 | |
1466 void | |
1467 playlistwin_hide_timer(void) | |
1468 { | |
1469 textbox_set_text(playlistwin_time_min, " "); | |
1470 textbox_set_text(playlistwin_time_sec, " "); | |
1471 } | |
1472 | |
1473 void | |
1474 playlistwin_set_time(gint time, gint length, TimerMode mode) | |
1475 { | |
1476 gchar *text, sign; | |
1477 | |
1478 if (mode == TIMER_REMAINING && length != -1) { | |
1479 time = length - time; | |
1480 sign = '-'; | |
1481 } | |
1482 else | |
1483 sign = ' '; | |
1484 | |
1485 time /= 1000; | |
1486 | |
1487 if (time < 0) | |
1488 time = 0; | |
1489 if (time > 99 * 60) | |
1490 time /= 60; | |
1491 | |
1492 text = g_strdup_printf("%c%-2.2d", sign, time / 60); | |
1493 textbox_set_text(playlistwin_time_min, text); | |
1494 g_free(text); | |
1495 | |
1496 text = g_strdup_printf("%-2.2d", time % 60); | |
1497 textbox_set_text(playlistwin_time_sec, text); | |
1498 g_free(text); | |
1499 } | |
1500 | |
1501 static void | |
1502 playlistwin_drag_motion(GtkWidget * widget, | |
1503 GdkDragContext * context, | |
1504 gint x, gint y, | |
1505 GtkSelectionData * selection_data, | |
1506 guint info, guint time, gpointer user_data) | |
1507 { | |
1508 playlistwin_list->pl_drag_motion = TRUE; | |
1509 playlistwin_list->drag_motion_x = x; | |
1510 playlistwin_list->drag_motion_y = y; | |
1511 playlistwin_update_list(); | |
1512 playlistwin_hint_flag = TRUE; | |
1513 } | |
1514 | |
1515 static void | |
1516 playlistwin_drag_end(GtkWidget * widget, | |
1517 GdkDragContext * context, gpointer user_data) | |
1518 { | |
1519 playlistwin_list->pl_drag_motion = FALSE; | |
1520 playlistwin_hint_flag = FALSE; | |
1521 playlistwin_update_list(); | |
1522 } | |
1523 | |
1524 static void | |
1525 playlistwin_drag_data_received(GtkWidget * widget, | |
1526 GdkDragContext * context, | |
1527 gint x, gint y, | |
1528 GtkSelectionData * | |
1529 selection_data, guint info, | |
1530 guint time, gpointer user_data) | |
1531 { | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
1532 gint pos; |
0 | 1533 |
1534 g_return_if_fail(selection_data != NULL); | |
1535 | |
1536 if (!selection_data->data) { | |
1537 g_message("Received no DND data!"); | |
1538 return; | |
1539 } | |
1540 | |
1541 if (widget_contains(WIDGET(playlistwin_list), x, y)) { | |
1542 pos = (y - WIDGET(playlistwin_list)->y) / | |
1543 playlistwin_list->pl_fheight + playlistwin_list->pl_first; | |
1544 | |
1545 pos = MIN(pos, playlist_get_length()); | |
1546 playlist_ins_url((gchar *) selection_data->data, pos); | |
1547 } | |
1548 else | |
1549 playlist_add_url((gchar *) selection_data->data); | |
1550 } | |
1551 | |
1552 static void | |
1553 playlistwin_create_widgets(void) | |
1554 { | |
1555 /* This function creates the custom widgets used by the playlist editor */ | |
1556 | |
1557 /* text box for displaying song title in shaded mode */ | |
1558 playlistwin_sinfo = | |
1559 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1560 4, 4, playlistwin_get_width() - 35, FALSE, SKIN_TEXT); | |
1561 | |
1562 if (!cfg.playlist_shaded) | |
1563 widget_hide(WIDGET(playlistwin_sinfo)); | |
1564 | |
1565 /* shade/unshade window push button */ | |
1566 if (cfg.playlist_shaded) | |
1567 playlistwin_shade = | |
1568 create_pbutton(&playlistwin_wlist, playlistwin_bg, | |
1569 playlistwin_gc, playlistwin_get_width() - 21, 3, | |
1570 9, 9, 128, 45, 150, 42, | |
1571 playlistwin_shade_toggle, SKIN_PLEDIT); | |
1572 else | |
1573 playlistwin_shade = | |
1574 create_pbutton(&playlistwin_wlist, playlistwin_bg, | |
1575 playlistwin_gc, playlistwin_get_width() - 21, 3, | |
1576 9, 9, 157, 3, 62, 42, playlistwin_shade_toggle, | |
1577 SKIN_PLEDIT); | |
1578 | |
1579 playlistwin_shade->pb_allow_draw = FALSE; | |
1580 | |
1581 /* close window push button */ | |
1582 playlistwin_close = | |
1583 create_pbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1584 playlistwin_get_width() - 11, 3, 9, 9, | |
1585 cfg.playlist_shaded ? 138 : 167, | |
1586 cfg.playlist_shaded ? 45 : 3, 52, 42, | |
1587 playlistwin_hide, SKIN_PLEDIT); | |
1588 playlistwin_close->pb_allow_draw = FALSE; | |
1589 | |
1590 /* playlist list box */ | |
1591 playlistwin_list = | |
1592 create_playlist_list(&playlistwin_wlist, playlistwin_bg, | |
1593 playlistwin_gc, 12, 20, | |
1594 playlistwin_get_width() - 31, | |
1595 cfg.playlist_height - 58); | |
1596 playlist_list_set_font(cfg.playlist_font); | |
1597 | |
1598 /* playlist list box slider */ | |
1599 playlistwin_slider = | |
1600 create_playlistslider(&playlistwin_wlist, playlistwin_bg, | |
1601 playlistwin_gc, playlistwin_get_width() - 15, | |
1602 20, cfg.playlist_height - 58, playlistwin_list); | |
1603 /* track time (minute) */ | |
1604 playlistwin_time_min = | |
1605 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1606 playlistwin_get_width() - 82, | |
1607 cfg.playlist_height - 15, 15, FALSE, SKIN_TEXT); | |
1608 | |
1609 /* track time (second) */ | |
1610 playlistwin_time_sec = | |
1611 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1612 playlistwin_get_width() - 64, | |
1613 cfg.playlist_height - 15, 10, FALSE, SKIN_TEXT); | |
1614 | |
1615 /* playlist information (current track length / total track length) */ | |
1616 playlistwin_info = | |
1617 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1618 playlistwin_get_width() - 143, | |
1040 | 1619 cfg.playlist_height - 28, 90, FALSE, SKIN_TEXT); |
0 | 1620 |
1621 /* mini play control buttons at right bottom corner */ | |
1622 | |
1623 /* rewind button */ | |
1624 playlistwin_srew = | |
1625 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1626 playlistwin_get_width() - 144, | |
1627 cfg.playlist_height - 16, 8, 7, playlist_prev); | |
1628 | |
1629 /* play button */ | |
1630 playlistwin_splay = | |
1631 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1632 playlistwin_get_width() - 138, | |
1633 cfg.playlist_height - 16, 10, 7, mainwin_play_pushed); | |
1634 | |
1635 /* pause button */ | |
1636 playlistwin_spause = | |
1637 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1638 playlistwin_get_width() - 128, | |
1639 cfg.playlist_height - 16, 10, 7, bmp_playback_pause); | |
1640 | |
1641 /* stop button */ | |
1642 playlistwin_sstop = | |
1643 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1644 playlistwin_get_width() - 118, | |
1645 cfg.playlist_height - 16, 9, 7, mainwin_stop_pushed); | |
1646 | |
1647 /* forward button */ | |
1648 playlistwin_sfwd = | |
1649 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1650 playlistwin_get_width() - 109, | |
1651 cfg.playlist_height - 16, 8, 7, playlist_next); | |
1652 | |
1653 /* eject button */ | |
1654 playlistwin_seject = | |
1655 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1656 playlistwin_get_width() - 100, | |
1657 cfg.playlist_height - 16, 9, 7, mainwin_eject_pushed); | |
1658 | |
1659 | |
1660 playlistwin_sscroll_up = | |
1661 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1662 playlistwin_get_width() - 14, | |
1663 cfg.playlist_height - 35, 8, 5, | |
1664 playlistwin_scroll_up_pushed); | |
1665 playlistwin_sscroll_down = | |
1666 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1667 playlistwin_get_width() - 14, | |
1668 cfg.playlist_height - 30, 8, 5, | |
1669 playlistwin_scroll_down_pushed); | |
1670 | |
1671 } | |
1672 | |
1673 static void | |
1674 selection_received(GtkWidget * widget, | |
1675 GtkSelectionData * selection_data, gpointer data) | |
1676 { | |
1677 if (selection_data->type == GDK_SELECTION_TYPE_STRING && | |
1678 selection_data->length > 0) | |
1679 playlist_add_url((gchar *) selection_data->data); | |
1680 } | |
1681 | |
1682 static void | |
1683 playlistwin_create_window(void) | |
1684 { | |
1685 GdkPixbuf *icon; | |
1686 | |
1687 playlistwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
187 | 1688 gtk_window_set_title(GTK_WINDOW(playlistwin), _("Audacious Playlist Editor")); |
999
386cda529c28
[svn] Add wmclass information to the playlist and equalizer. Patch by cha0smaster, closes bug #481.
chainsaw
parents:
852
diff
changeset
|
1689 gtk_window_set_wmclass(GTK_WINDOW(playlistwin), "playlist", "Audacious"); |
0 | 1690 gtk_window_set_role(GTK_WINDOW(playlistwin), "playlist"); |
1691 gtk_window_set_default_size(GTK_WINDOW(playlistwin), | |
1692 playlistwin_get_width(), | |
1693 playlistwin_get_height()); | |
1694 gtk_window_set_resizable(GTK_WINDOW(playlistwin), TRUE); | |
1695 playlistwin_set_geometry_hints(cfg.playlist_shaded); | |
1068 | 1696 dock_window_list = dock_window_set_decorated(dock_window_list, |
1697 GTK_WINDOW(playlistwin), | |
1698 cfg.show_wm_decorations); | |
1069 | 1699 |
1085 | 1700 gtk_window_set_transient_for(GTK_WINDOW(playlistwin), |
1701 GTK_WINDOW(mainwin)); | |
1702 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(playlistwin), TRUE); | |
1703 | |
0 | 1704 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) bmp_playlist_icon); |
1705 gtk_window_set_icon(GTK_WINDOW(playlistwin), icon); | |
1706 g_object_unref(icon); | |
1707 | |
1708 gtk_widget_set_app_paintable(playlistwin, TRUE); | |
1709 | |
1710 if (cfg.playlist_x != -1 && cfg.save_window_position) | |
1711 gtk_window_move(GTK_WINDOW(playlistwin), | |
1712 cfg.playlist_x, cfg.playlist_y); | |
1713 | |
1286 | 1714 gtk_widget_add_events(playlistwin, GDK_POINTER_MOTION_MASK | |
0 | 1715 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | |
1716 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
1717 GDK_SCROLL_MASK | GDK_VISIBILITY_NOTIFY_MASK); | |
1718 gtk_widget_realize(playlistwin); | |
1719 | |
1720 util_set_cursor(playlistwin); | |
1721 | |
1722 g_signal_connect(playlistwin, "delete_event", | |
1723 G_CALLBACK(playlistwin_delete), NULL); | |
1724 g_signal_connect(playlistwin, "button_press_event", | |
1725 G_CALLBACK(playlistwin_press), NULL); | |
1726 g_signal_connect(playlistwin, "button_release_event", | |
1727 G_CALLBACK(playlistwin_release), NULL); | |
1728 g_signal_connect(playlistwin, "scroll_event", | |
1729 G_CALLBACK(playlistwin_scrolled), NULL); | |
1730 g_signal_connect(playlistwin, "motion_notify_event", | |
1731 G_CALLBACK(playlistwin_motion), NULL); | |
1286 | 1732 g_signal_connect(playlistwin, "enter_notify_event", |
1733 G_CALLBACK(playlistwin_enter), NULL); | |
1734 g_signal_connect(playlistwin, "leave_notify_event", | |
1735 G_CALLBACK(playlistwin_leave), NULL); | |
0 | 1736 g_signal_connect_after(playlistwin, "focus_in_event", |
1737 G_CALLBACK(playlistwin_focus_in), NULL); | |
1738 g_signal_connect_after(playlistwin, "focus_out_event", | |
1739 G_CALLBACK(playlistwin_focus_out), NULL); | |
1740 g_signal_connect(playlistwin, "configure_event", | |
1741 G_CALLBACK(playlistwin_configure), NULL); | |
1742 g_signal_connect(playlistwin, "style_set", | |
1743 G_CALLBACK(playlistwin_set_back_pixmap), NULL); | |
1744 | |
1745 bmp_drag_dest_set(playlistwin); | |
1746 | |
1747 /* DnD stuff */ | |
1748 g_signal_connect(playlistwin, "drag-leave", | |
1749 G_CALLBACK(playlistwin_drag_end), NULL); | |
1750 g_signal_connect(playlistwin, "drag-data-delete", | |
1751 G_CALLBACK(playlistwin_drag_end), NULL); | |
1752 g_signal_connect(playlistwin, "drag-end", | |
1753 G_CALLBACK(playlistwin_drag_end), NULL); | |
1754 g_signal_connect(playlistwin, "drag-drop", | |
1755 G_CALLBACK(playlistwin_drag_end), NULL); | |
1756 g_signal_connect(playlistwin, "drag-data-received", | |
1757 G_CALLBACK(playlistwin_drag_data_received), NULL); | |
1758 g_signal_connect(playlistwin, "drag-motion", | |
1759 G_CALLBACK(playlistwin_drag_motion), NULL); | |
1760 | |
1761 g_signal_connect(playlistwin, "key_press_event", | |
1762 G_CALLBACK(playlistwin_keypress), NULL); | |
1763 g_signal_connect(playlistwin, "selection_received", | |
1764 G_CALLBACK(selection_received), NULL); | |
1765 | |
1766 playlistwin_set_mask(); | |
1767 } | |
1768 | |
1769 void | |
1770 playlistwin_create_popup_menus(void) | |
1771 { | |
1772 playlistwin_accel = gtk_accel_group_new(); | |
1773 | |
1774 /* playlist window popup menu */ | |
1775 playlistwin_popup_menu = create_menu(playlistwin_popup_menu_entries, | |
1776 G_N_ELEMENTS(playlistwin_popup_menu_entries), | |
1777 playlistwin_accel); | |
1778 | |
1779 pladd_menu = create_menu(pladd_menu_entries, G_N_ELEMENTS(pladd_menu_entries), | |
1780 playlistwin_accel); | |
1781 pldel_menu = create_menu(pldel_menu_entries, G_N_ELEMENTS(pldel_menu_entries), | |
1782 playlistwin_accel); | |
1783 plsel_menu = create_menu(plsel_menu_entries, G_N_ELEMENTS(plsel_menu_entries), | |
1784 playlistwin_accel); | |
1785 plsort_menu = create_menu(plsort_menu_entries, | |
1786 G_N_ELEMENTS(plsort_menu_entries), | |
1787 playlistwin_accel); | |
1788 pllist_menu = create_menu(pllist_menu_entries, G_N_ELEMENTS(pllist_menu_entries), | |
1789 playlistwin_accel); | |
1790 | |
1791 #if 0 | |
1792 make_submenu(playlistwin_popup_menu, "/Playlist", | |
1793 playlistwin_playlist_menu); | |
1794 make_submenu(playlistwin_popup_menu, "/Playback", | |
1795 playlistwin_playback_menu); | |
1796 make_submenu(playlistwin_popup_menu, "/Add", | |
1797 pladd_menu); | |
1798 #endif | |
1799 } | |
1800 | |
1801 void | |
1802 playlistwin_create(void) | |
1803 { | |
1804 playlistwin_create_window(); | |
1805 playlistwin_create_popup_menus(); | |
1806 | |
1807 /* create GC and back pixmap for custom widget to draw on */ | |
1808 playlistwin_gc = gdk_gc_new(playlistwin->window); | |
1809 playlistwin_bg = gdk_pixmap_new(playlistwin->window, | |
1810 playlistwin_get_width(), | |
1811 playlistwin_get_height_unshaded(), -1); | |
1812 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
1813 | |
1814 playlistwin_create_widgets(); | |
1815 playlistwin_update_info(); | |
1816 | |
1817 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), playlistwin_accel); | |
1818 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), mainwin_accel); | |
1819 } | |
1820 | |
1821 | |
1822 void | |
1823 playlistwin_show(void) | |
1824 { | |
1825 GtkWidget *item; | |
1826 | |
1827 item = gtk_item_factory_get_widget(mainwin_view_menu, | |
1828 "/Show Playlist Editor"); | |
1829 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); | |
1830 | |
1831 tbutton_set_toggled(mainwin_pl, TRUE); | |
1832 cfg.playlist_visible = TRUE; | |
1833 | |
1834 playlistwin_set_toprow(0); | |
1835 playlist_check_pos_current(); | |
1836 | |
1837 gtk_widget_show(playlistwin); | |
1838 } | |
1839 | |
1840 void | |
1841 playlistwin_hide(void) | |
1842 { | |
1843 GtkWidget *item; | |
1844 | |
1845 item = gtk_item_factory_get_widget(mainwin_view_menu, | |
1846 "/Show Playlist Editor"); | |
1847 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), FALSE); | |
1848 | |
1849 gtk_widget_hide(playlistwin); | |
1850 tbutton_set_toggled(mainwin_pl, FALSE); | |
1851 cfg.playlist_visible = FALSE; | |
1852 | |
1853 gtk_window_present(GTK_WINDOW(mainwin)); | |
1854 gtk_widget_grab_focus(mainwin); | |
1855 } | |
1856 | |
1857 | |
1858 static void | |
1859 plsort_menu_callback(gpointer data, | |
1860 guint action, | |
1861 GtkWidget * widget) | |
1862 { | |
1863 switch (action) { | |
1430
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1864 case PLAYLISTWIN_SORT_BYPLAYLIST: |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1865 playlist_sort(PLAYLIST_SORT_PLAYLIST); |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1866 playlistwin_update_list(); |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1867 break; |
1415 | 1868 case PLAYLISTWIN_SORT_BYTRACK: |
1869 playlist_sort(PLAYLIST_SORT_TRACK); | |
1870 playlistwin_update_list(); | |
1871 break; | |
0 | 1872 case PLAYLISTWIN_SORT_BYTITLE: |
1873 playlist_sort(PLAYLIST_SORT_TITLE); | |
1874 playlistwin_update_list(); | |
1875 break; | |
1251 | 1876 case PLAYLISTWIN_SORT_BYARTIST: |
1877 playlist_sort(PLAYLIST_SORT_ARTIST); | |
1878 playlistwin_update_list(); | |
1879 break; | |
0 | 1880 case PLAYLISTWIN_SORT_BYPATH: |
1881 playlist_sort(PLAYLIST_SORT_PATH); | |
1882 playlistwin_update_list(); | |
1883 break; | |
1884 case PLAYLISTWIN_SORT_BYDATE: | |
1885 playlist_sort(PLAYLIST_SORT_DATE); | |
1886 playlistwin_update_list(); | |
1887 break; | |
1888 case PLAYLISTWIN_SORT_BYFILENAME: | |
1889 playlist_sort(PLAYLIST_SORT_FILENAME); | |
1890 playlistwin_update_list(); | |
1891 break; | |
1430
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1892 case PLAYLISTWIN_SORT_SEL_BYPLAYLIST: |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1893 playlist_sort_selected(PLAYLIST_SORT_PLAYLIST); |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1894 playlistwin_update_list(); |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1895 break; |
1415 | 1896 case PLAYLISTWIN_SORT_SEL_BYTRACK: |
1897 playlist_sort_selected(PLAYLIST_SORT_TRACK); | |
1898 playlistwin_update_list(); | |
1899 break; | |
0 | 1900 case PLAYLISTWIN_SORT_SEL_BYTITLE: |
1901 playlist_sort_selected(PLAYLIST_SORT_TITLE); | |
1902 playlistwin_update_list(); | |
1903 break; | |
1251 | 1904 case PLAYLISTWIN_SORT_SEL_BYARTIST: |
1905 playlist_sort_selected(PLAYLIST_SORT_ARTIST); | |
1906 playlistwin_update_list(); | |
1907 break; | |
0 | 1908 case PLAYLISTWIN_SORT_SEL_BYFILENAME: |
1909 playlist_sort_selected(PLAYLIST_SORT_FILENAME); | |
1910 playlistwin_update_list(); | |
1911 break; | |
1912 case PLAYLISTWIN_SORT_SEL_BYPATH: | |
1913 playlist_sort_selected(PLAYLIST_SORT_PATH); | |
1914 playlistwin_update_list(); | |
1915 break; | |
1916 case PLAYLISTWIN_SORT_SEL_BYDATE: | |
1917 playlist_sort_selected(PLAYLIST_SORT_DATE); | |
1918 playlistwin_update_list(); | |
1919 break; | |
1920 case PLAYLISTWIN_SORT_REVERSE: | |
1921 playlist_reverse(); | |
1922 playlistwin_update_list(); | |
1923 break; | |
1924 case PLAYLISTWIN_SORT_RANDOMIZE: | |
1925 playlist_random(); | |
1926 playlistwin_update_list(); | |
1927 break; | |
1928 } | |
1929 } | |
1930 | |
1931 static void | |
1932 playlistwin_sub_menu_callback(gpointer data, | |
1933 guint action, | |
1934 GtkWidget * widget) | |
1935 { | |
1936 switch (action) { | |
1937 case PLIST_NEW: | |
1938 playlist_set_current_name(NULL); | |
1939 playlist_clear(); | |
1940 mainwin_clear_song_info(); | |
1941 mainwin_set_info_text(); | |
1942 break; | |
1943 case PLIST_SAVE: | |
1944 playlistwin_select_playlist_to_save(playlist_get_current_name()); | |
1945 break; | |
1062
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
1946 case PLIST_DEFAULTSAVE: |
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
1947 playlist_save(bmp_paths[BMP_PATH_PLAYLIST_FILE], FALSE); |
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
1948 break; |
0 | 1949 case PLIST_SAVE_AS: |
1950 playlistwin_select_playlist_to_save(playlist_get_current_name()); | |
1951 break; | |
1952 case PLIST_LOAD: | |
1953 playlistwin_select_playlist_to_load(playlist_get_current_name()); | |
1954 break; | |
1955 case SEL_INV: | |
1956 playlistwin_inverse_selection(); | |
1957 break; | |
1958 case SEL_ZERO: | |
1959 playlistwin_select_none(); | |
1960 break; | |
1961 case SEL_ALL: | |
1962 playlistwin_select_all(); | |
1963 break; | |
1964 case SUB_ALL: | |
1965 playlist_clear(); | |
1966 mainwin_clear_song_info(); | |
1967 mainwin_set_info_text(); | |
1968 break; | |
1969 case SUB_CROP: | |
1970 playlist_delete(TRUE); | |
1971 break; | |
1972 case SUB_SELECTED: | |
1973 playlist_delete(FALSE); | |
1974 break; | |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1975 case SUB_DUPLICATE_BYTITLE: |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1976 playlist_remove_duplicates(PLAYLIST_DUPS_TITLE); |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1977 break; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1978 case SUB_DUPLICATE_BYFILENAME: |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1979 playlist_remove_duplicates(PLAYLIST_DUPS_FILENAME); |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1980 break; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1981 case SUB_DUPLICATE_BYPATH: |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1982 playlist_remove_duplicates(PLAYLIST_DUPS_PATH); |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
625
diff
changeset
|
1983 break; |
0 | 1984 case PLAYLISTWIN_REMOVE_DEAD_FILES: |
1985 playlist_remove_dead_files(); | |
1986 break; | |
1987 case PLAYLISTWIN_REFRESH: | |
1988 playlist_read_info_selection(); | |
1989 playlistwin_update_list(); | |
1990 break; | |
1991 } | |
1992 } | |
1993 | |
1994 static void | |
1995 playlistwin_popup_menu_callback(gpointer data, | |
1996 guint action, | |
1997 GtkWidget * widget) | |
1998 { | |
1388
b8e521f642e4
[svn] - when the playlist page of the preferences window is shown, the checkbox for filepopup follows the popup menu now.
yaz
parents:
1360
diff
changeset
|
1999 extern GtkWidget *filepopupbutton; |
b8e521f642e4
[svn] - when the playlist page of the preferences window is shown, the checkbox for filepopup follows the popup menu now.
yaz
parents:
1360
diff
changeset
|
2000 |
0 | 2001 switch (action) { |
2002 case ADD_FILES: | |
2003 playlistwin_show_filebrowser(); | |
2004 break; | |
2005 case CLOSE_PL_WINDOW: | |
2006 playlistwin_hide(); | |
2007 break; | |
2008 case MISC_FILEINFO: | |
2009 playlistwin_fileinfo(); | |
2010 break; | |
2011 case SEL_LOOKUP: | |
2012 playlist_read_info_selection(); | |
2013 break; | |
2014 case MISC_QUEUE: | |
2015 playlist_queue(); | |
2016 break; | |
2017 case PLIST_CQUEUE: | |
2018 playlist_clear_queue(); | |
2019 break; | |
2020 case PLIST_JTT: | |
2021 mainwin_jump_to_time(); | |
2022 break; | |
2023 case PLIST_JTF: | |
2024 mainwin_jump_to_file(); | |
2025 break; | |
1359
c60990f0bf2a
[svn] - add a menu item that toggles filepopup to the playlist popup menu.
yaz
parents:
1286
diff
changeset
|
2026 case MISC_FILEPOPUP: |
1360
7e312e0c33e8
[svn] - now filepopup menu shows its state through checkbox.
yaz
parents:
1359
diff
changeset
|
2027 cfg.show_filepopup_for_tuple = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
1388
b8e521f642e4
[svn] - when the playlist page of the preferences window is shown, the checkbox for filepopup follows the popup menu now.
yaz
parents:
1360
diff
changeset
|
2028 if(filepopupbutton != NULL){ |
b8e521f642e4
[svn] - when the playlist page of the preferences window is shown, the checkbox for filepopup follows the popup menu now.
yaz
parents:
1360
diff
changeset
|
2029 gtk_signal_emit_by_name(GTK_OBJECT(filepopupbutton), "realize"); |
b8e521f642e4
[svn] - when the playlist page of the preferences window is shown, the checkbox for filepopup follows the popup menu now.
yaz
parents:
1360
diff
changeset
|
2030 } |
1359
c60990f0bf2a
[svn] - add a menu item that toggles filepopup to the playlist popup menu.
yaz
parents:
1286
diff
changeset
|
2031 break; |
c60990f0bf2a
[svn] - add a menu item that toggles filepopup to the playlist popup menu.
yaz
parents:
1286
diff
changeset
|
2032 |
0 | 2033 } |
2034 } |