Exemplo n.º 1
0
void
show_scrollbars(widget_t *w, gboolean show)
{
    GtkWidget *view = g_object_get_data(G_OBJECT(w->widget), "webview");
    WebKitWebFrame *mf = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(view));
    gulong id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(view), "hide_handler_id"));

    if (show) {
        if (id)
            g_signal_handler_disconnect((gpointer) mf, id);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w->widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
        id = 0;
    } else if (!id) {
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w->widget), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
        id = g_signal_connect(G_OBJECT(mf), "scrollbars-policy-changed", G_CALLBACK(true_cb), NULL);
    }
    g_object_set_data(G_OBJECT(view), "hide_handler_id", GINT_TO_POINTER(id));
}
Exemplo n.º 2
0
static void
search_bar_show (GtkWidget *widget)
{
	ESearchBar *search_bar;
	EWebView *web_view;

	search_bar = E_SEARCH_BAR (widget);

	/* Chain up to parent's show() method. */
	GTK_WIDGET_CLASS (e_search_bar_parent_class)->show (widget);

	gtk_widget_grab_focus (search_bar->priv->entry);

	web_view = e_search_bar_get_web_view (search_bar);
	webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (web_view));

	search_bar_find (search_bar, TRUE);
}
Exemplo n.º 3
0
/* ghtml_get_source */
char const * ghtml_get_source(GtkWidget * widget)
{
#if WEBKIT_CHECK_VERSION(1, 1, 0)
	GHtml * ghtml;
	WebKitWebFrame * frame;
	WebKitWebDataSource * source;
	GString * str;

	ghtml = g_object_get_data(G_OBJECT(widget), "ghtml");
	frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(ghtml->view));
	source = webkit_web_frame_get_data_source(frame);
	if((str = webkit_web_data_source_get_data(source)) == NULL)
		return NULL;
	return str->str;
#else
	return NULL;
