2007-09-20 [holger] 3.0.1cvs13
authorHolger Berndt <hb@claws-mail.org>
Thu, 20 Sep 2007 08:16:39 +0000 (08:16 +0000)
committerHolger Berndt <hb@claws-mail.org>
Thu, 20 Sep 2007 08:16:39 +0000 (08:16 +0000)
* src/printing.c
Add page layout to print preview.
Make the close-button in the toolbar
right-aligned.

ChangeLog
PATCHSETS
configure.ac
src/printing.c

index 7704cbd2a82f7050081c3f389b84be6787aba1f8..ce8233f6374fc949d2a66b8bc44291339cfb8306 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-09-20 [holger]    3.0.1cvs13
+
+       * src/printing.c
+               Add page layout to print preview.
+               Make the close-button in the toolbar
+               right-aligned.
+
 2007-09-20 [paul]      3.0.1cvs12
 
        * po/ru.po
index 14310c87b65de050f784fbbd28c421d196f0773a..1ae0b3ab87a550b8a99a896e1ff91ac8ba844c0c 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/printing.c;  ) > 3.0.1cvs10.patchset
 ( cvs diff -u -r 1.36.2.112 -r 1.36.2.113 src/common/utils.c;  ) > 3.0.1cvs11.patchset
 ( cvs diff -u -r 1.17.2.16 -r 1.17.2.17 po/ru.po;  ) > 3.0.1cvs12.patchset
+( cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/printing.c;  ) > 3.0.1cvs13.patchset
index f7a102ddb84ca8581d65824bdb84ce71fc019f9a..04c8113102bfe8c2179cf5b8522d1e0714b41b87 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=12
+EXTRA_VERSION=13
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index e8c38ddb58d8129cbae2896c06dd28e00cbeff42..e86f9ccf977abe24bcf9f3fe851c7f56e7c12236 100644 (file)
@@ -47,7 +47,6 @@ typedef struct {
   gint sel_end;
   GHashTable *images;
   gint img_cnt;
-  gboolean is_preview;
 } PrintData;
 
 typedef struct {
@@ -55,8 +54,6 @@ typedef struct {
   GtkPrintOperationPreview *preview;
   GtkWidget         *area;
   PrintData         *print_data;
-  gdouble           dpi_x;
-  gdouble           dpi_y;
   GtkWidget         *page_nr_label;
   GList             *pages_to_print;
   GList             *current_page;
@@ -66,6 +63,8 @@ typedef struct {
   GtkWidget *last;
   GtkWidget *close;
   gboolean rendering;
+  gint page_width;
+  gint page_height;
 } PreviewData;
 
 /* callbacks */
@@ -98,6 +97,7 @@ static gboolean printing_is_pango_gdk_color_equal(PangoColor*, GdkColor*);
 static gint     printing_text_iter_get_offset_bytes(PrintData *, const GtkTextIter*);
 
 #define PREVIEW_SCALE 72
+#define PREVIEW_SHADOW_OFFSET 3
 
 static void free_pixbuf(gpointer key, gpointer value, gpointer data)
 {
@@ -250,7 +250,6 @@ static gboolean cb_preview(GtkPrintOperation        *operation,
   debug_print("Creating internal print preview\n");
 
   print_data = (PrintData*) data;
-  print_data->is_preview = TRUE;
 
   preview_data = g_new0(PreviewData,1);
   preview_data->print_data = print_data;
@@ -289,7 +288,7 @@ static gboolean cb_preview(GtkPrintOperation        *operation,
   preview_data->last = gtk_button_new_from_stock(GTK_STOCK_GOTO_LAST);
   gtk_box_pack_start(GTK_BOX(hbox), preview_data->last, FALSE, FALSE, 0);
   preview_data->close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
-  gtk_box_pack_start(GTK_BOX(hbox), preview_data->close, FALSE, FALSE, 0);
+  gtk_box_pack_end(GTK_BOX(hbox), preview_data->close, FALSE, FALSE, 0);
 
   /* Drawing area */
   scrolled_window = gtk_scrolled_window_new(NULL, NULL);
@@ -407,43 +406,71 @@ static void cb_preview_got_page_size(GtkPrintOperationPreview *preview,
   PreviewData *preview_data;
   GtkPageOrientation orientation;
   GtkPaperSize *paper_size;
-  gdouble preview_width;
-  gdouble preview_height;
-  gdouble paper_width;
-  gdouble paper_height;
-  cairo_t *cr;
-  gdouble dpi_x;
-  gdouble dpi_y;
+  gint paper_width;
+  gint paper_height;
 
   preview_data = (PreviewData*) data;
   debug_print("got_page_size\n");
   orientation  = gtk_page_setup_get_orientation(page_setup);
   paper_size   = gtk_page_setup_get_paper_size(page_setup);
-  paper_width  = gtk_paper_size_get_width(paper_size, GTK_UNIT_INCH);
-  paper_height = gtk_paper_size_get_height(paper_size,  GTK_UNIT_INCH);
+  paper_width  = (gint)(gtk_paper_size_get_width(paper_size, GTK_UNIT_INCH)  
+                       * PREVIEW_SCALE);
+  paper_height = (gint)(gtk_paper_size_get_height(paper_size,  GTK_UNIT_INCH)
+                       * PREVIEW_SCALE);
 
-  if((orientation == GTK_PAGE_ORIENTATION_PORTRAIT) ||
-     (orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT)) {
-    preview_width  = paper_width;
-    preview_height = paper_height;
-  }
-  else {
-    preview_width  = paper_height;
-    preview_height = paper_width;
-  }
+  preview_data->page_width  = paper_width;
+  preview_data->page_height = paper_height;
 
-  debug_print("w/h %f/%f\n", paper_width * PREVIEW_SCALE, paper_height * PREVIEW_SCALE);
+  debug_print("w/h %d/%d\n", paper_width, paper_height);
   gtk_widget_set_size_request(GTK_WIDGET(preview_data->area), 
-                 (gint) paper_width * PREVIEW_SCALE, 
-                 (gint) paper_height * PREVIEW_SCALE);
+                             paper_width, paper_height);
 }
 
 static gboolean cb_preview_expose(GtkWidget *widget, GdkEventExpose *event,
                                  gpointer data)
 {
   PreviewData *preview_data = data;
+  GdkGC *gc;
+  GdkColor white;
+  GdkColor black;
+  GdkColor gray;
+
   debug_print("preview_expose (current %p)\n", preview_data->current_page);
   gdk_window_clear(preview_data->area->window);
+
+  white.red   = 65535;
+  white.green = 65535;
+  white.blue  = 65535;
+  black.red   = 0;
+  black.green = 0;
+  black.blue  = 0;
+  gray.red   = 32700;
+  gray.green = 32700;
+  gray.blue  = 32700;
+
+  gc = gdk_gc_new(GDK_DRAWABLE(preview_data->area->window));
+
+  /* background */
+  gdk_gc_set_rgb_fg_color(gc, &gray);
+  gdk_draw_rectangle(preview_data->area->window, gc, TRUE, 0, 0,
+                    preview_data->area->allocation.width,
+                    preview_data->area->allocation.height);
+
+  /* shadow */
+  gdk_gc_set_rgb_fg_color(gc, &black);
+  gdk_draw_rectangle(preview_data->area->window, gc, TRUE,
+                    PREVIEW_SHADOW_OFFSET, PREVIEW_SHADOW_OFFSET,
+                    preview_data->page_width+PREVIEW_SHADOW_OFFSET,
+                    preview_data->page_height+PREVIEW_SHADOW_OFFSET);
+
+  /* paper */
+  gdk_gc_set_rgb_fg_color(gc, &white);
+  gdk_draw_rectangle(preview_data->area->window, gc, TRUE, 0, 0,
+                    preview_data->page_width,
+                    preview_data->page_height);
+
+  g_object_unref(gc);
+
   if(preview_data->current_page) {
     preview_data->rendering = TRUE;
     gtk_widget_set_sensitive(preview_data->close, FALSE);
@@ -689,10 +716,6 @@ static void cb_draw_page(GtkPrintOperation *op, GtkPrintContext *context,
     end = GPOINTER_TO_INT(pagebreak->data);
 
   cr = gtk_print_context_get_cairo_context(context);
-  if (print_data->is_preview) {
-    cairo_set_source_rgb(cr, 1., 1., 1.);
-    cairo_paint(cr);
-  }
   cairo_set_source_rgb(cr, 0., 0., 0.);
 
   ii = 0;