Esempio n. 1
0
/* ghtml_load_url */
void ghtml_load_url(GtkWidget * widget, char const * url)
{
	GHtml * ghtml;
	char * p;
	char * q = NULL;
	const char about[] = "<!DOCTYPE html>\n<html>\n"
		"<head><title>About " PACKAGE "</title></head>\n"
		"<body>\n<center>\n<h1>" PACKAGE " " VERSION "</h1>\n"
		"<p>Copyright &copy; 2009-2013 Pierre Pronchery &lt;khorben@"
		"defora.org&gt;</p>\n</center>\n</body>\n</html>";

	ghtml = g_object_get_data(G_OBJECT(widget), "ghtml");
	if((p = _ghtml_make_url(NULL, url)) != NULL)
		url = p;
	if(strcmp("about:blank", url) == 0)
		webkit_web_view_load_string(WEBKIT_WEB_VIEW(ghtml->view), "",
				NULL, NULL, url);
	else if(strncmp("about:", url, 6) == 0)
		webkit_web_view_load_string(WEBKIT_WEB_VIEW(ghtml->view),
				about, NULL, NULL, url);
	else
	{
#if WEBKIT_CHECK_VERSION(1, 1, 1)
		webkit_web_view_load_uri(WEBKIT_WEB_VIEW(ghtml->view), url);
#else
		webkit_web_view_open(WEBKIT_WEB_VIEW(ghtml->view), url);
#endif
	}
	g_free(p);
	g_free(q);
	surfer_set_progress(ghtml->surfer, 0.0);
	surfer_set_security(ghtml->surfer, SS_NONE);
	_ghtml_set_status(widget, _("Connecting..."));
}
Esempio n. 2
0
File: wrapper.c Progetto: WDavidX/OS
/**********
 * Name:	create_labeled_tab
 * Input:	'cb_data' - the browser_window passed in
 * Output:      none
 * Function:    Build a new scrolling window, set the size, create the button
 * 		and tab area on the window, and display it all.  Used by 
 * 		create_browser function.
 */
