🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: netscape.public.mozilla.gtk
Article #1

Gtk Print Probleem

#1
From: ldries46
Date: Fri, 23 Nov 2018 10:01
91 lines
4114 bytes
I have a problem with printing from Gtk.

The print is working correctly if I print a document which results in 19
pages. But with one page with 48 lines of text I just get an empty page and
I just don't get the print dialog. Herewith I give you the part of  the
program where it goes wrong.:

In the On_Print procedure:

      last_line := integer(nr) - 1;
      Print_Op := new Gtkada_Print_Operation_Record;
      Gtkada.Printing.Initialize (Print_Op);
      Gtk_New(Print_Set);
      Set_Current_Page (Print_Op, 1);
      Number := long_float(last_line) / long_float(delta_lines);
      Number := long_float'Rounding(Number + 0.4999999);
      nr_Pages := Gint(Number);
      Set_N_Pages (Print_Op, nr_Pages);
      Set_Use_Full_Page(Print_Op, true);
      Set_Unit (Print_Op, points);
      Print_Op.Set_Print_Settings(Print_Set);
--------------------------------------------------------------------
--   procedure On_Draw_Page
--      (Self  : not null access Gtk_Print_Operation_Record;
--       Call  : Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void;
--       After : Boolean := False);
--------------------------------------------------------------------
      On_Draw_Page(Print_Op, Draw);
      Result := Connect_and_Run(Print_Op ,Action_Print_Dialog, Main_Window);

Draw is declared as

Draw      : Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void
            := Draw_Page'Access;


and  the Draw_Page procedure

   procedure Draw_Page
     (Op          : access Gtk_Print_Operation_Record'Class;
      Context     : not null access Gtk_Print_Context_Record'Class;
      Page_Number : Gint) is
      Cr    : Cairo_Context;
      nr    : integer;
      width : integer;
      rb    : boolean;
--      re    : boolean;
      ok    : boolean;
      str   : Unbounded_String;
   begin
      nr := first_line;
      Cr := Get_Cairo_Context (Context);
      Set_Source_Rgb (Cr, 0.0, 0.0, 0.0);
      Select_font_face(Cr, "Monospace", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
      Set_Font_Size(Cr, GDouble(9));
      if nr = 1 then
         pagenr := 1;
      else
         pagenr := pagenr + 1;
      end if;
      if pagenr rem 2 = 1 then
         width := 70;
      else
         width := 40;
      end if;
      if last_page_line > last_line then
         last_page_line := last_line;
      end if;
      ok := false;
      while not ok loop
         Get_Iter_At_Line(Main_Window.Draw_Buffer, first, Gint(nr));
         Get_Iter_At_Line_Offset(Main_Window.Draw_Buffer, endln, Gint(nr),
500);
         move_to(cr, Gdouble(width), Gdouble((nr - first_line + 1) * 13 +
65));
         str :=
To_Unbounded_String(Get_Text(Main_Window.Draw_Buffer,first,endln));
         show_text(cr, To_String(str));
         nr := nr + 1;
         ok := nr >= last_page_line;
         if nr <= last_line then
            Forward_Line(first, rb);
         end if;
      end loop;
      first_line := nr - 1;
      last_page_line := last_page_line + delta_lines;
   end Draw_Page; 


Technical Details
Message-ID: <5bf7cfff$0$25672$e4fe514c@news.kpn.nl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-netscape.public.mozilla.gtk.(239).mbox.7z!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <5bf7cfff$0$25672$e4fe514c@news.kpn.nl>
Subject: Gtk Print Probleem
Date: Fri, 23 Nov 2018 11:01:33 +0100
From: "ldries46" <bertus.dries@planet.nl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-netscape.public.mozilla.gtk.(239).mbox.7z!not-for-mail
Newsgroups: netscape.public.mozilla.gtk
MIME-Version: 1.0
Content-Type: text/plain;
 format=flowed;
 charset="iso-8859-1";
 reply-type=original
Content-Transfer-Encoding: 7bit
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
Lines: 89
NNTP-Posting-Host: 8c7db140.news.kpn.nl
X-Trace: G=eEDnGMLg,C=U2FsdGVkX19itIcNMGHy9y2jVKPBC3Y0R7wCizz/hB7dkFSTlLnZ7S5TXeeqAhrPOj64ZBJZ9oKbH7+q309G1kbw7ciG4rLSXJNrspTDtAQ=
X-Complaints-To: abuse@kpn.nl
X-Received-Bytes: 4116
X-Received-Body-CRC: 342430198