formatting pass.
This commit is contained in:
parent
e5e194f1eb
commit
0f5baf1129
33
rose.c
33
rose.c
|
@ -1,20 +1,22 @@
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <webkit2/webkit2.h>
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "plugins/libre_redirect/libre_redirect.h"
|
#include "plugins/libre_redirect/libre_redirect.h"
|
||||||
#include "plugins/readability/readability.h"
|
#include "plugins/readability/readability.h"
|
||||||
#include "plugins/shortcuts/shortcuts.h"
|
#include "plugins/shortcuts/shortcuts.h"
|
||||||
#include "plugins/style/style.h"
|
#include "plugins/style/style.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <webkit2/webkit2.h>
|
||||||
|
|
||||||
/* Global declarations */
|
/* Global declarations */
|
||||||
static GtkNotebook* notebook;
|
static GtkNotebook* notebook;
|
||||||
static GtkWindow* window;
|
static GtkWindow* window;
|
||||||
static struct {
|
static struct {
|
||||||
GtkHeaderBar *widget;
|
GtkHeaderBar* widget;
|
||||||
GtkEntry *line;
|
GtkEntry* line;
|
||||||
GtkEntryBuffer *line_text;
|
GtkEntryBuffer* line_text;
|
||||||
enum { _SEARCH, _FIND, _HIDDEN } entry_mode;
|
enum { _SEARCH,
|
||||||
|
_FIND,
|
||||||
|
_HIDDEN } entry_mode;
|
||||||
} bar; // top bar.
|
} bar; // top bar.
|
||||||
static int num_tabs = 0;
|
static int num_tabs = 0;
|
||||||
|
|
||||||
|
@ -62,7 +64,8 @@ void redirect_if_annoying(WebKitWebView* view, const char* uri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void set_custom_style(WebKitWebView* view){
|
void set_custom_style(WebKitWebView* view)
|
||||||
|
{
|
||||||
if (CUSTOM_STYLE_ENABLED) {
|
if (CUSTOM_STYLE_ENABLED) {
|
||||||
char* style_js = malloc(STYLE_N + 1);
|
char* style_js = malloc(STYLE_N + 1);
|
||||||
read_style_js(style_js);
|
read_style_js(style_js);
|
||||||
|
@ -78,15 +81,15 @@ void handle_signal_load_changed(WebKitWebView* self, WebKitLoadEvent 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:
|
||||||
set_custom_style(self);
|
set_custom_style(self);
|
||||||
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
||||||
break;
|
break;
|
||||||
case WEBKIT_LOAD_REDIRECTED:
|
case WEBKIT_LOAD_REDIRECTED:
|
||||||
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
||||||
break;
|
break;
|
||||||
case WEBKIT_LOAD_COMMITTED:
|
case WEBKIT_LOAD_COMMITTED:
|
||||||
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
||||||
set_custom_style(self);
|
set_custom_style(self);
|
||||||
break;
|
break;
|
||||||
case WEBKIT_LOAD_FINISHED: {
|
case WEBKIT_LOAD_FINISHED: {
|
||||||
/* Add gtk tab title */
|
/* Add gtk tab title */
|
||||||
|
@ -131,7 +134,7 @@ GtkWidget* handle_signal_create_new_tab(WebKitWebView* self,
|
||||||
"alert('Too many tabs, not opening a new one')", NULL, NULL, NULL);
|
"alert('Too many tabs, not opening a new one')", NULL, NULL, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
WebKitGTK documentation recommends returning the new webview.
|
WebKitGTK documentation recommends returning the new webview.
|
||||||
I imagine that this might allow e.g., to go back in a new tab
|
I imagine that this might allow e.g., to go back in a new tab
|
||||||
or generally to keep track of history.
|
or generally to keep track of history.
|
||||||
|
@ -401,7 +404,7 @@ int handle_signal_keypress(void* self, GdkEvent* event, GtkNotebook* notebook)
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
/* Initialize GTK in general */
|
/* Initialize GTK in general */
|
||||||
gtk_init(NULL, NULL); // <https://docs.gtk.org/gtk3/func.init.html>
|
gtk_init(NULL, NULL); // <https://docs.gtk.org/gtk3/func.init.html>
|
||||||
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, "/usr/share/themes/rose/style.css", NULL);
|
gtk_css_provider_load_from_path(css, "/usr/share/themes/rose/style.css", NULL);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user