Commit ccfd4e1c authored by Cosimo Cecchi's avatar Cosimo Cecchi

all: hook up the previewer with NautilusIconView

parent 4241ccfd
......@@ -144,6 +144,7 @@ typedef struct {
static GType nautilus_icon_container_accessible_get_type (void);
static void preview_selected_items (NautilusIconContainer *container);
static void activate_selected_items (NautilusIconContainer *container);
static void activate_selected_items_alternate (NautilusIconContainer *container,
NautilusIcon *icon);
......@@ -226,6 +227,7 @@ G_DEFINE_TYPE (NautilusIconContainer, nautilus_icon_container, EEL_TYPE_CANVAS);
enum {
ACTIVATE,
ACTIVATE_ALTERNATE,
ACTIVATE_PREVIEWER,
BAND_SELECT_STARTED,
BAND_SELECT_ENDED,
BUTTON_PRESS,
......@@ -3891,7 +3893,7 @@ keyboard_space (NautilusIconContainer *container,
} else if ((event->state & GDK_SHIFT_MASK) != 0) {
activate_selected_items_alternate (container, NULL);
} else {
activate_selected_items (container);
preview_selected_items (container);
}
}
......@@ -5743,6 +5745,16 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class)
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
signals[ACTIVATE_PREVIEWER]
= g_signal_new ("activate_previewer",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusIconContainerClass,
activate_previewer),
NULL, NULL,
nautilus_marshal_VOID__POINTER_POINTER,
G_TYPE_NONE, 2,
G_TYPE_POINTER, G_TYPE_POINTER);
signals[CONTEXT_CLICK_SELECTION]
= g_signal_new ("context_click_selection",
G_TYPE_FROM_CLASS (class),
......@@ -6740,6 +6752,37 @@ activate_selected_items (NautilusIconContainer *container)
g_list_free (selection);
}
static void
preview_selected_items (NautilusIconContainer *container)
{
GList *selection;
GArray *locations;
gint idx;
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
selection = nautilus_icon_container_get_selection (container);
locations = nautilus_icon_container_get_selected_icon_locations (container);
for (idx = 0; idx < locations->len; idx++) {
GdkPoint *point = &(g_array_index (locations, GdkPoint, idx));
gint scroll_x, scroll_y;
eel_canvas_get_scroll_offsets (EEL_CANVAS (container),
&scroll_x, &scroll_y);
point->x -= scroll_x;
point->y -= scroll_y;
}
if (selection != NULL) {
g_signal_emit (container,
signals[ACTIVATE_PREVIEWER], 0,
selection, locations);
}
g_list_free (selection);
}
static void
activate_selected_items_alternate (NautilusIconContainer *container,
NautilusIcon *icon)
......
......@@ -93,6 +93,9 @@ typedef struct {
NautilusIconData *data);
void (* activate_alternate) (NautilusIconContainer *container,
NautilusIconData *data);
void (* activate_previewer) (NautilusIconContainer *container,
GList *files,
GArray *locations);
void (* context_click_selection) (NautilusIconContainer *container,
GdkEventButton *event);
void (* move_copy_items) (NautilusIconContainer *container,
......
......@@ -1688,6 +1688,19 @@ icon_container_activate_callback (NautilusIconContainer *container,
0, TRUE);
}
static void
icon_container_activate_previewer_callback (NautilusIconContainer *container,
GList *file_list,
GArray *locations,
NautilusIconView *icon_view)
{
g_assert (NAUTILUS_IS_ICON_VIEW (icon_view));
g_assert (container == get_icon_container (icon_view));
nautilus_view_preview_files (NAUTILUS_VIEW (icon_view),
file_list, locations);
}
/* this is called in one of these cases:
* - we activate with enter holding shift
* - we activate with space holding shift
......@@ -2558,6 +2571,8 @@ create_icon_container (NautilusIconView *icon_view)
G_CALLBACK (icon_container_activate_callback), icon_view, 0);
g_signal_connect_object (icon_container, "activate_alternate",
G_CALLBACK (icon_container_activate_alternate_callback), icon_view, 0);
g_signal_connect_object (icon_container, "activate_previewer",
G_CALLBACK (icon_container_activate_previewer_callback), icon_view, 0);
g_signal_connect_object (icon_container, "band_select_started",
G_CALLBACK (band_select_started_callback), icon_view, 0);
g_signal_connect_object (icon_container, "band_select_ended",
......
......@@ -36,9 +36,11 @@
#include "nautilus-error-reporting.h"
#include "nautilus-list-view.h"
#include "nautilus-mime-actions.h"
#include "nautilus-previewer.h"
#include "nautilus-properties-window.h"
#include "nautilus-src-marshal.h"
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
......@@ -1109,6 +1111,34 @@ get_view_directory (NautilusView *view)
return path;
}
void
nautilus_view_preview_files (NautilusView *view,
GList *files,
GArray *locations)
{
NautilusPreviewer *previewer;
gchar *uri;
guint xid, x, y;
GdkPoint location;
GtkWidget *toplevel;
previewer = nautilus_previewer_dup_singleton ();
uri = nautilus_file_get_uri (files->data);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
if (locations != NULL) {
location = g_array_index (locations, GdkPoint, 0);
x = location.x;
y = location.y;
} else {
x = y = 0;
}
xid = gdk_x11_window_get_xid (gtk_widget_get_window (toplevel));
nautilus_previewer_call_show_file (previewer, uri, xid, x, y);
}
void
nautilus_view_activate_files (NautilusView *view,
GList *files,
......
......@@ -329,6 +329,9 @@ void nautilus_view_activate_files (NautilusView
GList *files,
NautilusWindowOpenFlags flags,
gboolean confirm_multiple);
void nautilus_view_preview_files (NautilusView *view,
GList *files,
GArray *locations);
void nautilus_view_start_batching_selection_changes (NautilusView *view);
void nautilus_view_stop_batching_selection_changes (NautilusView *view);
void nautilus_view_notify_selection_changed (NautilusView *view);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment