Changeset 6837


Ignore:
Timestamp:
Oct 2, 2008, 7:51:16 PM (13 years ago)
Author:
charles
Message:

(gtk) #1265: In Details->Tracker one can only remove one tracker at a time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tracker-list.c

    r6831 r6837  
    104104{
    105105    struct tracker_page * page = gpage;
    106     gboolean              has_selection = gtk_tree_selection_get_selected(
    107         sel, NULL, NULL );
    108     gboolean              ok_to_remove = !page->gtor
    109                                          || gtk_tree_model_iter_n_children(
    110         GTK_TREE_MODEL(
    111             page->store ),
    112         NULL )
    113                                          > 1;
    114 
    115     gtk_widget_set_sensitive( page->remove_button,
    116                               has_selection && ok_to_remove );
     106    const gboolean        has_selection = gtk_tree_selection_count_selected_rows( sel ) > 0;
     107    const int             trackerCount = gtk_tree_model_iter_n_children( GTK_TREE_MODEL( page->store ), NULL );
     108    const gboolean        ok_to_remove = !page->gtor || ( trackerCount > 1 );
     109    gtk_widget_set_sensitive( page->remove_button, has_selection && ok_to_remove );
    117110}
    118111
     
    122115{
    123116    struct tracker_page * page = gpage;
    124     GtkTreeIter           iter;
    125 
    126     if( gtk_tree_selection_get_selected( page->sel, NULL, &iter ) )
    127     {
     117    GtkTreeModel * model;
     118    GList * l;
     119    GList * list = gtk_tree_selection_get_selected_rows( page->sel, &model );
     120
     121    /* convert the list to references */
     122    for( l=list; l; l=l->next ) {
     123        GtkTreePath * path = l->data;
     124        l->data = gtk_tree_row_reference_new( model, path );
     125        gtk_tree_path_free( path );
     126    }
     127
     128    /* remove the selected rows */
     129    for( l=list; l; l=l->next ) {
     130        GtkTreePath * path = gtk_tree_row_reference_get_path( l->data );
     131        GtkTreeIter iter;
     132        gtk_tree_model_get_iter( model, &iter, path );
    128133        gtk_list_store_remove( page->store, &iter );
    129         setTrackerChangeState( page, TRUE );
    130     }
     134        gtk_tree_path_free( path );
     135        gtk_tree_row_reference_free( l->data );
     136    }
     137
     138    setTrackerChangeState( page, TRUE );
     139
     140    /* cleanup */
     141    g_list_free( list );
    131142}
    132143
     
    339350    g_signal_connect( sel, "changed",
    340351                      G_CALLBACK( onTrackerSelectionChanged ), page );
     352    gtk_tree_selection_set_mode( sel, GTK_SELECTION_MULTIPLE );
    341353    gtk_container_add( GTK_CONTAINER( w ), GTK_WIDGET( page->view ) );
    342354    gtk_widget_set_size_request( w, -1, 133 );
Note: See TracChangeset for help on using the changeset viewer.