[gnome-love]ghex patch
- From: Chema Celorio <chema ximian com>
- To: jaka gnu org
- Cc: gnome-love gnome org
- Subject: [gnome-love]ghex patch
- Date: Fri, 13 Apr 2001 10:38:24 -0400
Hello jaka,
here is a patch from Alex Espinoza that verifies that the
fonts needed for printing are available.
thanks,
Chema
[I have another patch for priting in the pipeline, but we
need to get this one in first cause they are conflicting]
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/ghex/ChangeLog,v
retrieving revision 1.131
diff -u -5 -r1.131 ChangeLog
--- ChangeLog 2001/04/12 20:34:05 1.131
+++ ChangeLog 2001/04/13 15:33:55
@@ -1,5 +1,10 @@
+2001-04-01 AleX Espinoza <cured yahoo com>
+
+ * src/print.c (print_verify_fonts): Added to verify that the fonts
+ are available for printing.
+
2001-04-12 Chema Celorio <chema celorio com>
* src/converter.c (set_values): remove leading 0's
from the entries
(clean): implement.
Index: src/print.c
===================================================================
RCS file: /cvs/gnome/ghex/src/print.c,v
retrieving revision 1.12
diff -u -5 -r1.12 print.c
--- src/print.c 2001/03/18 18:44:14 1.12
+++ src/print.c 2001/04/13 15:33:57
@@ -22,11 +22,10 @@
Printing module by: Chema Celorio <chema celorio com>
*/
#include "ghex.h"
#include "gtkhex.h"
-
#include <libgnomeprint/gnome-print-master-preview.h>
#define is_printable(c) (((((guchar)c)>=0x20) && (((guchar)c)<=0x7F))?1:0)
const GnomePaper *def_paper;
@@ -42,37 +41,50 @@
static void end_job(GnomePrintContext *pc);
static void format_hex(HexDocument *doc, guint gt, gchar *out, guint start, guint end);
static void format_ascii(HexDocument *doc, gchar *out, guint start, guint end);
static void print_shaded_boxes( GHexPrintJobInfo *pji, guint page, guint max_row);
static void print_shaded_box( GHexPrintJobInfo *pji, guint row, guint rows);
+static gboolean print_verify_fonts (void);
static void preview_destroy_cb(GtkObject *obj, GHexPrintJobInfo *job)
{
gtk_object_unref(GTK_OBJECT(job->master));
g_free(job);
}
+/**
+ * print_document:
+ *
+ * The main printing function.
+ **/
void print_document(HexDocument *doc, guint gt, GnomePrinter *printer)
{
gint i, j;
GHexPrintJobInfo *pji;
GnomeFont *d_font, *h_font;
guint32 glyph;
ArtPoint point;
+ /* -- Added to verify fonts (Extract from Gedit) --*/
+ if (!print_verify_fonts ())
+ return;
+
d_font = gnome_font_new(data_font_name, data_font_size);
if(!d_font)
return;
+
h_font = gnome_font_new(header_font_name, header_font_size);
- if(!h_font) {
+ if(!h_font){
gtk_object_unref(GTK_OBJECT(d_font));
return;
}
-
+
+ /* Create Printing Job */
pji = g_new0(GHexPrintJobInfo, 1);
pji->h_font = h_font;
pji->d_font = d_font;
+
pji->gt = gt;
pji->master = gnome_print_master_new();
gnome_print_master_set_paper(pji->master, def_paper);
if(printer) {
@@ -327,10 +339,53 @@
gnome_print_lineto(pji->pc, box_right, box_top);
gnome_print_closepath(pji->pc);
gnome_print_fill(pji->pc);
gnome_print_setrgbcolor(pji->pc, 0.0, 0.0, 0.0);
}
-
+/**
+ * -- Taken from GEdit print-util: gedit_print_verify_fonts --
+ * ghex_print_verify_fonts:
+ * @void:
+ *
+ * verify that the fonts that we are going to use are available
+ *
+ * Return Value:
+ **/
+gboolean print_verify_fonts (void)
+{
+ GnomeFont *test_font;
+ guchar * test_font_name;
+
+ test_font_name = g_strdup (data_font_name);
+ test_font = gnome_font_new (test_font_name, 10);
+ if (test_font==NULL)
+ {
+ gchar *errstr = g_strdup_printf (_("ghex could not find the font \"%s\".\n"
+ "ghex is unable to print without this font
installed."),
+ test_font_name);
+ gnome_app_error (mdi->active_window, errstr);
+ g_free (errstr);
+ return FALSE;
+ }
+ gnome_font_unref (test_font);
+ g_free (test_font_name);
+
+ test_font_name = g_strdup (header_font_name);
+ test_font = gnome_font_new (test_font_name, 10);
+ if (test_font==NULL)
+ {
+ gchar *errstr = g_strdup_printf (_("ghex could not find the font \"%s\".\n"
+ "ghex is unable to print without this font
installed."),
+ test_font_name);
+ gnome_app_error (mdi->active_window, errstr);
+ g_free (errstr);
+ return FALSE;
+ }
+ gnome_font_unref (test_font);
+ g_free (test_font_name);
+
+ return TRUE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]