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