#endif
}
Exemplo n.º 4
0
static void
dialog_unmap (GtkWidget *window,
              GtkWidget *paned)
{
  DialogData data;

  gtk_window_get_size (GTK_WINDOW (window), &data.width, &data.height);

  data.paned_position = gtk_paned_get_position (GTK_PANED (paned));
  data.show_index     = gtk_widget_get_visible (sidebar);

  data.zoom = (view ?
               webkit_web_view_get_zoom_level (WEBKIT_WEB_VIEW (view)) : 1.0);

  gimp_set_data (GIMP_HELP_BROWSER_DIALOG_DATA, &data, sizeof (data));

  gtk_main_quit ();
}
/* Status of loading a site has changed */
static void _interface_tweaks_on_notify_view_load_status(InterfaceTweaks *self, GParamSpec *inSpec, gpointer inUserData)
{
	g_return_if_fail(IS_INTERFACE_TWEAKS(self));
	g_return_if_fail(WEBKIT_IS_WEB_VIEW(inUserData));

	InterfaceTweaksPrivate	*priv=self->priv;
	WebKitWebView			*webkitView=WEBKIT_WEB_VIEW(inUserData);
	WebKitLoadStatus		status;

	/* Check load status */ 
	status=webkit_web_view_get_load_status(webkitView);

	/* If webview was prepared to start network request */
	if(status==WEBKIT_LOAD_PROVISIONAL)
	{
		/* Show start-request throbber now if set */
		if(priv->showStartRequestThrobber)
		{
			MidoriView		*view;
			KatzeThrobber	*throbber;

			/* Get Midori view and the size for icon in tab */
			view=midori_view_get_for_widget(GTK_WIDGET(webkitView));

			/* Start throbber animation of view */
			throbber=_interface_tweaks_find_view_throbber(view);
			if(throbber) katze_throbber_set_animated(throbber, TRUE);
		}
	}

	/* First data of network response has been sent or first data of
	 * network response has been received
	 */
	if(status==WEBKIT_LOAD_COMMITTED)
	{
		const gchar			*uri;

		/* Get URI for current request */
		uri=webkit_web_view_get_uri(webkitView);

		/* Add URI to completion model */
		_interface_tweaks_add_uri_to_completion_model(self, uri);
	}
}
Exemplo n.º 6
0
static void
night_mode_tabs_view_notify_uri_cb (MidoriView*      view,
                                    GParamSpec*      pspec,
                                    MidoriExtension* extension)
{
   gchar* exception = NULL;
   gchar *script=NULL;
   FILE *fp;
   int file_size;
   gboolean result;

   const gchar* uri = midori_view_get_display_uri (view);
   if (!*uri)
      return;
   if (g_night_mode)
        {
      if (!midori_uri_is_blank (uri))
                {
         gchar* hostname = midori_uri_parse_hostname (uri, NULL);
         if (hostname)
                        {
            if((fp=fopen(midori_paths_get_res_filename("night_mode/nightingale_view_content.js"),"r"))!=NULL)
                               {
               fseek(fp,0,SEEK_END);
               file_size=ftell(fp);
               fseek(fp,0,SEEK_SET);
               script=(char *)malloc(file_size * sizeof(char)+1);
               fread(script,file_size,sizeof(char),fp);
               script[file_size*sizeof(char)]='\0';
               fclose(fp);
               result = midori_view_execute_script (view, script, &exception);
               free(script);
               script=NULL;
                               }         
            g_free (hostname);
                         }
               }
        }
   else
        {
      GtkWidget* current_web_view = midori_view_get_web_view (MIDORI_VIEW (view));
      webkit_web_view_run_javascript(WEBKIT_WEB_VIEW (current_web_view), night_mode_remove, NULL, NULL, NULL);
        }
}
/* A tab of a browser was added */
static void _interface_tweaks_on_add_tab(InterfaceTweaks *self, MidoriView *inView, gpointer inUserData)
{
	g_return_if_fail(IS_INTERFACE_TWEAKS(self));
	g_return_if_fail(MIDORI_IS_VIEW(inView));
	g_return_if_fail(MIDORI_IS_BROWSER(inUserData));

	WebKitWebView			*webkitView;

	/* Connect signals to midori view and webkit webview to monitor loading state */
	g_signal_connect_swapped(inView, "notify::minimized", G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_close_button), self);
	_interface_tweaks_on_notify_minimized_tab_for_close_button(self, NULL, inView);

	g_signal_connect_swapped(inView, "notify::minimized", G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);
	_interface_tweaks_on_notify_minimized_tab_for_group_tabs(self, NULL, inView);

	webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(inView));
	g_signal_connect_swapped(webkitView, "notify::load-status", G_CALLBACK(_interface_tweaks_on_notify_view_load_status), self);
	_interface_tweaks_on_notify_view_load_status(self, NULL, webkitView);
}
Exemplo n.º 8
0
static void
test_webkit_download_perform(void)
{
    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());

    g_object_ref_sink(G_OBJECT(webView));

    g_signal_connect(webView, "navigation-policy-decision-requested",
                     G_CALLBACK(navigation_policy_decision_requested_cb),
                     NULL);

    gboolean beenThere = FALSE;
    g_signal_connect(webView, "download-requested",
                     G_CALLBACK(download_requested_cb),
                     &beenThere);

    /* Preparation; FIXME: we should move this code to a test
     * utilities file, because we have a very similar one in
     * testwebframe.c */
    GError *error = NULL;
    int fd = g_file_open_tmp ("webkit-testwebdownload-XXXXXX",
                              &temporaryFilename, &error);
    close(fd);

    if (error)
        g_critical("Failed to open a temporary file for writing: %s.", error->message);

    if (g_unlink(temporaryFilename) == -1)
        g_critical("Failed to delete the temporary file: %s.", g_strerror(errno));

    loop = g_main_loop_new(NULL, TRUE);
    webkit_web_view_load_uri(webView, "http://gnome.org/");
    g_main_loop_run(loop);

    g_assert_cmpint(beenThere, ==, TRUE);

    g_assert_cmpint(g_file_test(temporaryFilename, G_FILE_TEST_IS_REGULAR), ==, TRUE);

    g_unlink(temporaryFilename);
    g_free(temporaryFilename);
    g_main_loop_unref(loop);
    g_object_unref(webView);
}
Exemplo n.º 9
0
static void phidias_items_classic_set_model (PhidiasItemsViewer *self, GtkTreeModel *items)
{
    GtkTreeModel *sorter;
    PhidiasItemsClassic *item;

    item = PHIDIAS_ITEMS_CLASSIC (self);
    webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (item->priv->description), "", "file://");

    sorter = gtk_tree_view_get_model (GTK_TREE_VIEW (item->priv->list));
    if (sorter != NULL)
        g_object_unref (sorter);

    sorter = gtk_tree_model_sort_new_with_model (items);
    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sorter), ITEM_INFO_DATE, GTK_SORT_DESCENDING);
    gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (sorter), ITEM_INFO_DATE, sort_items, NULL, NULL);
    gtk_tree_view_set_model (GTK_TREE_VIEW (item->priv->list), sorter);

    scroll_to_position (item);
}
Exemplo n.º 10
0
gchar *webview_executeExpression(WebView *webview, const gchar *expr) {
    WebKitWebView *widget = WEBKIT_WEB_VIEW(webview->widget);
    
    /*
        A "nicer" solution would be to catch "window-object-cleared" and add
        a special property/function there, but that's much more work for little
        practical benefit.
    */
    
    // Use the title to store the value of the expression
    webview_executeFormattedScript(webview, "var oldTitle = document.title;"
                                            "document.title = encodeURIComponent(%s);", expr);
    
    gchar *result = g_uri_unescape_string(webkit_web_view_get_title(widget), NULL);
    
    // Restore old title
    webview_executeScript(webview, "document.title = oldTitle; delete oldTitle;");
    return result;
}
Exemplo n.º 11
0
static void testWebkitAtkGetTextInParagraphAndBodyModerate(void)
{
    WebKitWebView* webView;
    AtkObject* obj;
    AtkObject* obj1;
    AtkObject* obj2;
    GMainLoop* loop;
    AtkText* textObj1;
    AtkText* textObj2;

    webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
    g_object_ref_sink(webView);
    GtkAllocation alloc = { 0, 0, 800, 600 };
    gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc);
    webkit_web_view_load_string(webView, contentsInParagraphAndBodyModerate, NULL, NULL, NULL);
    loop = g_main_loop_new(NULL, TRUE);

    g_timeout_add(100, (GSourceFunc)bail_out, loop);
    g_main_loop_run(loop);

    /* Get to the inner AtkText object */
    obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
    g_assert(obj);
    obj1 = atk_object_ref_accessible_child(obj, 0);
    g_assert(obj1);
    obj2 = atk_object_ref_accessible_child(obj, 1);
    g_assert(obj2);

    textObj1 = ATK_TEXT(obj1);
    g_assert(ATK_IS_TEXT(textObj1));
    textObj2 = ATK_TEXT(obj2);
    g_assert(ATK_IS_TEXT(textObj2));

    char *text = atk_text_get_text(textObj1, 0, -1);
    g_assert_cmpstr(text, ==, "This is a test.");

    text = atk_text_get_text(textObj2, 0, 53);
    g_assert_cmpstr(text, ==, "Hello world.\nThis sentence is green.\nThis one is not.");

    g_object_unref(obj1);
    g_object_unref(obj2);
    g_object_unref(webView);
}
Exemplo n.º 12
0
static void
copy_location_callback (GtkAction *action,
                        gpointer   data)
{
  WebKitWebFrame *frame;
  const gchar    *uri;

  frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view));
  uri = webkit_web_frame_get_uri (frame);

  if (uri)
    {
      GtkClipboard *clipboard;

      clipboard = gtk_clipboard_get_for_display (gtk_widget_get_display (view),
                                                 GDK_SELECTION_CLIPBOARD);
      gtk_clipboard_set_text (clipboard, uri, -1);
    }
}
Exemplo n.º 13
0
Arquivo: main.c Projeto: AndySze/OS.js
int
main (int argc, gchar *argv[])
{
#ifndef NOX11

  initialize_x11();

#endif

  char          *uri = "http://OSjs.local";

  // Initialize GTK+
  if ( !g_thread_supported() )
    g_thread_init (NULL);

  gtk_init_check (&argc, &argv);

  // Create WebKit view
  WebKitWebView *web_view;
  web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ());
  webkit_web_view_load_uri (web_view, uri);

  // Create Window
  GtkWidget     *window;
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET(web_view));

  // Run
  gtk_widget_show_all (window);
  gtk_window_fullscreen (GTK_WINDOW(window));

  gtk_main();

#ifndef NOX11

  XCloseDisplay(d);

#endif

  return 0;
}
Exemplo n.º 14
0
/**
 * Launch URL
 */
static void
liferea_webkit_launch_url (GtkWidget *scrollpane, const gchar *url)
{
	// FIXME: hack to make URIs like "gnome.org" work
	// https://bugs.webkit.org/show_bug.cgi?id=24195
	gchar *http_url;
	if (!strstr (url, "://")) {
		http_url = g_strdup_printf ("http://%s", url);
	} else {
		http_url = g_strdup (url);
	}

	webkit_web_view_load_uri (
		WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (scrollpane))),
		http_url
	);

	g_free (http_url);
}
Exemplo n.º 15
0
static void
night_mode_deactivated_cb (MidoriExtension* extension,
                           MidoriBrowser*   browser)
{
   if(night_mode_button)
      gtk_widget_destroy (night_mode_button);
   g_signal_handlers_disconnect_by_func (extension, night_mode_deactivated_cb, browser);
   if(g_night_mode)
        {
      GList* children = midori_browser_get_tabs (MIDORI_BROWSER (browser));
      for (; children; children = g_list_next (children))
                 {
         GtkWidget* current_web_view = midori_view_get_web_view (MIDORI_VIEW (children->data));
         webkit_web_view_run_javascript(WEBKIT_WEB_VIEW (current_web_view), night_mode_remove, NULL, NULL, NULL);
                }
      g_list_free (children);
      g_signal_handlers_disconnect_by_func (browser, night_mode_extension_browser_add_tab_cb, NULL);
        }            
}
Exemplo n.º 16
0
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist; 
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view));
    GList* list = webkit_web_back_forward_list_get_forward_list_with_limit(history, 
                                                                           m_historyLimit);
    for(guint i = 0; i < g_list_length(list); i++)
    {
        WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                                   webkit_web_history_item_get_uri(gtkitem),
                                   webkit_web_history_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        forwardhist.push_back(item);
    }
    return forwardhist;
}
Exemplo n.º 17
0
/**
 *  e.g. after a click on javascript:openZoom()
 */
