Fedora Linux Support Community & Resources Center
  #1  
Old 23rd May 2012, 11:49 AM
nicobi Offline
Registered User
 
Join Date: May 2012
Location: chatellerault
Posts: 3
linuxchrome
screenshot of a webkit webview for a gnome shell extension

Hello,

I'm currently trying to write a gnome shell extension. I would like to get the screenshot of a web page as a png file. To serve this purpose, I tried to get the Gdk.Pixbuf of the WebView window, in order to call savev... (the widget in the following code excerpt is indeed a WebKit.WebView):

const Gdk = imports.gi.Gdk;
const Gtk = imports.gi.Gtk;
const WebKit = imports.gi.WebKit;
...

function save_as_png(widget)
{
let allocation = widget.get_allocation();
let wdw = widget.get_parent_window();

global.log(wdw); // (1)
global.log(allocation.width); // (2)
global.log(allocation.height); // (3)

let pixbuf = Gdk.pixpuf_get_from_window(wdw,0,0,allocation.widt h,allocat ion.height);

global.log(pixbuf); // (4)
}

when calling my extension, the logs (1),(2) and (3) are displayed on the gjs error console, but the (4) is never called. So I suspect that something has gone wrong...

how should I do in order to get the pixbuf right ?

In profond despear, I tried an alternative solution, by creating a cairo surface and context for my web view, hoping somehow that I would be able to call a write_to_png method from the surface. I did not succeed, in case someone would be pretty fit in on the subject, I write a buggy excerpt of what I tried :

let allocation = widget.get_allocation();
let wdw = widget.get_parent_window();
let surface = Cairo.image_surface_create(0,allocation.width,allo cation.height);
let crt = Gdk.cairo_create(wdw);

and then :
surface.write_to_png("/home/bluebird/tst.png");
or :
let pixbuf = Gdk.pixbuf_get_from_surface(surface,0,0,allocation .width,allocation.height);

This did not lead to the hoped success, and subsequents logs were not shown.

Any way, if anyone has any lead on the subject, this will be greatly appreciated.

Thanks for reading..

Nicolas

Last edited by nicobi; 23rd May 2012 at 06:06 PM. Reason: unclear
Reply With Quote
Reply

Tags
extension, gnome, screenshot, shell, webkit, webview

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gnome Shell Extension noim, doesn't work RCVwho Using Fedora 4 4th February 2012 08:06 PM
Problem with gnome-shell extension alternative status menu wu_qso Using Fedora 2 25th November 2011 01:25 PM
Gnome Shell Extension systemMonitor kaiserkarl13 Using Fedora 4 22nd November 2011 05:41 PM
new gnome shell extension: search open windows by title line72 Fedora Spins & Remixes 1 4th August 2011 05:28 PM
My synclient gnome-shell extension for laptop soleilpqd Fedora Spins & Remixes 0 30th June 2011 08:58 AM


Current GMT-time: 12:07 (Wednesday, 22-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat