Exemple #1
0
static void
title_cb (GObject *obj, GParamSpec *spec, GtkWindow *dlg)
{
  const gchar *title = webkit_web_view_get_title (view);
  if (title)
    gtk_window_set_title (dlg, title);
}
Exemple #2
0
bool
cmd_bookmark_add(girara_session_t* session, girara_list_t* argument_list)
{
  g_return_val_if_fail(session != NULL, false);
  g_return_val_if_fail(session->global.data != NULL, false);
  jumanji_t* jumanji = session->global.data;

  if (jumanji->database == NULL) {
    return false;
  }

  int number_of_arguments = girara_list_size(argument_list);
  char* url   = NULL;
  char* title = NULL;

  if (number_of_arguments > 0) {
    url   = girara_list_nth(argument_list, 0);
    title = (number_of_arguments > 1) ? girara_list_nth(argument_list, 1) : NULL;
  } else {
    jumanji_tab_t* tab = jumanji_tab_get_current(jumanji);
    if (tab != NULL && tab->web_view != NULL) {
      url   = (char*) webkit_web_view_get_uri(WEBKIT_WEB_VIEW(tab->web_view));
      title = (char*) webkit_web_view_get_title(WEBKIT_WEB_VIEW(tab->web_view));
    }
  }

  gchar* escaped_url = g_markup_escape_text(url, -1);

  jumanji_db_bookmark_add(jumanji->database, url, title);
  girara_notify(session, GIRARA_INFO, "Added bookmark: %s", escaped_url);

  g_free(escaped_url);

  return true;
}
Exemple #3
0
static void
notify_title_cb (WebKitWebView* web_view, GParamSpec* pspec, gpointer data)
{
    if (main_title)
        g_free (main_title);
    main_title = g_strdup (webkit_web_view_get_title(web_view));
    update_title (GTK_WINDOW (main_window));
}
static void titleChanged(WebKitWebView* webView, GParamSpec*, WebViewTest* test)
{
    if (!test->m_expectedTitle.isNull() && test->m_expectedTitle != webkit_web_view_get_title(webView))
        return;

    g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(titleChanged), test);
    g_main_loop_quit(test->m_mainLoop);
}
Exemple #5
0
void cb_wv_notify_title(WebKitWebView *view, GParamSpec *pspec, Browser *b)
{
	const char *title = webkit_web_view_get_title(b->UI.view);
	if (title) {
		/* update state */
		browser_update(b);
	}
}
Exemple #6
0
static void webViewTitleChanged(WebKitWebView *webView, GParamSpec *pspec, BrowserWindow *window)
{
    g_print("bbbbbbb\n");
    const char *title = webkit_web_view_get_title(webView);
    gtk_window_set_title(GTK_WINDOW(window), title ? title : defaultWindowTitle);
    g_print("cccccccccc\n");
//   HS_history_new(window, webView); //add by zlf
   g_print("ddddddddddd\n");
}
Exemple #7
0
JNIEXPORT jintLong JNICALL WebKitGTK_NATIVE(_1webkit_1web_1view_1get_1title)
	(JNIEnv *env, jclass that, jintLong arg0)
{
	jintLong rc = 0;
	WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1web_1view_1get_1title_FUNC);
	rc = (jintLong)webkit_web_view_get_title((WebKitWebView *)arg0);
	WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1web_1view_1get_1title_FUNC);
	return rc;
}
Exemple #8
0
void onMouseTargetChange(WebKitWebView *webview, WebKitHitTestResult *hitTest, guint modifiers, RuskWindow *rusk)
{
	if(webkit_hit_test_result_context_is_link(hitTest))
	{
		gtk_window_set_title(rusk->window, webkit_hit_test_result_get_link_uri(hitTest));
	}else
	{
		gtk_window_set_title(rusk->window, webkit_web_view_get_title(rusk->webview));
	}
}
Exemple #9
0
void
title_change_cb (WebKitWebView* web_view, GParamSpec param_spec) {
    (void) web_view;
    (void) param_spec;
    const gchar *title = webkit_web_view_get_title(web_view);
    if (uzbl.gui.main_title)
        g_free (uzbl.gui.main_title);
    uzbl.gui.main_title = title ? g_strdup (title) : g_strdup ("(no title)");
    update_title();
    send_event(TITLE_CHANGED, uzbl.gui.main_title, NULL);
}
Exemple #10
0
static void updateTitle(GtkWindow* window, WebKitWebView* webView)
{
    GString *string = g_string_new(webkit_web_view_get_title(webView));
    gdouble loadProgress = webkit_web_view_get_progress(webView) * 100;
    g_string_append(string, " - WebKit Launcher");
    if (loadProgress < 100)
        g_string_append_printf(string, " (%f%%)", loadProgress);
    gchar *title = g_string_free(string, FALSE);
    gtk_window_set_title(window, title);
    g_free(title);
}
Exemple #11
0
static VALUE
WebView_title(VALUE self)
{
  VALUE __p_retval = Qnil;
  WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));