static WebKitWebView*
webkit_create_web_view (WebKitWebView *view, WebKitWebFrame *frame)
{
	LifereaHtmlView *htmlview;
	GtkWidget	*container;
	GtkWidget	*htmlwidget;
	GList 		*children;

	htmlview = browser_tabs_add_new (NULL, NULL, TRUE);
	container = liferea_htmlview_get_widget (htmlview);

	/* Ugly lookup of the webview. LifereaHtmlView uses a GtkBox
	   with first a URL bar (sometimes invisble) and the HTML renderer
	   as 2nd child */
	children = gtk_container_get_children (GTK_CONTAINER (container));
	htmlwidget = gtk_bin_get_child (GTK_BIN (children->next->data));

	return WEBKIT_WEB_VIEW (htmlwidget);
}
Exemplo n.º 18
0
static gint
get_caret_position (EHTMLEditorView *view)
{
	WebKitDOMDocument *document;
	WebKitDOMDOMWindow *window;
	WebKitDOMDOMSelection *selection;
	WebKitDOMRange *range;
	gint range_count;
	WebKitDOMNodeList *nodes;
	gulong ii, length;

	document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
	window = webkit_dom_document_get_default_view (document);
	selection = webkit_dom_dom_window_get_selection (window);

	if (webkit_dom_dom_selection_get_range_count (selection) < 1)
		return 0;

	range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
	range_count = 0;
	nodes = webkit_dom_node_get_child_nodes (
		webkit_dom_node_get_parent_node (
			webkit_dom_dom_selection_get_anchor_node (
				selection)));
	length = webkit_dom_node_list_get_length (nodes);
	for (ii = 0; ii < length; ii++) {
		WebKitDOMNode *node;

		node = webkit_dom_node_list_item (nodes, ii);
		if (webkit_dom_node_is_same_node (
			node, webkit_dom_dom_selection_get_anchor_node (selection))) {

			break;
		} else if (WEBKIT_DOM_IS_TEXT (node)) {
			gchar *text = webkit_dom_node_get_text_content (node);
			range_count += strlen (text);
			g_free (text);
		}
	}

	g_object_unref (nodes);
	return webkit_dom_range_get_start_offset (range, NULL) + range_count;
}
Exemplo n.º 19
0
static gboolean
activate_link (GtkLabel       *label,
               const gchar    *uri,
               GisPrivacyPage *page)
{
  GtkWidget *dialog;
  GtkWidget *overlay;
  GtkWidget *view;
  GtkWidget *progress_bar;

  dialog = gtk_dialog_new_with_buttons (_("Privacy Policy"),
                                        GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page))),
                                        GTK_DIALOG_MODAL
                                        | GTK_DIALOG_DESTROY_WITH_PARENT
                                        | GTK_DIALOG_USE_HEADER_BAR,
                                        NULL);

  overlay = gtk_overlay_new ();
  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), overlay);

  progress_bar = gtk_progress_bar_new ();
  gtk_style_context_add_class (gtk_widget_get_style_context (progress_bar), GTK_STYLE_CLASS_OSD);
  gtk_widget_set_halign (progress_bar, GTK_ALIGN_FILL);
  gtk_widget_set_valign (progress_bar, GTK_ALIGN_START);
  gtk_overlay_add_overlay (GTK_OVERLAY (overlay), progress_bar);

  view = webkit_web_view_new ();
  gtk_widget_set_size_request (view, 600, 500);
  gtk_widget_set_hexpand (view, TRUE);
  gtk_widget_set_vexpand (view, TRUE);
  g_signal_connect (view, "notify::estimated-load-progress",
                    G_CALLBACK (notify_progress_cb), progress_bar);

  gtk_container_add (GTK_CONTAINER (overlay), view);
  gtk_widget_show_all (overlay);

  gtk_window_present (GTK_WINDOW (dialog));

  webkit_web_view_load_uri (WEBKIT_WEB_VIEW (view), uri);

  return TRUE;
}
static void test_webkit_web_data_source_lifetime()
{
    WebKitWebView* view;
    GMainLoop* loop;

    view = WEBKIT_WEB_VIEW(webkit_web_view_new());
    g_object_ref_sink(view);
    loop = g_main_loop_new(NULL, TRUE);
    g_signal_connect(view, "notify::load-status", G_CALLBACK(notify_load_status_lifetime_cb), loop);
    webkit_web_view_load_uri(view, "http://www.webkit.org");

    waitTimer = g_timeout_add_seconds(defaultTimeout, (GSourceFunc)wait_timer_fired, loop);

    g_main_loop_run(loop);

    WebKitWebDataSource* dataSource = webkit_web_frame_get_data_source(webkit_web_view_get_main_frame(view));
    GList* subResources = webkit_web_data_source_get_subresources(dataSource);
    gint numberOfResources = g_list_length(subResources);
    g_list_free(subResources);

    g_assert_cmpint(webkit_web_view_get_load_status(view), ==, WEBKIT_LOAD_FINISHED);

    webkit_web_view_load_uri(view, "http://gnome.org");

    g_assert_cmpint(webkit_web_view_get_load_status(view), ==, WEBKIT_LOAD_PROVISIONAL);

    webkit_web_view_stop_loading(view);

    g_assert_cmpint(webkit_web_view_get_load_status(view), ==, WEBKIT_LOAD_FAILED);

    subResources = webkit_web_data_source_get_subresources(dataSource);
    g_assert_cmpint(numberOfResources, ==, g_list_length(subResources));
    g_list_free(subResources);

    if (waitTimer)
        g_source_remove(waitTimer);

    waitTimer = 0;

    g_main_loop_unref(loop);
    g_object_unref(view);
}
Exemplo n.º 21
0
static void _new_init(GHtml * ghtml)
{
	static int initialized = 0;
#if WEBKIT_CHECK_VERSION(1, 1, 0)
	SoupSession * session;
# if WEBKIT_CHECK_VERSION(1, 3, 5) && defined(EMBEDDED)
	WebKitWebSettings * settings;
# endif
	char const * cacerts[] =
	{
		"/etc/pki/tls/certs/ca-bundle.crt",
		"/etc/ssl/certs/ca-certificates.crt",
		"/etc/openssl/certs/ca-certificates.crt",
		PREFIX "/etc/ssl/certs/ca-certificates.crt",
		PREFIX "/etc/openssl/certs/ca-certificates.crt"
	};
	size_t i;
#endif

	if(initialized++ != 0)
	{
		initialized = 1;
		return;
	}
#if WEBKIT_CHECK_VERSION(1, 1, 0)
	session = webkit_get_default_session();
# if WEBKIT_CHECK_VERSION(1, 3, 5) && defined(EMBEDDED)
	settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(ghtml->view));
	g_object_set(settings, "enable-frame-flattening", TRUE, NULL);
