[webkit-gtk] Webkitgtk page autoscrolling

haithem rahmani haithem.rahmani at gmail.com
Tue Mar 9 08:40:29 PST 2010


Hi all,
I'm trying to write a simple test that do the following

- load a webpage
- start an autoscrolling for 1000 times
- display the total time.

what I did is the following :
- created a webview  and used the "webkit_web_view_load_uri" to load the
uri.
- inserted this webview object inside a scrolledwindow
- attached a "scroll-chid" callback to this scrolledwindow
- the scroll-child callback calls " webkit_web_view_move_cursor" to trigger
the page scrolling , well this what I understood

but this callback is not working.
 any help please? here is the full dirty source code.

the code compiles and runs if someone can test to check that
the page does not get scrolled to the desired position.

thanks indeed for your help.

#include <webkit/webkit.h>

static void destroy(GtkWidget *, gpointer);
static gboolean deleteEvent(GtkWidget*, GdkEvent*, gpointer);
static void scroll_child (GtkScrolledWindow *sw, GtkScrollType st, gboolean
b, gpointer p);

int main(int argc , char ** argv)
{
    GtkWidget *window, *label, *webview;
    GtkWidget *scrolled;
    GtkWidget *vbox;
    GtkAdjustment  *vscroll;
    gdouble up, down ,ps, val;
    gchar *uri;

        // Initalize GTK+
    g_thread_init (NULL);
    gtk_init (&argc, &argv);

    if (argc == 1){
     g_print("error : missing url!!!\n");
     return 1;
    }
    else
     uri = argv[1];

    // create Window
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    gtk_container_set_border_width(GTK_CONTAINER(window), 10);
    gtk_widget_set_size_request(window, 720, 576);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);

    scrolled = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                  GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);

    //create a webview
    webview = webkit_web_view_new();
    //
    webkit_web_view_load_uri(WEBKIT_WEB_VIEW (webview), uri);

    gtk_container_add (GTK_CONTAINER (scrolled), webview);

    gtk_container_add(GTK_CONTAINER(window), scrolled);

    g_signal_connect(G_OBJECT(scrolled), "scroll-child",
G_CALLBACK(scroll_child),NULL);
    g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy),NULL);
    g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(deleteEvent),NULL);

    gtk_widget_show_all(window);

    gtk_main();
    return 0;
}


static void destroy(GtkWidget *w, gpointer data)
{
    gtk_main_quit();
}

static gboolean deleteEvent(GtkWidget* w, GdkEvent* e, gpointer data)
{
   return FALSE;
}

static void scroll_child (GtkScrolledWindow *sw, GtkScrollType st, gboolean
b, gpointer p)
{
     GList *gl = gtk_container_get_children(GTK_CONTAINER(sw));

     WebKitWebView *wv =  WEBKIT_WEB_VIEW(gl->data);
     webkit_web_view_move_cursor(wv, GTK_MOVEMENT_PAGES, 1);
}


-- 
Say: He is God, the One and Only;
God, the Eternal, Absolute;
He begetteth not, nor is He begotten;
And there is none like unto Him.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-gtk/attachments/20100309/b81ba899/attachment.html>


More information about the webkit-gtk mailing list