Glibification.
authorLaurent Monin <geeqie@norz.org>
Sat, 21 Feb 2009 18:04:52 +0000 (18:04 +0000)
committerLaurent Monin <geeqie@norz.org>
Sat, 21 Feb 2009 18:04:52 +0000 (18:04 +0000)
src/bar_keywords.c
src/debug.c
src/exif.c
src/lirc.c
src/pan-calendar.c
src/print.c
src/secure_save.c

index 0b9f203..336c322 100644 (file)
@@ -10,6 +10,7 @@
  * This software comes with no warranty of any kind, use at your own risk!
  */
 
+#include <glib/gprintf.h>
 
 #include "main.h"
 #include "bar_keywords.h"
@@ -378,7 +379,7 @@ static gchar *bar_pane_keywords_get_mark_text(const gchar *key)
                file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &data);
                if (get_mark_func == meta_data_get_keyword_mark && strcmp(data, key) == 0) 
                        {
-                       sprintf(buf, " %d ", i + 1);
+                       g_sprintf(buf, " %d ", i + 1);
                        return buf;
                        }
                }
@@ -693,17 +694,17 @@ static GtkTreeModel *create_marks_list(void)
        gint i;
 
        /* create list store */
-       model = gtk_list_store_new (1, G_TYPE_STRING);
+       model = gtk_list_store_new(1, G_TYPE_STRING);
        for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
                {
-               char str[10];
-               sprintf(str, " %d ", i + 1);
+               gchar str[10];
+               g_sprintf(str, " %d ", i + 1);
                gtk_list_store_append (model, &iter);
                gtk_list_store_set(model, &iter, 0, str, -1);
                }
        gtk_list_store_append (model, &iter);
        gtk_list_store_set(model, &iter, 0, " ... ", -1);
-       return GTK_TREE_MODEL (model);
+       return GTK_TREE_MODEL(model);
 }
 
 GtkWidget *bar_pane_keywords_new(const gchar *title, const gchar *key)
index 96d732b..f7750ec 100644 (file)
@@ -15,6 +15,9 @@
 #include "logwindow.h"
 #include "ui_fileops.h"
 
+#include <glib/gprintf.h>
+
+
 /*
  * Logging functions
  */
@@ -26,7 +29,7 @@ gint log_domain_printf(const gchar *domain, const gchar *format, ...)
        gint ret;
 
        va_start(ap, format);
-       ret = vsnprintf(buf, sizeof(buf), format, ap);
+       ret = g_vsnprintf(buf, sizeof(buf), format, ap);
        va_end(ap);
 
        print_term(buf);
index 459257d..2dc8b65 100644 (file)
@@ -67,6 +67,7 @@
 #include <math.h>
 
 #include <glib.h>
+#include <glib/gprintf.h>
 
 #include "intl.h"
 
@@ -1534,7 +1535,7 @@ static void exif_write_item(FILE *f, ExifItem *item)
        if (text)
                {
                gchar *tag = exif_item_get_tag_name(item);
-               fprintf(f, "%4x %9s %30s %s\n", item->tag, ExifFormatList[item->format].short_name,
+               g_fprintf(f, "%4x %9s %30s %s\n", item->tag, ExifFormatList[item->format].short_name,
                        tag, text);
                g_free(tag);
                }
@@ -1545,8 +1546,8 @@ void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list)
 {
        if (!f || !exif) return;
 
-       fprintf(f, " tag   format                             key value\n");
-       fprintf(f, "----------------------------------------------------\n");
+       g_fprintf(f, " tag   format                             key value\n");
+       g_fprintf(f, "----------------------------------------------------\n");
 
        if (human_readable_list)
                {
@@ -1560,7 +1561,7 @@ void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list)
                        text = exif_get_formatted_by_key(exif, ExifFormattedList[i].key, NULL);
                        if (text)
                                {
-                               fprintf(f, "     %9s %30s %s\n", "string", ExifFormattedList[i].key, text);
+                               g_fprintf(f, "     %9s %30s %s\n", "string", ExifFormattedList[i].key, text);
                                }
                        i++;
                        }
@@ -1580,7 +1581,7 @@ void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list)
                        exif_write_item(f, item);
                        }
                }
