From da87d460089ca625be22148e3edf0b49ebd91bd1 Mon Sep 17 00:00:00 2001
From: Eero Nurkkala <eenurkka@server88-208-244-8.live-servers.net>
Date: Fri, 7 Sep 2012 12:15:13 +0100
Subject: [PATCH 1/2] immediatenet.com changes

Signed-off-by: Eero Nurkkala <eenurkka@server88-208-244-8.live-servers.net>
---
 src/gnome-web-photo.c |   31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/gnome-web-photo.c b/src/gnome-web-photo.c
index 6425c64..ed07249 100644
--- a/src/gnome-web-photo.c
+++ b/src/gnome-web-photo.c
@@ -65,6 +65,7 @@
 #define MIN_WIDTH       64
 #define MAX_WIDTH       2048
 #define DEFAULT_WIDTH   1024
+#define DEFAULT_HEIGHT	768
 
 #define DEFAULT_THUMBNAIL_SIZE  256
 
@@ -98,6 +99,7 @@ typedef struct {
 
   char          *user_css;
   int            width;
+  int		 height;
   int            thumbnail_size;
   gboolean       print_background;
   gboolean       disable_plugins;
@@ -257,6 +259,7 @@ _prepare_web_settings (WebKitWebSettings *settings,
   g_object_set (G_OBJECT (settings),
                 /* printing settings */
                 "print-backgrounds", print_background,
+		"user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.22+ (KHTML, like Gecko) Chromium/17.0.963.56 Chrome/17.0.963.56 Safari/535.22+; (+http://immediatenet.com/thumbnail_api.html; free thumbnails)",
                 /* enable/disable plugins */
                 "enable-plugins", !disable_plugins,
                 /* don't save anything from this to the global history */
@@ -361,11 +364,23 @@ static void
 _write_photo (PhotoData *data)
 {
 #ifdef HAVE_GNOME3
-  cairo_surface_t *surface;
+  cairo_surface_t *surface, *t_s;
   cairo_status_t   status;
+  cairo_t *cr;
 
   surface = gtk_offscreen_window_get_surface (GTK_OFFSCREEN_WINDOW (data->window));
-  status = cairo_surface_write_to_png (surface, data->outfile);
+  if (data->width > 1280)
+	data->width = 1280;
+  if (data->height > 1280)
+	data->height = 1280;
+  t_s = cairo_surface_create_similar(surface, CAIRO_CONTENT_COLOR, data->width, data->height);
+
+  cr = cairo_create (t_s);
+  cairo_set_source_surface (cr, surface, 0, 0);
+  cairo_paint (cr);
+  cairo_destroy (cr);
+
+  status = cairo_surface_write_to_png (t_s, data->outfile);
 
   switch (status) {
     case CAIRO_STATUS_SUCCESS:
@@ -740,7 +755,7 @@ _create_web_window (PhotoData *data)
    * need the whole page), nor for MODE_PRINT (the print operation is not
    * related to what is displayed). So it only affects MODE_PHOTO. But it's
    * better than not getting anything anyway. */
-  gtk_widget_set_size_request (window, data->width, -1);
+  gtk_widget_set_size_request (window, data->width, data->height);
 
   if (data->mode != MODE_DEBUG) {
     /* For thumbnails, there is no point in having a height larger than the
@@ -902,7 +917,7 @@ main (int    argc,
                      MODE_INVALID,
                      /* thumbnail_size set to -1 to be able to check if option
                       * was passed or not */
-                     NULL, DEFAULT_WIDTH, -1, FALSE, FALSE, NULL,
+                     NULL, DEFAULT_WIDTH, DEFAULT_HEIGHT, -1, FALSE, TRUE, NULL,
                      0, 60, FALSE,
                      FALSE,
                      NULL, NULL, 0, 0, 0 };
@@ -929,6 +944,10 @@ main (int    argc,
       N_("Desired width of the web page (default: 1024)"),
       /* Translators: W will appear in the help, as in: --width=W */
       N_("W") },
+    { "height", 'h', 0, G_OPTION_ARG_INT, &data.height,
+      N_("Desired width of the web page (default: 768)"),
+      /* Translators: W will appear in the help, as in: --width=W */
+      N_("H") },
     { "thumbnail-size", 's', 0, G_OPTION_ARG_INT, &data.thumbnail_size,
       N_("Thumbnail size (default: 256)"),
       /* Translators: S will appear in the help, as in: --thumbnail-size=S */
@@ -991,9 +1010,9 @@ main (int    argc,
 
   /* Renice when thumbnailing, since it is likely that we are called multiple
    * times in sequence in order to thumbnail a bunch of HTML files. */
-  if (data.mode == MODE_THUMBNAIL) {
+ // if (data.mode == MODE_THUMBNAIL) {
     nice (5);
-  }
+ // }
 
   /* Check user css */
   if (user_css_path) {
-- 
1.7.9.5

