Mercurial > audlegacy
changeset 3629:5481a48b3101
Automated merge with ssh://sidhe.atheme.org//hg/audacious
author | Jonathan Schleifer <js@h3c.de> |
---|---|
date | Tue, 25 Sep 2007 16:27:07 +0200 |
parents | 05648eaa2e1f (current diff) 9038c338ebc2 (diff) |
children | 773f69be3d14 |
files | |
diffstat | 4 files changed, 193 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Tue Sep 25 16:26:48 2007 +0200 +++ b/.hgignore Tue Sep 25 16:27:07 2007 +0200 @@ -1,31 +1,39 @@ +syntax: regexp +^aclocal\.m4 +^autom4te\.cache +^audacious\.pc +^audclient\.pc +^buildsys\.mk +^config\.h +^config\.h\.in +^config\.log +^config\.status +^configure +^extra\.mk +^man/audacious\.1 +^man/audtool\.1 +^mk/rules\.mk +^po/Makefile +^po/Makefile\.in +^po/POTFILES +^po/stamp-po +^src/audacious/audacious +^src/audacious/audacious\.desktop +^src/audacious/build_stamp\.c +^src/audacious/dbus-client-bindings\.h +^src/audacious/dbus-server-bindings\.h +^src/audtool/audtool +^cscope\.out +^tags syntax: glob -aclocal.m4 -autom4te.cache -audacious.pc -audclient.pc -buildsys.mk -config.h -config.h.in -config.log -config.status -configure -extra.mk -man/audacious.1 -man/audtool.1 -po/Makefile -po/Makefile.in -po/POTFILES -po/stamp-po -src/audacious/audacious -src/audacious/audacious.desktop -src/audacious/build_stamp.c -src/audacious/dbus-client-bindings.h -src/audacious/dbus-server-bindings.h -src/audtool/audtool +.git .deps +.depend +.depend-done *.a *.dylib *.gmo *.o *.so *~ +*.swp
--- a/AUTHORS Tue Sep 25 16:26:48 2007 +0200 +++ b/AUTHORS Tue Sep 25 16:27:07 2007 +0200 @@ -4,6 +4,7 @@ -------------------------------------------- George Averill <nhjm449@gmail.com> +Kieran Clancy <clancy.kieran+audacious@gmail.com> Michael Färber <0102@gmx.at> Giacomo Lozito <james@develia.org> William Pitcock <nenolod@sacredspiral.co.uk>
--- a/src/audacious/playlist.c Tue Sep 25 16:26:48 2007 +0200 +++ b/src/audacious/playlist.c Tue Sep 25 16:27:07 2007 +0200 @@ -328,6 +328,7 @@ playlists_iter = playlists; playlistwin_update_list(playlist_get_active()); + playlist_manager_update(); } void @@ -342,6 +343,7 @@ playlists_iter = playlists; playlistwin_update_list(playlist_get_active()); + playlist_manager_update(); } void @@ -353,6 +355,7 @@ playlists_iter = playlists; playlistwin_update_list(playlist); + playlist_manager_update(); } /* *********************** playlist code ********************** */ @@ -374,11 +377,13 @@ if (!title) { playlist->title = NULL; if(oldtitle) g_free(oldtitle); + playlist_manager_update(); return FALSE; } playlist->title = str_to_utf8(title); if(oldtitle) g_free(oldtitle); + playlist_manager_update(); return TRUE; } @@ -789,6 +794,7 @@ __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec); playlist_generate_shuffle_list(playlist); playlistwin_update_list(playlist); + playlist_manager_update(); return TRUE; } @@ -1231,6 +1237,7 @@ playback_initiate(); playlistwin_update_list(playlist); + playlist_manager_update(); } void @@ -1291,6 +1298,8 @@ playback_initiate(); else playlistwin_update_list(playlist); + + playlist_manager_update(); } void @@ -1844,6 +1853,7 @@ playlist_generate_shuffle_list(playlist); playlistwin_update_list(playlist); + playlist_manager_update(); return new_len - old_len; } @@ -3358,6 +3368,7 @@ playlist_recalc_total_time(newpl); playlistwin_update_list(playlist); + playlist_manager_update(); return newpl; }
--- a/src/audacious/ui_playlist_manager.c Tue Sep 25 16:26:48 2007 +0200 +++ b/src/audacious/ui_playlist_manager.c Tue Sep 25 16:27:07 2007 +0200 @@ -41,18 +41,24 @@ { PLLIST_COL_NAME = 0, PLLIST_COL_ENTRIESNUM, - PLLIST_COL_PLPOINTER, + PLLIST_PLPOINTER, + PLLIST_TEXT_WEIGHT, PLLIST_NUMCOLS }; -static void +static GtkTreeIter playlist_manager_populate ( GtkListStore * store ) { GList *playlists = NULL; - GtkTreeIter iter; + Playlist *active, *iter_playlist, *next_playlist; + GtkTreeIter iter, insert, next, active_iter; + gboolean valid, have_active_iter; + active = playlist_get_active(); playlists = playlist_get_playlists(); + valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(store) , &iter ); + have_active_iter = FALSE; while ( playlists != NULL ) { GList *entries = NULL; @@ -67,14 +73,75 @@ entriesnum++; PLAYLIST_UNLOCK(playlist); - gtk_list_store_append( store , &iter ); - gtk_list_store_set( store, &iter, + /* update the tree model conservatively */ + + if ( !valid ) + { + /* append */ + gtk_list_store_append( store , &insert ); + goto store_set; + } + + gtk_tree_model_get( GTK_TREE_MODEL(store) , &iter , + PLLIST_PLPOINTER , &iter_playlist , -1 ); + + if ( playlist == iter_playlist ) + { + /* already have - just update */ + insert = iter; + valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(store) , &iter ); + goto store_set; + } + + /* handle movement/deletion/insertion of single elements */ + if ( gtk_tree_model_iter_next( GTK_TREE_MODEL(store) , &next ) ) + { + gtk_tree_model_get( GTK_TREE_MODEL(store) , &next , + PLLIST_PLPOINTER , &next_playlist , -1 ); + if ( playlist == next_playlist ) + { + /* remove */ + gtk_list_store_remove( store , &iter ); + iter = next; + valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); + goto next_playlist; + } + } + + /* insert */ + gtk_list_store_insert_before( store , &insert , &iter ); + +store_set: + gtk_list_store_set( store, &insert, PLLIST_COL_NAME , pl_name , PLLIST_COL_ENTRIESNUM , entriesnum , - PLLIST_COL_PLPOINTER , playlist , -1 ); + PLLIST_PLPOINTER , playlist , + PLLIST_TEXT_WEIGHT , playlist == active ? + PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL , + -1 ); + if ( !have_active_iter && playlist == active ) + { + active_iter = insert; + have_active_iter = TRUE; + } + +next_playlist: playlists = g_list_next(playlists); } - return; + + while (valid) + { + /* remove any other elements */ + next = iter; + valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(store) , &next ); + gtk_list_store_remove( store , &iter ); + iter = next; + } + + if ( !have_active_iter ) + gtk_tree_model_get_iter_first( GTK_TREE_MODEL(store) , &active_iter ); + + return active_iter; } @@ -101,7 +168,9 @@ gtk_list_store_set( store, &iter, PLLIST_COL_NAME , pl_name , PLLIST_COL_ENTRIESNUM , 0 , - PLLIST_COL_PLPOINTER , newpl , -1 ); + PLLIST_PLPOINTER , newpl , + PLLIST_TEXT_WEIGHT , PANGO_WEIGHT_NORMAL , + -1 ); ENABLE_MANAGER_UPDATE(); @@ -115,11 +184,16 @@ GtkTreeSelection *listsel = gtk_tree_view_get_selection( GTK_TREE_VIEW(listview) ); GtkTreeModel *store; GtkTreeIter iter; + Playlist *active; + gboolean was_active; if ( gtk_tree_selection_get_selected( listsel , &store , &iter ) == TRUE ) { Playlist *playlist = NULL; - gtk_tree_model_get( store, &iter, PLLIST_COL_PLPOINTER , &playlist , -1 ); + gtk_tree_model_get( store, &iter, PLLIST_PLPOINTER , &playlist , -1 ); + + active = playlist_get_active(); + was_active = ( playlist == active ); if ( gtk_tree_model_iter_n_children( store , NULL ) < 2 ) { @@ -135,6 +209,20 @@ playlist_remove_playlist( playlist ); ENABLE_MANAGER_UPDATE(); } + + if ( was_active && gtk_tree_model_get_iter_first( store , &iter ) ) + { + /* update bolded playlist */ + active = playlist_get_active(); + do { + gtk_tree_model_get( store , &iter , + PLLIST_PLPOINTER , &playlist , -1 ); + gtk_list_store_set( GTK_LIST_STORE(store) , &iter , + PLLIST_TEXT_WEIGHT , playlist == active ? + PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL , + -1 ); + } while ( gtk_tree_model_iter_next( store , &iter ) ); + } } return; @@ -142,18 +230,34 @@ static void -playlist_manager_cb_lv_dclick ( GtkTreeView * lv , GtkTreePath * path , +playlist_manager_cb_lv_dclick ( GtkTreeView * listview , GtkTreePath * path , GtkTreeViewColumn * col , gpointer userdata ) { GtkTreeModel *store; GtkTreeIter iter; + Playlist *playlist = NULL, *active; - store = gtk_tree_view_get_model( GTK_TREE_VIEW(lv) ); + store = gtk_tree_view_get_model( GTK_TREE_VIEW(listview) ); if ( gtk_tree_model_get_iter( store , &iter , path ) == TRUE ) { - Playlist *playlist = NULL; - gtk_tree_model_get( store , &iter , PLLIST_COL_PLPOINTER , &playlist , -1 ); + gtk_tree_model_get( store , &iter , PLLIST_PLPOINTER , &playlist , -1 ); + DISABLE_MANAGER_UPDATE(); playlist_select_playlist( playlist ); + ENABLE_MANAGER_UPDATE(); + } + + if ( gtk_tree_model_get_iter_first( store , &iter ) ) + { + /* update bolded playlist */ + active = playlist_get_active(); + do { + gtk_tree_model_get( store , &iter , + PLLIST_PLPOINTER , &playlist , -1 ); + gtk_list_store_set( GTK_LIST_STORE(store) , &iter , + PLLIST_TEXT_WEIGHT , playlist == active ? + PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL , + -1 ); + } while ( gtk_tree_model_iter_next( store , &iter ) ); } return; @@ -181,17 +285,19 @@ static void playlist_manager_cb_lv_name_edited ( GtkCellRendererText *cell , gchar *path_string , - gchar *new_text , gpointer lv ) + gchar *new_text , gpointer listview ) { /* this is currently used to change playlist names */ - GtkTreeModel *store = gtk_tree_view_get_model( GTK_TREE_VIEW(lv) ); + GtkTreeModel *store = gtk_tree_view_get_model( GTK_TREE_VIEW(listview) ); GtkTreeIter iter; if ( gtk_tree_model_get_iter_from_string( store , &iter , path_string ) == TRUE ) { Playlist *playlist = NULL; - gtk_tree_model_get( GTK_TREE_MODEL(store), &iter, PLLIST_COL_PLPOINTER , &playlist , -1 ); + gtk_tree_model_get( GTK_TREE_MODEL(store), &iter, PLLIST_PLPOINTER , &playlist , -1 ); + DISABLE_MANAGER_UPDATE(); playlist_set_current_name( playlist , new_text ); + ENABLE_MANAGER_UPDATE(); gtk_list_store_set( GTK_LIST_STORE(store), &iter, PLLIST_COL_NAME , new_text , -1 ); } /* set the renderer uneditable again */ @@ -241,6 +347,8 @@ GtkWidget *playman_bbar_hbbox; GtkWidget *playman_bbar_bt_new, *playman_bbar_bt_del, *playman_bbar_bt_close; GdkGeometry playman_win_hints; + GtkTreeIter active_iter; + GtkTreePath *active_path; if ( playman_win != NULL ) { @@ -271,27 +379,37 @@ G_TYPE_STRING -> playlist name G_TYPE_UINT -> number of entries in playlist G_TYPE_POINTER -> playlist pointer (Playlist*) + PANGO_TYPE_WEIGHT -> font weight ---------------------------------------------- */ - pl_store = gtk_list_store_new( PLLIST_NUMCOLS , G_TYPE_STRING , G_TYPE_UINT , G_TYPE_POINTER ); - playlist_manager_populate( pl_store ); + pl_store = gtk_list_store_new( PLLIST_NUMCOLS , + G_TYPE_STRING , G_TYPE_UINT , G_TYPE_POINTER , PANGO_TYPE_WEIGHT ); + active_iter = playlist_manager_populate( pl_store ); playman_pl_lv_frame = gtk_frame_new( NULL ); playman_pl_lv = gtk_tree_view_new_with_model( GTK_TREE_MODEL(pl_store) ); - g_object_unref( pl_store ); + g_object_set_data( G_OBJECT(playman_win) , "lv" , playman_pl_lv ); g_object_set_data( G_OBJECT(playman_pl_lv) , "opt1" , GINT_TO_POINTER(0) ); playman_pl_lv_textrndr_entriesnum = gtk_cell_renderer_text_new(); /* uneditable */ playman_pl_lv_textrndr_name = gtk_cell_renderer_text_new(); /* can become editable */ + g_object_set( G_OBJECT(playman_pl_lv_textrndr_entriesnum) , "weight-set" , TRUE , NULL ); + g_object_set( G_OBJECT(playman_pl_lv_textrndr_name) , "weight-set" , TRUE , NULL ); g_signal_connect( G_OBJECT(playman_pl_lv_textrndr_name) , "edited" , G_CALLBACK(playlist_manager_cb_lv_name_edited) , playman_pl_lv ); g_object_set_data( G_OBJECT(playman_pl_lv) , "rn" , playman_pl_lv_textrndr_name ); playman_pl_lv_col_name = gtk_tree_view_column_new_with_attributes( - _("Playlist") , playman_pl_lv_textrndr_name , "text" , PLLIST_COL_NAME , NULL ); + _("Playlist") , playman_pl_lv_textrndr_name , + "text" , PLLIST_COL_NAME , + "weight", PLLIST_TEXT_WEIGHT , + NULL ); gtk_tree_view_column_set_expand( GTK_TREE_VIEW_COLUMN(playman_pl_lv_col_name) , TRUE ); gtk_tree_view_append_column( GTK_TREE_VIEW(playman_pl_lv), playman_pl_lv_col_name ); playman_pl_lv_col_entriesnum = gtk_tree_view_column_new_with_attributes( - _("Entries") , playman_pl_lv_textrndr_entriesnum , "text" , PLLIST_COL_ENTRIESNUM , NULL ); + _("Entries") , playman_pl_lv_textrndr_entriesnum , + "text" , PLLIST_COL_ENTRIESNUM , + "weight", PLLIST_TEXT_WEIGHT , + NULL ); gtk_tree_view_column_set_expand( GTK_TREE_VIEW_COLUMN(playman_pl_lv_col_entriesnum) , FALSE ); gtk_tree_view_append_column( GTK_TREE_VIEW(playman_pl_lv), playman_pl_lv_col_entriesnum ); playman_pl_lv_sw = gtk_scrolled_window_new( NULL , NULL ); @@ -337,6 +455,17 @@ g_signal_connect_swapped( G_OBJECT(playman_bbar_bt_close) , "clicked" , G_CALLBACK(gtk_widget_destroy) , playman_win ); + /* have active playlist selected and scrolled to */ + active_path = gtk_tree_model_get_path( GTK_TREE_MODEL(pl_store) , + &active_iter ); + gtk_tree_view_set_cursor( GTK_TREE_VIEW(playman_pl_lv) , + active_path , NULL , FALSE ); + gtk_tree_view_scroll_to_cell( GTK_TREE_VIEW(playman_pl_lv) , + active_path , NULL , TRUE , 0.5 , 0.0 ); + gtk_tree_path_free( active_path ); + + g_object_unref( pl_store ); + gtk_widget_show_all( playman_win ); } @@ -356,8 +485,6 @@ if ( GPOINTER_TO_INT(g_object_get_data(G_OBJECT(lv),"opt1")) == 0 ) { GtkListStore *store = (GtkListStore*)gtk_tree_view_get_model( GTK_TREE_VIEW(lv) ); - /* TODO: this re-populates everything... there's definitely room for optimization */ - gtk_list_store_clear( store ); playlist_manager_populate( store ); } return;