Fix webkit bg color error, add rose-nativefier
This commit is contained in:
parent
68ca1eb61a
commit
5e7587dd99
37
.clang-format
Normal file
37
.clang-format
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# vim:ft=yaml
|
||||||
|
|
||||||
|
IndentWidth: 8
|
||||||
|
BreakBeforeBraces: Linux
|
||||||
|
UseTab: Always
|
||||||
|
AlignArrayOfStructures: Left
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||||
|
AllowShortLoopsOnASingleLine: True
|
||||||
|
AlwaysBreakBeforeMultilineStrings: True
|
||||||
|
BreakBeforeTernaryOperators: True
|
||||||
|
BreakStringLiterals: True
|
||||||
|
ColumnLimit: 100
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: True
|
||||||
|
RemoveBracesLLVM: True
|
||||||
|
SortIncludes: CaseInsensitive
|
||||||
|
SortUsingDeclarations: True
|
||||||
|
SpaceAfterLogicalNot: True
|
||||||
|
SpaceAfterCStyleCast: True
|
||||||
|
SpaceAfterTemplateKeyword: False
|
||||||
|
PointerAlignment: Right
|
||||||
|
SpaceBeforeAssignmentOperators: True
|
||||||
|
SpaceBeforeCaseColon: False
|
||||||
|
SpaceBeforeCpp11BracedList: True
|
||||||
|
SpaceBeforeCtorInitializerColon: False
|
||||||
|
SpaceBeforeInheritanceColon: False
|
||||||
|
SpaceBeforeParens: Custom
|
||||||
|
SpaceBeforeParensOptions:
|
||||||
|
AfterControlStatements: True
|
||||||
|
AfterForeachMacros: True
|
||||||
|
AfterFunctionDeclarationName: False
|
||||||
|
AfterFunctionDefinitionName: False
|
||||||
|
AfterIfMacros: True
|
||||||
|
AfterOverloadedOperator: False
|
||||||
|
BeforeNonEmptyParentheses: False
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: True
|
|
@ -7,7 +7,8 @@
|
||||||
- ~400L code base
|
- ~400L code base
|
||||||
- custom gtk and websites css
|
- custom gtk and websites css
|
||||||
- hackable without any knowledge
|
- hackable without any knowledge
|
||||||
|
- builtin script nativefier
|
||||||
|
|
||||||
#
|
#
|
||||||
### 👐 Contribute
|
### 👐 Contribute
|
||||||
See [contributing.md](https://github.com/mini-rose/rose/.github/contributing.md).
|
See [contributing.md](https://github.com/mini-rose/rose/.github/contributing.md).
|
||||||
|
|
5
build.sh
5
build.sh
|
@ -5,4 +5,7 @@ DEPS=('webkit2gtk-4.0')
|
||||||
INCS=`pkg-config --cflags ${DEPS[@]}`
|
INCS=`pkg-config --cflags ${DEPS[@]}`
|
||||||
LIBS=`pkg-config --libs ${DEPS[@]}`
|
LIBS=`pkg-config --libs ${DEPS[@]}`
|
||||||
|
|
||||||
$CC $INCS $LIBS $SRC -o rose
|
# Optional adblocking depends on https://github.com/jun7/wyebadblock
|
||||||
|
WYEBAB='-L/usr/lib/wyebrowser/adblock.so'
|
||||||
|
|
||||||
|
$CC $INCS $LIBS $SRC $WYEBAB -o rose
|
||||||
|
|
27
compile_flags.txt
Normal file
27
compile_flags.txt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
-I/usr/include/webkitgtk-4.0
|
||||||
|
-I/usr/include/glib-2.0
|
||||||
|
-I/usr/lib/glib-2.0/include
|
||||||
|
-I/usr/include/sysprof-4
|
||||||
|
-I/usr/include/gtk-3.0
|
||||||
|
-I/usr/include/pango-1.0
|
||||||
|
-I/usr/include/harfbuzz
|
||||||
|
-I/usr/include/freetype2
|
||||||
|
-I/usr/include/libpng16
|
||||||
|
-I/usr/include/libmount
|
||||||
|
-I/usr/include/blkid
|
||||||
|
-I/usr/include/fribidi
|
||||||
|
-I/usr/include/cairo
|
||||||
|
-I/usr/include/lzo
|
||||||
|
-I/usr/include/pixman-1
|
||||||
|
-I/usr/include/gdk-pixbuf-2.0
|
||||||
|
-I/usr/include/gio-unix-2.0
|
||||||
|
-I/usr/include/cloudproviders
|
||||||
|
-I/usr/include/atk-1.0
|
||||||
|
-I/usr/include/at-spi2-atk/2.0
|
||||||
|
-I/usr/include/at-spi-2.0
|
||||||
|
-I/usr/include/dbus-1.0
|
||||||
|
-I/usr/lib/dbus-1.0/include
|
||||||
|
-I/usr/include/libsoup-2.4
|
||||||
|
-I/usr/include/libxml2
|
||||||
|
-pthread
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
./build.sh && {
|
./build.sh && {
|
||||||
cp -f rose /usr/bin
|
cp -f rose /usr/bin
|
||||||
mkdir -p /usr/share/themes/rose
|
mkdir -p /usr/share/themes/rose
|
||||||
cp ./style.css /usr/share/themes/rose/
|
cp style.css /usr/share/themes/rose/
|
||||||
|
cp rose-nativefier /usr/bin
|
||||||
}
|
}
|
||||||
|
|
9
rose-nativefier
Executable file
9
rose-nativefier
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test "$1" = "--help" && {
|
||||||
|
echo "usage: rose-nativefier <alias> <url>"
|
||||||
|
}
|
||||||
|
|
||||||
|
test -z "$1" || test -z "$2" || {
|
||||||
|
echo -e "#!/bin/sh\n\nrose $2" > /usr/bin/$1
|
||||||
|
}
|
298
rose.c
298
rose.c
|
@ -10,24 +10,19 @@
|
||||||
* Author: fenze <contact@fenze.dev>
|
* Author: fenze <contact@fenze.dev>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <webkit2/webkit2.h>
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define CACHE \
|
#include <webkit2/webkit2.h>
|
||||||
"base-cache-directory", CACHE_DIR, \
|
|
||||||
"base-data-directory", CACHE_DIR, \
|
|
||||||
"disk-cache-directory", CACHE_DIR, \
|
|
||||||
"dom-cache-directory", CACHE_DIR, \
|
|
||||||
"hsts-cache-directory", CACHE_DIR, \
|
|
||||||
"indexeddb-directory", CACHE_DIR, \
|
|
||||||
"itp-directory", CACHE_DIR, \
|
|
||||||
"local-storage-directory", CACHE_DIR, \
|
|
||||||
"offline-application-cache-directory", CACHE_DIR, \
|
|
||||||
"service-worker-registrations-directory", CACHE_DIR
|
|
||||||
|
|
||||||
enum {
|
#define CACHE \
|
||||||
_SEARCH, _FIND
|
"base-cache-directory", CACHE_DIR, "base-data-directory", CACHE_DIR, \
|
||||||
};
|
"disk-cache-directory", CACHE_DIR, "dom-cache-directory", CACHE_DIR, \
|
||||||
|
"hsts-cache-directory", CACHE_DIR, "indexeddb-directory", CACHE_DIR, "itp-directory", \
|
||||||
|
CACHE_DIR, "local-storage-directory", CACHE_DIR, \
|
||||||
|
"offline-application-cache-directory", CACHE_DIR, \
|
||||||
|
"service-worker-registrations-directory", CACHE_DIR
|
||||||
|
|
||||||
|
enum { _SEARCH, _FIND };
|
||||||
|
|
||||||
static int entry_mode;
|
static int entry_mode;
|
||||||
static GtkWindow *window;
|
static GtkWindow *window;
|
||||||
|
@ -45,47 +40,32 @@ WebKitWebView *webview_new()
|
||||||
|
|
||||||
settings = webkit_settings_new_with_settings(WEBKIT, NULL);
|
settings = webkit_settings_new_with_settings(WEBKIT, NULL);
|
||||||
web_context = webkit_web_context_new_with_website_data_manager(
|
web_context = webkit_web_context_new_with_website_data_manager(
|
||||||
webkit_website_data_manager_new(CACHE, NULL)
|
webkit_website_data_manager_new(CACHE, NULL));
|
||||||
);
|
|
||||||
contentmanager = webkit_user_content_manager_new();
|
contentmanager = webkit_user_content_manager_new();
|
||||||
cookiemanager = webkit_web_context_get_cookie_manager(web_context);
|
cookiemanager = webkit_web_context_get_cookie_manager(web_context);
|
||||||
|
|
||||||
webkit_cookie_manager_set_persistent_storage(
|
webkit_cookie_manager_set_persistent_storage(cookiemanager, CACHE_DIR "/cookies.sqlite",
|
||||||
cookiemanager, CACHE_DIR"/cookies.sqlite",
|
WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
|
||||||
WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE
|
|
||||||
);
|
|
||||||
|
|
||||||
webkit_cookie_manager_set_accept_policy(
|
webkit_cookie_manager_set_accept_policy(cookiemanager, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
|
||||||
cookiemanager, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS
|
|
||||||
);
|
|
||||||
|
|
||||||
webkit_web_context_set_process_model(
|
webkit_web_context_set_process_model(web_context,
|
||||||
web_context,
|
WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
|
||||||
WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES
|
|
||||||
);
|
|
||||||
|
|
||||||
if (g_file_get_contents("~/.config/rose/style.css", &style, NULL, NULL))
|
if (g_file_get_contents("~/.config/rose/style.css", &style, NULL, NULL))
|
||||||
webkit_user_content_manager_add_style_sheet(
|
webkit_user_content_manager_add_style_sheet(
|
||||||
contentmanager,
|
contentmanager,
|
||||||
webkit_user_style_sheet_new(
|
webkit_user_style_sheet_new(style, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
|
||||||
style, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
|
WEBKIT_USER_STYLE_LEVEL_USER, NULL, NULL));
|
||||||
WEBKIT_USER_STYLE_LEVEL_USER, NULL, NULL));
|
|
||||||
|
|
||||||
return g_object_new(
|
return g_object_new(WEBKIT_TYPE_WEB_VIEW, "settings", settings, "web-context", web_context,
|
||||||
WEBKIT_TYPE_WEB_VIEW,
|
"user-content-manager", contentmanager, NULL);
|
||||||
"settings", settings,
|
|
||||||
"web-context", web_context,
|
|
||||||
"user-content-manager", contentmanager,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_uri(WebKitWebView *view, const char *uri)
|
void load_uri(WebKitWebView *view, const char *uri)
|
||||||
{
|
{
|
||||||
if (g_str_has_prefix(uri, "http://")
|
if (g_str_has_prefix(uri, "http://") || g_str_has_prefix(uri, "https://") ||
|
||||||
|| g_str_has_prefix(uri, "https://")
|
g_str_has_prefix(uri, "file://") || g_str_has_prefix(uri, "about:")) {
|
||||||
|| g_str_has_prefix(uri, "file://")
|
|
||||||
|| g_str_has_prefix(uri, "about:")) {
|
|
||||||
webkit_web_view_load_uri(view, uri);
|
webkit_web_view_load_uri(view, uri);
|
||||||
} else {
|
} else {
|
||||||
char tmp[strlen(uri) + strlen(SEARCH)];
|
char tmp[strlen(uri) + strlen(SEARCH)];
|
||||||
|
@ -94,13 +74,11 @@ void load_uri(WebKitWebView *view, const char *uri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_changed(WebKitWebView* self, WebKitLoadEvent load_event, GtkNotebook *notebook)
|
void load_changed(WebKitWebView *self, WebKitLoadEvent load_event, GtkNotebook *notebook)
|
||||||
{
|
{
|
||||||
if (load_event == WEBKIT_LOAD_FINISHED) {
|
if (load_event == WEBKIT_LOAD_FINISHED) {
|
||||||
gtk_notebook_set_tab_label_text(
|
gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(self),
|
||||||
notebook, GTK_WIDGET(self),
|
webkit_web_view_get_title(self));
|
||||||
webkit_web_view_get_title(self)
|
|
||||||
);
|
|
||||||
gtk_widget_hide(GTK_WIDGET(bar));
|
gtk_widget_hide(GTK_WIDGET(bar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,14 +93,14 @@ void notebook_append(GtkNotebook *notebook, const char *uri)
|
||||||
|
|
||||||
WebKitWebView *view = webview_new();
|
WebKitWebView *view = webview_new();
|
||||||
|
|
||||||
gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual);
|
gtk_widget_set_visual(GTK_WIDGET(window), rgba_visual);
|
||||||
g_signal_connect(view, "load_changed", G_CALLBACK(load_changed), notebook);
|
g_signal_connect(view, "load_changed", G_CALLBACK(load_changed), notebook);
|
||||||
|
|
||||||
int n = gtk_notebook_append_page(notebook, GTK_WIDGET(view), NULL);
|
int n = gtk_notebook_append_page(notebook, GTK_WIDGET(view), NULL);
|
||||||
gtk_notebook_set_tab_reorderable(notebook, GTK_WIDGET(view), true);
|
gtk_notebook_set_tab_reorderable(notebook, GTK_WIDGET(view), true);
|
||||||
gtk_widget_show_all(GTK_WIDGET(window));
|
gtk_widget_show_all(GTK_WIDGET(window));
|
||||||
gtk_widget_hide(GTK_WIDGET(bar));
|
gtk_widget_hide(GTK_WIDGET(bar));
|
||||||
webkit_web_view_set_background_color(view, rgba);
|
webkit_web_view_set_background_color(view, &rgba);
|
||||||
load_uri(view, (uri) ? uri : HOME);
|
load_uri(view, (uri) ? uri : HOME);
|
||||||
gtk_notebook_set_current_page(notebook, n);
|
gtk_notebook_set_current_page(notebook, n);
|
||||||
}
|
}
|
||||||
|
@ -130,10 +108,7 @@ void notebook_append(GtkNotebook *notebook, const char *uri)
|
||||||
WebKitWebView *notebook_get_webview(GtkNotebook *notebook)
|
WebKitWebView *notebook_get_webview(GtkNotebook *notebook)
|
||||||
{
|
{
|
||||||
return WEBKIT_WEB_VIEW(
|
return WEBKIT_WEB_VIEW(
|
||||||
gtk_notebook_get_nth_page(
|
gtk_notebook_get_nth_page(notebook, gtk_notebook_get_current_page(notebook)));
|
||||||
notebook, gtk_notebook_get_current_page(notebook)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_bar(GtkNotebook *notebook)
|
void show_bar(GtkNotebook *notebook)
|
||||||
|
@ -146,10 +121,7 @@ void show_bar(GtkNotebook *notebook)
|
||||||
gtk_window_set_focus(window, GTK_WIDGET(search));
|
gtk_window_set_focus(window, GTK_WIDGET(search));
|
||||||
} else {
|
} else {
|
||||||
const char *search_text = webkit_find_controller_get_search_text(
|
const char *search_text = webkit_find_controller_get_search_text(
|
||||||
webkit_web_view_get_find_controller(
|
webkit_web_view_get_find_controller(notebook_get_webview(notebook)));
|
||||||
notebook_get_webview(notebook)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (search_text != NULL)
|
if (search_text != NULL)
|
||||||
gtk_entry_buffer_set_text(search_buf, search_text, strlen(search_text));
|
gtk_entry_buffer_set_text(search_buf, search_text, strlen(search_text));
|
||||||
|
@ -165,117 +137,98 @@ int handle_key(func id, GtkNotebook *notebook)
|
||||||
static bool is_fullscreen = 0;
|
static bool is_fullscreen = 0;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case goback:
|
case goback:
|
||||||
webkit_web_view_go_back(notebook_get_webview(notebook));
|
webkit_web_view_go_back(notebook_get_webview(notebook));
|
||||||
|
break;
|
||||||
|
case goforward:
|
||||||
|
webkit_web_view_go_forward(notebook_get_webview(notebook));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case refresh:
|
||||||
|
webkit_web_view_reload(notebook_get_webview(notebook));
|
||||||
|
break;
|
||||||
|
case refresh_force:
|
||||||
|
webkit_web_view_reload_bypass_cache(notebook_get_webview(notebook));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case back_to_home:
|
||||||
|
load_uri(notebook_get_webview(notebook), HOME);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case zoomin:
|
||||||
|
webkit_web_view_set_zoom_level(notebook_get_webview(notebook), (zoom += ZOOM_VAL));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case zoomout:
|
||||||
|
webkit_web_view_set_zoom_level(notebook_get_webview(notebook), (zoom -= ZOOM_VAL));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case zoom_reset:
|
||||||
|
webkit_web_view_set_zoom_level(notebook_get_webview(notebook), (zoom = ZOOM));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case prev_tab:
|
||||||
|
if (gtk_notebook_get_current_page(notebook) == 0) {
|
||||||
|
gtk_notebook_set_current_page(notebook,
|
||||||
|
gtk_notebook_get_n_pages(notebook) - 1);
|
||||||
|
} else {
|
||||||
|
gtk_notebook_prev_page(notebook);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case next_tab:
|
||||||
|
if (gtk_notebook_get_current_page(notebook) ==
|
||||||
|
gtk_notebook_get_n_pages(notebook) - 1) {
|
||||||
|
notebook_append(notebook, NULL);
|
||||||
|
gtk_notebook_set_show_tabs(notebook, true);
|
||||||
|
} else {
|
||||||
|
gtk_notebook_next_page(notebook);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case close_tab:
|
||||||
|
gtk_notebook_remove_page(notebook, gtk_notebook_get_current_page(notebook));
|
||||||
|
|
||||||
|
switch (gtk_notebook_get_n_pages(notebook)) {
|
||||||
|
case 0:
|
||||||
|
exit(0);
|
||||||
break;
|
break;
|
||||||
case goforward:
|
case 1:
|
||||||
webkit_web_view_go_forward(notebook_get_webview(notebook));
|
gtk_notebook_set_show_tabs(notebook, false);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case refresh:
|
break;
|
||||||
webkit_web_view_reload(notebook_get_webview(notebook));
|
|
||||||
break;
|
|
||||||
case refresh_force:
|
|
||||||
webkit_web_view_reload_bypass_cache(notebook_get_webview(notebook));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case back_to_home:
|
case toggle_fullscreen:
|
||||||
load_uri(notebook_get_webview(notebook), HOME);
|
if (is_fullscreen)
|
||||||
break;
|
gtk_window_unfullscreen(window);
|
||||||
|
else
|
||||||
|
gtk_window_fullscreen(window);
|
||||||
|
|
||||||
case zoomin:
|
is_fullscreen = ! is_fullscreen;
|
||||||
webkit_web_view_set_zoom_level(
|
break;
|
||||||
notebook_get_webview(notebook),
|
|
||||||
(zoom += ZOOM_VAL)
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case zoomout:
|
case show_searchbar:
|
||||||
webkit_web_view_set_zoom_level(
|
entry_mode = _SEARCH;
|
||||||
notebook_get_webview(notebook),
|
show_bar(notebook);
|
||||||
(zoom -= ZOOM_VAL)
|
break;
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case zoom_reset:
|
case show_finder:
|
||||||
webkit_web_view_set_zoom_level(
|
entry_mode = _FIND;
|
||||||
notebook_get_webview(notebook),
|
show_bar(notebook);
|
||||||
(zoom = ZOOM)
|
break;
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case prev_tab:
|
case finder_next:
|
||||||
if (gtk_notebook_get_current_page(notebook) == 0) {
|
webkit_find_controller_search_next(
|
||||||
gtk_notebook_set_current_page(
|
webkit_web_view_get_find_controller(notebook_get_webview(notebook)));
|
||||||
notebook,
|
break;
|
||||||
gtk_notebook_get_n_pages(notebook) - 1
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
gtk_notebook_prev_page(notebook);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
case finder_prev:
|
||||||
|
webkit_find_controller_search_previous(
|
||||||
case next_tab:
|
webkit_web_view_get_find_controller(notebook_get_webview(notebook)));
|
||||||
if (gtk_notebook_get_current_page(notebook)
|
break;
|
||||||
== gtk_notebook_get_n_pages(notebook) - 1) {
|
|
||||||
notebook_append(notebook, NULL);
|
|
||||||
gtk_notebook_set_show_tabs(notebook, true);
|
|
||||||
} else {
|
|
||||||
gtk_notebook_next_page(notebook);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case close_tab:
|
|
||||||
gtk_notebook_remove_page(
|
|
||||||
notebook,
|
|
||||||
gtk_notebook_get_current_page(notebook)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
switch (gtk_notebook_get_n_pages(notebook)) {
|
|
||||||
case 0: exit(0);
|
|
||||||
break;
|
|
||||||
case 1: gtk_notebook_set_show_tabs(notebook, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case toggle_fullscreen:
|
|
||||||
if (is_fullscreen)
|
|
||||||
gtk_window_unfullscreen(window);
|
|
||||||
else
|
|
||||||
gtk_window_fullscreen(window);
|
|
||||||
|
|
||||||
is_fullscreen = !is_fullscreen;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case show_searchbar:
|
|
||||||
entry_mode = _SEARCH;
|
|
||||||
show_bar(notebook);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case show_finder:
|
|
||||||
entry_mode = _FIND;
|
|
||||||
show_bar(notebook);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case finder_next:
|
|
||||||
webkit_find_controller_search_next(
|
|
||||||
webkit_web_view_get_find_controller(
|
|
||||||
notebook_get_webview(notebook)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case finder_prev:
|
|
||||||
webkit_find_controller_search_previous(
|
|
||||||
webkit_web_view_get_find_controller(
|
|
||||||
notebook_get_webview(notebook)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -286,8 +239,7 @@ int keypress(void *self, GdkEvent *e, GtkNotebook *notebook)
|
||||||
(void) self;
|
(void) self;
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(keys) / sizeof(keys[0]); i++)
|
for (int i = 0; i < sizeof(keys) / sizeof(keys[0]); i++)
|
||||||
if (e->key.keyval == keys[i].key
|
if (e->key.keyval == keys[i].key && e->key.state == keys[i].mod)
|
||||||
&& e->key.state == keys[i].mod)
|
|
||||||
return handle_key(keys[i].id, notebook);
|
return handle_key(keys[i].id, notebook);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -296,18 +248,13 @@ int keypress(void *self, GdkEvent *e, GtkNotebook *notebook)
|
||||||
void search_activate(GtkEntry *self, GtkNotebook *notebook)
|
void search_activate(GtkEntry *self, GtkNotebook *notebook)
|
||||||
{
|
{
|
||||||
if (entry_mode == _SEARCH)
|
if (entry_mode == _SEARCH)
|
||||||
load_uri(notebook_get_webview(notebook),
|
load_uri(notebook_get_webview(notebook), gtk_entry_buffer_get_text(search_buf));
|
||||||
gtk_entry_buffer_get_text(search_buf));
|
|
||||||
else if (entry_mode == _FIND)
|
else if (entry_mode == _FIND)
|
||||||
webkit_find_controller_search(
|
webkit_find_controller_search(
|
||||||
webkit_web_view_get_find_controller(
|
webkit_web_view_get_find_controller(notebook_get_webview(notebook)),
|
||||||
notebook_get_webview(notebook)
|
gtk_entry_buffer_get_text(search_buf),
|
||||||
),
|
WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | WEBKIT_FIND_OPTIONS_WRAP_AROUND,
|
||||||
gtk_entry_buffer_get_text(search_buf),
|
G_MAXUINT);
|
||||||
WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE
|
|
||||||
| WEBKIT_FIND_OPTIONS_WRAP_AROUND,
|
|
||||||
G_MAXUINT
|
|
||||||
);
|
|
||||||
|
|
||||||
gtk_widget_hide(GTK_WIDGET(bar));
|
gtk_widget_hide(GTK_WIDGET(bar));
|
||||||
}
|
}
|
||||||
|
@ -317,9 +264,8 @@ void window_init(GtkNotebook *notebook)
|
||||||
GtkCssProvider *css = gtk_css_provider_new();
|
GtkCssProvider *css = gtk_css_provider_new();
|
||||||
|
|
||||||
gtk_css_provider_load_from_path(css, "/usr/share/themes/rose/style.css", NULL);
|
gtk_css_provider_load_from_path(css, "/usr/share/themes/rose/style.css", NULL);
|
||||||
gtk_style_context_add_provider_for_screen(
|
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css),
|
||||||
gdk_screen_get_default(),
|
800);
|
||||||
GTK_STYLE_PROVIDER(css), 800);
|
|
||||||
|
|
||||||
gtk_entry_buffer_new("", 0);
|
gtk_entry_buffer_new("", 0);
|
||||||
gtk_entry_set_alignment(search, 0.48);
|
gtk_entry_set_alignment(search, 0.48);
|
||||||
|
@ -339,7 +285,7 @@ void notebook_init(GtkNotebook *notebook, const char *uri)
|
||||||
notebook_append(notebook, uri);
|
notebook_append(notebook, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(GtkNotebook *notebook, const char* uri)
|
void setup(GtkNotebook *notebook, const char *uri)
|
||||||
{
|
{
|
||||||
window = GTK_WINDOW(gtk_window_new(0));
|
window = GTK_WINDOW(gtk_window_new(0));
|
||||||
notebook = GTK_NOTEBOOK(gtk_notebook_new());
|
notebook = GTK_NOTEBOOK(gtk_notebook_new());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user