-       fprintf(f, "----------------------------------------------------\n");
+       g_fprintf(f, "----------------------------------------------------\n");
 }
 
 gboolean exif_write(ExifData *exif)
index c5174c9..2f15ec1 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Geeqie
+ * Copyright (C) 2008 - 2009 The Geeqie Team
+ *
+ */
+
+#include <glib/gprintf.h>
+
 #include "lirc.h"
 
 #include "misc.h"
@@ -182,7 +190,7 @@ static gboolean lirc_input_callback(GIOChannel *source, GIOCondition condition,
        if (ret == -1)
                {
                /* something went badly wrong */
-               fprintf(stderr, _("disconnected from LIRC\n"));
+               g_fprintf(stderr, _("disconnected from LIRC\n"));
                lirc_cleanup();
                return (gboolean)FALSE;
                }
@@ -197,13 +205,13 @@ void layout_image_lirc_init(LayoutWindow *lw)
        lirc_fd = lirc_init(GQ_APPNAME_LC, get_debug_level() > 0);
        if (lirc_fd == -1)
                {
-               fprintf(stderr, _("Could not init LIRC support\n"));
+               g_fprintf(stderr, _("Could not init LIRC support\n"));
                return;
                }
        if (lirc_readconfig(NULL, &config, NULL) == -1)
                {
                lirc_deinit();
-               fprintf(stderr,
+               g_fprintf(stderr,
                        _("could not read LIRC config file\n"
                        "please read the documentation of LIRC to \n"
                        "know how to create a proper config file\n"));
index b4a71d4..842b622 100644 (file)
@@ -14,7 +14,7 @@
 #include "main.h"
 #include "pan-types.h"
 
-
+#include <glib/gprintf.h>
 #include <math.h>
 
 
index 11d2db8..ab8ac7e 100644 (file)
@@ -10,7 +10,6 @@
  * This software comes with no warranty of any kind, use at your own risk!
  */
 
-
 #include "main.h"
 #include "print.h"
 
 #include "ui_spinner.h"
 #include "ui_tabcomp.h"
 
-
 #include <locale.h>
 #include <signal.h>
-
+#include <glib/gprintf.h>
 
 #define PRINT_LPR_COMMAND "lpr"
 #define PRINT_LPR_CUSTOM  "lpr -P %s"
@@ -1108,29 +1106,29 @@ static gint print_job_ps_init(PrintWindow *pw)
        pe = pipe_handler_new();
 
        /* comments, etc. */
-       fprintf(f, "%%!PS-Adobe-3.0\n");
-       fprintf(f, "%%%%Creator: %s Version %s\n", GQ_APPNAME, VERSION);
-       fprintf(f, "%%%%CreationDate: \n");
-       fprintf(f, "%%%%LanguageLevel 2\n");
-       fprintf(f, "%%%%DocumentMedia: \n");
-       fprintf(f, "%%%%Orientation: %s\n",
+       g_fprintf(f, "%%!PS-Adobe-3.0\n");
+       g_fprintf(f, "%%%%Creator: %s Version %s\n", GQ_APPNAME, VERSION);
+       g_fprintf(f, "%%%%CreationDate: \n");
+       g_fprintf(f, "%%%%LanguageLevel 2\n");
+       g_fprintf(f, "%%%%DocumentMedia: \n");
+       g_fprintf(f, "%%%%Orientation: %s\n",
                (pw->paper_orientation == PAPER_ORIENTATION_PORTRAIT) ? "Portrait" : "Landscape");
-       fprintf(f, "%%%%BoundingBox: %f %f %f %f\n",
+       g_fprintf(f, "%%%%BoundingBox: %f %f %f %f\n",
                0.0, 0.0, pw->paper_width, pw->paper_height);
-       fprintf(f, "%%%%Pages: %d\n", print_layout_page_count(pw));
-       fprintf(f, "%%%%PageOrder: Ascend\n");
-       fprintf(f, "%%%%Title:\n");
+       g_fprintf(f, "%%%%Pages: %d\n", print_layout_page_count(pw));
+       g_fprintf(f, "%%%%PageOrder: Ascend\n");
+       g_fprintf(f, "%%%%Title:\n");
 
        /* setup page size, coordinates (do we really need this?) */
 #if 0
-       fprintf(f, "<<\n");
-       fprintf(f, "/PageSize [%f %f]\n", pw->layout_width, pw->layout_height);
-       fprintf(f, "/ImagingBBox [%f %f %f %f]\n", /* l b r t */
+       g_fprintf(f, "<<\n");
+       g_fprintf(f, "/PageSize [%f %f]\n", pw->layout_width, pw->layout_height);
+       g_fprintf(f, "/ImagingBBox [%f %f %f %f]\n", /* l b r t */
                pw->margin_left, pw->margin_bottom,
                pw->layout_width - pw->margin_right, pw->layout_height - pw->margin_top);
-       fprintf(f, "/Orientation %d\n",
+       g_fprintf(f, "/Orientation %d\n",
                (pw->paper_orientation == PAPER_ORIENTATION_PORTRAIT) ? 0 : 1);
-       fprintf(f, ">> setpagedevice\n");
+       g_fprintf(f, ">> setpagedevice\n");
 #endif
 
        ret = !pipe_handler_check(pe);
@@ -1162,12 +1160,12 @@ static gint print_job_ps_page_new(PrintWindow *pw, gint page)
 
        pe = pipe_handler_new();
 
-       fprintf(f, "%%%% page %d\n", page + 1);
+       g_fprintf(f, "%%%% page %d\n", page + 1);
 
        if (pw->paper_orientation == PAPER_ORIENTATION_LANDSCAPE)
                {
-               fprintf(f, "/pagelevel save def\n");
-               fprintf(f, "%d 0 translate 90 rotate\n", (gint)pw->layout_height);
+               g_fprintf(f, "/pagelevel save def\n");
+               g_fprintf(f, "%d 0 translate 90 rotate\n", (gint)pw->layout_height);
                }
 
        ret = !pipe_handler_check(pe);
@@ -1201,10 +1199,10 @@ static gint print_job_ps_page_done(PrintWindow *pw)
 
        if (pw->paper_orientation == PAPER_ORIENTATION_LANDSCAPE)
                {
-               fprintf(f, "pagelevel restore\n");
+               g_fprintf(f, "pagelevel restore\n");
                }
 
-       fprintf(f, "showpage\n");
+       g_fprintf(f, "showpage\n");
 
        ret = !pipe_handler_check(pe);
        pipe_handler_free(pe);
@@ -1233,7 +1231,7 @@ static void print_job_ps_page_image_pixel(FILE *f, guchar *pix)
                }
        text[6] = '\0';
 
-       fprintf(f, "%s", text);
+       g_fprintf(f, "%s", text);
 }
 static gint print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
                                    gdouble x, gdouble y, gdouble w, gdouble h,
@@ -1284,13 +1282,13 @@ static gint print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
 
        pe = pipe_handler_new();
 
-       fprintf(f, "gsave\n");
-       fprintf(f, "[%f 0 0 %f %f %f] concat\n", w, h, x, pw->layout_height - h - y);
-       fprintf(f, "/buf %d string def\n", sw * 3);
-       fprintf(f, "%d %d %d\n", sw, sh, 8);
-       fprintf(f, "[%d 0 0 -%d 0 %d]\n", sw, sh, sh);
-       fprintf(f, "{ currentfile buf readhexstring pop }\n");
-       fprintf(f, "false %d colorimage\n", 3);
+       g_fprintf(f, "gsave\n");
+       g_fprintf(f, "[%f 0 0 %f %f %f] concat\n", w, h, x, pw->layout_height - h - y);
+       g_fprintf(f, "/buf %d string def\n", sw * 3);
+       g_fprintf(f, "%d %d %d\n", sw, sh, 8);
+       g_fprintf(f, "[%d 0 0 -%d 0 %d]\n", sw, sh, sh);
+       g_fprintf(f, "{ currentfile buf readhexstring pop }\n");
+       g_fprintf(f, "false %d colorimage\n", 3);
 
        c = 0;
        for (j = 0; j < sh; j++)
@@ -1313,13 +1311,13 @@ static gint print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
                        c++;
                        if (c > 11)
                                {
-                               fprintf(f, "\n");
+                               g_fprintf(f, "\n");
                                c = 0;
                                }
                        }
                }
-       if (c > 0) fprintf(f, "\n");
-       fprintf(f, "grestore\n");
+       if (c > 0) g_fprintf(f, "\n");
+       g_fprintf(f, "grestore\n");
 
        ret = !pipe_handler_check(pe);
        pipe_handler_free(pe);
@@ -1344,8 +1342,8 @@ static const gchar *ps_text_to_hex_array(FILE *f, const gchar *text, gdouble x,
 
        if (!text) return NULL;
 
-       fprintf(f, "%f %f moveto\n", x, y);
-       fprintf(f, "<");
+       g_fprintf(f, "%f %f moveto\n", x, y);
+       g_fprintf(f, "<");
 
        /* fixme: convert utf8 to ascii or proper locale string.. */
 
@@ -1358,13 +1356,13 @@ static const gchar *ps_text_to_hex_array(FILE *f, const gchar *text, gdouble x,
                text[1] = hex_digits[*p & 0xf];
                text[2] = '\0';
 
-               fprintf(f, "%s", text);
+               g_fprintf(f, "%s", text);
 
                p++;
                }
 
-       fprintf(f, ">\n");
-       fprintf(f, "dup stringwidth pop 2 div neg 0 rmoveto show\n");
+       g_fprintf(f, ">\n");
+       g_fprintf(f, "dup stringwidth pop 2 div neg 0 rmoveto show\n");
 
        return p;
 }
@@ -1375,7 +1373,7 @@ static void ps_text_parse(FILE *f, const gchar *text, gdouble x, gdouble y, gdou
 
        if (!text) return;
 
-       fprintf(f, "newpath\n");
+       g_fprintf(f, "newpath\n");
 
        p = text;
        while (p && *p != '\0')
@@ -1385,7 +1383,7 @@ static void ps_text_parse(FILE *f, const gchar *text, gdouble x, gdouble y, gdou
                y -= point_size;
                }
 
-       fprintf(f, "closepath\n");
+       g_fprintf(f, "closepath\n");
 }
 
 static gint print_job_ps_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
@@ -1407,11 +1405,11 @@ static gint print_job_ps_page_text(PrintWindow *pw, const gchar *text, gdouble p
 
        pe = pipe_handler_new();
 
-       fprintf(f, "/Sans findfont\n");
-       fprintf(f, "%f scalefont\n", point_size);
-       fprintf(f, "setfont\n");
+       g_fprintf(f, "/Sans findfont\n");
+       g_fprintf(f, "%f scalefont\n", point_size);
+       g_fprintf(f, "setfont\n");
 
-       fprintf(f, "%f %f %f setrgbcolor\n", (gdouble)r / 255.0, (gdouble)g / 255.0, (gdouble)b / 255.0);
+       g_fprintf(f, "%f %f %f setrgbcolor\n", (gdouble)r / 255.0, (gdouble)g / 255.0, (gdouble)b / 255.0);
        ps_text_parse(f, text, x, pw->layout_height - y - point_size, point_size);
 
        ret = !pipe_handler_check(pe);
@@ -1443,7 +1441,7 @@ static gint print_job_ps_end(PrintWindow *pw)
 
        pe = pipe_handler_new();
 
-       fprintf(f, "%%%%EOF\n");
+       g_fprintf(f, "%%%%EOF\n");
 
        ret = !pipe_handler_check(pe);
        pipe_handler_free(pe);
index 41a4fea..687e8b9 100644 (file)
@@ -9,6 +9,7 @@
  * This software comes with no warranty of any kind, use at your own risk!
  */
 
+#include <glib/gprintf.h>
 #include <glib/gstdio.h>
 #include <errno.h>
 #include <utime.h>
@@ -362,8 +363,7 @@ secure_fprintf(SecureSaveInfo *ssi, const gchar *format, ...)
        if (!ssi || !ssi->fp || ssi->err) return -1;
 
        va_start(ap, format);
-       ret = vfprintf(ssi->fp, format, ap);
-       if (ret < 0) ssi->err = errno;
+       ret = g_vfprintf(ssi->fp, format, ap);
        va_end(ap);
 
        return ret;