#line 282 "/home/ngl/Progetti/gtk-webkit-ruby/ext/webkit/webkit.cr"
  do { __p_retval =  rb_str_new2(webkit_web_view_get_title(_self)); goto out; } while(0);
out:
  return __p_retval;
}
Exemple #12
0
/**
 * ephy_title_box_set_web_view:
 * @title_box: an #EphyTitleBox
 * @web_view: a #WebKitWebView
 *
 * Sets the web view of the @title_box.
 **/
void
ephy_title_box_set_web_view (EphyTitleBox  *title_box,
                             WebKitWebView *web_view)
{
  const gchar         *title;

  g_return_if_fail (EPHY_IS_TITLE_BOX (title_box));

  if (title_box->web_view == web_view)
    return;

  LOG ("ephy_title_box_set_web_view title-box %p web_view %p", title_box, web_view);

  if (title_box->web_view != NULL) {
    g_signal_handlers_disconnect_by_func (title_box->entry,
                                          G_CALLBACK (ephy_title_box_entry_key_press_cb),
                                          title_box);
    g_signal_handlers_disconnect_by_func (title_box->web_view,
                                          G_CALLBACK (ephy_title_box_view_focus_in_cb),
                                          title_box);
    if (title_box->title_sig_id > 0)
      g_signal_handler_disconnect (title_box->web_view, title_box->title_sig_id);

    g_clear_object (&title_box->title_binding);

    g_object_remove_weak_pointer (G_OBJECT (title_box->web_view), (gpointer *)&title_box->web_view);
  }

  title_box->web_view = web_view;

  if (web_view == NULL)
    return;

  g_object_add_weak_pointer (G_OBJECT (web_view), (gpointer *)&title_box->web_view);

  title = webkit_web_view_get_title (web_view);

  ephy_title_box_set_mode (title_box, title && *title != '\0' ?
                           EPHY_TITLE_BOX_MODE_TITLE : EPHY_TITLE_BOX_MODE_LOCATION_ENTRY);

  title_box->title_binding = g_object_bind_property (title_box->web_view, "title",
                                                     title_box->title, "label",
                                                     G_BINDING_SYNC_CREATE);

  title_box->title_sig_id = g_signal_connect (title_box->web_view, "notify::title",
                                              G_CALLBACK (ephy_title_box_title_changed_cb),
                                              title_box);
  g_signal_connect (title_box->entry, "key-press-event",
                    G_CALLBACK (ephy_title_box_entry_key_press_cb), title_box);
  g_signal_connect (title_box->web_view, "focus-in-event",
                    G_CALLBACK (ephy_title_box_view_focus_in_cb), title_box);
}
Exemple #13
0
void browser_update(Browser *b)
{
	const char *view_title;
	char *title = NULL;

	/* update title */
	view_title = webkit_web_view_get_title(b->UI.view);
	if (view_title) {
		asprintf(&title, "%s%s", view_title, (private_browsing) ? " [P]" : "");
	}
	gtk_window_set_title(GTK_WINDOW(b->UI.window), (title && strlen(title) > 0) ? title : "ripcurl");
	free(title);

	browser_update_uri(b);
	browser_update_position(b);
}
Exemple #14
0
void
changed_title(GObject *obj, GParamSpec *pspec, gpointer data)
{
    const gchar *t, *u;
    struct Client *c = (struct Client *)data;

    u = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
    t = webkit_web_view_get_title(WEBKIT_WEB_VIEW(c->web_view));

    u = u == NULL ? __NAME__ : u;
    u = u[0] == 0 ? __NAME__ : u;

    t = t == NULL ? u : t;
    t = t[0] == 0 ? u : t;

    gtk_window_set_title(GTK_WINDOW(c->win), t);
}
static void notify_title_cb (WebKitWebView* web_view, GParamSpec* pspec, Document_Webkit *doc)
{
  Document_WebkitDetails *docdet = DOCUMENT_WEBKIT_GET_PRIVATE(doc);
  gchar *main_title = g_strdup (webkit_web_view_get_title(web_view));
  gchar *short_filename = NULL;
  if (main_title){
    if (docdet->type==TAB_HELP){
      short_filename = g_strconcat(_("Help: "), main_title, NULL);
    } else {
      short_filename = g_strconcat(_("Preview: "), main_title, NULL);
    }
    g_object_set(doc, "short_filename", short_filename, NULL);
    gtk_label_set_text(GTK_LABEL(docdet->label), short_filename);
    g_signal_emit (G_OBJECT (doc), signals[SAVE_UPDATE], 0);
    g_free(main_title);
    g_free(short_filename);
  }
}
Exemple #16
0
static void collecturiCallback(BrowserWindow *window, GtkEntryIconPosition iconPosition, GdkEvent *event)
{
    if (iconPosition == GTK_ENTRY_ICON_SECONDARY) { 
		 g_print("add bookmarkbutton\n");
		/*
		GtkWidget *bookmarkbtn = gtk_button_new();
		GtkBox *hBox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));`
		
        GtkWidget *image = gtk_image_new_from_pixbuf(window->favicon);
		GtkWidget *lab = gtk_label_new(webkit_web_view_get_title(window->webView));
		gtk_box_pack_start(hBox, image, FALSE, FALSE, 0);
		gtk_box_pack_start(hBox, lab, FALSE, FALSE, 0);
		gtk_container_add(GTK_CONTAINER(bookmarkbtn), hBox);
		gtk_box_pack_start(window->bookmarkbox, bookmarkbtn, FALSE, FALSE, 0);
		
		gtk_widget_show_all(bookmarkbtn);
		*/
		
		 GtkToolItem *item = gtk_tool_button_new(NULL, "");
    GtkWidget *image = gtk_image_new_from_pixbuf(window->favicon);
    cairo_surface_t* fivacon = webkit_web_view_get_favicon(window->webView);
    gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (item), fivacon);

    GtkWidget* label = gtk_label_new (webkit_web_view_get_title(window->webView));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_label_set_max_width_chars (GTK_LABEL (label), 25);
    gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_MIDDLE);
    gtk_widget_show (label);
    gtk_tool_button_set_label_widget (GTK_TOOL_BUTTON (item), label);
    //        g_signal_connect_swapped(item, "clicked", G_CALLBACK(goBackCallback), (gpointer)window);
    gtk_toolbar_insert(GTK_TOOLBAR(window->bookmarkbar), item, -1);
    gtk_widget_show_all(GTK_WIDGET(item));

		/*
        GtkToolItem *item = gtk_tool_button_new_from_stock(GTK_STOCK_HOME);
//        g_signal_connect_swapped(item, "clicked", G_CALLBACK(goBackCallback), (gpointer)window);
        gtk_toolbar_insert(GTK_TOOLBAR(window->bookmarkbar), item, -1);
        gtk_widget_show(GTK_WIDGET(item));
        */
        
