changeset 1305:2abdd6e50120

Glibification.
author zas_
date Sat, 21 Feb 2009 18:04:52 +0000
parents edeb07e1da5d
children c59358ba7ad1
files src/bar_keywords.c src/debug.c src/exif.c src/lirc.c src/pan-calendar.c src/print.c src/secure_save.c
diffstat 7 files changed, 75 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar_keywords.c	Sat Feb 21 10:53:18 2009 +0000
+++ b/src/bar_keywords.c	Sat Feb 21 18:04:52 2009 +0000
@@ -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 @@
 		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 @@
 	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)
--- a/src/debug.c	Sat Feb 21 10:53:18 2009 +0000
+++ b/src/debug.c	Sat Feb 21 18:04:52 2009 +0000
@@ -15,6 +15,9 @@
 #include "logwindow.h"
 #include "ui_fileops.h"
 
+#include <glib/gprintf.h>
+
+
 /*
  * Logging functions
  */
@@ -26,7 +29,7 @@
 	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);
--- a/src/exif.c	Sat Feb 21 10:53:18 2009 +0000
+++ b/src/exif.c	Sat Feb 21 18:04:52 2009 +0000
@@ -67,6 +67,7 @@
 #include <math.h>
 
 #include <glib.h>
+#include <glib/gprintf.h>
 
 #include "intl.h"
 
@@ -1534,7 +1535,7 @@
 	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 @@
 {
 	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 @@
 			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 @@
 			exif_write_item(f, item);
 			}
 		}
-	fprintf(f, "----------------------------------------------------\n");
+	g_fprintf(f, "----------------------------------------------------\n");
 }
 
 gboolean exif_write(ExifData *exif)
--- a/src/lirc.c	Sat Feb 21 10:53:18 2009 +0000
+++ b/src/lirc.c	Sat Feb 21 18:04:52 2009 +0000
@@ -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 @@
 	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 @@
 	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"));
--- a/src/pan-calendar.c	Sat Feb 21 10:53:18 2009 +0000
+++ b/src/pan-calendar.c	Sat Feb 21 18:04:52 2009 +0000
@@ -14,7 +14,7 @@
 #include "main.h"
 #include "pan-types.h"
 
-
+#include <glib/gprintf.h>
 #include <math.h>
 
 
--- a/src/print.c	Sat Feb 21 10:53:18 2009 +0000
+++ b/src/print.c	Sat Feb 21 18:04:52 2009 +0000
@@ -10,7 +10,6 @@
  * This software comes with no warranty of any kind, use at your own risk!
  */
 
-
 #include "main.h"
 #include "print.h"
 
@@ -28,10 +27,9 @@
 #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 @@
 	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 @@
 
 	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 @@
 
 	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 @@
 		}
 	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 @@
 
 	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 @@
 			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 @@
 
 	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 @@
 		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 @@
 
 	if (!text) return;
 
-	fprintf(f, "newpath\n");
+	g_fprintf(f, "newpath\n");
 
 	p = text;
 	while (p && *p != '\0')
@@ -1385,7 +1383,7 @@
 		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 @@
 
 	pe = pipe_handler_new();
 
-	fprintf(f, "/Sans findfont\n");
-	fprintf(f, "%f scalefont\n", point_size);
-	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, "/Sans findfont\n");
+	g_fprintf(f, "%f scalefont\n", point_size);
+	g_fprintf(f, "setfont\n");
+
+	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 @@
 
 	pe = pipe_handler_new();
 
-	fprintf(f, "%%%%EOF\n");
+	g_fprintf(f, "%%%%EOF\n");
 
 	ret = !pipe_handler_check(pe);
 	pipe_handler_free(pe);
--- a/src/secure_save.c	Sat Feb 21 10:53:18 2009 +0000
+++ b/src/secure_save.c	Sat Feb 21 18:04:52 2009 +0000
@@ -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 @@
 	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;