Fix build with LTO
[geeqie.git] / src / osd.cc
index 6adb7ed..0815593 100644 (file)
  * used for the same purposes by the Print routines
  */
 
-#include "main.h"
 #include "osd.h"
 
+#include <cmath>
+#include <cstdlib>
+#include <cstring>
+
+#include <gdk/gdk.h>
+#include <glib-object.h>
+
+#include <config.h>
+
+#include "compat.h"
 #include "dnd.h"
 #include "exif.h"
 #include "glua.h"
+#include "intl.h"
 #include "metadata.h"
-#include "ui-fileops.h"
+#include "typedefs.h"
 #include "ui-misc.h"
 
-#include <cmath>
-
 static const gchar *predefined_tags[][2] = {
        {"%name%",                                                      N_("Name")},
        {"%path:60%",                                           N_("Path")},
@@ -123,7 +131,7 @@ static void osd_btn_destroy_cb(GtkWidget *btn, GdkDragContext *, GtkSelectionDat
        g_free(td->title);
 }
 
-static void set_osd_button(GtkTable *table, const gint rows, const gint cols, const gchar *key, const gchar *title, GtkWidget *template_view)
+static void set_osd_button(GtkGrid *grid, const gint rows, const gint cols, const gchar *key, const gchar *title, GtkWidget *template_view)
 {
        GtkWidget *new_button;
        TagData *td;
@@ -144,7 +152,7 @@ static void set_osd_button(GtkTable *table, const gint rows, const gint cols, co
        g_signal_connect(G_OBJECT(new_button), "destroy",
                                                        G_CALLBACK(osd_btn_destroy_cb), new_button);
 
-       gtk_table_attach_defaults(table, new_button, cols, cols+1, rows, rows+1);
+       gtk_grid_attach(grid, new_button, cols, rows, 1, 1);
 
 }
 
@@ -163,8 +171,8 @@ GtkWidget *osd_new(gint max_cols, GtkWidget *template_view)
 
        pref_label_new(vbox, _("To include predefined tags in the template, click a button or drag-and-drop"));
 
-       scrolled = gtk_scrolled_window_new(nullptr, nullptr);
-       gtk_box_pack_start(GTK_BOX(vbox), scrolled, FALSE, FALSE, 0);
+       scrolled = gq_gtk_scrolled_window_new(nullptr, nullptr);
+       gq_gtk_box_pack_start(GTK_BOX(vbox), scrolled, FALSE, FALSE, 0);
        gtk_container_set_border_width(GTK_CONTAINER(scrolled), PREF_PAD_BORDER);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
                                       GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
@@ -173,16 +181,16 @@ GtkWidget *osd_new(gint max_cols, GtkWidget *template_view)
 
        viewport = gtk_viewport_new(nullptr, nullptr);
        gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
-       gtk_container_add(GTK_CONTAINER(scrolled), viewport);
+       gq_gtk_container_add(GTK_WIDGET(scrolled), viewport);
        gtk_widget_show(viewport);
 
-       entries = (sizeof(predefined_tags) / sizeof(predefined_tags[0])) - 1;
+       entries = ((gdouble)sizeof(predefined_tags) / sizeof(predefined_tags[0])) - 1;
        max_rows = ceil(entries / max_cols);
 
-       GtkTable *table;
-       table = GTK_TABLE(gtk_table_new(max_rows, max_cols, FALSE));
-       gtk_container_add(GTK_CONTAINER(viewport), GTK_WIDGET(table));
-       gtk_widget_show(GTK_WIDGET(table));
+       GtkGrid *grid;
+       grid = GTK_GRID(gtk_grid_new());
+       gq_gtk_container_add(GTK_WIDGET(viewport), GTK_WIDGET(grid));
+       gtk_widget_show(GTK_WIDGET(grid));
 
        for (rows = 0; rows < max_rows; rows++)
                {
@@ -190,7 +198,7 @@ GtkWidget *osd_new(gint max_cols, GtkWidget *template_view)
 
                while (cols < max_cols && predefined_tags[i][0])
                        {
-                       set_osd_button(table, rows, cols, predefined_tags[i][0], predefined_tags[i][1], template_view);
+                       set_osd_button(grid, rows, cols, predefined_tags[i][0], predefined_tags[i][1], template_view);
                        i = i + 1;
                        cols++;
                        }
@@ -236,11 +244,16 @@ static gchar *keywords_to_string(FileData *fd)
 
 gchar *image_osd_mkinfo(const gchar *str, FileData *fd, GHashTable *vars)
 {
-       gchar delim = '%', imp = '|', sep[] = " - ";
-       gchar *start, *end;
-       guint pos, prev;
+       gchar delim = '%';
+       gchar imp = '|';
+       gchar sep[] = " - ";
+       gchar *start;
+       gchar *end;
+       guint pos;
+       guint prev;
        gboolean want_separator = FALSE;
-       gchar *name, *data;
+       gchar *name;
+       gchar *data;
        GString *osd_info;
        gchar *ret;
 
@@ -313,7 +326,7 @@ gchar *image_osd_mkinfo(const gchar *str, FileData *fd, GHashTable *vars)
                        {
                        data = metadata_read_string(fd, RATING_KEY, METADATA_PLAIN);
                        }
-#ifdef HAVE_LUA
+#if HAVE_LUA
                else if (strncmp(name, "lua/", 4) == 0)
                        {
                        gchar *tmp;
@@ -360,10 +373,10 @@ gchar *image_osd_mkinfo(const gchar *str, FileData *fd, GHashTable *vars)
                                 * Examples:
                                 * "<i>*</i>\n" -> data is displayed in italics ended with a newline
                                 * "\n"         -> ended with newline
-                                * "ISO *"      -> prefix data with "ISO " (ie. "ISO 100")
+                                * 'ISO *'      -> prefix data with 'ISO ' (ie. 'ISO 100')
                                 * "\**\*"      -> prefix data with a star, and append a star (ie. "*100*")
                                 * "\\*"        -> prefix data with an anti slash (ie "\100")
-                                * "Collection <b>*</b>\n" -> display data in bold prefixed by "Collection " and a newline is appended
+                                * 'Collection <b>*</b>\n' -> display data in bold prefixed by 'Collection ' and a newline is appended
                                 */
                                /** @FIXME using background / foreground colors lead to weird results.
                                 */
@@ -459,10 +472,8 @@ void osd_template_insert(GHashTable *vars, const gchar *keyword, const gchar *va
                g_hash_table_insert(vars, const_cast<gchar *>(keyword), const_cast<gchar *>(value));
                return;
                }
-       else
-               {
-               g_hash_table_insert(vars, const_cast<gchar *>(keyword), g_strdup(value));
-               }
+
+       g_hash_table_insert(vars, const_cast<gchar *>(keyword), g_strdup(value));
 
        if (flags & OSDT_FREE) g_free(const_cast<gchar *>(value));
 }