# endif
	for(i = 0; i < sizeof(cacerts) / sizeof(*cacerts); i++)
		if(access(cacerts[i], R_OK) == 0)
		{
			g_object_set(session, "ssl-ca-file", cacerts[i],
					"ssl-strict", FALSE, NULL);
			ghtml->ssl = TRUE;
			return;
		}
#endif
	surfer_warning(ghtml->surfer, _("Could not load certificate bundle:\n"
			"SSL certificates will not be verified."));
}
Exemplo n.º 22
0
static gboolean
search_entry_key_press (GtkWidget   *entry,
                        GdkEventKey *event)
{
  switch (event->keyval)
    {
    case GDK_KEY_Escape:
      gtk_widget_hide (searchbar);
      webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (view));
      return TRUE;

    case GDK_KEY_Return:
    case GDK_KEY_KP_Enter:
    case GDK_KEY_ISO_Enter:
      search (gtk_entry_get_text (GTK_ENTRY (entry)), TRUE);
      return TRUE;
    }

  return FALSE;
}
Exemplo n.º 23
0
Arquivo: gu.c Projeto: Cy-4AH/showtime
static void
webkit_test(void)
{
/* Create the widgets */
GtkWidget *main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
GtkWidget *web_view = webkit_web_view_new ();

/* Place the WebKitWebView in the GtkScrolledWindow */
gtk_container_add (GTK_CONTAINER (scrolled_window), web_view);
gtk_container_add (GTK_CONTAINER (main_window), scrolled_window);

/* Open a webpage */
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "http://www.gnome.org");

