Eliminate a FIXME: Collection window position
[geeqie.git] / src / collect.c
index f700181..695133a 100644 (file)
@@ -1,16 +1,24 @@
 /*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-
 #include "main.h"
 #include "collect.h"
 
@@ -141,6 +149,11 @@ static gint collection_list_sort_cb(gconstpointer a, gconstpointer b)
                        if (cia->fd->date > cib->fd->date) return 1;
                        return 0;
                        break;
+               case SORT_CTIME:
+                       if (cia->fd->cdate < cib->fd->cdate) return -1;
+                       if (cia->fd->cdate > cib->fd->cdate) return 1;
+                       return 0;
+                       break;
                case SORT_PATH:
                        return utf8_compare(cia->fd->path, cib->fd->path, options->file_sort.case_sensitive);
                        break;
@@ -337,7 +350,7 @@ CollectionData *collection_new(const gchar *path)
 
 
        collection_list = g_list_append(collection_list, cd);
-       
+
        return cd;
 }
 
@@ -349,7 +362,7 @@ void collection_free(CollectionData *cd)
 
        collection_load_stop(cd);
        collection_list_free(cd->list);
-       
+
        file_data_unregister_notify_func(collection_notify_cb, cd);
 
        collection_list = g_list_remove(collection_list, cd);
@@ -406,15 +419,15 @@ CollectionData *collection_from_dnd_data(const gchar *data, GList **list, GList
        if (info_list) *info_list = NULL;
 
        if (strncmp(data, "COLLECTION:", 11) != 0) return NULL;
-       
+
        ptr = data + 11;
-               
+
        collection_number = atoi(ptr);
        cd = collection_from_number(collection_number);
        if (!cd) return NULL;
 
        if (!list && !info_list) return cd;
-       
+
        while (*ptr != '\0' && *ptr != '\n' ) ptr++;
        if (*ptr == '\0') return cd;
        ptr++;
@@ -423,7 +436,7 @@ CollectionData *collection_from_dnd_data(const gchar *data, GList **list, GList
                {
                guint item_number;
                CollectInfo *info;
-               
+
                item_number = (guint) atoi(ptr);
                while (*ptr != '\n' && *ptr != '\0') ptr++;
                if (*ptr == '\0')
@@ -437,7 +450,7 @@ CollectionData *collection_from_dnd_data(const gchar *data, GList **list, GList
                if (list) *list = g_list_append(*list, file_data_ref(info->fd));
                if (info_list) *info_list = g_list_append(*info_list, info);
                }
-       
+
        return cd;
 }
 
@@ -468,7 +481,7 @@ gchar *collection_info_list_to_dnd_data(CollectionData *cd, GList *list, gint *l
                work = work->next;
 
                if (item_number < 0) continue;
-               
+
                text = g_strdup_printf("%d\n", item_number);
                temp = g_list_prepend(temp, text);
                *length += strlen(text);
@@ -595,6 +608,10 @@ gboolean collection_add_check(CollectionData *cd, FileData *fd, gboolean sorted,
        struct stat st;
        gboolean valid;
 
+       if (!fd) return FALSE;
+
+       g_assert(fd->magick == FD_MAGICK);
+
        if (must_exist)
                {
                valid = (stat_utf8(fd->path, &st) && !S_ISDIR(st.st_mode));
@@ -747,7 +764,7 @@ static void collection_notify_cb(FileData *fd, NotifyType type, gpointer data)
        if (!(type & NOTIFY_CHANGE) || !fd->change) return;
 
        DEBUG_1("Notify collection: %s %04x", fd->path, type);
-       
+
        switch (fd->change->type)
                {
                case FILEDATA_CHANGE_MOVE:
@@ -891,6 +908,12 @@ static gboolean collection_window_keypress(GtkWidget *widget, GdkEventKey *event
                                        collection_set_sort_method(cw->cd, SORT_PATH);
                                        }
                                break;
+                       case 'R': case 'r':
+                               if (event->state & GDK_MOD1_MASK)
+                                       {
+                                               options->collections.rectangular_selection = !(options->collections.rectangular_selection);
+                                       }
+                               break;
                        case GDK_KEY_Delete: case GDK_KEY_KP_Delete:
                                list = g_list_copy(cw->table->selection);
                                if (list)
@@ -903,6 +926,9 @@ static gboolean collection_window_keypress(GtkWidget *widget, GdkEventKey *event
                                        collection_remove_by_info(cw->cd, collection_table_get_focus_info(cw->table));
                                        }
                                break;
+                       case GDK_KEY_F1:
+                               help_window_show("GuideReferenceKeyboardShortcuts.html#CollectionsKeyboardShortcuts");
+                               break;
                        default:
                                stop_signal = FALSE;
                                break;
@@ -1152,8 +1178,8 @@ CollectWindow *collection_window_new(const gchar *path)
 
        if (options->save_window_positions && path && collection_load_only_geometry(cw->cd, path))
                {
-               /* FIXME: x, y is not implemented */
                gtk_window_set_default_size(GTK_WINDOW(cw->window), cw->cd->window_w, cw->cd->window_h);
+               gtk_window_move(GTK_WINDOW(cw->window), cw->cd->window_x, cw->cd->window_y);
                }
        else
                {
@@ -1193,6 +1219,10 @@ CollectWindow *collection_window_new(const gchar *path)
 
        extra_label = gtk_progress_bar_new();
        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(extra_label), 0.0);
+#if GTK_CHECK_VERSION(3,0,0)
+       gtk_progress_bar_set_text(GTK_PROGRESS_BAR(extra_label), "");
+       gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(extra_label), TRUE);
+#endif
        gtk_box_pack_start(GTK_BOX(cw->status_box), extra_label, TRUE, TRUE, 0);
        gtk_widget_show(extra_label);