/*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2004 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 "bar_sort.h"
SortModeType mode;
SortActionType action;
gchar *filter_key;
-
+
SortSelectionType selection;
GtkWidget *folder_group;
history_list_free_key(SORT_KEY_COLLECTIONS);
bookmark_list_set_key(bookmarks, SORT_KEY_COLLECTIONS);
- dir_fd = file_data_new_simple(get_collections_dir());
+ dir_fd = file_data_new_dir(get_collections_dir());
filelist_read(dir_fd, &list, NULL);
file_data_unref(dir_fd);
static void bar_sort_mode_sync(SortData *sd, SortModeType mode)
{
- gint folder_mode;
+ gboolean folder_mode;
if (sd->mode == mode) return;
sd->mode = mode;
GList *list;
gchar *src_dir;
- list = g_list_append(NULL, file_data_new_simple(sd->undo_dest));
+ list = g_list_append(NULL, file_data_new_group(sd->undo_dest));
src_dir = remove_level_from_path(sd->undo_src);
file_util_move_simple(list, src_dir, sd->lw->window);
g_free(src_dir);
}
break;
case BAR_SORT_COPY:
- file_util_delete(file_data_new_simple(sd->undo_dest), NULL, button);
+ file_util_delete(file_data_new_group(sd->undo_dest), NULL, button);
break;
default:
/* undo external command */
- file_util_delete(file_data_new_simple(sd->undo_dest), NULL, button);
+ file_util_delete(file_data_new_group(sd->undo_dest), NULL, button);
break;
}
if (isfile(sd->undo_src))
{
- layout_image_set_fd(sd->lw, file_data_new_simple(sd->undo_src));
+ layout_image_set_fd(sd->lw, file_data_new_group(sd->undo_src));
}
bar_sort_undo_set(sd, NULL, NULL, NULL);
source = work->data;
work = work->next;
- collect_manager_remove(file_data_new_simple(source), sd->undo_dest);
+ collect_manager_remove(file_data_new_group(source), sd->undo_dest);
}
bar_sort_undo_set(sd, NULL, NULL, NULL);
static void bar_sort_add_ok_cb(FileDialog *fd, gpointer data)
{
SortData *sd = data;
- const gchar *name;
+ const gchar *name = gtk_entry_get_text(GTK_ENTRY(sd->dialog_name_entry));
+ gboolean empty_name = (name[0] == '\0');
name = gtk_entry_get_text(GTK_ENTRY(sd->dialog_name_entry));
if (sd->mode == BAR_SORT_MODE_FOLDER)
{
- if (strlen(name) == 0)
+ if (empty_name)
{
name = filename_from_path(fd->dest_path);
}
else
{
gchar *path;
-
- if (strlen(name) == 0) return;
+ gboolean has_extension;
+ gchar *filename = (gchar *) name;
+
+ if (empty_name) return;
- if (!file_extension_match(name, GQ_COLLECTION_EXT))
+ has_extension = file_extension_match(name, GQ_COLLECTION_EXT);
+ if (!has_extension)
{
- gchar *tmp = g_strconcat(name, GQ_COLLECTION_EXT, NULL);
- g_free((gpointer) name);
- name = tmp;
+ filename = g_strconcat(name, GQ_COLLECTION_EXT, NULL);
}
- path = g_build_filename(get_collections_dir(), name, NULL);
+ path = g_build_filename(get_collections_dir(), filename, NULL);
if (isfile(path))
{
- gchar *text = g_strdup_printf(_("The collection:\n%s\nalready exists."), name);
+ gchar *text = g_strdup_printf(_("The collection:\n%s\nalready exists."), filename);
file_util_warning_dialog(_("Collection exists"), text, GTK_STOCK_DIALOG_INFO, NULL);
g_free(text);
}
collection_unref(cd);
}
+ if (!has_extension) g_free(filename);
g_free(path);
}
g_free(data);
}
-static GtkWidget *bar_sort_new(LayoutWindow *lw, SortActionType action, SortModeType mode, SortSelectionType selection, const gchar *filter_key)
+static GtkWidget *bar_sort_new(LayoutWindow *lw, SortActionType action,
+ SortModeType mode, SortSelectionType selection,
+ const gchar *filter_key)
{
SortData *sd;
GtkWidget *buttongrp;
sd->lw = lw;
sd->action = action;
-
+
if (sd->action == BAR_SORT_FILTER && (!filter_key || !filter_key[0]))
{
sd->action = BAR_SORT_COPY;
}
-
+
sd->selection = selection;
sd->undo_src = NULL;
sd->undo_dest = NULL;
gtk_box_pack_start(GTK_BOX(sd->vbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
- combo = gtk_combo_box_new_text();
+ combo = gtk_combo_box_text_new();
gtk_box_pack_start(GTK_BOX(sd->vbox), combo, FALSE, FALSE, 0);
gtk_widget_show(combo);
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Folders"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Collections"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Folders"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Collections"));
g_signal_connect(G_OBJECT(combo), "changed",
G_CALLBACK(bar_sort_mode_cb), sd);
gboolean select = FALSE;
work = work->next;
-
+
if (!editor_is_filter(editor->key)) continue;
-
+
key = g_strdup(editor->key);
if (sd->action == BAR_SORT_FILTER && strcmp(key, filter_key) == 0)
{
select = TRUE;
have_filter = TRUE;
}
-
+
button = pref_radiobutton_new(sd->folder_group, buttongrp,
editor->name, select,
G_CALLBACK(bar_sort_set_filter_cb), sd);
g_object_set_data_full(G_OBJECT(button), "filter_key", key, bar_sort_edit_button_free);
}
g_list_free(editors_list);
-
+
if (sd->action == BAR_SORT_FILTER && !have_filter) sd->action = BAR_SORT_COPY;
sd->collection_group = pref_box_new(sd->vbox, FALSE, GTK_ORIENTATION_VERTICAL, 0);
GtkWidget *bar_sort_new_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values)
{
GtkWidget *bar;
-
+
gboolean enabled = TRUE;
gint action = 0;
gint mode = 0;
if (READ_INT_CLAMP_FULL("selection", selection, 0, BAR_SORT_SELECTION_COUNT - 1)) continue;
if (READ_CHAR_FULL("filter_key", filter_key)) continue;
- DEBUG_1("unknown attribute %s = %s", option, value);
+ log_printf("unknown attribute %s = %s\n", option, value);
}
bar = bar_sort_new(lw, action, mode, selection, filter_key);
sd = g_object_get_data(G_OBJECT(bar), "bar_sort_data");
if (!sd) return;
- WRITE_STRING("<bar_sort\n");
- indent++;
- write_bool_option(outstr, indent, "enabled", GTK_WIDGET_VISIBLE(bar));
+ WRITE_NL(); WRITE_STRING("<bar_sort ");
+ write_bool_option(outstr, indent, "enabled", gtk_widget_get_visible(bar));
WRITE_INT(*sd, mode);
WRITE_INT(*sd, action);
WRITE_INT(*sd, selection);
WRITE_CHAR(*sd, filter_key);
- indent--;
- WRITE_STRING("/>\n");
+ WRITE_STRING("/>");
}