/* Show the result */
gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600);
gtk_widget_show_all (main_window);

}
Exemplo n.º 24
0
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist; 
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view));
    GList* list = webkit_web_back_forward_list_get_back_list_with_limit(history, 
                                                                        m_historyLimit);
    //We need to iterate in reverse to get the order we desire
    for(int i = g_list_length(list) - 1; i >= 0 ; i--)
    {
        WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                                   webkit_web_history_item_get_uri(gtkitem),
                                   webkit_web_history_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        backhist.push_back(item);
    }
    return backhist;
}
Exemplo n.º 25
0
/* on_create_web_view */
static WebKitWebView * _on_create_web_view(WebKitWebView * view,
		WebKitWebFrame * frame, gpointer data)
{
	GHtml * ghtml;
	Surfer * surfer;
	GtkWidget * widget;

	if((surfer = surfer_new(NULL)) == NULL)
		return NULL;
	/* FIXME we may want the history to be copied (and then more) */
	if((widget = surfer_get_view(surfer)) == NULL)
	{
		surfer_delete(surfer);
		return NULL;
	}
	ghtml = g_object_get_data(G_OBJECT(widget), "ghtml");
	g_signal_connect(G_OBJECT(ghtml->view), "web-view-ready", G_CALLBACK(
				_on_web_view_ready), widget);
	return WEBKIT_WEB_VIEW(ghtml->view);
}
Exemplo n.º 26
0
Arquivo: uzbl.c Projeto: dusanx/uzbl
static GtkWidget*
create_browser () {
    GtkWidget* scrolled_window = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_NEVER); //todo: some sort of display of position/total length. like what emacs does

    web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ());
    gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view));

    g_signal_connect (G_OBJECT (web_view), "title-changed", G_CALLBACK (title_change_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "load-progress-changed", G_CALLBACK (progress_change_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "load-committed", G_CALLBACK (load_commit_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "load-committed", G_CALLBACK (log_history_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "hovering-over-link", G_CALLBACK (link_hover_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "key-press-event", G_CALLBACK (key_press_cb), web_view);
    g_signal_connect (G_OBJECT (web_view), "new-window-policy-decision-requested", G_CALLBACK (new_window_cb), web_view); 
    g_signal_connect (G_OBJECT (web_view), "download-requested", G_CALLBACK (download_cb), web_view); 
    g_signal_connect (G_OBJECT (web_view), "create-web-view", G_CALLBACK (create_web_view_cb), web_view);  

    return scrolled_window;
}
Exemplo n.º 27
0
static void
load_finished_cb (MarinaWebView *web_view)
{
  MarinaWebViewPrivate *priv;
  WebKitWebSettings    *settings;

  g_return_if_fail (MARINA_IS_WEB_VIEW (web_view));

  priv = web_view->priv;
  
  priv->loaded = TRUE;
  
  settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view->priv->web_view));
  update_fonts (web_view, settings);
  
  marina_web_view_set_source (web_view, priv->source);

  if (priv->item)
    marina_web_view_set_item (web_view, priv->item);
}
Exemplo n.º 28
0
/**
 * Load HTML string into the rendering scrollpane
 *
 * Load an HTML string into the web view. This is used to render
 * HTML documents created internally.
 */
static void
liferea_webkit_write_html (
	GtkWidget *scrollpane,
	const gchar *string,
	const guint length,
	const gchar *base,
	const gchar *content_type
)
{
	GtkWidget *htmlwidget;
	
	htmlwidget = gtk_bin_get_child (GTK_BIN (scrollpane));

	/* Note: we explicitely ignore the passed base URL
	   because we don't need it as Webkit supports <div href="">
	   and throws a security exception when accessing file://
	   with a non-file:// base URL */
	webkit_web_view_load_string (WEBKIT_WEB_VIEW (htmlwidget), string,
				     content_type, "UTF-8", "file://");
}
Exemplo n.º 29
0
int main(int argc, char **argv)
{
  gtk_init(&argc, &argv);

  GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);
  GtkWidget *web_view = webkit_web_view_new();

  gtk_container_add(GTK_CONTAINER(scrolled_window), web_view);
  gtk_container_add(GTK_CONTAINER(main_window), scrolled_window);

  webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view), "http://www.grooveshark.com");

  g_signal_connect (main_window, "destroy", G_CALLBACK(destroy), NULL);

  gtk_widget_show_all(main_window);
  gtk_main();

  return 0;
}
Exemplo n.º 30
0
void ygtk_html_wrap_set_text (GtkWidget *widget, const gchar *text, gboolean plain_mode)
{
	WebKitWebView *view = WEBKIT_WEB_VIEW (widget);
	// webkit prepends base-uri to non-uri hrefs
	if (plain_mode)
			webkit_web_view_load_string (view, text, "text/plain", "UTF-8", "/");
	else {
		GString *str = NULL;
		int i, last_i = 0;
		for (i = 0; text[i]; i++) {
			if (!strncmp (text+i, "href=", 5)) {
				i += 5;
				if (text[i] == '"')
					i++;
				int j;
				for (j = i; text[j] && text[j] != ':'; j++)
					if (text[j] == '"' || g_ascii_isspace (text[j])) {
						if (!str)
							str = g_string_new ("");
						str = g_string_append_len (str, text+last_i, i-last_i);
						last_i = i;
						str = g_string_append (str, "label:/");
						break;
					}
			}
		}
		if (str) {
			str = g_string_append (str, text+last_i);
			text = g_string_free (str, FALSE);
		}

		const gchar *extra_css = g_object_get_data (G_OBJECT (widget), "extra-css");
		if (!extra_css) extra_css = "";

		gchar *html = g_strdup_printf ("%s\n%s\n%s", CSS, extra_css, text);
		if (str)
			g_free ((gchar *) text);
		webkit_web_view_load_string (view, html, "text/html", "UTF-8", "/");
		g_free (html);
	}
}