| 17 |
17 |
* the use of this software.
|
| 18 |
18 |
*/
|
| 19 |
19 |
|
| 20 |
|
#include "config.h"
|
|
20 |
#include <stdlib.h>
|
| 21 |
21 |
|
| 22 |
22 |
#include <gdk/gdkkeysyms.h>
|
| 23 |
23 |
#include <gtk/gtk.h>
|
| ... | ... | |
| 27 |
27 |
#include <audacious/misc.h>
|
| 28 |
28 |
#include <audacious/playlist.h>
|
| 29 |
29 |
#include <audacious/plugin.h>
|
|
30 |
#include <libaudcore/hook.h>
|
| 30 |
31 |
#include <libaudgui/list.h>
|
| 31 |
32 |
#include <libaudgui/libaudgui.h>
|
| 32 |
33 |
|
|
34 |
#include "config.h"
|
| 33 |
35 |
#include "gtkui.h"
|
| 34 |
36 |
#include "ui_playlist_notebook.h"
|
| 35 |
37 |
#include "ui_playlist_widget.h"
|
| ... | ... | |
| 123 |
125 |
return GTK_NOTEBOOK(notebook);
|
| 124 |
126 |
}
|
| 125 |
127 |
|
|
128 |
static void save_column_widths ()
|
|
129 |
{
|
|
130 |
int current = gtk_notebook_get_current_page ((GtkNotebook *) notebook);
|
|
131 |
GtkWidget * treeview = playlist_get_treeview (current);
|
|
132 |
|
|
133 |
char * widths, * expand;
|
|
134 |
ui_playlist_widget_get_column_widths (treeview, & widths, & expand);
|
|
135 |
|
|
136 |
aud_set_string ("gtkui", "column_widths", widths);
|
|
137 |
aud_set_string ("gtkui", "column_expand", expand);
|
|
138 |
|
|
139 |
free (widths);
|
|
140 |
free (expand);
|
|
141 |
}
|
|
142 |
|
|
143 |
static void apply_column_widths (GtkWidget * treeview)
|
|
144 |
{
|
|
145 |
char * widths = aud_get_string ("gtkui", "column_widths");
|
|
146 |
char * expand = aud_get_string ("gtkui", "column_expand");
|
|
147 |
|
|
148 |
if (widths && widths[0] && expand && expand[0])
|
|
149 |
ui_playlist_widget_set_column_widths (treeview, widths, expand);
|
|
150 |
|
|
151 |
free (widths);
|
|
152 |
free (expand);
|
|
153 |
}
|
|
154 |
|
| 126 |
155 |
static void tab_title_reset(GtkWidget *ebox)
|
| 127 |
156 |
{
|
| 128 |
157 |
GtkWidget *label = g_object_get_data(G_OBJECT(ebox), "label");
|
| ... | ... | |
| 169 |
198 |
static void tab_changed (GtkNotebook * notebook, GtkWidget * page, gint
|
| 170 |
199 |
page_num, void * unused)
|
| 171 |
200 |
{
|
| 172 |
|
GtkWidget * treeview = playlist_get_treeview (page_num);
|
|
201 |
save_column_widths ();
|
|
202 |
apply_column_widths (playlist_get_treeview (page_num));
|
| 173 |
203 |
|
| 174 |
|
if (treeview != NULL)
|
| 175 |
|
aud_playlist_set_active (page_num);
|
|
204 |
aud_playlist_set_active (page_num);
|
| 176 |
205 |
}
|
| 177 |
206 |
|
| 178 |
207 |
static void tab_reordered(GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data)
|
| ... | ... | |
| 233 |
262 |
vscroll = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrollwin));
|
| 234 |
263 |
|
| 235 |
264 |
treeview = ui_playlist_widget_new(playlist);
|
|
265 |
apply_column_widths (treeview);
|
|
266 |
|
| 236 |
267 |
g_object_set_data(G_OBJECT(scrollwin), "treeview", treeview);
|
| 237 |
268 |
|
| 238 |
269 |
gtk_container_add(GTK_CONTAINER(scrollwin), treeview);
|
| ... | ... | |
| 320 |
351 |
|
| 321 |
352 |
static void add_remove_pages (void)
|
| 322 |
353 |
{
|
|
354 |
g_signal_handlers_block_by_func (notebook, (void *) tab_changed, NULL);
|
|
355 |
g_signal_handlers_block_by_func (notebook, (void *) tab_reordered, NULL);
|
|
356 |
|
|
357 |
save_column_widths ();
|
|
358 |
|
| 323 |
359 |
gint lists = aud_playlist_count ();
|
| 324 |
360 |
gint pages = gtk_notebook_get_n_pages ((GtkNotebook *) notebook);
|
| 325 |
361 |
|
| ... | ... | |
| 333 |
369 |
/* do we have an orphaned treeview? */
|
| 334 |
370 |
if (aud_playlist_by_unique_id (tree_id) < 0)
|
| 335 |
371 |
{
|
| 336 |
|
g_signal_handlers_block_by_func (notebook, (void *) tab_changed, NULL);
|
| 337 |
372 |
gtk_notebook_remove_page ((GtkNotebook *) notebook, i);
|
| 338 |
|
g_signal_handlers_unblock_by_func (notebook, (void *) tab_changed, NULL);
|
| 339 |
373 |
pages --;
|
| 340 |
374 |
continue;
|
| 341 |
375 |
}
|
| ... | ... | |
| 362 |
396 |
/* found it? move it to the right place */
|
| 363 |
397 |
if (tree_id == list_id)
|
| 364 |
398 |
{
|
| 365 |
|
g_signal_handlers_block_by_func (notebook, (void *) tab_reordered, NULL);
|
| 366 |
399 |
gtk_notebook_reorder_child ((GtkNotebook *) notebook, page, i);
|
| 367 |
|
g_signal_handlers_unblock_by_func (notebook, (void *) tab_reordered, NULL);
|
| 368 |
400 |
found = TRUE;
|
| 369 |
401 |
break;
|
| 370 |
402 |
}
|
| ... | ... | |
| 385 |
417 |
ui_playlist_notebook_create_tab (pages);
|
| 386 |
418 |
pages ++;
|
| 387 |
419 |
}
|
|
420 |
|
|
421 |
int active = aud_playlist_get_active ();
|
|
422 |
apply_column_widths (playlist_get_treeview (active));
|
|
423 |
gtk_notebook_set_current_page ((GtkNotebook *) notebook, active);
|
|
424 |
|
|
425 |
g_signal_handlers_unblock_by_func (notebook, (void *) tab_changed, NULL);
|
|
426 |
g_signal_handlers_unblock_by_func (notebook, (void *) tab_reordered, NULL);
|
| 388 |
427 |
}
|
| 389 |
428 |
|
| 390 |
429 |
void ui_playlist_notebook_update (void * data, void * user)
|
| ... | ... | |
| 461 |
500 |
|
| 462 |
501 |
static void destroy_cb (void)
|
| 463 |
502 |
{
|
|
503 |
hook_dissociate ("config save", (HookFunction) save_column_widths);
|
|
504 |
|
| 464 |
505 |
notebook = NULL;
|
| 465 |
506 |
switch_handler = 0;
|
| 466 |
507 |
reorder_handler = 0;
|
| ... | ... | |
| 472 |
513 |
gtk_notebook_set_scrollable ((GtkNotebook *) notebook, TRUE);
|
| 473 |
514 |
make_add_button (notebook);
|
| 474 |
515 |
|
|
516 |
hook_associate ("config save", (HookFunction) save_column_widths, NULL);
|
|
517 |
|
| 475 |
518 |
g_signal_connect (notebook, "destroy", (GCallback) destroy_cb, NULL);
|
| 476 |
519 |
return notebook;
|
| 477 |
520 |
}
|