void create_labeled_tab(void* cb_data)
{
  GtkWidget* scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_set_size_request (scrolled_window, WINDOW_WIDTH, WINDOW_HEIGHT);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), 
	GTK_POLICY_AUTOMATIC, 
	GTK_POLICY_AUTOMATIC);
  gtk_widget_show(scrolled_window);

  // Create 'button-press-event' callback event data
  browser_window* b_window = (browser_window*)cb_data;

  // Create web-page rendering area
  b_window->web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ());
  gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(b_window->web_view));

  webkit_web_view_open(b_window->web_view, "about:blank");

  GtkWidget* label = gtk_label_new(b_window->tab_label);
  gtk_widget_show(label);

  // Attach tab to the browser
  gtk_notebook_append_page (GTK_NOTEBOOK (b_window->notebook), scrolled_window, label);

}
Esempio n. 3
0
static void
load_scheme (MarinaWebView *web_view,
             const gchar   *scheme)
{
  MarinaWebViewPrivate *priv;
  gchar                *file;
  gchar                *uri;
  
  g_return_if_fail (MARINA_IS_WEB_VIEW (web_view));
  
  priv = web_view->priv;
  
  priv->loaded = FALSE;
  
  if (!scheme)
    scheme = "Default";
  
  file = g_build_filename (marina_dirs_get_marina_data_dir (),
                           "schemes",
                           scheme,
                           "index.html",
                           NULL);

  uri = g_filename_to_uri (file, NULL, NULL);
  
  webkit_web_view_open (WEBKIT_WEB_VIEW (priv->web_view), uri);
  
  g_free (file);
  g_free (uri);
}
static void activate_uri_entry_box (GtkWidget* entry, gpointer data)
{
 const gchar* uri = gtk_entry_get_text(GTK_ENTRY (entry));

 g_assert(uri);
 webkit_web_view_open (web_view, uri);
}
Esempio n. 5
0
void atlantis_browser_view_Open (AtlantisBrowserView* self, const char* uri) {
#line 20 "browserview.vala"
	g_return_if_fail (self != NULL);
#line 20 "browserview.vala"
	g_return_if_fail (uri != NULL);
#line 22 "browserview.vala"
	webkit_web_view_open (self->priv->htmlWidget, uri);
#line 128 "browserview.c"
}
Esempio n. 6
0
static VALUE
WebView_open(VALUE self, VALUE __v_uri)
{
  char * uri; char * __orig_uri;
  WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
  __orig_uri = uri = ( NIL_P(__v_uri) ? NULL : StringValuePtr(__v_uri) );

#line 256 "/home/ngl/Progetti/gtk-webkit-ruby/ext/webkit/webkit.cr"
  webkit_web_view_open(_self, uri);
 
  return Qnil;
}
Esempio n. 7
0
void wp_changed(GtkWidget *tree, GtkTreeIter *iter)
{
	mpd_Song *song = mpd_playlist_get_current_song(connection);
	gchar *artist = NULL;

	if(!song)
		return;

	/* copied from metadata.h */
	if(song->artist) {
		if (cfg_get_single_value_as_int_with_default(config, "metadata", "rename", FALSE))
		{
			gchar **str = g_strsplit(song->artist, ",", 2);
			if(str[1])
				artist = g_strdup_printf("%s %s", g_strstrip(str[1]), g_strstrip(str[0]));
			else
				artist = g_strdup(song->artist);
			g_strfreev(str);
			g_log(wikipedia_logdomain, G_LOG_LEVEL_DEBUG, "string converted to: '%s'", artist);
		} else {
			artist = g_strdup(song->artist);
		}
	}

	if(artist == NULL)
	{
		if (strcmp(old_artist, "NONE") != 0)
		{
			if (current_url)
				g_free(current_url);
			current_url = g_strdup("http://www.musicpd.org/");
			webkit_web_view_open(WEBKIT_WEB_VIEW(moz), current_url);
			old_artist = g_strdup("NONE");
		}
		return;
	}

	gchar *esc_artist = wp_clean_for_url(artist);

	if (strcmp(old_artist, esc_artist) != 0)
	{
		gchar *url = g_strdup_printf("http://%s.wikipedia.org/w/api.php?action=opensearch&search=%s&format=xml", locale, esc_artist);
		g_log(wikipedia_logdomain, G_LOG_LEVEL_DEBUG, "Trying to fetch: %s\n", url);
		gmpc_easy_async_downloader(url, wp_query_callback, NULL);
		g_free(url);

	}
	old_artist = g_strdup(esc_artist);
	g_free(esc_artist);
	g_free(artist);
}
Esempio n. 8
0
static void wp_set_url(char *wp)
{
	gchar *new_url;

	new_url = malloc(strlen(wp) + strlen(WP_SKINSTR) + 1);
	strcpy(new_url, wp);
	strcat(new_url, WP_SKINSTR);

	if (current_url)
		g_free(current_url);
	current_url = soup_uri_decode(new_url);

	webkit_web_view_open(WEBKIT_WEB_VIEW(moz), new_url);
	gtk_widget_show_all(moz);
	g_free(new_url);
}
Esempio n. 9
0
Page* ChromeClient::createWindow(Frame* frame, const FrameLoadRequest& frameLoadRequest, const WindowFeatures& coreFeatures)
{
    WebKitWebView* webView = 0;

    g_signal_emit_by_name(m_webView, "create-web-view", kit(frame), &webView);

    if (!webView)
        return 0;

    WebKitWebWindowFeatures* webWindowFeatures = webkit_web_window_features_new_from_core_features(coreFeatures);
    g_object_set(webView, "window-features", webWindowFeatures, NULL);
    g_object_unref(webWindowFeatures);

    if (!frameLoadRequest.isEmpty())
        webkit_web_view_open(webView, frameLoadRequest.resourceRequest().url().string().utf8().data());

    return core(webView);
}
Esempio n. 10
0
static void create_browser() {
    browser->browser_window = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (browser->browser_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

    browser->webview = webkit_web_view_new();
    gtk_container_add(GTK_CONTAINER(browser->browser_window), browser->webview);

    g_signal_connect (G_OBJECT (browser->webview), "load-progress-changed", G_CALLBACK (progress_change_cb), browser);
    g_signal_connect (G_OBJECT (browser->webview), "load-committed", G_CALLBACK (load_commit_cb), browser);
    g_signal_connect (G_OBJECT (browser->webview), "hovering-over-link", G_CALLBACK (link_hover_cb), browser);

    WebKitWebSettings* settings = webkit_web_settings_new();
    g_object_set(G_OBJECT(settings), "enable-private-browsing", FALSE, NULL);
    g_object_set(G_OBJECT(settings), "enable-plugins", FALSE, NULL);
    webkit_web_view_set_settings(WEBKIT_WEB_VIEW(browser->webview), settings);

    /* Translators: you may change the web address to get a localized page, if it exists */
    webkit_web_view_open(WEBKIT_WEB_VIEW(browser->webview), _("http://images.google.com"));
}
Esempio n. 11
0
void
html_open_uri(Html *self, const gchar *str_uri)
{
	gchar *full_uri;

	g_return_if_fail(IS_HTML (self));
	g_return_if_fail(str_uri != NULL);

	if (str_uri[0] == '/')
		full_uri = g_strdup_printf("file://%s", str_uri);
	else
		full_uri = g_strdup(str_uri);

	if(g_strcmp0(full_uri, html_get_location(self)) != 0) {
		g_debug("Open uri %s", full_uri);
		webkit_web_view_open (self->webview, full_uri);
	}
	g_free(full_uri);
}
Esempio n. 12
0
void devhelp_plugin_search_code(DevhelpPlugin *self, const gchar *term, const gchar *lang)
{
	gint i;
	gchar *uri, *term_enc, *lang_enc;
	const gchar *google_lang = NULL;

	g_return_if_fail(self != NULL);
	g_return_if_fail(term != NULL);

	if (lang != NULL)
	{
		for (i = 0; i < LANG_MAP_MAX; i++)
		{
			if (g_strcmp0(lang, lang_map[i].geany_name) == 0)
			{
				google_lang = lang_map[i].google_name;
				break;
			}
		}
	}

	if (google_lang != NULL)
	{
		lang_enc = g_uri_escape_string(google_lang, NULL, TRUE);
		term_enc = g_uri_escape_string(term, NULL, TRUE);
		uri = g_strdup_printf("%s?as_q=%s&as_lang=%s", GOOGLE_CODE_SEARCH_URI, term_enc, lang_enc);
		g_free(lang_enc);
		g_free(term_enc);
	}
	else
	{
		term_enc = g_uri_escape_string(term, NULL, TRUE);
		uri = g_strdup_printf("%s?as_q=%s", GOOGLE_CODE_SEARCH_URI, term_enc);
		g_free(term_enc);
	}

	webkit_web_view_open(devhelp_plugin_get_webview(self), uri);
	g_free(uri);

	devhelp_plugin_activate_webview_tab(self);
}
int main (int argc, char* argv[])
{
 gtk_init (&argc, &argv);

 GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
 gtk_box_pack_start(GTK_BOX (vbox), create_toolbar (), FALSE, FALSE, 0);
 gtk_box_pack_start(GTK_BOX (vbox), create_browser (), TRUE, TRUE, 0);
 gtk_box_pack_start(GTK_BOX (vbox), create_statusbar (), FALSE, FALSE, 0);

 main_window = create_window();
 gtk_container_add(GTK_CONTAINER (main_window), vbox);

 gchar* uri = (gchar*) (argc > 1 ? argv[1] : "https://github.com/CoolerVoid/");
 webkit_web_view_open(web_view, uri);

 gtk_widget_grab_focus(GTK_WIDGET(web_view));
 gtk_widget_show_all(main_window);
 gtk_main();

 return 0;
}
/* Show the authentication browser */
void
auth_browser_open_url (AuthBrowser *browser,
                       const char  *url,
                       const char  *stop_url,
                       void       (*callback) (gpointer data, const char *url),
                       gpointer     data)
{
    AuthBrowserPrivate *priv = GET_PRIVATE (browser);

    g_free (priv->stop_url);
    priv->stop_url = g_strdup (stop_url);

    if (callback)
        priv->callback = callback;

    priv->data = data;

    webkit_web_view_open (priv->webview, url);

    gtk_widget_grab_focus (GTK_WIDGET (priv->webview));
    gtk_widget_show_all (priv->window);
}
Esempio n. 15
0
static gint32
webpage_capture (void)
{
  gint32 image = -1;
  gchar *scheme;
  GtkWidget *window;
  GtkWidget *view;
  WebKitWebSettings *settings;
  char *ua_old;
  char *ua;

  if (webpagevals.pixbuf)
    {
      g_object_unref (webpagevals.pixbuf);
      webpagevals.pixbuf = NULL;
    }
  if (webpagevals.error)
    {
      g_error_free (webpagevals.error);
      webpagevals.error = NULL;
    }

  if ((!webpagevals.url) ||
      (strlen (webpagevals.url) == 0))
    {
      g_set_error (&webpagevals.error, 0, 0, _("No URL was specified"));
      return -1;
    }

  scheme = g_uri_parse_scheme (webpagevals.url);
  if (!scheme)
    {
      char *url;

      /* If we were not given a well-formed URL, make one. */

      url = g_strconcat ("http://", webpagevals.url, NULL);
      g_free (webpagevals.url);
      webpagevals.url = url;

      g_free (scheme);
    }

  if (webpagevals.width < 32)
    {
      g_warning ("Width '%d' is too small. Clamped to 32.",
                 webpagevals.width);
      webpagevals.width = 32;
    }
  else if (webpagevals.width > 8192)
    {
      g_warning ("Width '%d' is too large. Clamped to 8192.",
                 webpagevals.width);
      webpagevals.width = 8192;
    }

  window = gtk_offscreen_window_new ();
  gtk_widget_show (window);

  view = webkit_web_view_new ();
  gtk_widget_show (view);

  gtk_widget_set_size_request (view, webpagevals.width, -1);
  gtk_container_add (GTK_CONTAINER (window), view);

  /* Append "GIMP/<GIMP_VERSION>" to the user agent string */
  settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (view));
  g_object_get (settings,
                "user-agent", &ua_old,
                NULL);
  ua = g_strdup_printf ("%s GIMP/%s", ua_old, GIMP_VERSION);
  g_object_set (settings,
                "user-agent", ua,
                NULL);
  g_free (ua_old);
  g_free (ua);

  /* Set font size */
  g_object_set (settings,
                "default-font-size", webpagevals.font_size,
                NULL);

  g_signal_connect (view, "notify::progress",
                    G_CALLBACK (notify_progress_cb),
                    window);
  g_signal_connect (view, "load-error",
                    G_CALLBACK (load_error_cb),
                    window);
  g_signal_connect (view, "notify::load-status",
                    G_CALLBACK (notify_load_status_cb),
                    window);

  gimp_progress_init_printf (_("Downloading webpage '%s'"), webpagevals.url);

  webkit_web_view_open (WEBKIT_WEB_VIEW (view),
                        webpagevals.url);

  gtk_main ();

  gtk_widget_destroy (window);

  gimp_progress_update (1.0);

  if (webpagevals.pixbuf)
    {
      gint width;
      gint height;
      gint32 layer;

      gimp_progress_init_printf (_("Transferring webpage image for '%s'"),
                                 webpagevals.url);

      width  = gdk_pixbuf_get_width (webpagevals.pixbuf);
      height = gdk_pixbuf_get_height (webpagevals.pixbuf);

      image = gimp_image_new (width, height, GIMP_RGB);

      gimp_image_undo_disable (image);
      layer = gimp_layer_new_from_pixbuf (image, _("Webpage"), webpagevals.pixbuf,
                                          100, GIMP_NORMAL_MODE, 0.0, 1.0);
      gimp_image_insert_layer (image, layer, -1, 0);
      gimp_image_undo_enable (image);

      g_object_unref (webpagevals.pixbuf);
      webpagevals.pixbuf = NULL;

      gimp_progress_update (1.0);
    }

  return image;
}
Esempio n. 16
0
static void activate_uri_entry_cb(GtkWidget* entry, gpointer data) {
    const gchar* uri = gtk_entry_get_text(GTK_ENTRY (entry));
    g_assert (uri);
    webkit_web_view_open(WEBKIT_WEB_VIEW(browser->webview), uri);
}
Esempio n. 17
0
void WebkitBrowser::go_to(const ustring & url)
{
  webkit_web_view_open (WEBKIT_WEB_VIEW(webview), url.c_str());
}
Esempio n. 18
0
static void bookmark_menu_item_cb(GtkMenuItem* mi, gpointer data) {
    webkit_web_view_open(WEBKIT_WEB_VIEW(browser->webview), gtk_menu_item_get_label(mi));
}
Esempio n. 19
0
void plat_load_url(struct gtk_state* state, void* ptr, int sz) {
  webkit_web_view_open(WEBKIT_WEB_VIEW(state->web_view), (const gchar*)ptr);
}