//        GdkEventButton *eventButton = (GdkEventButton *)event;
//todo 弹出对话框
    }
}
Exemple #17
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;
}
Exemple #18
0
static gboolean webViewEnterFullScreen(WebKitWebView *webView, BrowserWindow *window)
{
    gchar *titleOrURI = g_strdup(webkit_web_view_get_title(window->webView));
    if (!titleOrURI)
        titleOrURI = getExternalURI(webkit_web_view_get_uri(window->webView));
    gchar *message = g_strdup_printf("%s is now full screen. Press ESC or f to exit.", titleOrURI);
    gtk_label_set_text(GTK_LABEL(window->fullScreenMessageLabel), message);
    g_free(titleOrURI);
    g_free(message);

    gtk_widget_show(window->fullScreenMessageLabel);

    window->fullScreenMessageLabelId = g_timeout_add_seconds(2, (GSourceFunc)fullScreenMessageTimeoutCallback, window);
    g_source_set_name_by_id(window->fullScreenMessageLabelId, "[WebKit] fullScreenMessageTimeoutCallback");
    gtk_widget_hide(window->toolbar);
    window->searchBarVisible = gtk_widget_get_visible(GTK_WIDGET(window->searchBar));
    browser_search_bar_close(window->searchBar);

    return FALSE;
}
Exemple #19
0
static void
ephy_title_box_title_changed_cb (GObject    *gobject,
                                 GParamSpec *pspec,
                                 gpointer    user_data)
{
  EphyTitleBox        *title_box = EPHY_TITLE_BOX (user_data);
  WebKitWebView       *web_view = WEBKIT_WEB_VIEW (gobject);
  const gchar         *title;

  LOG ("notify::title web_view %p title-box %p\n", web_view, title_box);

  title = webkit_web_view_get_title (web_view);

  if (gtk_widget_is_focus (title_box->entry) ||
      !title || *title == '\0') {
    ephy_title_box_set_mode (title_box, EPHY_TITLE_BOX_MODE_LOCATION_ENTRY);
    return;
  }

  ephy_title_box_set_mode (title_box, EPHY_TITLE_BOX_MODE_TITLE);
}
Exemple #20
0
/**
 * ephy_title_box_set_mode:
 * @title_box: an #EphyTitleBox
 * @mode: an #EphyTitleBoxMode
 *
 * Sets the mode of the @title_box.
 **/
