summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-05-01 16:59:57 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-05-01 16:59:57 +0200
commit80d6497a3460c68a604b8a3c7a316c26d8cec9bb (patch)
tree0b6adc8e6b04a13537aaaf9549089c526ed8e3d0
parent858fefb5f1db61b8cc90149432fdc5f76677311e (diff)
Move thumbnail code from events.c to thumbnail.c
-rw-r--r--src/events.c49
-rw-r--r--src/thumbnail.c51
-rw-r--r--src/thumbnail.h2
3 files changed, 58 insertions, 44 deletions
diff --git a/src/events.c b/src/events.c
index 7c56b96..fe87513 100644
--- a/src/events.c
+++ b/src/events.c
@@ -195,9 +195,7 @@ static void feh_event_handle_ButtonRelease(XEvent * ev)
} else if ((winwid != NULL)
&& (winwid->type == WIN_TYPE_THUMBNAIL)) {
feh_file *thumbfile;
- winwidget thumbwin = NULL;
int x, y;
- char *s;
x = ev->xbutton.x;
y = ev->xbutton.y;
@@ -206,25 +204,8 @@ static void feh_event_handle_ButtonRelease(XEvent * ev)
x /= winwid->zoom;
y /= winwid->zoom;
thumbfile = feh_thumbnail_get_file_from_coords(x, y);
- if (thumbfile) {
- if (!opt.thumb_title)
- s = thumbfile->name;
- else
- s = feh_printf(opt.thumb_title, thumbfile);
- thumbwin = winwidget_get_first_window_of_type(WIN_TYPE_THUMBNAIL_VIEWER);
- if (!thumbwin) {
- thumbwin = winwidget_create_from_file(
- gib_list_add_front(NULL, thumbfile),
- s, WIN_TYPE_THUMBNAIL_VIEWER);
- if (thumbwin)
- winwidget_show(thumbwin);
- } else if (FEH_FILE(thumbwin->file->data) != thumbfile) {
- free(thumbwin->file);
- thumbwin->file = gib_list_add_front(NULL, thumbfile);
- winwidget_rename(thumbwin, s);
- feh_reload_image(thumbwin, 1, 0);
- }
- }
+ if (thumbfile)
+ feh_thumbnail_show_fullsize(thumbfile);
}
} else {
if (winwid != NULL) {
@@ -519,29 +500,9 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
y = (ev->xbutton.y - winwid->im_y) / winwid->zoom;
thumbnail = feh_thumbnail_get_thumbnail_from_coords(x, y);
if (thumbnail != last_thumb) {
- if (thumbnail) {
- Imlib_Image origwin;
-
- origwin = winwid->im;
- winwid->im = gib_imlib_clone_image(origwin);
- gib_imlib_image_fill_rectangle(winwid->im,
- thumbnail->x, thumbnail->y, thumbnail->w,
- thumbnail->h, 50, 50, 255, 100);
- gib_imlib_image_draw_rectangle(winwid->im,
- thumbnail->x, thumbnail->y, thumbnail->w,
- thumbnail->h, 255, 255, 255, 255);
- gib_imlib_image_draw_rectangle(winwid->im,
- thumbnail->x + 1, thumbnail->y + 1,
- thumbnail->w - 2, thumbnail->h - 2,
- 0, 0, 0, 255);
- gib_imlib_image_draw_rectangle(winwid->im,
- thumbnail->x + 2, thumbnail->y + 2,
- thumbnail->w - 4, thumbnail->h - 4,
- 255, 255, 255, 255);
- winwidget_render_image(winwid, 0, 0);
- gib_imlib_free_image_and_decache(winwid->im);
- winwid->im = origwin;
- } else
+ if (thumbnail)
+ feh_thumbnail_mark_selected(winwid, thumbnail);
+ else
winwidget_render_image(winwid, 0, 0);
}
last_thumb = thumbnail;
diff --git a/src/thumbnail.c b/src/thumbnail.c
index 0e93447..4dbc76f 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -901,6 +901,57 @@ int feh_thumbnail_get_generated(Imlib_Image * image, feh_file * file,
return (0);
}
+void feh_thumbnail_show_fullsize(feh_file *thumbfile)
+{
+ winwidget thumbwin = NULL;
+ char *s;
+
+ if (!opt.thumb_title)
+ s = thumbfile->name;
+ else
+ s = feh_printf(opt.thumb_title, thumbfile);
+
+ thumbwin = winwidget_get_first_window_of_type(WIN_TYPE_THUMBNAIL_VIEWER);
+ if (!thumbwin) {
+ thumbwin = winwidget_create_from_file(
+ gib_list_add_front(NULL, thumbfile),
+ s, WIN_TYPE_THUMBNAIL_VIEWER);
+ if (thumbwin)
+ winwidget_show(thumbwin);
+ } else if (FEH_FILE(thumbwin->file->data) != thumbfile) {
+ free(thumbwin->file);
+ thumbwin->file = gib_list_add_front(NULL, thumbfile);
+ winwidget_rename(thumbwin, s);
+ feh_reload_image(thumbwin, 1, 0);
+ }
+}
+
+void feh_thumbnail_mark_selected(winwidget winwid, feh_thumbnail *thumbnail)
+{
+ Imlib_Image origwin;
+ origwin = winwid->im;
+ winwid->im = gib_imlib_clone_image(origwin);
+ gib_imlib_image_fill_rectangle(winwid->im,
+ thumbnail->x, thumbnail->y, thumbnail->w,
+ thumbnail->h, 50, 50, 255, 100);
+ gib_imlib_image_draw_rectangle(winwid->im,
+ thumbnail->x, thumbnail->y, thumbnail->w,
+ thumbnail->h, 255, 255, 255, 255);
+ gib_imlib_image_draw_rectangle(winwid->im,
+ thumbnail->x + 1, thumbnail->y + 1,
+ thumbnail->w - 2, thumbnail->h - 2,
+ 0, 0, 0, 255);
+ gib_imlib_image_draw_rectangle(winwid->im,
+ thumbnail->x + 2, thumbnail->y + 2,
+ thumbnail->w - 4, thumbnail->h - 4,
+ 255, 255, 255, 255);
+ winwidget_render_image(winwid, 0, 0);
+ gib_imlib_free_image_and_decache(winwid->im);
+ winwid->im = origwin;
+}
+
+
+
int feh_thumbnail_setup_thumbnail_dir(void)
{
int status = 0;
diff --git a/src/thumbnail.h b/src/thumbnail.h
index 6d2dc77..e9c3f09 100644
--- a/src/thumbnail.h
+++ b/src/thumbnail.h
@@ -80,6 +80,8 @@ int feh_thumbnail_get_generated(Imlib_Image * image, feh_file * file, char * thu
char *feh_thumbnail_get_name(char *uri);
char *feh_thumbnail_get_name_uri(char *name);
char *feh_thumbnail_get_name_md5(char *uri);
+void feh_thumbnail_show_fullsize(feh_file *thumbfile);
+void feh_thumbnail_mark_selected(winwidget winwid, feh_thumbnail *thumbnail);
int feh_thumbnail_setup_thumbnail_dir(void);