diff --git a/config.h b/config.h index 65dda04..4b97763 100644 --- a/config.h +++ b/config.h @@ -8,10 +8,12 @@ static const char *homepage = "https://duckduckgo.com"; #define MODKEY GDK_CONTROL_MASK static Key keys[] = { - { MODKEY, GDK_KEY_h, goback }, - { MODKEY, GDK_KEY_l, goforward }, - { MODKEY, GDK_KEY_y, copy_url }, - { MODKEY, GDK_KEY_p, paste_url }, - { 0, GDK_KEY_F11, fullscreen }, - { MODKEY, GDK_KEY_e, search } + { MODKEY, GDK_KEY_h, goback }, + { MODKEY, GDK_KEY_l, goforward }, + { MODKEY, GDK_KEY_y, copy_url }, + { MODKEY, GDK_KEY_p, paste_url }, + { MODKEY, GDK_KEY_e, search }, + { MODKEY, GDK_KEY_equal, zoomin }, + { MODKEY, GDK_KEY_minus, zoomout }, + { 0, GDK_KEY_F11, fullscreen }, }; diff --git a/keyconf.h b/keyconf.h index 948a9b9..f33e1f7 100644 --- a/keyconf.h +++ b/keyconf.h @@ -18,5 +18,7 @@ enum { paste_url, fullscreen, inspector, - search + search, + zoomin, + zoomout }; diff --git a/makefile b/makefile index d413d37..f0a417b 100644 --- a/makefile +++ b/makefile @@ -1,9 +1,24 @@ -CC = clang -CFLAGS = `pkg-config --cflags gtk4 webkit2gtk-5.0 x11` -LIBS = `pkg-config --libs gtk4 webkit2gtk-5.0 x11` +CC = clang +CFLAGS = `pkg-config --cflags gtk4 webkit2gtk-5.0 x11 ` +LIBS = `pkg-config --libs gtk4 webkit2gtk-5.0 x11` +GTKFLAGS = -Dgtk_doc=false -Dintrospection=false \ + -DG_DISABLE_CAST_CHECKS \ + -Dcloudproviders=false \ + -DGTK_DISABLE_DEPRECATED \ + -GDK_PIXBUF_DISABLE_DEPRECATED \ + -G_DISABLE_DEPRECATED -DENABLE_GLES2=ON \ + -DENABLE_GEOLOCATION=OFF -DENABLE_PLUGIN_PROCESS_GTK2=OFF \ + -DPORT=GTK \ + -Dforce_posix_threads=true \ + -Dman=false \ + -Dxinerama=false \ + -Dcolord=false \ + -Db_coverage=false \ + -Ddebug=false + all: - ${CC} -fPIC -O3 -o rose *.c $(CFLAGS) $(LIBS) + ${CC} -fPIC -Os -o rose *.c $(CFLAGS) $(LIBS) $(GTKFLAGS) strip ./rose install: all diff --git a/webview.c b/webview.c index 87b6b86..5590cf0 100644 --- a/webview.c +++ b/webview.c @@ -113,12 +113,16 @@ GtkWidget* rose_webview_new() WebKitUserContentManager *contentmanager; WebKitSettings *settings = webkit_settings_new_with_settings( - "auto-load-images", true, - "enable-back-forward-navigation-gestures", true, - "enable-developer-extras", true, - "enable-media-stream", true, + "auto-load-images", TRUE, + "enable-back-forward-navigation-gestures", TRUE, + "enable-developer-extras", TRUE, + "enable-media-stream", TRUE, + "enable-plugins", FALSE, + "enable-dns-prefetching", TRUE, + "enable-smooth-scrolling", TRUE, + "media-content-types-requiring-hardware-support", "video:/mp4;codecs=\"H.264-encoded\"", "hardware-acceleration-policy", WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS, - "javascript-can-access-clipboard", true, NULL); + "javascript-can-access-clipboard", TRUE, NULL); WebKitWebContext *context = webkit_web_context_new_with_website_data_manager( webkit_website_data_manager_new( @@ -129,7 +133,6 @@ GtkWidget* rose_webview_new() webkit_settings_set_user_agent_with_application_details( settings, "Mini", "0.1"); - webkit_web_context_set_process_model(context, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES); webkit_web_context_set_cache_model(context, WEBKIT_CACHE_MODEL_WEB_BROWSER); contentmanager = webkit_user_content_manager_new(); cookiemanager = webkit_web_context_get_cookie_manager(context); diff --git a/window.c b/window.c index 816b8e0..b18e8bd 100644 --- a/window.c +++ b/window.c @@ -20,6 +20,8 @@ enum { PROP_ACTIVE_CHILD }; +static float zoom = 1.0; + G_DEFINE_TYPE(RoseWindow, rose_window, GTK_TYPE_APPLICATION_WINDOW) static void read_clipboard(GObject *object, @@ -85,10 +87,20 @@ static gboolean key_press_callback(RoseWindow *window, webkit_web_view_load_uri(window->webview, getatom(AtomGo)); } } + case zoomin: + zoom += 0.1; + webkit_web_view_set_zoom_level(window->webview, zoom); + break; + case zoomout: + zoom -= 0.1; + webkit_web_view_set_zoom_level(window->webview, zoom); + break; } } } + printf("%i\n", keyval); + puts(""); return GDK_EVENT_PROPAGATE; } @@ -105,7 +117,12 @@ static void rose_window_init(RoseWindow *window) guint rose_window_show(GtkApplication *app, RoseWindow *window, const char *url) { GtkWidget *w = gtk_application_window_new(app); + + gtk_application_set_menubar(app, FALSE); GtkWidget *webview = rose_webview_new(); + gtk_widget_set_has_tooltip(webview, FALSE); + gtk_widget_has_default(webview); + gtk_window_set_destroy_with_parent(GTK_WINDOW(w), TRUE); window->webview = WEBKIT_WEB_VIEW(webview); if (url)