#include #include #include #include #include typedef void (* SetEnvFunc) (void); typedef GWeb* (* GetWebNewFunc) (void); GWeb *web; GObject *engine_widget; GWebEngine *engine; gboolean open_new_engine() { engine = g_web_new_web_engine_window_with_context(web, NULL, TRUE, TRUE); engine_widget = g_web_engine_get_engine_widget(engine); if (!engine_widget) { printf("Error opening new engine"); return 1; } return TRUE; } static GWeb* init_engine_by_name() { gchar *engine_name = NULL; SetEnvFunc web_set_env; GetWebNewFunc web_get_new; engine_name = g_strdup_printf("/usr/lib/libmozilla-eal.so.0"); printf("\tOpening engine: %s\n", engine_name); GModule* module = g_module_open(engine_name, G_MODULE_BIND_LAZY); g_free(engine_name); if (g_module_error ()) printf("\tModule error: %s\n", g_module_error ()); if (!g_module_symbol (module, "g_web_set_env", (gpointer *)&web_set_env)) printf("\tg_web_set_env Function opened unsuccessefully\n"); else printf("\tg_web_set_env Function opened successefully\n"); if (!g_module_symbol (module, "g_web_new", (gpointer *)&web_get_new)) printf("\tg_web_new Function opened unsuccessefully\n"); else printf("\tg_web_new Function opened successefully\n"); web_set_env(); return web_get_new (); } int main(int argc, char *argv[]) { /* Create needed variables */ HildonProgram *program; HildonWindow *window; GtkWidget *button; GtkWidget *box1; /* Initialize the GTK. */ gtk_init(&argc, &argv); /* Create the hildon program and setup the title */ program = HILDON_PROGRAM(hildon_program_get_instance()); g_set_application_name("Hello maemo!"); /* Create HildonWindow and set it to HildonProgram */ window = HILDON_WINDOW(hildon_window_new()); hildon_program_add_window(program, window); /* Connect signal to X in the upper corner */ g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL); box1 = gtk_hbox_new (FALSE, 0); gtk_container_add(GTK_CONTAINER(window), box1); /* Create button and add it to main view */ button = gtk_button_new_with_label("Hello!"); gtk_box_pack_start (GTK_BOX(box1), button, TRUE, TRUE, 0); gtk_widget_show(button); web = init_engine_by_name(); open_new_engine(); gtk_widget_show(GTK_WIDGET(engine_widget)); gtk_box_pack_start (GTK_BOX(box1), GTK_WIDGET(engine_widget), TRUE, TRUE, 0); gtk_widget_show_all(GTK_WIDGET(window)); gtk_widget_show(box1); gtk_widget_show(GTK_WIDGET(window)); GObject *en_notify; en_notify = g_web_engine_get_engine_notifier(engine); g_signal_connect_swapped(en_notify, G_WEBWIDGET_SIGNAL_URL_CHANGED,G_CALLBACK(g_web_widget_signal_url_changed), NULL); g_signal_connect(en_notify, G_WEBWIDGET_SIGNAL_TITLE,G_CALLBACK(g_web_widget_signal_title), NULL); g_signal_connect(en_notify, G_WEBWIDGET_SIGNAL_START_LOADING,G_CALLBACK(g_web_widget_signal_start_loading), NULL); g_signal_connect(en_notify, G_WEBWIDGET_SIGNAL_FINISHED_LOADING,G_CALLBACK(g_web_widget_signal_finished_loading), NULL); g_web_engine_load_url(engine, "file://test.html"); gtk_main(); /* Exit */ return 0; } void g_web_widget_signal_title(GObject *engine_widget, const gchar *title,GObject *browser_window) { printf("Title changed signal, new title is: %s\n", title); } void g_web_widget_signal_url_changed(GObject *browser_window,const gchar *url) { printf("Url changed signal, new url is: %s\n", url); } void g_web_widget_signal_start_loading(GObject *engine_widget,const gchar *url,GObject *browser_window) { printf("Start Loading signal, with url: %s\n", url); } void g_web_widget_signal_finished_loading(GObject *engine_widget,gint finish_status,gint page_size,gboolean has_frames,GObject *browser_window) { printf("Finished Loading signal with status %d, and page size %d\n", finish_status, page_size); }