Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation of various PRs #142

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion data/vnr-crop-dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
Expand Down
1 change: 0 additions & 1 deletion data/vnr-preferences-dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<property name="resizable">False</property>
<property name="icon_name">viewnior</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ i18n = import('i18n')
glib_ver = '>= 2.32'

viewnior_deps = [
dependency('gtk+-2.0', version: '>= 2.20'),
dependency('gtk+-3.0'),
dependency('glib-2.0', version: glib_ver),
dependency('gio-2.0', version: glib_ver),
dependency('shared-mime-info', version: '>= 0.20'),
Expand Down
25 changes: 16 additions & 9 deletions src/uni-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,14 @@ uni_pixbuf_draw_cache_intersect_draw (UniPixbufDrawCache * cache,
* uni_pixbuf_draw_cache_draw:
* @cache: a #UniPixbufDrawCache
* @opts: the #UniPixbufDrawOpts to use in this draw
* @window: a #GdkWindow to draw on
* @cr: a #cairo_t to draw with
*
* Redraws the area specified in the pixbuf draw options in an
* efficient way by using caching.
**/
void
uni_pixbuf_draw_cache_draw (UniPixbufDrawCache * cache,
UniPixbufDrawOpts * opts, GdkWindow * window)
UniPixbufDrawOpts * opts, cairo_t *cr)
{
GdkRectangle this = opts->zoom_rect;
UniPixbufDrawMethod method =
Expand Down Expand Up @@ -306,13 +306,20 @@ uni_pixbuf_draw_cache_draw (UniPixbufDrawCache * cache,
(double) -this.x, (double) -this.y,
opts->zoom, opts->interp, this.x, this.y);
}
gdk_draw_pixbuf (window,
NULL,
cache->last_pixbuf,
deltax, deltay,
opts->widget_x, opts->widget_y,
this.width, this.height,
GDK_RGB_DITHER_MAX, opts->widget_x, opts->widget_y);
cairo_save(cr);
GdkRectangle rect;
rect.x = opts->widget_x;
rect.y = opts->widget_y;
rect.width = this.width;
rect.height = this.height;
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
GdkPixbuf *subpixbuf = gdk_pixbuf_new_subpixbuf(cache->last_pixbuf, deltax, deltay, this.width, this.height);
gdk_cairo_set_source_pixbuf(cr, subpixbuf, rect.x, rect.y);
cairo_rectangle(cr, opts->widget_x, opts->widget_y, this.width, this.height);
cairo_clip(cr);
cairo_paint(cr);
cairo_restore(cr);
g_object_unref(subpixbuf);
if (method != UNI_PIXBUF_DRAW_METHOD_CONTAINS)
cache->old = *opts;
}
2 changes: 1 addition & 1 deletion src/uni-cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void uni_pixbuf_draw_cache_free (UniPixbufDrawCache * cache);
void uni_pixbuf_draw_cache_invalidate (UniPixbufDrawCache * cache);
void uni_pixbuf_draw_cache_draw (UniPixbufDrawCache * cache,
UniPixbufDrawOpts * opts,
GdkWindow * window);
cairo_t *cr);

UniPixbufDrawMethod uni_pixbuf_draw_cache_get_method (UniPixbufDrawOpts * old,
UniPixbufDrawOpts *
Expand Down
8 changes: 4 additions & 4 deletions src/uni-dragger.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ uni_dragger_motion_notify (UniDragger * tool, GdkEventMotion * ev)
if (abs (dx) < 1 && abs (dy) < 1)
return FALSE;

vadj = UNI_IMAGE_VIEW(tool->view)->vadj;
hadj = UNI_IMAGE_VIEW(tool->view)->hadj;
vadj = uni_image_view_get_vadjustment(UNI_IMAGE_VIEW(tool->view));
hadj = uni_image_view_get_hadjustment(UNI_IMAGE_VIEW(tool->view));
if ( pow(dx, 2) + pow(dy, 2) > 7 && UNI_IMAGE_VIEW(tool->view)->pixbuf != NULL &&
gtk_adjustment_get_upper(vadj) <= gtk_adjustment_get_page_size(vadj) &&
gtk_adjustment_get_upper(hadj) <= gtk_adjustment_get_page_size(hadj) )
Expand Down Expand Up @@ -139,9 +139,9 @@ uni_dragger_pixbuf_changed (UniDragger * tool,

void
uni_dragger_paint_image (UniDragger * tool,
UniPixbufDrawOpts * opts, GdkWindow * window)
UniPixbufDrawOpts * opts, cairo_t *cr)
{
uni_pixbuf_draw_cache_draw (tool->cache, opts, window);
uni_pixbuf_draw_cache_draw (tool->cache, opts, cr);
}

/*************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion src/uni-dragger.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void uni_dragger_pixbuf_changed (UniDragger * tool,

void uni_dragger_paint_image (UniDragger * tool,
UniPixbufDrawOpts * opts,
GdkWindow * window);
cairo_t *cr);

G_END_DECLS
#endif /* __UNI_TOOL_DRAGGER_H__ */
36 changes: 23 additions & 13 deletions src/uni-exiv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,31 @@

#include <exiv2/exiv2.hpp>
#include <iostream>
#include <memory>

#include "uni-exiv2.hpp"

#define ARRAY_SIZE(array) (sizeof array/sizeof(array[0]))

static Exiv2::Image::AutoPtr cached_image;
#define EXIV_ERROR Exiv2::AnyError
#ifdef EXIV2_VERSION
#ifdef EXIV2_TEST_VERSION
#if EXIV2_TEST_VERSION(0,28,0)
#define EXIV_ERROR Exiv2::Error
#endif
#endif
#endif

static std::unique_ptr<Exiv2::Image> cached_image;

extern "C"
void
uni_read_exiv2_map(const char *uri, void (*callback)(const char*, const char*, void*), void *user_data)
{
Exiv2::LogMsg::setLevel(Exiv2::LogMsg::mute);
try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(uri);
if ( image.get() == 0 ) {
std::unique_ptr<Exiv2::Image> image = Exiv2::ImageFactory::open(uri);
if (image == nullptr) {
return;
}

Expand Down Expand Up @@ -80,7 +90,7 @@ uni_read_exiv2_map(const char *uri, void (*callback)(const char*, const char*, v
}
}
}
} catch (Exiv2::AnyError& e) {
} catch (EXIV_ERROR& e) {
std::cerr << "Exiv2: '" << e << "'\n";
}
}
Expand All @@ -91,19 +101,19 @@ uni_read_exiv2_to_cache(const char *uri)
{
Exiv2::LogMsg::setLevel(Exiv2::LogMsg::mute);

if ( cached_image.get() != NULL ) {
if (cached_image != nullptr) {
cached_image->clearMetadata();
cached_image.reset(NULL);
cached_image.reset(nullptr);
}

try {
cached_image = Exiv2::ImageFactory::open(uri);
if ( cached_image.get() == 0 ) {
if (cached_image == nullptr) {
return 1;
}

cached_image->readMetadata();
} catch (Exiv2::AnyError& e) {
} catch (EXIV_ERROR& e) {
std::cerr << "Exiv2: '" << e << "'\n";
}

Expand All @@ -116,24 +126,24 @@ uni_write_exiv2_from_cache(const char *uri)
{
Exiv2::LogMsg::setLevel(Exiv2::LogMsg::mute);

if ( cached_image.get() == NULL ) {
if (cached_image == nullptr) {
return 1;
}

try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(uri);
if ( image.get() == 0 ) {
std::unique_ptr<Exiv2::Image> image = Exiv2::ImageFactory::open(uri);
if (image == nullptr) {
return 2;
}

image->setMetadata( *cached_image );
image->writeMetadata();

cached_image->clearMetadata();
cached_image.reset(NULL);
cached_image.reset(nullptr);

return 0;
} catch (Exiv2::AnyError& e) {
} catch (EXIV_ERROR& e) {
std::cerr << "Exiv2: '" << e << "'\n";
}

Expand Down
Loading