Exemplo n.º 1
0
static EphyFindResult
real_find (EphyFindToolbarPrivate *priv,
	   EphyFindDirection direction)
{
        WebKitWebView *web_view = priv->web_view;
        gboolean case_sensitive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->case_sensitive));
        gboolean forward = (direction == EPHY_FIND_DIRECTION_NEXT);

        if (!priv->find_string || !g_strcmp0 (priv->find_string, ""))
                return EPHY_FIND_RESULT_NOTFOUND;

        if (!webkit_web_view_search_text
            (web_view, priv->find_string, case_sensitive, forward, FALSE)) {
                /* not found, try to wrap */
                if (!webkit_web_view_search_text
                    (web_view, priv->find_string, case_sensitive, forward, TRUE)) {
                        /* there's no result */
                        return EPHY_FIND_RESULT_NOTFOUND;
                } else {
                        /* found wrapped */
                        return EPHY_FIND_RESULT_FOUNDWRAPPED;
                }
        }

        return EPHY_FIND_RESULT_FOUND;
}
Exemplo n.º 2
0
void browser_search_and_highlight(Browser *b, char *input, int direction)
{
	static char *search_text = NULL;
	gboolean forward;

	if (input) {
		/* free search_text from previous search */
		if (search_text) {
			free(search_text);
		}
		search_text = strdup(input);
	}

	if (search_text == NULL) {
		/*
		 * the only way this should happen is if sc_search is called
		 * and no searches have been performed during this session.
		 */
		return;
	}

	forward = (direction == NEXT) ? TRUE : FALSE;

	/* TODO: set case-sensitivity with "/.../c" */
	webkit_web_view_search_text(b->UI.view, search_text, FALSE, forward, TRUE);
}
Exemplo n.º 3
0
gboolean command_search(const Arg *arg)
{
    static short dir;   /* last direction 1 forward, -1 backward*/
    const char *query;
    static gboolean newsearch = true;
    gboolean forward;

    if (arg->i == 0) {
#ifdef FEATURE_SEARCH_HIGHLIGHT
        webkit_web_view_unmark_text_matches(vb.gui.webview);
        vb.state.search_matches = 0;
        vb_update_statusbar();
#endif
        newsearch = true;
        return true;
    }

    /* copy search query for later use */
    if (arg->s) {
        /* set search direction only when the searching is started */
        dir   = arg->i > 0 ? 1 : -1;
        query = arg->s;
        /* add new search query to history and search register */
        vb_register_add('/', query);
        history_add(HISTORY_SEARCH, query, NULL);
    } else {
        /* no search phrase given - continue a previous search */
        query = vb_register_get('/');
    }

    forward = (arg->i * dir) > 0;

    if (query) {
        unsigned int count = abs(arg->i);
        if (newsearch) {
#ifdef FEATURE_SEARCH_HIGHLIGHT
            /* highlight matches if the search is started new or continued
             * after switch to normal mode which calls this function with
             * COMMAND_SEARCH_OFF */
            vb.state.search_matches = webkit_web_view_mark_text_matches(vb.gui.webview, query, false, 0);
            webkit_web_view_set_highlight_text_matches(vb.gui.webview, true);
            vb_update_statusbar();
#endif
            newsearch = false;
            /* skip first search because this is done during typing in ex
             * mode, else the search will mark the next match as active */
            if (count) {
                count -= 1;
            }
        }

        while (count--) {
            if (!webkit_web_view_search_text(vb.gui.webview, query, false, forward, true)) {
                break;
            }
        };
    }

    return true;
}
Exemplo n.º 4
0
void
find(Client *c, const Arg *arg) {
	const char *s;

	s = getatom(c, findprop);
	gboolean forward = *(gboolean *)arg;
	webkit_web_view_search_text(c->view, s, FALSE, forward, TRUE);
}
Exemplo n.º 5
0
static void
search (const gchar *text,
        gboolean     forward)
{
  if (text)
    webkit_web_view_search_text (WEBKIT_WEB_VIEW (view),
                                 text, FALSE, forward, TRUE);
}
Exemplo n.º 6
0
/* ghtml_find */
gboolean ghtml_find(GtkWidget * widget, char const * text, gboolean sensitive,
		gboolean backwards, gboolean wrap)
{
	GHtml * ghtml;

	ghtml = g_object_get_data(G_OBJECT(widget), "ghtml");
	return webkit_web_view_search_text(WEBKIT_WEB_VIEW(ghtml->view), text,
			sensitive, !backwards, wrap);
}
Exemplo n.º 7
0
Arquivo: uzbl.c Projeto: DuClare/uzbl
static void
search_text (WebKitWebView *page, const char *param) {
    if ((param) && (param[0] != '\0')) {
        strcpy(uzbl.state.searchtx, param);
    }
    if (uzbl.state.searchtx[0] != '\0') {
        printf ("Searching: %s\n", uzbl.state.searchtx);
        webkit_web_view_unmark_text_matches (page);
        webkit_web_view_mark_text_matches (page, uzbl.state.searchtx, FALSE, 0);
        webkit_web_view_set_highlight_text_matches (page, TRUE);
        webkit_web_view_search_text (page, uzbl.state.searchtx, FALSE, TRUE, TRUE);
    }
}
Exemplo n.º 8
0
gboolean wk_html_find_again(WkHtml *html, gboolean forward)
{
#ifdef USE_WEBKIT2
	WebKitFindController *find_controller;
	find_controller = webkit_web_view_get_find_controller(WEBKIT_WEB_VIEW(html));
	webkit_find_controller_search(find_controller,
				      html->priv->find_string,
				      WEBKIT_FIND_OPTIONS_NONE, G_MAXUINT);
#else
	return webkit_web_view_search_text(WEBKIT_WEB_VIEW(html),
					   html->priv->find_string,
					   FALSE, forward, TRUE);
#endif
}
Exemplo n.º 9
0
void
win_find(Win *w, gboolean b) {
    char buf[BUFSIZ];
    unsigned char *p;

    webkit_web_view_unmark_text_matches(w->web);
    if(!atom_get(w, atoms[_OWL_FIND], XA_STRING, sizeof(buf), &p) || !p)
        return;
    memset(&buf, '\0', sizeof(buf));
    strncpy(buf, (char*)p, sizeof(buf));
    XFree(p);
    webkit_web_view_mark_text_matches(w->web, buf, CASEFIND, 0);
    webkit_web_view_set_highlight_text_matches(w->web, TRUE);
    webkit_web_view_search_text(w->web, buf, CASEFIND, b, TRUE);
}
Exemplo n.º 10
0
static gint
luaH_webview_search(lua_State *L)
{
    widget_t *w = luaH_checkudata(L, 1, &widget_class);
    WebKitWebView *view = WEBKIT_WEB_VIEW(GTK_WIDGET(g_object_get_data(G_OBJECT(w->widget), "webview")));
    const gchar *text = luaL_checkstring(L, 2);
    gboolean case_sensitive = luaH_checkboolean(L, 3);
    gboolean forward = luaH_checkboolean(L, 4);
    gboolean wrap = luaH_checkboolean(L, 5);

    webkit_web_view_unmark_text_matches(view);
    webkit_web_view_search_text(view, text, case_sensitive, forward, wrap);
    webkit_web_view_mark_text_matches(view, text, case_sensitive, 0);
    webkit_web_view_set_highlight_text_matches(view, TRUE);
    return 0;
}
Exemplo n.º 11
0
void
search_text (WebKitWebView *page, const gchar *key, const gboolean forward) {
    if (key && (*key != '\0')) {
        if (g_strcmp0 (uzbl.state.searchtx, key) != 0) {
            webkit_web_view_unmark_text_matches (page);
            webkit_web_view_mark_text_matches (page, key, FALSE, 0);
            g_free (uzbl.state.searchtx);
            uzbl.state.searchtx = g_strdup (key);
        }
    }

    if (uzbl.state.searchtx) {
        if (uzbl.state.verbose)
            printf ("Searching: %s\n", uzbl.state.searchtx);
        webkit_web_view_set_highlight_text_matches (page, TRUE);
        webkit_web_view_search_text (page, uzbl.state.searchtx, FALSE, forward, TRUE);
    }
}
Exemplo n.º 12
0
gboolean wk_html_find(WkHtml *html, const gchar *find_string)
{
	if (html->priv->find_string)
		g_free(html->priv->find_string);
	html->priv->find_string = g_strdup(find_string);

#ifdef USE_WEBKIT2
	WebKitFindController *find_controller;

	find_controller = webkit_web_view_get_find_controller(WEBKIT_WEB_VIEW(html));
	webkit_find_controller_search(find_controller, find_string,
				      WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE,
				      G_MAXUINT);
#else
	return webkit_web_view_search_text(WEBKIT_WEB_VIEW(html),
					   find_string, FALSE, TRUE, TRUE);
#endif
}
Exemplo n.º 13
0
static void
html_editor_find_dialog_find_cb (EHTMLEditorFindDialog *dialog)
{
	gboolean found;
	EHTMLEditor *editor;
	EHTMLEditorView *view;

	editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
	view = e_html_editor_get_view (editor);
	found = webkit_web_view_search_text (
			WEBKIT_WEB_VIEW (view),
			gtk_entry_get_text (
				GTK_ENTRY (dialog->priv->entry)),
			gtk_toggle_button_get_active (
				GTK_TOGGLE_BUTTON (
					dialog->priv->case_sensitive)),
			!gtk_toggle_button_get_active (
				GTK_TOGGLE_BUTTON (
					dialog->priv->backwards)),
			gtk_toggle_button_get_active (
				GTK_TOGGLE_BUTTON (
					dialog->priv->wrap_search)));

	gtk_widget_set_sensitive (dialog->priv->find_button, found);

	/* We give focus to WebKit so that the selection is highlited.
	 * Without focus selection is not visible (at least with my default
	 * color scheme). The focus in fact is not given to WebKit, because
	 * this dialog is modal, but it satisfies it in a way that it paints
	 * the selection :) */
	gtk_widget_grab_focus (GTK_WIDGET (view));

	if (!found) {
		gtk_label_set_label (
			GTK_LABEL (dialog->priv->result_label),
			N_("No match found"));
		gtk_widget_show (dialog->priv->result_label);
	}
}
Exemplo n.º 14
0
static void
search_bar_find (ESearchBar *search_bar,
                 gboolean search_forward)
{
	EWebView *web_view;
	GtkWidget *widget;
	gboolean case_sensitive;
	gboolean wrapped = FALSE;
	gboolean success;
	gchar *text;
	guint matches;

	web_view = e_search_bar_get_web_view (search_bar);
	case_sensitive = e_search_bar_get_case_sensitive (search_bar);
	text = e_search_bar_get_text (search_bar);

	if (text == NULL || *text == '\0') {
		e_search_bar_clear (search_bar);
		g_free (text);
		return;
	}

	webkit_web_view_unmark_text_matches (
		WEBKIT_WEB_VIEW (web_view));
	matches = webkit_web_view_mark_text_matches (
		WEBKIT_WEB_VIEW (web_view),
		text, case_sensitive, 0);
	webkit_web_view_set_highlight_text_matches (
		WEBKIT_WEB_VIEW (web_view), TRUE);
	search_bar_update_matches (search_bar, matches);

	success = webkit_web_view_search_text (
		WEBKIT_WEB_VIEW (web_view),
		text, case_sensitive, search_forward, FALSE);

	if (!success)
		wrapped = webkit_web_view_search_text (
			WEBKIT_WEB_VIEW (web_view),
			text, case_sensitive, search_forward, TRUE);

	g_free (search_bar->priv->active_search);
	search_bar->priv->active_search = text;

	gtk_widget_set_sensitive (search_bar->priv->next_button, matches != 0);
	gtk_widget_set_sensitive (search_bar->priv->prev_button, matches != 0);

	g_object_notify (G_OBJECT (search_bar), "active-search");

	/* Update wrapped label visibility. */
	widget = search_bar->priv->wrapped_next_box;

	if (wrapped && search_forward)
		gtk_widget_show (widget);
	else
		gtk_widget_hide (widget);

	widget = search_bar->priv->wrapped_prev_box;

	if (wrapped && !search_forward)
		gtk_widget_show (widget);
	else
		gtk_widget_hide (widget);
}
Exemplo n.º 15
0
void document_webkit_incremental_search (Documentable  *doc, gchar *current_text, gboolean advancing)
{
  g_return_if_fail(doc);
  Document_WebkitDetails *docdet = DOCUMENT_WEBKIT_GET_PRIVATE(doc);
  webkit_web_view_search_text (WEBKIT_WEB_VIEW(docdet->help_view), current_text, FALSE, advancing, TRUE);
}
Exemplo n.º 16
0
static void searchText(WebKitWebView* webView, gchar* searchString) {
	webkit_web_view_unmark_text_matches(webView);
	webkit_web_view_search_text(webView, searchString, false, true, true);
	webkit_web_view_mark_text_matches(webView, searchString, false, 0);
	webkit_web_view_set_highlight_text_matches(webView, true);
}
Exemplo n.º 17
0
long wxWebViewWebKit::Find(const wxString& text, int flags)
{
    bool newSearch = false;
    if(text != m_findText || 
       (flags & wxWEBVIEW_FIND_MATCH_CASE) != (m_findFlags & wxWEBVIEW_FIND_MATCH_CASE))
    {
        newSearch = true;
        //If it is a new search we need to clear existing highlights
        webkit_web_view_unmark_text_matches(m_web_view);
        webkit_web_view_set_highlight_text_matches(m_web_view, false);
    }

    m_findFlags = flags;
    m_findText = text;

    //If the search string is empty then we clear any selection and highlight
    if(text == "")
    {
        webkit_web_view_unmark_text_matches(m_web_view);
        webkit_web_view_set_highlight_text_matches(m_web_view, false);
        ClearSelection();
        return wxNOT_FOUND;
    }

    bool wrap = false, matchCase = false, forward = true;
    if(flags & wxWEBVIEW_FIND_WRAP)
        wrap = true;
    if(flags & wxWEBVIEW_FIND_MATCH_CASE)
        matchCase = true;
    if(flags & wxWEBVIEW_FIND_BACKWARDS)
        forward = false;

    if(newSearch)
    {
        //Initially we mark the matches to know how many we have
        m_findCount = webkit_web_view_mark_text_matches(m_web_view, wxGTK_CONV(text), matchCase, 0);
        //In this case we return early to match IE behaviour
        m_findPosition = -1;
        return m_findCount;
    }
    else
    {
        if(forward)
            m_findPosition++;
        else
            m_findPosition--;
        if(m_findPosition < 0)
            m_findPosition += m_findCount;
        if(m_findPosition > m_findCount)
            m_findPosition -= m_findCount;
    }

    //Highlight them if needed
    bool highlight = flags & wxWEBVIEW_FIND_HIGHLIGHT_RESULT ? true : false;
    webkit_web_view_set_highlight_text_matches(m_web_view, highlight);     

    if(!webkit_web_view_search_text(m_web_view, wxGTK_CONV(text), matchCase, forward, wrap))
    {
        m_findPosition = -1;
        ClearSelection();
        return wxNOT_FOUND;
    }
    return newSearch ? m_findCount : m_findPosition;
}
Exemplo n.º 18
0
gboolean ygtk_html_wrap_search_next (GtkWidget *widget, const gchar *text)
{
	WebKitWebView *view = WEBKIT_WEB_VIEW (widget);
	return webkit_web_view_search_text (view, text, FALSE, TRUE, TRUE);
}
Exemplo n.º 19
0
gboolean document_webkit_search_text (Documentable  *doc, const gchar *text, gboolean checkwholedoc, gboolean checkcase, gboolean checkwholeword, gboolean checkregex)
{
  g_return_val_if_fail(doc, FALSE);
  Document_WebkitDetails *docdet = DOCUMENT_WEBKIT_GET_PRIVATE(doc);
  return webkit_web_view_search_text (WEBKIT_WEB_VIEW(docdet->help_view), text, checkcase, TRUE, checkwholeword);
}
Exemplo n.º 20
0
Arquivo: surf.c Projeto: sr/surf
gboolean
keypress(GtkWidget* w, GdkEventKey *ev, gpointer d) {
    Client *c = (Client *)d;

    if(ev->type != GDK_KEY_PRESS)
        return FALSE;
    if(GTK_WIDGET_HAS_FOCUS(c->searchbar)) {
        switch(ev->keyval) {
        case GDK_Escape:
            hidesearch(c);
            return TRUE;
        case GDK_Return:
            webkit_web_view_search_text(c->view,
                                        gtk_entry_get_text(GTK_ENTRY(c->searchbar)),
                                        FALSE,
                                        !(ev->state & GDK_SHIFT_MASK),
                                        TRUE);
            return TRUE;
        case GDK_Left:
        case GDK_Right:
        case GDK_r:
            return FALSE;
        }
    }
    else if(GTK_WIDGET_HAS_FOCUS(c->urlbar)) {
        switch(ev->keyval) {
        case GDK_Escape:
            hideurl(c);
            return TRUE;
        case GDK_Return:
            loaduri(c, gtk_entry_get_text(GTK_ENTRY(c->urlbar)));
            hideurl(c);
            return TRUE;
        case GDK_Left:
        case GDK_Right:
        case GDK_r:
            return FALSE;
        }
    }
    else if(ev->state == GDK_CONTROL_MASK || ev->state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) {
        switch(ev->keyval) {
        case GDK_r:
        case GDK_R:
            if((ev->state & GDK_SHIFT_MASK))
                webkit_web_view_reload_bypass_cache(c->view);
            else
                webkit_web_view_reload(c->view);
            return TRUE;
        case GDK_b:
            return TRUE;
        case GDK_g:
            showurl(c);
            return TRUE;
        case GDK_slash:
            showsearch(c);
            return TRUE;
        case GDK_Left:
            webkit_web_view_go_back(c->view);
            return TRUE;
        case GDK_Right:
            webkit_web_view_go_forward(c->view);
            return TRUE;
        }
    }
    else {
        switch(ev->keyval) {
        case GDK_k:
            webkit_web_view_move_cursor(c->view, GTK_MOVEMENT_DISPLAY_LINES, -1);
            return TRUE;
        case GDK_j:
            webkit_web_view_move_cursor(c->view, GTK_MOVEMENT_DISPLAY_LINES, 1);
            return TRUE;
        }
    }
    return FALSE;
}