~am-monkeyd/marlin/marlin-gtk2-test

« back to all changes in this revision

Viewing changes to src/fm-list-view.c

  • Committer: am.monkeyd at gmail
  • Date: 2011-03-26 20:45:52 UTC
  • Revision ID: am.monkeyd@gmail.com-20110326204552-i24m2x53u34ht84s
listview: store get_selection

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "marlin-tags.h"
34
34
 
35
35
struct FMListViewDetails {
 
36
    GList       *selection;
36
37
    GtkTreePath *new_selection_path;   /* Path of the new selection after removing a file */
37
38
};
38
39
 
64
65
};
65
66
 
66
67
/* Declaration Prototypes */
67
 
static GList    *fm_list_view_get_selection (FMListView *view);
 
68
static GList    *fm_list_view_get_selection (FMDirectoryView *view);
 
69
static GList    *get_selection (FMListView *view);
68
70
//static void     fm_list_view_clear (FMListView *view);
69
71
 
70
72
#if 0
164
166
    GOFFile *file = NULL;
165
167
    FMListView *view = FM_LIST_VIEW (user_data);
166
168
 
167
 
    GList *paths = gtk_tree_selection_get_selected_rows (selection, NULL);
 
169
    /*GList *paths = gtk_tree_selection_get_selected_rows (selection, NULL);
168
170
    if (paths!=NULL && gtk_tree_model_get_iter (GTK_TREE_MODEL(view->model), &iter, paths->data))   
169
171
    {
170
172
        gtk_tree_model_get (GTK_TREE_MODEL (view->model), &iter,
171
173
                            FM_LIST_MODEL_FILE_COLUMN, &file,
172
174
                            -1);
173
175
        //if (file != NULL) 
174
 
    }
 
176
    }*/
 
177
    if (view->details->selection != NULL)
 
178
        gof_file_list_free (view->details->selection);
 
179
    view->details->selection = get_selection(view);
 
180
 
 
181
    if (view->details->selection != NULL) 
 
182
        file = view->details->selection->data;
 
183
    
175
184
    fm_directory_view_notify_selection_changed (FM_DIRECTORY_VIEW (view), file);
176
185
 
177
 
    g_list_foreach (paths, (GFunc) gtk_tree_path_free, NULL);
178
 
    g_list_free (paths);
 
186
    //fm_directory_view_notify_selection_changed (FM_DIRECTORY_VIEW (view), file);
 
187
    /*g_list_foreach (paths, (GFunc) gtk_tree_path_free, NULL);
 
188
    g_list_free (paths);*/
179
189
}
180
190
 
181
191
static void
231
241
            }
232
242
    }
233
243
 
234
 
    gof_file_list_free (file_list);
 
244
    //gof_file_list_free (file_list);
235
245
}
236
246
 
237
247
static void
273
283
static void
274
284
fm_list_view_sync_selection (FMDirectoryView *view)
275
285
{
 
286
    //TODO replace this crap
276
287
    FMListView *list_view = FM_LIST_VIEW (view);
277
288
 
278
289
    list_selection_changed_callback (gtk_tree_view_get_selection (list_view->tree), view);
772
783
}*/
773
784
 
774
785
static void
775
 
fm_list_view_get_selection_foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
 
786
get_selection_foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
776
787
{
777
788
    GList **list;
778
789
    GOFFile *file;
789
800
}
790
801
 
791
802
static GList *
792
 
fm_list_view_get_selection (FMListView *view)
 
803
get_selection (FMListView *view)
793
804
{
794
805
    GList *list;
795
806
 
796
807
    list = NULL;
797
808
 
798
809
    gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (view->tree),
799
 
                                         fm_list_view_get_selection_foreach_func, &list);
 
810
                                         get_selection_foreach_func, &list);
800
811
 
801
812
    return g_list_reverse (list);
802
813
}
803
814
 
 
815
static GList *
 
816
fm_list_view_get_selection (FMDirectoryView *view)
 
817
{
 
818
    return FM_LIST_VIEW (view)->details->selection;
 
819
}
 
820
 
804
821
/*static void
805
822
  fm_list_view_set_selection (FMListView *list_view, GList *selection)
806
823
  {
910
927
 
911
928
    log_printf (LOG_LEVEL_UNDEFINED, "$$ %s\n", G_STRFUNC);
912
929
 
913
 
    if (view->details->new_selection_path) {
 
930
    if (view->details->new_selection_path)
914
931
        gtk_tree_path_free (view->details->new_selection_path);
915
 
    }
 
932
    if (view->details->selection)
 
933
        gof_file_list_free (view->details->selection);
916
934
 
917
935
    g_object_unref (view->model);
918
936
    g_free (view->details);
923
941
fm_list_view_init (FMListView *view)
924
942
{
925
943
    view->details = g_new0 (FMListViewDetails, 1);
 
944
    view->details->selection = NULL;
 
945
 
926
946
    create_and_set_up_tree_view (view);
927
947
 
928
948
    g_settings_bind (settings, "single-click", 
948
968
    fm_directory_view_class->remove_file = fm_list_view_remove_file;
949
969
    fm_directory_view_class->colorize_selection = fm_list_view_colorize_selected_items;        
950
970
    fm_directory_view_class->sync_selection = fm_list_view_sync_selection;
 
971
    fm_directory_view_class->get_selection = fm_list_view_get_selection;
951
972
    fm_directory_view_class->get_selection_for_file_transfer = fm_list_view_get_selection_for_file_transfer;
952
973
 
953
974
    fm_directory_view_class->get_path_at_pos = fm_list_view_get_path_at_pos;