Drop unused variables.
[geeqie.git] / src / view_file_list.c
index d8ca134..a230921 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Geeqie
  * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis
  *
@@ -185,6 +185,10 @@ static gboolean vflist_store_clear_cb(GtkTreeModel *model, GtkTreePath *path, Gt
 {
        FileData *fd;
        gtk_tree_model_get(model, iter, FILE_COLUMN_POINTER, &fd, -1);
+
+       /* it seems that gtk_tree_store_clear may call some callbacks
+          that use the column. Set the pointer to NULL to be safe. */
+       gtk_tree_store_set(GTK_TREE_STORE(model), iter, FILE_COLUMN_POINTER, NULL, -1);
        file_data_unref(fd);
        return FALSE;
 }
@@ -219,7 +223,7 @@ static void vflist_move_cursor(ViewFile *vf, GtkTreeIter *iter)
        gtk_tree_path_free(tpath);
 }
 
-
+#if 0
 static gint vflist_column_idx(ViewFile *vf, gint store_idx)
 {
        GList *columns, *work;
@@ -239,7 +243,7 @@ static gint vflist_column_idx(ViewFile *vf, gint store_idx)
        g_list_free(columns);
        return i;
 }
-
+#endif
 
 /*
  *-----------------------------------------------------------------------------
@@ -253,8 +257,6 @@ static void vflist_dnd_get(GtkWidget *widget, GdkDragContext *context,
 {
        ViewFile *vf = data;
        GList *list = NULL;
-       gchar *uri_text = NULL;
-       gint total;
 
        if (!VFLIST(vf)->click_fd) return;
 
@@ -268,15 +270,8 @@ static void vflist_dnd_get(GtkWidget *widget, GdkDragContext *context,
                }
 
        if (!list) return;
-
-       uri_text = uri_text_from_filelist(list, &total, (info == TARGET_TEXT_PLAIN));
+       uri_selection_data_set_uris_from_filelist(selection_data, list);
        filelist_free(list);
-
-       DEBUG_1("%s", uri_text);
-
-       gtk_selection_data_set(selection_data, selection_data->target,
-                              8, (guchar *)uri_text, total);
-       g_free(uri_text);
 }
 
 static void vflist_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
@@ -305,7 +300,7 @@ static void vflist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer
 
        vflist_color_set(vf, VFLIST(vf)->click_fd, FALSE);
 
-       if (context->action == GDK_ACTION_MOVE)
+       if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE)
                {
                vf_refresh(vf);
                }
@@ -322,7 +317,7 @@ static void vflist_drag_data_received(GtkWidget *entry_widget, GdkDragContext *c
 
                if (fd) {
                        /* Add keywords to file */
-                       gchar *str = g_strndup((gchar *)selection->data, selection->length);
+                       gchar *str = gtk_selection_data_get_text(selection);
                        GList *kw_list = string_to_keywords_list(str);
                        
                        metadata_append_list(fd, KEYWORD_KEY, kw_list);
@@ -363,26 +358,18 @@ void vflist_dnd_init(ViewFile *vf)
  *-----------------------------------------------------------------------------
  */
 
