gtk_webkit_pdf 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README ADDED
@@ -0,0 +1,11 @@
1
+ Creating The PDF from HTML using GTK WEBKIT Tool.
2
+
3
+ EXAMPLE:
4
+
5
+ webkit = GTK::Webkit.new("http://www.gtk.org", "gtk.pdf") #creates the webkit object
6
+ webkit.convert_to_pdf #creates the pdf specified in the initialization parameter(in our case gtk.pdf) in current directory
7
+
8
+
9
+
10
+
11
+ This is the first version of the gem, we will update the readme as well the gem features ASAP.
@@ -0,0 +1,6 @@
1
+ require 'mkmf'
2
+
3
+ $CFLAGS << " -I /usr/include/gtk-2.0/ -I /usr/include/glib-2.0/ -Wall -Werror -fpic -I /usr/lib/i386-linux-gnu/glib-2.0/include/ -I /usr/include/cairo/ -I /usr/include/pango-1.0/ -I /usr/lib/i386-linux-gnu/gtk-2.0/include -I /usr/include/gdk-pixbuf-2.0/ -I /usr/include/atk-1.0/ -I /usr/include/webkitgtk-1.0/ -I /usr/include/libsoup-2.4/"
4
+
5
+ $LIBS << " -L /usr/lib/i386-linux-gnu/ -lgtk-3 -L /usr/lib/webkitgtk-1.0-0/ -lwebkitgtk-3.0"
6
+ create_makefile("gtk_webkit_pdf/webkit")
@@ -0,0 +1,56 @@
1
+ #include <utility.h>
2
+
3
+ void free_webkit(void *void_webkit) {
4
+ webkit_wrapper *webkit = void_webkit;
5
+ free(webkit);
6
+ }
7
+
8
+ void initialize_webkit(webkit_wrapper *webkit) {
9
+ webkit -> print_status = Qfalse;
10
+ webkit -> gtk_print_settings = NULL;
11
+ webkit -> webkit_webview = WEBKIT_WEB_VIEW(webkit_web_view_new());
12
+ }
13
+
14
+ void activate_webkit(webkit_wrapper *webkit) {
15
+ webkit_web_view_load_uri(webkit -> webkit_webview, webkit -> webkit_url);
16
+ g_signal_connect(webkit -> webkit_webview, "load-finished", G_CALLBACK(webkit_load_finished), webkit);
17
+ }
18
+
19
+ void webkit_load_finished(WebKitWebView *webView, WebKitWebFrame *webkitwebframe, webkit_wrapper *webkit) {
20
+ activate_printer(webkit);
21
+ gtk_print_operation_set_export_filename(webkit -> gtk_print_operation, webkit -> export_filename);
22
+ webkit -> gtk_print_operation_result = webkit_web_frame_print_full(webkit -> webkit_webframe,
23
+ webkit -> gtk_print_operation, GTK_PRINT_OPERATION_ACTION_EXPORT, NULL);
24
+ actual_print_operation(webkit);
25
+ }
26
+
27
+ void activate_printer(webkit_wrapper *webkit) {
28
+ webkit -> webkit_webframe = webkit_web_view_get_main_frame(webkit -> webkit_webview);
29
+ set_printer_configurations(webkit);
30
+ }
31
+
32
+ void set_printer_configurations(webkit_wrapper *webkit) {
33
+ webkit -> gtk_print_operation = gtk_print_operation_new();
34
+ if(webkit -> gtk_print_settings != NULL)
35
+ gtk_print_operation_set_print_settings(webkit -> gtk_print_operation, webkit -> gtk_print_settings);
36
+ g_signal_connect(webkit -> gtk_print_operation, "begin_print", G_CALLBACK(begin_print), NULL);
37
+ g_signal_connect(webkit -> gtk_print_operation, "draw_page", G_CALLBACK(draw_page), NULL);
38
+ }
39
+
40
+ void actual_print_operation(webkit_wrapper *webkit) {
41
+ if(webkit -> gtk_print_operation_result == GTK_PRINT_OPERATION_RESULT_APPLY) {
42
+ g_object_unref(webkit -> gtk_print_settings);
43
+ webkit -> gtk_print_settings = g_object_ref(gtk_print_operation_get_print_settings(webkit -> gtk_print_operation));
44
+ webkit -> print_status = Qtrue;
45
+ }
46
+ g_object_unref(webkit -> gtk_print_operation);
47
+ gtk_main_quit();
48
+ }
49
+
50
+ void begin_print() {
51
+ //begin print callback
52
+ }
53
+
54
+ void draw_page() {
55
+ //draw page callback
56
+ }
@@ -0,0 +1,30 @@
1
+ #ifndef utility_h__
2
+ #define utility_h__
3
+ #include<ruby.h>
4
+ #include <gtk/gtk.h>
5
+ #include <webkit/webkit.h>
6
+ #include <stdlib.h>
7
+
8
+ typedef struct {
9
+ WebKitWebView *webkit_webview;
10
+ char *export_filename;
11
+ char *webkit_url;
12
+
13
+ WebKitWebFrame *webkit_webframe;
14
+ GtkPrintSettings *gtk_print_settings;
15
+ GtkPrintOperation *gtk_print_operation;
16
+ GtkPrintOperationResult gtk_print_operation_result;
17
+ VALUE print_status;
18
+ } webkit_wrapper;
19
+
20
+ extern void webkit_load_finished(WebKitWebView *webView, WebKitWebFrame *webkitwebframe, webkit_wrapper *webkit);
21
+ extern void begin_print();
22
+ extern void draw_page();
23
+
24
+ extern void initialize_webkit(webkit_wrapper *webkit);
25
+ extern void free_webkit(void *void_webkit);
26
+ extern void activate_webkit(webkit_wrapper *webkit);
27
+ extern void activate_printer(webkit_wrapper *webkit);
28
+ extern void set_printer_configurations(webkit_wrapper *webkit);
29
+ extern void actual_print_operation(webkit_wrapper *webkit);
30
+ #endif
@@ -0,0 +1,37 @@
1
+ #include <ruby.h>
2
+ #include <gtk/gtk.h>
3
+ #include <webkit/webkit.h>
4
+ #include <webkit.h>
5
+
6
+ VALUE cGTK = Qnil;
7
+ VALUE cWebkit = Qnil;
8
+
9
+ static VALUE c_new(VALUE self, VALUE webkit_url, VALUE export_filename) {
10
+ webkit_wrapper *webkit;
11
+ VALUE argv[2];
12
+ VALUE data_object = Data_Make_Struct(self, webkit_wrapper, 0, free_webkit, webkit);
13
+ webkit -> webkit_url = StringValuePtr(webkit_url);
14
+ webkit -> export_filename = StringValuePtr(export_filename);
15
+
16
+ argv[0] = webkit_url;
17
+ argv[1] = export_filename;
18
+ rb_obj_call_init(data_object, 2, argv);
19
+ return data_object;
20
+ }
21
+
22
+ static VALUE c_convert_to_pdf(VALUE self) {
23
+ webkit_wrapper *webkit;
24
+ gtk_init(NULL, NULL);
25
+ Data_Get_Struct(self, webkit_wrapper, webkit);
26
+ initialize_webkit(webkit);
27
+ activate_webkit(webkit);
28
+ gtk_main();
29
+ return webkit -> print_status;
30
+ }
31
+
32
+ void Init_webkit(void) {
33
+ cGTK = rb_define_module("GTK");
34
+ cWebkit = rb_define_class_under(cGTK, "Webkit", rb_cObject);
35
+ rb_define_singleton_method(cWebkit, "new", c_new, 2);
36
+ rb_define_method(cWebkit, "convert_to_pdf", c_convert_to_pdf, 0);
37
+ }
@@ -0,0 +1,4 @@
1
+ #ifndef webkit_h__
2
+ #define webkit_h__
3
+ #include <utility.h>
4
+ #endif
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'gtk_webkit_pdf'
3
+ s.version = '0.0.0'
4
+ s.date = '2013-01-03'
5
+ s.summary = "GTK WEBKIT"
6
+ s.description = "Generates the PDF from the HTML using GTK WEBKIT"
7
+ s.authors = ["Mohanraj Ramanujam"]
8
+ s.email = 'mohanraj.ramanujam@gmail.com'
9
+ s.files = Dir.glob("lib/**/*.rb") + Dir.glob("ext/**/*.{c,h}") + ['README', 'gtk_webkit_pdf.gemspec']
10
+ s.extensions = ["ext/gtk_webkit_pdf/extconf.rb"]
11
+ s.executables = ["webkit"]
12
+ s.homepage =
13
+ 'http://rubygems.org/gems/gtk_webkit_pdf'
14
+ end
@@ -0,0 +1,13 @@
1
+ module GTK
2
+ class Webkit
3
+ attr_accessor :webkit_url, :export_filename
4
+
5
+ def initialize(webkit_url, export_filename)
6
+ @webkit_url = webkit_url
7
+ @export_filename = export_filename
8
+ end
9
+ end
10
+ end
11
+
12
+ #require the SO(shared object) file
13
+ require "gtk_webkit_pdf/webkit"
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gtk_webkit_pdf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mohanraj Ramanujam
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-03 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Generates the PDF from the HTML using GTK WEBKIT
15
+ email: mohanraj.ramanujam@gmail.com
16
+ executables: []
17
+ extensions:
18
+ - ext/gtk_webkit_pdf/extconf.rb
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/gtk_webkit_pdf/gtk_webkit_pdf.rb
22
+ - ext/gtk_webkit_pdf/utility.c
23
+ - ext/gtk_webkit_pdf/webkit.c
24
+ - ext/gtk_webkit_pdf/utility.h
25
+ - ext/gtk_webkit_pdf/webkit.h
26
+ - README
27
+ - gtk_webkit_pdf.gemspec
28
+ - ext/gtk_webkit_pdf/extconf.rb
29
+ homepage: http://rubygems.org/gems/gtk_webkit_pdf
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.24
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: GTK WEBKIT
53
+ test_files: []