Commit 7e6d0567 authored by Debarshi Ray's avatar Debarshi Ray

Port to G_APPROX_VALUE

Bump minimum GLib version to 2.57.2.
parent 29ae619e
......@@ -45,7 +45,7 @@ GDK_PIXBUF_MIN_VERSION=2.32
GEGL_MIN_VERSION=0.4.0
GEXIV2_MIN_VERSION=0.10.8
GFBGRAPH_MIN_VERSION=0.2.1
GLIB_MIN_VERSION=2.44.0
GLIB_MIN_VERSION=2.57.2
GOA_MIN_VERSION=3.8.0
GRILO_MIN_VERSION=0.3.5
GTK_MIN_VERSION=3.22.16
......
......@@ -156,7 +156,7 @@ geocode_glib_dep = dependency('geocode-glib-1.0')
gexiv_dep = dependency('gexiv2', version: '>= 0.10.8')
gio_dep = dependency('gio-2.0')
gio_unix_dep = dependency('gio-unix-2.0')
glib_dep = dependency('glib-2.0', version: '>= 2.44.0')
glib_dep = dependency('glib-2.0', version: '>= 2.57.2')
goa_dep = dependency('goa-1.0', version: '>= 3.8.0')
config_h.set('GOA_API_IS_SUBJECT_TO_CHANGE', true)
......
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2017 Red Hat, Inc.
* Copyright © 2017 – 2018 Red Hat, Inc.
*
* 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
......@@ -24,7 +24,6 @@
#include "photos-enums.h"
#include "photos-gesture-zoom.h"
#include "photos-marshalers.h"
#include "photos-utils.h"
struct _PhotosGestureZoom
......@@ -117,14 +116,14 @@ photos_gesture_zoom_update (PhotosGestureZoom *self)
g_return_if_fail (PHOTOS_IS_GESTURE_ZOOM (self));
g_return_if_fail ((self->previous_direction == PHOTOS_GESTURE_ZOOM_DIRECTION_NONE
&& photos_utils_equal_double (self->initial_distance, self->previous_distance))
&& G_APPROX_VALUE (self->initial_distance, self->previous_distance, PHOTOS_EPSILON))
|| (self->previous_direction != PHOTOS_GESTURE_ZOOM_DIRECTION_NONE
&& !photos_utils_equal_double (self->initial_distance, self->previous_distance)));
&& !G_APPROX_VALUE (self->initial_distance, self->previous_distance, PHOTOS_EPSILON)));
distance = photos_gesture_zoom_calculate_distance (self, GDK_TOUCHPAD_GESTURE_PHASE_UPDATE);
g_return_if_fail (distance >= 0.0);
if (photos_utils_equal_double (distance, self->previous_distance))
if (G_APPROX_VALUE (distance, self->previous_distance, PHOTOS_EPSILON))
goto out;
if (self->previous_distance > distance)
......
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2015 – 2017 Red Hat, Inc.
* Copyright © 2015 – 2018 Red Hat, Inc.
*
* 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
......@@ -20,7 +20,6 @@
#include "config.h"
#include "photos-image-view-helper.h"
#include "photos-utils.h"
struct _PhotosImageViewHelper
......@@ -127,7 +126,7 @@ photos_image_view_helper_set_zoom (PhotosImageViewHelper *self, gdouble zoom)
g_return_if_fail (PHOTOS_IS_IMAGE_VIEW_HELPER (self));
g_return_if_fail (zoom > 0.0);
if (photos_utils_equal_double (self->zoom, zoom))
if (G_APPROX_VALUE (self->zoom, zoom, PHOTOS_EPSILON))
return;
self->zoom = zoom;
......
......@@ -30,7 +30,6 @@
#include "photos-image-view.h"
#include "photos-image-view-helper.h"
#include "photos-marshalers.h"
#include "photos-utils.h"
struct _PhotosImageView
......@@ -387,7 +386,7 @@ photos_image_view_update (PhotosImageView *self)
photos_image_view_calculate_best_fit_zoom (self, &zoom, &zoom_scaled);
if (!photos_utils_equal_double (self->zoom, zoom))
if (!G_APPROX_VALUE (self->zoom, zoom, PHOTOS_EPSILON))
{
self->zoom = zoom;
g_object_notify (G_OBJECT (self), "zoom");
......@@ -1184,7 +1183,7 @@ photos_image_view_set_zoom (PhotosImageView *self, gdouble zoom, gboolean enable
g_return_if_fail (PHOTOS_IS_IMAGE_VIEW (self));
g_return_if_fail (zoom > 0.0);
if (photos_utils_equal_double (self->zoom, zoom))
if (G_APPROX_VALUE (self->zoom, zoom, PHOTOS_EPSILON))
return;
if (self->zoom_animation != NULL)
......
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2013 – 2017 Red Hat, Inc.
* Copyright © 2013 – 2018 Red Hat, Inc.
*
* 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
......@@ -960,7 +960,7 @@ photos_preview_view_zoom_end (PhotosPreviewView *self, GVariant *parameter)
view = photos_preview_view_get_view_from_view_container (view_container);
zoom = photos_image_view_get_zoom (PHOTOS_IMAGE_VIEW (view));
if (zoom < self->zoom_best_fit || photos_utils_equal_double (self->zoom_best_fit, zoom))
if (zoom < self->zoom_best_fit || G_APPROX_VALUE (self->zoom_best_fit, zoom, PHOTOS_EPSILON))
{
photos_image_view_set_best_fit (PHOTOS_IMAGE_VIEW (view), TRUE, TRUE);
g_simple_action_set_enabled (G_SIMPLE_ACTION (self->zoom_best_fit_action), FALSE);
......@@ -991,8 +991,10 @@ photos_preview_view_calculate_zoom_for_non_touch (PhotosPreviewView *self,
g_return_val_if_fail (event != PHOTOS_ZOOM_EVENT_NONE, 0.0);
g_return_val_if_fail (event != PHOTOS_ZOOM_EVENT_TOUCH, 0.0);
g_return_val_if_fail ((event == PHOTOS_ZOOM_EVENT_KEYBOARD_ACCELERATOR && photos_utils_equal_double (delta, 1.0))
|| (event == PHOTOS_ZOOM_EVENT_MOUSE_CLICK && photos_utils_equal_double (delta, 1.0))
g_return_val_if_fail ((event == PHOTOS_ZOOM_EVENT_KEYBOARD_ACCELERATOR
&& G_APPROX_VALUE (delta, 1.0, PHOTOS_EPSILON))
|| (event == PHOTOS_ZOOM_EVENT_MOUSE_CLICK
&& G_APPROX_VALUE (delta, 1.0, PHOTOS_EPSILON))
|| (event == PHOTOS_ZOOM_EVENT_SCROLL && delta >= 0.0),
0.0);
......@@ -1047,8 +1049,9 @@ photos_preview_view_zoom_in (PhotosPreviewView *self, GVariant *parameter)
g_return_if_fail (event != PHOTOS_ZOOM_EVENT_NONE);
delta = photos_utils_get_zoom_delta (parameter);
g_return_if_fail ((event == PHOTOS_ZOOM_EVENT_KEYBOARD_ACCELERATOR && photos_utils_equal_double (delta, 1.0))
|| (event == PHOTOS_ZOOM_EVENT_MOUSE_CLICK && photos_utils_equal_double (delta, 1.0))
g_return_if_fail ((event == PHOTOS_ZOOM_EVENT_KEYBOARD_ACCELERATOR
&& G_APPROX_VALUE (delta, 1.0, PHOTOS_EPSILON))
|| (event == PHOTOS_ZOOM_EVENT_MOUSE_CLICK && G_APPROX_VALUE (delta, 1.0, PHOTOS_EPSILON))
|| (event == PHOTOS_ZOOM_EVENT_SCROLL && delta >= 0.0)
|| (event == PHOTOS_ZOOM_EVENT_TOUCH && delta >= 0.0 && self->zoom_begin > 0.0));
......@@ -1101,8 +1104,9 @@ photos_preview_view_zoom_out (PhotosPreviewView *self, GVariant *parameter)
g_return_if_fail (event != PHOTOS_ZOOM_EVENT_NONE);
delta = photos_utils_get_zoom_delta (parameter);
g_return_if_fail ((event == PHOTOS_ZOOM_EVENT_KEYBOARD_ACCELERATOR && photos_utils_equal_double (delta, 1.0))
|| (event == PHOTOS_ZOOM_EVENT_MOUSE_CLICK && photos_utils_equal_double (delta, 1.0))
g_return_if_fail ((event == PHOTOS_ZOOM_EVENT_KEYBOARD_ACCELERATOR
&& G_APPROX_VALUE (delta, 1.0, PHOTOS_EPSILON))
|| (event == PHOTOS_ZOOM_EVENT_MOUSE_CLICK && G_APPROX_VALUE (delta, 1.0, PHOTOS_EPSILON))
|| (event == PHOTOS_ZOOM_EVENT_SCROLL && delta >= 0.0)
|| (event == PHOTOS_ZOOM_EVENT_TOUCH && delta >= 0.0 && self->zoom_begin > 0.0));
......@@ -1132,7 +1136,7 @@ photos_preview_view_zoom_out (PhotosPreviewView *self, GVariant *parameter)
view = photos_preview_view_get_view_from_view_container (view_container);
zoom_best_fit = self->zoom_best_fit * zoom_best_fit_factor;
if (zoom < zoom_best_fit || photos_utils_equal_double (zoom_best_fit, zoom))
if (zoom < zoom_best_fit || G_APPROX_VALUE (zoom_best_fit, zoom, PHOTOS_EPSILON))
{
photos_image_view_set_best_fit (PHOTOS_IMAGE_VIEW (view), TRUE, TRUE);
g_simple_action_set_enabled (G_SIMPLE_ACTION (self->zoom_best_fit_action), FALSE);
......
......@@ -21,7 +21,6 @@
#include "config.h"
#include "photos-tool-crop-helper.h"
#include "photos-utils.h"
struct _PhotosToolCropHelper
......@@ -228,7 +227,7 @@ photos_tool_crop_helper_set_height (PhotosToolCropHelper *self, gdouble height)
g_return_if_fail (PHOTOS_IS_TOOL_CROP_HELPER (self));
g_return_if_fail (height >= 0.0);
if (photos_utils_equal_double (self->height, height))
if (G_APPROX_VALUE (self->height, height, PHOTOS_EPSILON))
goto out;
self->height = height;
......@@ -245,7 +244,7 @@ photos_tool_crop_helper_set_width (PhotosToolCropHelper *self, gdouble width)
g_return_if_fail (PHOTOS_IS_TOOL_CROP_HELPER (self));
g_return_if_fail (width >= 0.0);
if (photos_utils_equal_double (self->width, width))
if (G_APPROX_VALUE (self->width, width, PHOTOS_EPSILON))
goto out;
self->width = width;
......@@ -262,7 +261,7 @@ photos_tool_crop_helper_set_x (PhotosToolCropHelper *self, gdouble x)
g_return_if_fail (PHOTOS_IS_TOOL_CROP_HELPER (self));
g_return_if_fail (x >= 0.0);
if (photos_utils_equal_double (self->x, x))
if (G_APPROX_VALUE (self->x, x, PHOTOS_EPSILON))
goto out;
self->x = x;
......@@ -279,7 +278,7 @@ photos_tool_crop_helper_set_y (PhotosToolCropHelper *self, gdouble y)
g_return_if_fail (PHOTOS_IS_TOOL_CROP_HELPER (self));
g_return_if_fail (y >= 0.0);
if (photos_utils_equal_double (self->y, y))
if (G_APPROX_VALUE (self->y, y, PHOTOS_EPSILON))
goto out;
self->y = y;
......
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2015 – 2017 Red Hat, Inc.
* Copyright © 2015 – 2018 Red Hat, Inc.
* Copyright © 2015 – 2017 Umang Jain
* Copyright © 2011 – 2015 Yorba Foundation
*
......@@ -220,14 +220,14 @@ photos_tool_crop_find_constraint (PhotosToolCrop *self, gdouble aspect_ratio)
gdouble constraint_aspect_ratio;
constraint_aspect_ratio = photos_tool_crop_calculate_aspect_ratio (self, i);
if (photos_utils_equal_double (aspect_ratio, constraint_aspect_ratio))
if (G_APPROX_VALUE (aspect_ratio, constraint_aspect_ratio, PHOTOS_EPSILON))
{
ret_val = i;
break;
}
constraint_aspect_ratio = 1.0 / constraint_aspect_ratio;
if (photos_utils_equal_double (aspect_ratio, constraint_aspect_ratio))
if (G_APPROX_VALUE (aspect_ratio, constraint_aspect_ratio, PHOTOS_EPSILON))
{
ret_val = i;
break;
......
......@@ -772,14 +772,6 @@ photos_utils_ensure_extension_points (void)
}
gboolean
photos_utils_equal_double (gdouble a, gdouble b)
{
const gdouble diff = a - b;
return diff > -PHOTOS_EPSILON && diff < PHOTOS_EPSILON;
}
gdouble
photos_utils_eval_radial_line (gdouble crop_center_x,
gdouble crop_center_y,
......
......@@ -109,8 +109,6 @@ void photos_utils_ensure_builtins (void);
void photos_utils_ensure_extension_points (void);
gboolean photos_utils_equal_double (gdouble a, gdouble b);
gdouble photos_utils_eval_radial_line (gdouble crop_center_x,
gdouble crop_center_y,
gdouble corner_x,
......
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