-GList *vflist_pop_menu_file_list(ViewFile *vf)
+GList *vflist_selection_get_one(ViewFile *vf, FileData *fd)
 {
-       GList *list;
-       if (!VFLIST(vf)->click_fd) return NULL;
+       GList *list = g_list_append(NULL, file_data_ref(fd));
 
-       if (vflist_row_is_selected(vf, VFLIST(vf)->click_fd))
-               {
-               return vf_selection_get_list(vf);
-               }
-
-       list = g_list_append(NULL, file_data_ref(VFLIST(vf)->click_fd));
-
-       if (VFLIST(vf)->click_fd->sidecar_files)
+       if (fd->sidecar_files)
                {
                /* check if the row is expanded */
                GtkTreeModel *store;
                GtkTreeIter iter;
                
                store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
-               if (vflist_find_row(vf, VFLIST(vf)->click_fd, &iter) >= 0)
+               if (vflist_find_row(vf, fd, &iter) >= 0)
                        {
                        GtkTreePath *tpath;
 
@@ -390,7 +377,7 @@ GList *vflist_pop_menu_file_list(ViewFile *vf)
                        if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(vf->listview), tpath))
                                {
                                /* unexpanded - add whole group */
-                               GList *work = VFLIST(vf)->click_fd->sidecar_files;
+                               GList *work = fd->sidecar_files;
                                while (work)
                                        {
                                        FileData *sfd = work->data;
@@ -406,6 +393,18 @@ GList *vflist_pop_menu_file_list(ViewFile *vf)
        return list;
 }
 
+GList *vflist_pop_menu_file_list(ViewFile *vf)
+{
+       if (!VFLIST(vf)->click_fd) return NULL;
+
+       if (vflist_row_is_selected(vf, VFLIST(vf)->click_fd))
+               {
+               return vf_selection_get_list(vf);
+               }
+       return vflist_selection_get_one(vf, VFLIST(vf)->click_fd);
+}
+
+
 void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data)
 {
        ViewFile *vf = data;
@@ -512,7 +511,7 @@ static gboolean vflist_row_rename_cb(TreeEditData *td, const gchar *old, const g
        else
                {
                gchar *old_path = g_build_filename(vf->dir_fd->path, old, NULL);
-               FileData *fd = file_data_new_simple(old_path); /* get the fd from cache */
+               FileData *fd = file_data_new_group(old_path); /* get the fd from cache */
                file_util_rename_simple(fd, new_path, vf->listview);
                file_data_unref(fd);
                g_free(old_path);
@@ -545,7 +544,7 @@ gboolean vflist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer dat
        ViewFile *vf = data;
        GtkTreePath *tpath;
 
-       if (event->keyval != GDK_Menu) return FALSE;
+       if (event->keyval != GDK_KEY_Menu) return FALSE;
 
        gtk_tree_view_get_cursor(GTK_TREE_VIEW(vf->listview), &tpath, NULL);
        if (tpath)
@@ -958,7 +957,6 @@ static void vflist_setup_iter_recursive(ViewFile *vf, GtkTreeStore *store, GtkTr
 
                        if (valid)
                                {
-                               num_ordered++;
                                gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
                                                   FILE_COLUMN_POINTER, &old_fd,
                                                   FILE_COLUMN_VERSION, &old_version,
@@ -990,6 +988,7 @@ static void vflist_setup_iter_recursive(ViewFile *vf, GtkTreeStore *store, GtkTr
 
                                if (valid)
                                        {
+                                       num_ordered++;
                                        gtk_tree_store_insert_before(store, &new, parent_iter, &iter);
                                        }
                                else
@@ -1022,6 +1021,7 @@ static void vflist_setup_iter_recursive(ViewFile *vf, GtkTreeStore *store, GtkTr
                                }
                        else
                                {
+                               num_ordered++;
                                if (fd->version != old_version || force)
                                        {
                                        vflist_setup_iter(vf, store, &iter, fd);
@@ -1605,11 +1605,11 @@ void vflist_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode)
                        {
                        case MTS_MODE_SET: selected = mark_val;
                                break;
-                       case MTS_MODE_OR: selected = mark_val | selected;
+                       case MTS_MODE_OR: selected = mark_val || selected;
                                break;
-                       case MTS_MODE_AND: selected = mark_val & selected;
+                       case MTS_MODE_AND: selected = mark_val && selected;
                                break;
-                       case MTS_MODE_MINUS: selected = !mark_val & selected;
+                       case MTS_MODE_MINUS: selected = !mark_val && selected;
                                break;
                        }
 
@@ -1696,7 +1696,7 @@ static void vflist_listview_set_columns(GtkWidget *listview, gboolean thumb, gbo
 
        gtk_tree_view_column_set_fixed_width(column, options->thumbnails.max_width + 4);
 
-       list = gtk_tree_view_column_get_cell_renderers(column);
+       list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
        if (!list) return;
        cell = list->data;
        g_list_free(list);