some code simplification

- don't have main and "setup" as two separate functions
- declare all global variables at the same time
This commit is contained in:
NunoSempere 2024-02-11 13:52:38 +01:00
parent 2896ff4e52
commit 9113aac957
5 changed files with 31 additions and 32 deletions

View File

@ -1,7 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define READABILITY_N 88023 + 1000 #define READABILITY_N 88067 + 1000
void read_readability_js(char* string) void read_readability_js(char* string)
{ {

View File

@ -1,7 +1,7 @@
#ifndef READABILITY #ifndef READABILITY
#define READABILITY #define READABILITY
#define READABILITY_N 88023 + 1000 #define READABILITY_N 88067 + 1000
void read_readability_js(char* string); void read_readability_js(char* string);

View File

@ -2615,12 +2615,13 @@ var style_sheet_simple = `
<style type="text/css"> <style type="text/css">
body { body {
padding: 40px 200px 40px 200px; padding: 40px 200px 40px 200px !important;
font-size: 18px; font-size: 18px;
font: 18px/1.5 Roboto; font: 18px/1.5 Roboto;
line-height: 1.6; line-height: 1.6;
background-color: #FEFEFE !important; background-color: #FEFEFE !important;
color: #444 !important; color: #444 !important;
max-width: 99% !important;
} }
#readOverlay { #readOverlay {

BIN
rose

Binary file not shown.

56
rose.c
View File

@ -10,14 +10,33 @@
#include "plugins/shortcuts/shortcuts.h" #include "plugins/shortcuts/shortcuts.h"
#include "plugins/style/style.h" #include "plugins/style/style.h"
// #include "plugins/stand_in/stand_in.h" /* Global declarations */
static GtkNotebook* notebook;
static GtkWindow* window;
// Search, find and url bar
static GtkHeaderBar* bar;
static GtkEntryBuffer* search_buf;
static GtkEntry* search;
static int entry_mode;
enum { _SEARCH, _FIND, _HIDDEN };
/* CACHE */
#define CACHE \
"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
/* Plugins */
// #include "plugins/stand_in/stand_in.h"
int LIBRE_REDIRECT_ENABLED = true; int LIBRE_REDIRECT_ENABLED = true;
int READABILITY_ENABLED = true; int READABILITY_ENABLED = true;
int CUSTOM_STYLE_ENABLED = true; int CUSTOM_STYLE_ENABLED = true;
int CUSTOM_USER_AGENT = false; int CUSTOM_USER_AGENT = false;
int NUM_TABS = 0; int NUM_TABS = 0;
// to enable plugins, // to enable plugins,
// 1. Enable them: // 1. Enable them:
// - uncomment their #include statement // - uncomment their #include statement
@ -29,24 +48,6 @@ int NUM_TABS = 0;
// - In the make file, include the stand_in.c file and exclude the // - In the make file, include the stand_in.c file and exclude the
// relevant plugin // relevant plugin
#define CACHE \
"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,
_HIDDEN };
static int entry_mode;
static GtkWindow* window;
static GtkHeaderBar* bar;
static GtkEntryBuffer* search_buf;
static GtkEntry* search;
WebKitWebView* webview_new() WebKitWebView* webview_new()
{ {
char* style; char* style;
@ -460,15 +461,18 @@ void notebook_init(GtkNotebook* notebook, const char* uri)
notebook_append(notebook, uri); notebook_append(notebook, uri);
} }
void setup(GtkNotebook* notebook, int argc, char** argv) int main(int argc, char** argv)
{ {
// Define GTK entities // <https://docs.gtk.org/gtk3/func.init.html>
gtk_init(NULL, NULL);
// Define GTK entities. These are declared globally
window = GTK_WINDOW(gtk_window_new(0)); window = GTK_WINDOW(gtk_window_new(0));
notebook = GTK_NOTEBOOK(gtk_notebook_new());
bar = GTK_HEADER_BAR(gtk_header_bar_new()); bar = GTK_HEADER_BAR(gtk_header_bar_new());
search_buf = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0)); search_buf = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0));
search = GTK_ENTRY(gtk_entry_new_with_buffer(search_buf)); search = GTK_ENTRY(gtk_entry_new_with_buffer(search_buf));
gtk_window_set_default_size(window, WIDTH, HEIGHT); gtk_window_set_default_size(window, WIDTH, HEIGHT);
notebook = GTK_NOTEBOOK(gtk_notebook_new());
window_init(notebook); window_init(notebook);
// Initialize with first uri // Initialize with first uri
@ -488,13 +492,7 @@ void setup(GtkNotebook* notebook, int argc, char** argv)
notebook_append(notebook, argv[i]); notebook_append(notebook, argv[i]);
} }
} }
}
int main(int argc, char** argv)
{
GtkNotebook* notebook = NULL;
gtk_init(NULL, NULL);
setup(notebook, argc, argv);
gtk_main(); gtk_main();
// this point is never reached, since gtk_main(); never exits. // this point is never reached, since gtk_main(); never exits.
} }