/*
- * 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"
FILE_COLUMN_COUNT
};
-typedef enum {
- SELECTION_NONE = 0,
- SELECTION_SELECTED = 1 << 0,
- SELECTION_PRELIGHT = 1 << 1,
- SELECTION_FOCUS = 1 << 2
-} SelectionType;
-
-typedef struct _IconData IconData;
-struct _IconData
-{
- SelectionType selected;
- FileData *fd;
-};
-
static gint vficon_index_by_id(ViewFile *vf, IconData *in_id);
static IconData *vficon_icon_data(ViewFile *vf, FileData *fd)
return id;
}
-#if 0
-/* not used */
-static gint iconlist_read(FileData *dir_fd, GList **list)
-{
- GList *temp;
- GList *work;
-
- if (!filelist_read(dir_fd, &temp, NULL)) return FALSE;
-
- work = temp;
- while (work)
- {
- FileData *fd;
- IconData *id;
-
- fd = work->data;
- g_assert(fd->magick == FD_MAGICK);
- id = g_new0(IconData, 1);
-
- id->selected = SELECTION_NONE;
- id->fd = fd;
-
- work->data = id;
- work = work->next;
- }
-
- *list = temp;
-
- return TRUE;
-}
-#endif
-
static void iconlist_free(GList *list)
{
GList *work = list;
{
GtkWidget *label;
gint x, y;
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkDisplay *display;
+ GdkDeviceManager *device_manager;
+ GdkDevice *device;
+#endif
if (VFICON(vf)->tip_window) return;
+#if GTK_CHECK_VERSION(3,0,0)
+ device_manager = gdk_display_get_device_manager(gdk_window_get_display(
+ gtk_tree_view_get_bin_window(GTK_TREE_VIEW(vf->listview))));
+ device = gdk_device_manager_get_client_pointer(device_manager);
+ gdk_window_get_device_position(gtk_tree_view_get_bin_window(GTK_TREE_VIEW(vf->listview)),
+ device, &x, &y, NULL);
+#else
gdk_window_get_pointer(gtk_tree_view_get_bin_window(GTK_TREE_VIEW(vf->listview)), &x, &y, NULL);
+#endif
VFICON(vf)->tip_id = vficon_find_data_by_coord(vf, x, y, NULL);
if (!VFICON(vf)->tip_id) return;
gtk_container_add(GTK_CONTAINER(VFICON(vf)->tip_window), label);
gtk_widget_show(label);
+#if GTK_CHECK_VERSION(3,0,0)
+ display = gdk_display_get_default();
+ device_manager = gdk_display_get_device_manager(display);
+ device = gdk_device_manager_get_client_pointer(device_manager);
+ gdk_device_get_position(device, NULL, &x, &y);
+#else
gdk_window_get_pointer(NULL, &x, &y, NULL);
+#endif
if (!gtk_widget_get_realized(VFICON(vf)->tip_window)) gtk_widget_realize(VFICON(vf)->tip_window);
gtk_window_move(GTK_WINDOW(VFICON(vf)->tip_window), x + 16, y + 16);
static void tip_update(ViewFile *vf, IconData *id)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkDisplay *display = gdk_display_get_default();
+ GdkDeviceManager *device_manager = gdk_display_get_device_manager(display);
+ GdkDevice *device = gdk_device_manager_get_client_pointer(device_manager);
+#endif
+
if (VFICON(vf)->tip_window)
{
gint x, y;
+#if GTK_CHECK_VERSION(3,0,0)
+ gdk_device_get_position(device, NULL, &x, &y);
+#else
gdk_window_get_pointer(NULL, &x, &y, NULL);
+#endif
gtk_window_move(GTK_WINDOW(VFICON(vf)->tip_window), x + 16, y + 16);
if (id != VFICON(vf)->tip_id)
{
ViewFile *vf = data;
GList *list = NULL;
- gchar *uri_text = NULL;
- gint total;
if (!VFICON(vf)->click_id) return;
if (id && id->fd) {
/* Add keywords to file */
FileData *fd = id->fd;
- gchar *str = gtk_selection_data_get_text(selection);
+ gchar *str = (gchar *) gtk_selection_data_get_text(selection);
GList *kw_list = string_to_keywords_list(str);
-
+
metadata_append_list(fd, KEYWORD_KEY, kw_list);
string_list_free(kw_list);
g_free(str);
-/*
-file notification should handle this automatically
- if (vf->layout && vf->layout->bar_info) {
- bar_set_fd(vf->layout->bar_info, id->fd);
- }
-*/
}
}
}
{
IconData *id = work->data;
work = work->next;
-
+
VFICON(vf)->selection = g_list_append(VFICON(vf)->selection, id);
vficon_selection_add(vf, id, SELECTION_SELECTED, NULL);
}
g_assert(fd->magick == FD_MAGICK);
list = g_list_prepend(list, file_data_ref(fd));
-
+
work2 = fd->sidecar_files;
while (work2)
{
{
GList *work;
IconData *id = NULL;
-
+
if (sel_fd->parent) sel_fd = sel_fd->parent;
work = vf->list;
-
+
while (work)
{
gint match;
FileData *fd;
-
+
id = work->data;
fd = id->fd;
work = work->next;
match = filelist_sort_compare_filedata_full(fd, sel_fd, vf->sort_method, vf->sort_ascend);
-
+
if (match >= 0) break;
}
-
+
if (id)
{
vficon_select(vf, id);
{
/* ensure focus row col are correct */
vficon_find_position(vf, VFICON(vf)->focus_id, &VFICON(vf)->focus_row, &VFICON(vf)->focus_column);
+#if GTK_CHECK_VERSION(3,0,0)
+/* FIXME: Refer to issue #467 on Github. The thumbnail position is not
+ * preserved when the icon view is refreshed. Caused by an unknown call from
+ * the idle loop. This patch hides the problem.
+ */
+ if (vficon_find_iter(vf, VFICON(vf)->focus_id, &iter, NULL))
+ {
+ tree_view_row_make_visible(GTK_TREE_VIEW(vf->listview), &iter, FALSE);
+ }
+#endif
return;
}
vficon_selection_remove(vf, VFICON(vf)->focus_id, SELECTION_FOCUS, NULL);
}
}
-#if 0
-static void vficon_update_focus(ViewFile *vf)
-{
- gint new_row = 0;
- gint new_col = 0;
-
- if (VFICON(vf)->focus_id && vficon_find_position(vf, VFICON(vf)->focus_id, &new_row, &new_col))
- {
- /* first find the old focus, if it exists and is valid */
- }
- else
- {
- /* (try to) stay where we were */
- new_row = VFICON(vf)->focus_row;
- new_col = VFICON(vf)->focus_column;
- }
-
- vficon_move_focus(vf, new_row, new_col, FALSE);
-}
-#endif
-
/* used to figure the page up/down distances */
static gint page_height(ViewFile *vf)
{
if (stop_signal)
{
-#if 0
- g_signal_stop_emission_by_name(GTK_OBJECT(widget), "key_press_event");
-#endif
tip_unschedule(vf);
}
*-------------------------------------------------------------------
*/
-static gboolean vficon_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+static gboolean vficon_motion_cb(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
ViewFile *vf = data;
IconData *id;
- id = vficon_find_data_by_coord(vf, (gint)bevent->x, (gint)bevent->y, NULL);
+ id = vficon_find_data_by_coord(vf, (gint)event->x, (gint)event->y, NULL);
tip_update(vf, id);
return FALSE;
{
gtk_widget_grab_focus(vf->listview);
}
-#if 1
+
if (bevent->type == GDK_2BUTTON_PRESS &&
vf->layout)
{
vficon_selection_remove(vf, VFICON(vf)->click_id, SELECTION_PRELIGHT, &iter);
layout_image_full_screen_start(vf->layout);
}
-#endif
break;
case MOUSE_BUTTON_RIGHT:
vf->popup = vf_pop_menu(vf);
GList *list;
gtk_tree_model_get(store, iter, FILE_COLUMN_POINTER, &list, -1);
-
+
/* it seems that gtk_list_store_clear may call some callbacks
that use the column. Set the pointer to NULL to be safe. */
gtk_list_store_set(GTK_LIST_STORE(store), iter, FILE_COLUMN_POINTER, NULL, -1);
{
gint i;
gint thumb_width;
-
+
vficon_clear_store(vf);
thumb_width = vficon_get_icon_width(vf);
DEBUG_1("col tab pop cols=%d rows=%d", VFICON(vf)->columns, VFICON(vf)->rows);
}
-
-#if 0
-static void vficon_sync_idle(ViewFile *vf)
-{
- if (VFICON(vf)->sync_idle_id == -1)
- {
- /* high priority, the view needs to be resynced before a redraw
- * may contain invalid pointers at this time
- */
- VFICON(vf)->sync_idle_id = g_idle_add_full(G_PRIORITY_HIGH, vficon_sync_idle_cb, vf, NULL);
- }
-}
-#endif
-
static void vficon_sized_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
{
ViewFile *vf = data;
file_data_ref(first_selected);
g_list_free(VFICON(vf)->selection);
VFICON(vf)->selection = NULL;
-
+
}
FileData *fd = NULL;
FileData *new_fd = NULL;
gint match;
-
+
if (work && work_fd)
{
id = work->data;
fd = id->fd;
-
+
new_fd = work_fd->data;
-
+
if (fd == new_fd)
{
/* not changed, go to next */
work = work->next;
work_fd = work_fd->next;
- if (id->selected & SELECTION_SELECTED)
+ if (id->selected & SELECTION_SELECTED)
{
VFICON(vf)->selection = g_list_prepend(VFICON(vf)->selection, id);
}
continue;
}
-
+
match = filelist_sort_compare_filedata_full(fd, new_fd, vf->sort_method, vf->sort_ascend);
if (match == 0) g_warning("multiple fd for the same path");
}
new_fd = work_fd->data;
match = 1;
}
-
+
if (match < 0)
{
/* file no longer exists, delete from vf->list */
vf->list = g_list_insert_before(vf->list, work, id);
else
new_iconlist = g_list_prepend(new_iconlist, id); /* it is faster to append all new entries together later */
-
+
work_fd = work_fd->next;
}
{
vf->list = g_list_concat(vf->list, g_list_reverse(new_iconlist));
}
-
+
VFICON(vf)->selection = g_list_reverse(VFICON(vf)->selection);
filelist_free(new_filelist);
vficon_select_closest(vf, first_selected);
}
file_data_unref(first_selected);
-
+
/* attempt to keep focus on same icon when refreshing */
if (focus_id && g_list_find(vf->list, focus_id))
{
gtk_tree_model_get(tree_model, iter, FILE_COLUMN_POINTER, &list, -1);
id = g_list_nth_data(list, cd->number);
-
+
if (id)
{
GdkColor color_fg;
gchar *disabled_grouping = id->fd->disable_grouping ? _(" [NO GROUPING]") : "";
name_sidecars = g_strdup_printf("%s%s%s", link, id->fd->name, disabled_grouping);
}
-
+
style = gtk_widget_get_style(vf->listview);
if (id->selected & SELECTION_SELECTED)
{
state = GTK_STATE_SELECTED;
}
-
+
memcpy(&color_fg, &style->text[state], sizeof(color_fg));
memcpy(&color_bg, &style->base[state], sizeof(color_bg));
{
shift_color(&color_bg, -1, 0);
}
-
+
g_object_set(cell, "pixbuf", id->fd->thumb_pixbuf,
"text", name_sidecars,
"marks", file_data_get_marks(id->fd),
gtk_tree_view_column_set_cell_data_func(column, renderer, vficon_cell_data_cb, cd, g_free);
gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column);
-
+
g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vficon_mark_toggled_cb), vf);
}
ViewFile *vf = data;
vf_refresh_idle_cancel(vf);
-
+
file_data_unregister_notify_func(vf_notify_cb, vf);
tip_unschedule(vf);