GTK4: start trying to compile with gtk4
This commit is contained in:
parent
1c9fbe1122
commit
de1e608d06
1
TODO.md
1
TODO.md
|
@ -13,6 +13,7 @@
|
||||||
- Instructions for GTK-4 [here](https://docs.gtk.org/gtk4/migrating-3to4.html)
|
- Instructions for GTK-4 [here](https://docs.gtk.org/gtk4/migrating-3to4.html)
|
||||||
- [ ] Prepare for GTK-3 to GTK-4 transition
|
- [ ] Prepare for GTK-3 to GTK-4 transition
|
||||||
- [ ] Understand wtf is going on with signals and events: <https://docs.gtk.org/gtk4/migrating-3to4.html#stop-using-gtkwidget-event-signals>. <https://github.com/mini-rose/rose-browser/blob/288bf060d095c4895946669ae50d14193168b69c/src/window.c#L42>
|
- [ ] Understand wtf is going on with signals and events: <https://docs.gtk.org/gtk4/migrating-3to4.html#stop-using-gtkwidget-event-signals>. <https://github.com/mini-rose/rose-browser/blob/288bf060d095c4895946669ae50d14193168b69c/src/window.c#L42>
|
||||||
|
- [ ] Stop using direct access to GdkEvent structs
|
||||||
- [ ] Remove webkit2gtk-4.1 and download webkit2gtk-6.0
|
- [ ] Remove webkit2gtk-4.1 and download webkit2gtk-6.0
|
||||||
- [ ] Attempt to compile
|
- [ ] Attempt to compile
|
||||||
|
|
||||||
|
|
3
config.h
3
config.h
|
@ -1,6 +1,9 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <gdk/gdk.h> // <gdk/gdkenums.h>, <gdk/gdkkeysyms.h>
|
#include <gdk/gdk.h> // <gdk/gdkenums.h>, <gdk/gdkkeysyms.h>
|
||||||
|
|
||||||
|
// GKG 3 or GKG 4
|
||||||
|
# define GKG_NUM 4
|
||||||
|
|
||||||
// Key user config
|
// Key user config
|
||||||
#define WIDTH 1920 // 960 for half-width, 1920 for full width
|
#define WIDTH 1920 // 960 for half-width, 1920 for full width
|
||||||
// #define HEIGHT 1080
|
// #define HEIGHT 1080
|
||||||
|
|
10
makefile
10
makefile
|
@ -7,7 +7,8 @@ DEBUG= # -g
|
||||||
STD=-std=c99 # maybe consider moving to c11 and using safer string handling
|
STD=-std=c99 # maybe consider moving to c11 and using safer string handling
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
DEPS='webkit2gtk-4.1'
|
# DEPS='webkit2gtk-4.1'
|
||||||
|
DEPS='webkitgtk-6.0'
|
||||||
INCS=`pkg-config --cflags ${DEPS}`
|
INCS=`pkg-config --cflags ${DEPS}`
|
||||||
LIBS=`pkg-config --libs ${DEPS}`
|
LIBS=`pkg-config --libs ${DEPS}`
|
||||||
|
|
||||||
|
@ -30,8 +31,13 @@ MAINTAINER_CACHE_DIR=/home/nuno/.cache/rosenrot
|
||||||
USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot
|
USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot
|
||||||
RUNTIME_FILES_DIR=/opt/rosenrot/
|
RUNTIME_FILES_DIR=/opt/rosenrot/
|
||||||
|
|
||||||
|
# Start 3 to 4 transition
|
||||||
|
# https://docs.gtk.org/gtk4/migrating-3to4.html
|
||||||
|
# https://github.com/WebKit/WebKit/blob/ed1422596dce5ff012e64a38faf402ac1674fc7e/Source/WebKit/gtk/migrating-to-webkitgtk-6.0.md
|
||||||
|
# DEPRECATION_FLAGS=-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED
|
||||||
|
|
||||||
build: $(SRC) $(PLUGINS) $(CONFIG) constants user_cache
|
build: $(SRC) $(PLUGINS) $(CONFIG) constants user_cache
|
||||||
$(CC) $(STD) $(WARNINGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o rosenrot $(LIBS) $(ADBLOCK)
|
$(CC) $(STD) $(WARNINGS) $(DEPRECATION_FLAGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o rosenrot $(LIBS) $(ADBLOCK)
|
||||||
@echo
|
@echo
|
||||||
|
|
||||||
constants:
|
constants:
|
||||||
|
|
18
rosenrot.c
18
rosenrot.c
|
@ -1,7 +1,13 @@
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if GKG_NUM == 3
|
||||||
#include <webkit2/webkit2.h>
|
#include <webkit2/webkit2.h>
|
||||||
|
#elif GKG_NUM == 4
|
||||||
|
#include <webkit/webkit.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "plugins/plugins.h"
|
#include "plugins/plugins.h"
|
||||||
|
@ -380,7 +386,7 @@ int handle_signal_keypress(void* self, GdkEvent* event, GtkNotebook* notebook)
|
||||||
- https://docs.gtk.org/gdk3/union.Event.html
|
- https://docs.gtk.org/gdk3/union.Event.html
|
||||||
- https://docs.gtk.org/gdk3/struct.EventButton.html
|
- https://docs.gtk.org/gdk3/struct.EventButton.html
|
||||||
*/
|
*/
|
||||||
// This API is deprecated in GTK4 :(
|
// This API is deprecated in GTK4 :(.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +397,7 @@ int main(int argc, char** argv)
|
||||||
g_object_set(gtk_settings_get_default(), GTK_SETTINGS_CONFIG_H, NULL); // https://docs.gtk.org/gobject/method.Object.set.html
|
g_object_set(gtk_settings_get_default(), GTK_SETTINGS_CONFIG_H, NULL); // https://docs.gtk.org/gobject/method.Object.set.html
|
||||||
GtkCssProvider* css = gtk_css_provider_new();
|
GtkCssProvider* css = gtk_css_provider_new();
|
||||||
gtk_css_provider_load_from_path(css, "/opt/rosenrot/style.css", NULL);
|
gtk_css_provider_load_from_path(css, "/opt/rosenrot/style.css", NULL);
|
||||||
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), 800);
|
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), 800); /* might change with GTK4/webkitgtk6.0 */
|
||||||
|
|
||||||
/* Initialize GTK objects. These are declared as static globals at the top of this file */
|
/* Initialize GTK objects. These are declared as static globals at the top of this file */
|
||||||
// Notebook
|
// Notebook
|
||||||
|
@ -404,7 +410,11 @@ int main(int argc, char** argv)
|
||||||
gtk_window_set_default_size(window, WIDTH, HEIGHT);
|
gtk_window_set_default_size(window, WIDTH, HEIGHT);
|
||||||
g_signal_connect(window, "key-press-event", G_CALLBACK(handle_signal_keypress), notebook);
|
g_signal_connect(window, "key-press-event", G_CALLBACK(handle_signal_keypress), notebook);
|
||||||
g_signal_connect(window, "destroy", G_CALLBACK(exit), notebook);
|
g_signal_connect(window, "destroy", G_CALLBACK(exit), notebook);
|
||||||
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(notebook));
|
#if GKG_NUM == 3
|
||||||
|
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(notebook)); /* deprecated in GKG */
|
||||||
|
#elif GKG_NUM == 4
|
||||||
|
gtk_window_set_child(GTK_CONTAINER(window), GTK_WIDGET(notebook))
|
||||||
|
#endif
|
||||||
|
|
||||||
// Bar
|
// Bar
|
||||||
bar.line_text = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0));
|
bar.line_text = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0));
|
||||||
|
@ -433,5 +443,5 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_main();
|
gtk_main(); /* deprecated in GKT4: https://docs.gtk.org/gtk4/migrating-3to4.html#stop-using-gtk_main-and-related-apis */
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Key dependencies
|
# Key dependencies
|
||||||
sudo apt install git vim gcc make
|
sudo apt install git vim gcc make
|
||||||
sudo apt install libwebkit2gtk-4.1-dev
|
sudo apt install libwebkit2gtk-4.1-dev
|
||||||
|
# sudo apt install libwebkitgtk-6.0-dev
|
||||||
|
# sudo apt install libgtk-4-dev
|
||||||
|
|
||||||
# Optional adblock
|
# Optional adblock
|
||||||
git clone https://github.com/jun7/wyebadblock
|
git clone https://github.com/jun7/wyebadblock
|
||||||
|
|
Loading…
Reference in New Issue
Block a user