Pull the search UI construction code out into a distinct function.
[geeqie.git] / src / collect-table.c
index 160c1b6..757fa9f 100644 (file)
@@ -1,16 +1,24 @@
 /*
- * Geeqie
- * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2012 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 "collect-table.h"
 
@@ -54,14 +62,6 @@ enum {
        CTABLE_COLUMN_COUNT
 };
 
-typedef enum {
-       SELECTION_NONE          = 0,
-       SELECTION_SELECTED      = 1 << 0,
-       SELECTION_PRELIGHT      = 1 << 1,
-       SELECTION_FOCUS         = 1 << 2
-} SelectionType;
-
-
 #define INFO_SELECTED(x) (x->flag_mask & SELECTION_SELECTED)
 
 
@@ -519,10 +519,23 @@ static void tip_show(CollectTable *ct)
 {
        GtkWidget *label;
        gint x, y;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDisplay *display;
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        if (ct->tip_window) return;
 
+#if GTK_CHECK_VERSION(3,0,0)
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(
+                                                               gtk_widget_get_window(ct->listview)));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(gtk_widget_get_window(ct->listview),
+                                                               device, &x, &y, NULL);
+#else
        gdk_window_get_pointer(gtk_widget_get_window(ct->listview), &x, &y, NULL);
+#endif
 
        ct->tip_info = collection_table_find_data_by_coord(ct, x, y, NULL);
        if (!ct->tip_info) return;
@@ -537,7 +550,14 @@ static void tip_show(CollectTable *ct)
        gtk_container_add(GTK_CONTAINER(ct->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(ct->tip_window)) gtk_widget_realize(ct->tip_window);
        gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
@@ -588,13 +608,22 @@ static void tip_unschedule(CollectTable *ct)
 
 static void tip_update(CollectTable *ct, CollectInfo *info)
 {
+#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
+
        tip_schedule(ct);
 
        if (ct->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(ct->tip_window), x + 16, y + 16);
 
                if (info != ct->tip_info)
@@ -771,6 +800,13 @@ static void collection_table_popup_select_invert_cb(GtkWidget *widget, gpointer
        ct->prev_selection= ct->click_info;
 }
 
+static void collection_table_popup_rectangular_selection_cb(GtkWidget *widget, gpointer data)
+{
+       CollectTable *ct = data;
+
+       options->collections.rectangular_selection = !(options->collections.rectangular_selection);
+}
+
 static void collection_table_popup_remove_cb(GtkWidget *widget, gpointer data)
 {
        CollectTable *ct = data;
@@ -817,7 +853,7 @@ static void collection_table_popup_find_dupes_cb(GtkWidget *widget, gpointer dat
        CollectTable *ct = data;
        DupeWindow *dw;
 
-       dw = dupe_window_new(DUPE_MATCH_NAME);
+       dw = dupe_window_new();
        dupe_window_add_collection(dw, ct->cd);
 }
 
@@ -887,10 +923,12 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
                        G_CALLBACK(collection_table_popup_unselectall_cb), ct);
        menu_item_add(submenu, _("Invert selection"),
                        G_CALLBACK(collection_table_popup_select_invert_cb), ct);
+       menu_item_add_check(submenu, _("Rectangular selection"), (options->collections.rectangular_selection != FALSE),
+                       G_CALLBACK(collection_table_popup_rectangular_selection_cb), ct);
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
        menu_item_add_divider(menu);
 
-       
+
        ct->editmenu_fd_list = collection_table_selection_get_list(ct);
        submenu_add_edit(menu, &item,
                        G_CALLBACK(collection_table_popup_edit_cb), ct, ct->editmenu_fd_list);
@@ -1259,11 +1297,25 @@ static CollectInfo *collection_table_insert_find(CollectTable *ct, CollectInfo *
        GtkTreeIter iter;
        GtkTreePath *tpath;
        GtkTreeViewColumn *column;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
 
+#if GTK_CHECK_VERSION(3,0,0)
+       if (!use_coord)
+               {
+               device_manager = gdk_display_get_device_manager(gdk_window_get_display(
+                                                                       gtk_widget_get_window(ct->listview)));
+               device = gdk_device_manager_get_client_pointer(device_manager);
+               gdk_window_get_device_position(gtk_widget_get_window(ct->listview),
+                                                                       device, &x, &y, NULL);
+               }
+#else
        if (!use_coord) gdk_window_get_pointer(gtk_widget_get_window(ct->listview), &x, &y, NULL);
-
+#endif
        if (source)
                {
                gint col;
@@ -1477,11 +1529,21 @@ static gboolean collection_table_auto_scroll_idle_cb(gpointer data)
        GdkWindow *window;
        gint x, y;
        gint w, h;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        if (!ct->drop_idle_id) return FALSE;
 
        window = gtk_widget_get_window(ct->listview);
+#if GTK_CHECK_VERSION(3,0,0)
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(window));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(window, device, &x, &y, NULL);
+#else
        gdk_window_get_pointer(window, &x, &y, NULL);
+#endif
        w = gdk_window_get_width(window);
        h = gdk_window_get_height(window);
        if (x >= 0 && x < w && y >= 0 && y < h)
@@ -1531,11 +1593,11 @@ static void collection_table_scroll(CollectTable *ct, gboolean scroll)
  *-------------------------------------------------------------------
  */
 
-static gboolean collection_table_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+static gboolean collection_table_motion_cb(GtkWidget *widget, GdkEventMotion *event, gpointer data)
 {
        CollectTable *ct = data;
 
-       collection_table_motion_update(ct, (gint)bevent->x, (gint)bevent->y, FALSE);
+       collection_table_motion_update(ct, (gint)event->x, (gint)event->y, FALSE);
 
        return FALSE;
 }
@@ -2466,7 +2528,7 @@ CollectTable *collection_table_new(CollectionData *cd)
        gint i;
 
        ct = g_new0(CollectTable, 1);
-       
+
        ct->cd = cd;
        ct->show_text = options->show_icon_names;