- 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:
- 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:
- return FALSE;
- }
- }
- if(ev->state & GDK_CONTROL_MASK) {
- switch(ev->keyval) {
- case GDK_p:
- gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), pasteurl, c);
- return TRUE;
- case GDK_y:
- gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), webkit_web_view_get_uri(c->view), -1);
- return TRUE;
- 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_plus:
- case GDK_equal:
- webkit_web_view_zoom_in(c->view);
- return TRUE;
- case GDK_minus:
- webkit_web_view_zoom_out(c->view);
- return TRUE;
- case GDK_0:
- webkit_web_view_set_zoom_level(c->view, 1.0);
- return TRUE;
- case GDK_n:
- case GDK_N:
- 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:
- 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_Escape:
- stop(c);
- return TRUE;
+ if(GTK_WIDGET_HAS_FOCUS(c->searchbar))
+ focus = SEARCHBAR;
+ else if(GTK_WIDGET_HAS_FOCUS(c->urlbar))
+ focus = URLBAR;
+ else
+ focus = BROWSER;
+ for(i = 0; i < LENGTH(keys); i++) {
+ if(focus & keys[i].focus && ev->keyval == keys[i].keyval &&
+ (ev->state == keys[i].mod || ev->state & keys[i].mod)
+ && keys[i].func) {
+ keys[i].func(c, &(keys[i].arg));
+ processed = TRUE;