Sort headers using clang-tidy
[geeqie.git] / src / image.cc
index 36e5333..5cd517b 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "main.h"
 #include "image.h"
 
+#include <config.h>
+
 #include "collect-table.h"
 #include "color-man.h"
+#include "compat.h"
+#include "debug.h"
 #include "exif.h"
-#include "metadata.h"
+#include "filecache.h"
 #include "history-list.h"
 #include "image-load.h"
-#include "layout.h"
+#include "intl.h"
 #include "layout-image.h"
+#include "layout.h"
+#include "metadata.h"
 #include "pixbuf-renderer.h"
 #include "pixbuf-util.h"
 #include "ui-fileops.h"
 #include "ui-misc.h"
-#include "filecache.h"
 
 #include <cmath>
 
@@ -141,7 +145,8 @@ static void image_press_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer d
 {
        auto imd = static_cast<ImageWindow *>(data);
        LayoutWindow *lw;
-       gint x_pixel, y_pixel;
+       gint x_pixel;
+       gint y_pixel;
 
        if(options->draw_rectangle)
                {
@@ -198,18 +203,21 @@ static void image_release_cb(PixbufRenderer *, GdkEventButton *event, gpointer d
                layout_valid(&lw);
                }
 
-       defined_mouse_buttons(NULL, event, lw);
+       defined_mouse_buttons(nullptr, event, lw);
 }
 
 static void image_drag_cb(PixbufRenderer *pr, GdkEventMotion *event, gpointer data)
 {
        auto imd = static_cast<ImageWindow *>(data);
-       gint width, height;
+       gint width;
+       gint height;
        gint rect_width;
        gint rect_height;
        GdkPixbuf *rect_pixbuf;
-       gint x_pixel, y_pixel;
-       gint image_x_pixel, image_y_pixel;
+       gint x_pixel;
+       gint y_pixel;
+       gint image_x_pixel;
+       gint image_y_pixel;
 
        if (options->draw_rectangle)
                {
@@ -985,7 +993,7 @@ static gboolean image_read_ahead_check(ImageWindow *imd)
                imd->read_ahead_fd = nullptr;
                return TRUE;
                }
-       else if (imd->read_ahead_fd->pixbuf)
+       if (imd->read_ahead_fd->pixbuf)
                {
                image_change_pixbuf(imd, imd->read_ahead_fd->pixbuf, image_zoom_get(imd), FALSE);
 
@@ -1216,11 +1224,9 @@ static gboolean image_scroll_cb(GtkWidget *, GdkEventScroll *event, gpointer dat
                                }
                        return TRUE;
                        }
-               else
-                       {
-                       imd->func_scroll(imd, event, imd->data_scroll);
-                       return TRUE;
-                       }
+
+               imd->func_scroll(imd, event, imd->data_scroll);
+               return TRUE;
                }
 
        return FALSE;
@@ -1694,7 +1700,8 @@ void image_zoom_set_fill_geometry(ImageWindow *imd, gboolean vertical)
 {
        PixbufRenderer *pr;
        gdouble zoom;
-       gint width, height;
+       gint width;
+       gint height;
 
        pr = reinterpret_cast<PixbufRenderer *>(imd->pr);
 
@@ -1882,15 +1889,15 @@ void image_top_window_set_sync(ImageWindow *imd, gboolean allow_sync)
        g_object_set(G_OBJECT(imd->pr), "window_fit", allow_sync, NULL);
 }
 
-void image_background_set_color(ImageWindow *imd, GdkColor *color)
+void image_background_set_color(ImageWindow *imd, GdkRGBA *color)
 {
        pixbuf_renderer_set_color(reinterpret_cast<PixbufRenderer *>(imd->pr), color);
 }
 
 void image_background_set_color_from_options(ImageWindow *imd, gboolean fullscreen)
 {
-       GdkColor *color = nullptr;
-       GdkColor theme_color;
+       GdkRGBA *color = nullptr;
+       GdkRGBA theme_color;
        GdkRGBA bg_color;
        GtkStyleContext *style_context;
        LayoutWindow *lw = nullptr;
@@ -1908,9 +1915,9 @@ void image_background_set_color_from_options(ImageWindow *imd, gboolean fullscre
                style_context = gtk_widget_get_style_context(lw->window);
                gtk_style_context_get_background_color(style_context, GTK_STATE_FLAG_NORMAL, &bg_color);
 
-               theme_color.red = bg_color.red * 65535;
-               theme_color.green = bg_color.green * 65535;
-               theme_color.blue = bg_color.blue * 65535;
+               theme_color.red = bg_color.red * 1;
+               theme_color.green = bg_color.green * 1;
+               theme_color.blue = bg_color.blue * 1;
 
                color = &theme_color;
                }
@@ -2014,7 +2021,7 @@ void image_set_selectable(ImageWindow *imd, gboolean selectable)
 {
        if (!imd->has_frame) return;
 
-       gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE);
+       gq_gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE);
        gtk_container_set_border_width(GTK_CONTAINER(imd->frame), selectable ? 4 : 0);
 }
 