void
ephy_title_box_set_mode (EphyTitleBox    *title_box,
                         EphyTitleBoxMode mode)
{
  const gchar *title;

  g_return_if_fail (EPHY_IS_TITLE_BOX (title_box));

  ephy_title_box_cancel_switch_to_entry_after_double_click_time (title_box);

  if (!title_box->location_disabled) {
    const gchar *uri;

    uri = title_box->web_view ? webkit_web_view_get_uri (title_box->web_view) : NULL;
    if (!uri || g_str_has_prefix (uri, "about:") ||
        g_str_has_prefix (uri, "ephy-about:")) {
      mode = EPHY_TITLE_BOX_MODE_LOCATION_ENTRY;
    }
  } else
    mode = EPHY_TITLE_BOX_MODE_TITLE;

  if (title_box->mode == mode)
    return;

  if (mode == EPHY_TITLE_BOX_MODE_TITLE) {
    /* Don't allow showing title mode if there is no title. */
    title = title_box->web_view ? webkit_web_view_get_title (title_box->web_view) : NULL;
    if (!title || !*title)
      return;
  }

  LOG ("ephy_title_box_set_mode title-box %p mode %u", title_box, mode);

  title_box->mode = mode;

  gtk_stack_set_visible_child_name (GTK_STACK (title_box),
                                    mode == EPHY_TITLE_BOX_MODE_LOCATION_ENTRY ? "address-bar" : "title-bar");

  g_object_notify_by_pspec (G_OBJECT (title_box), object_properties[PROP_MODE]);
}
Exemple #21
0
static void load_changed(WebKitWebView *web_view, WebKitLoadEvent load_event, gpointer user_data) {
    if (load_event != WEBKIT_LOAD_FINISHED) {
        return;
    }

    if (mhtml_file != NULL) {
        GFile *f = g_file_new_for_path(mhtml_file);
        webkit_web_view_save_to_file(web_view, f, WEBKIT_SAVE_MODE_MHTML, NULL, mhtml_finished, NULL);
    }

    if (html_file != NULL) {
        WebKitWebResource *wr = webkit_web_view_get_main_resource(web_view);
        webkit_web_resource_get_data(wr, NULL, html_finished, NULL);
    }

    if (png_file != NULL) {
        webkit_web_view_get_snapshot(
            web_view,
            WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT,
            WEBKIT_SNAPSHOT_OPTIONS_NONE,
            NULL,
            png_finished,
            NULL
        );
    }

    if (title_file != NULL) {
        const gchar *title = webkit_web_view_get_title(web_view);
        GString *s = g_string_new(title);
        g_string_append_c(s, '\n');
        FILE *f = open_file(title_file, "w");
        if (fwrite(s->str, s->len, 1, f) != 1) {
            errx(1, "error saving title");
        }
        fclose(f);
        done();
    }
}
    bool getPageList()
    {
        loadHtml("<script type=\"text/javascript\">\n"
            "var pages;\n"
            "var xhr = new XMLHttpRequest;\n"
            "xhr.open(\"GET\", \"/pagelist.json\");\n"
            "xhr.onload = function(e) {\n"
                "if (xhr.status == 200) {\n"
                    "pages = JSON.parse(xhr.responseText);\n"
                    "document.title = \"OK\";\n"
                "} else \n"
                    "document.title = \"FAIL\";\n"
                "}\n"
            "xhr.send();\n"
            "</script>\n",
            "http://127.0.0.1:2999/");

        waitUntilTitleChanged();

        if (!strcmp(webkit_web_view_get_title(m_webView), "OK"))
            return true;

        return false;
    }
const char *
oauth_ask_authorization_dialog_get_title (OAuthAskAuthorizationDialog *self)
{
	return webkit_web_view_get_title (WEBKIT_WEB_VIEW (self->priv->view));
}
Exemple #24
0
wxString wxWebViewWebKit::GetCurrentTitle() const
{
    return wxString::FromUTF8(webkit_web_view_get_title(m_web_view));
}
Exemple #25
0
void onTitleChange(WebKitWebView *webview, GParamSpec *param, RuskWindow *rusk)
{
	gtk_window_set_title(rusk->window, webkit_web_view_get_title(rusk->webview));
}