tweaks
This commit is contained in:
parent
cbc9d35811
commit
18ac2627ad
2
makefile
2
makefile
|
@ -19,7 +19,7 @@ include plugins/plugins.mk
|
||||||
# PLUGINS=./plugins/stand_in/stand_in.c
|
# PLUGINS=./plugins/stand_in/stand_in.c
|
||||||
|
|
||||||
## Formatter
|
## Formatter
|
||||||
STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true}"
|
STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true, AllowShortEnumsOnASingleLine: true}"
|
||||||
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
|
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
|
||||||
|
|
||||||
# Runtime files
|
# Runtime files
|
||||||
|
|
|
@ -60,6 +60,6 @@ int shortcut_expand(const char* uri, char* output)
|
||||||
}
|
}
|
||||||
strcpy(output, uri);
|
strcpy(output, uri);
|
||||||
}
|
}
|
||||||
if(DEBUG) printf("No match found\n\n");
|
if (DEBUG) printf("No match found\n\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,3 @@ void read_style_js(char* string)
|
||||||
string[i] = '\0';
|
string[i] = '\0';
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
38
rosenrot.c
38
rosenrot.c
|
@ -13,22 +13,22 @@ static struct {
|
||||||
GtkHeaderBar* widget;
|
GtkHeaderBar* widget;
|
||||||
GtkEntry* line;
|
GtkEntry* line;
|
||||||
GtkEntryBuffer* line_text;
|
GtkEntryBuffer* line_text;
|
||||||
enum { _SEARCH,
|
enum { _SEARCH, _FIND, _HIDDEN } entry_mode;
|
||||||
_FIND,
|
|
||||||
_HIDDEN } entry_mode;
|
|
||||||
} bar;
|
} bar;
|
||||||
static int num_tabs = 0;
|
static int num_tabs = 0;
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
void toggle_bar(GtkNotebook* notebook);
|
||||||
|
void notebook_create_new_tab(GtkNotebook* notebook, const char* uri);
|
||||||
|
|
||||||
/* Utils */
|
/* Utils */
|
||||||
WebKitWebView* notebook_get_webview(GtkNotebook* notebook)
|
WebKitWebView* notebook_get_webview(GtkNotebook* notebook)
|
||||||
{
|
{
|
||||||
return WEBKIT_WEB_VIEW(gtk_notebook_get_nth_page(
|
return WEBKIT_WEB_VIEW(gtk_notebook_get_nth_page(notebook, gtk_notebook_get_current_page(notebook)));
|
||||||
notebook, gtk_notebook_get_current_page(notebook)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load content*/
|
/* Load content*/
|
||||||
|
|
||||||
void toggle_bar(GtkNotebook* notebook);
|
|
||||||
void load_uri(WebKitWebView* view, const char* uri)
|
void load_uri(WebKitWebView* view, const char* uri)
|
||||||
{
|
{
|
||||||
if (strlen(uri) == 0) {
|
if (strlen(uri) == 0) {
|
||||||
|
@ -83,8 +83,7 @@ void handle_signal_load_changed(WebKitWebView* self, WebKitLoadEvent load_event,
|
||||||
GtkNotebook* notebook)
|
GtkNotebook* notebook)
|
||||||
{
|
{
|
||||||
switch (load_event) {
|
switch (load_event) {
|
||||||
/* see <https://webkitgtk.org/reference/webkit2gtk/2.5.1/WebKitWebView.html>
|
// see <https://webkitgtk.org/reference/webkit2gtk/2.5.1/WebKitWebView.html>
|
||||||
*/
|
|
||||||
case WEBKIT_LOAD_STARTED:
|
case WEBKIT_LOAD_STARTED:
|
||||||
case WEBKIT_LOAD_COMMITTED:
|
case WEBKIT_LOAD_COMMITTED:
|
||||||
set_custom_style(self);
|
set_custom_style(self);
|
||||||
|
@ -105,7 +104,6 @@ void handle_signal_load_changed(WebKitWebView* self, WebKitLoadEvent load_event,
|
||||||
}
|
}
|
||||||
tab_title[max_length] = '\0';
|
tab_title[max_length] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(self),
|
gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(self),
|
||||||
webpage_title == NULL ? "—" : tab_title);
|
webpage_title == NULL ? "—" : tab_title);
|
||||||
// gtk_widget_hide(GTK_WIDGET(bar));
|
// gtk_widget_hide(GTK_WIDGET(bar));
|
||||||
|
@ -114,10 +112,6 @@ void handle_signal_load_changed(WebKitWebView* self, WebKitLoadEvent load_event,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create new tabs */
|
/* Create new tabs */
|
||||||
void notebook_create_new_tab(GtkNotebook* notebook, const char* uri);
|
|
||||||
// handle_signal_create_new_tab is bound to a signal inside notebook_create_new_tab
|
|
||||||
// and itself calls notebook_create_new_tab
|
|
||||||
// therefore we need to do a forward declaration for one of them.
|
|
||||||
GtkWidget* handle_signal_create_new_tab(WebKitWebView* self,
|
GtkWidget* handle_signal_create_new_tab(WebKitWebView* self,
|
||||||
WebKitNavigationAction* navigation_action,
|
WebKitNavigationAction* navigation_action,
|
||||||
GtkNotebook* notebook)
|
GtkNotebook* notebook)
|
||||||
|
@ -156,8 +150,7 @@ WebKitWebView* create_new_webview()
|
||||||
"like Gecko) Chrome/110.0.0.0 Safari/537.36");
|
"like Gecko) Chrome/110.0.0.0 Safari/537.36");
|
||||||
// See: <https://www.useragents.me/> for some common user agents
|
// See: <https://www.useragents.me/> for some common user agents
|
||||||
}
|
}
|
||||||
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(DATA_MANAGER_OPTS, NULL));
|
||||||
webkit_website_data_manager_new(DATA_MANAGER_OPTS, 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);
|
||||||
|
|
||||||
|
@ -193,7 +186,8 @@ void notebook_create_new_tab(GtkNotebook* notebook, const char* uri)
|
||||||
webkit_web_view_set_zoom_level(view, ZOOM);
|
webkit_web_view_set_zoom_level(view, ZOOM);
|
||||||
num_tabs += 1;
|
num_tabs += 1;
|
||||||
} else {
|
} else {
|
||||||
webkit_web_view_evaluate_javascript(notebook_get_webview(notebook), "alert('Too many tabs, not opening a new one')", -1, NULL, "rosenrot-alert-numtabs", NULL, NULL, NULL);
|
webkit_web_view_evaluate_javascript(notebook_get_webview(notebook), "alert('Too many tabs, not opening a new one')",
|
||||||
|
-1, NULL, "rosenrot-alert-numtabs", NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,8 +215,6 @@ void toggle_bar(GtkNotebook* notebook)
|
||||||
gtk_window_set_focus(window, GTK_WIDGET(bar.line));
|
gtk_window_set_focus(window, GTK_WIDGET(bar.line));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
// fallthrough
|
|
||||||
case _HIDDEN:
|
case _HIDDEN:
|
||||||
gtk_widget_hide(GTK_WIDGET(bar.widget));
|
gtk_widget_hide(GTK_WIDGET(bar.widget));
|
||||||
}
|
}
|
||||||
|
@ -231,8 +223,7 @@ void toggle_bar(GtkNotebook* notebook)
|
||||||
void handle_signal_bar_press_enter(GtkEntry* self, GtkNotebook* notebook)
|
void handle_signal_bar_press_enter(GtkEntry* self, GtkNotebook* notebook)
|
||||||
{
|
{
|
||||||
if (bar.entry_mode == _SEARCH)
|
if (bar.entry_mode == _SEARCH)
|
||||||
load_uri(notebook_get_webview(notebook),
|
load_uri(notebook_get_webview(notebook), gtk_entry_buffer_get_text(bar.line_text));
|
||||||
gtk_entry_buffer_get_text(bar.line_text));
|
|
||||||
else if (bar.entry_mode == _FIND)
|
else if (bar.entry_mode == _FIND)
|
||||||
webkit_find_controller_search(
|
webkit_find_controller_search(
|
||||||
webkit_web_view_get_find_controller(notebook_get_webview(notebook)),
|
webkit_web_view_get_find_controller(notebook_get_webview(notebook)),
|
||||||
|
@ -317,7 +308,6 @@ int handle_shortcut(func id, GtkNotebook* notebook)
|
||||||
gtk_window_unfullscreen(window);
|
gtk_window_unfullscreen(window);
|
||||||
else
|
else
|
||||||
gtk_window_fullscreen(window);
|
gtk_window_fullscreen(window);
|
||||||
|
|
||||||
is_fullscreen = !is_fullscreen;
|
is_fullscreen = !is_fullscreen;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -331,12 +321,10 @@ int handle_shortcut(func id, GtkNotebook* notebook)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case finder_next:
|
case finder_next:
|
||||||
webkit_find_controller_search_next(
|
webkit_find_controller_search_next(webkit_web_view_get_find_controller(view));
|
||||||
webkit_web_view_get_find_controller(view));
|
|
||||||
break;
|
break;
|
||||||
case finder_prev:
|
case finder_prev:
|
||||||
webkit_find_controller_search_previous(
|
webkit_find_controller_search_previous(webkit_web_view_get_find_controller(view));
|
||||||
webkit_web_view_get_find_controller(view));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case new_tab:
|
case new_tab:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user