@@ -2113,28 +2120,17 @@ gboolean selectable_frame_draw_cb(GtkWidget *widget, cairo_t *cr, gpointer)
 {
        GtkAllocation allocation;
        gtk_widget_get_allocation(widget, &allocation);
-       gtk_paint_flat_box(gtk_widget_get_style(widget),
-                          cr,
-                          gtk_widget_get_state(widget),
-                          gtk_frame_get_shadow_type(GTK_FRAME(widget)),
-                          widget,
-                          nullptr,
-                          allocation.x + 3, allocation.y + 3,
-                          allocation.width - 6, allocation.height - 6);
+
+       gtk_render_frame(gtk_widget_get_style_context(widget), cr, allocation.x + 3, allocation.y + 3, allocation.width - 6, allocation.height - 6);
+       gtk_render_background(gtk_widget_get_style_context(widget), cr, allocation.x + 3, allocation.y + 3, allocation.width - 6, allocation.height - 6);
 
        if (gtk_widget_has_focus(widget))
                {
-               gtk_paint_focus(gtk_widget_get_style(widget), cr, GTK_STATE_ACTIVE,
-                               widget, "image_window",
-                               allocation.x, allocation.y,
-                               allocation.width - 1, allocation.height - 1);
+               gtk_render_focus(gtk_widget_get_style_context(widget), cr, allocation.x, allocation.y, allocation.width - 1, allocation.height - 1);
                }
        else
                {
-               gtk_paint_shadow(gtk_widget_get_style(widget), cr, GTK_STATE_NORMAL, GTK_SHADOW_IN,
-                                widget, "image_window",
-                                allocation.x, allocation.y,
-                                allocation.width - 1, allocation.height - 1);
+               gtk_render_frame(gtk_widget_get_style_context(widget), cr, allocation.x, allocation.y, allocation.width - 1, allocation.height - 1);
                }
        return FALSE;
 }
@@ -2153,7 +2149,7 @@ void image_set_frame(ImageWindow *imd, gboolean frame)
                DEBUG_NAME(imd->frame);
                g_object_ref(imd->pr);
                if (imd->has_frame != -1) gtk_container_remove(GTK_CONTAINER(imd->widget), imd->pr);
-               gtk_container_add(GTK_CONTAINER(imd->frame), imd->pr);
+               gq_gtk_container_add(GTK_WIDGET(imd->frame), imd->pr);
 
                g_object_unref(imd->pr);
                gtk_widget_set_can_focus(imd->frame, TRUE);
@@ -2164,7 +2160,7 @@ void image_set_frame(ImageWindow *imd, gboolean frame)
                g_signal_connect(G_OBJECT(imd->frame), "focus_in_event",
                                 G_CALLBACK(image_focus_in_cb), imd);
 
-               gtk_box_pack_start(GTK_BOX(imd->widget), imd->frame, TRUE, TRUE, 0);
+               gq_gtk_box_pack_start(GTK_BOX(imd->widget), imd->frame, TRUE, TRUE, 0);
                gtk_widget_show(imd->frame);
                }
        else
@@ -2173,10 +2169,10 @@ void image_set_frame(ImageWindow *imd, gboolean frame)
                if (imd->frame)
                        {
                        gtk_container_remove(GTK_CONTAINER(imd->frame), imd->pr);
-                       gtk_widget_destroy(imd->frame);
+                       g_object_unref(imd->frame);
                        imd->frame = nullptr;
                        }
-               gtk_box_pack_start(GTK_BOX(imd->widget), imd->pr, TRUE, TRUE, 0);
+               gq_gtk_box_pack_start(GTK_BOX(imd->widget), imd->pr, TRUE, TRUE, 0);
 
                g_object_unref(imd->pr);
                }