logo

badwolf

minimalist and privacy-oriented web browser based on WebKitGTK
commit: c2b4c8fb07b50c064d8ffe5ce02e84e21b6cffaa
parent 74b19d30081537e052b314acf3752c5ee26a0e2c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 26 Oct 2020 07:28:06 +0100

Use [A..Z] instead of [0..F] for representing the context_id

Diffstat:

Mbadwolf.c29++++++++++++++++++++++++++---
Mbadwolf.h2+-
Minterface.txt2+-
3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/badwolf.c b/badwolf.c @@ -21,7 +21,7 @@ const gchar *homepage = "https://hacktivis.me/projects/badwolf"; const gchar *version = VERSION; static gchar *web_extensions_directory; -static int context_id_counter = 0; +static uint64_t context_id_counter = 0; GtkTreeModel *bookmarks_completion_model; static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data); @@ -130,13 +130,36 @@ WebViewCb_notify__uri(WebKitWebView *webView, GParamSpec *pspec, gpointer user_d return TRUE; } +static char * +fmt_context_id(uint64_t num, char *out) +{ + const char alpha_digits[27] = {" ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; + char buf[66] = {'\0'}; + int i, len = 0; + + // Get 0 = 'A' instead of 0 = '' and 1 = 'A' + num++; + + buf[len++] = ' '; + buf[len++] = ':'; + do + { + buf[len++] = alpha_digits[num % 26]; + } while(num /= 26); + + for(i = 0; len > 0; i++) + out[i] = buf[--len]; + + return out; +} + GtkWidget * badwolf_new_tab_box(const gchar *title, struct Client *browser) { (void)browser; - char context_id_str[7]; + char context_id_str[7] = ""; - snprintf(context_id_str, 7, "%4X: ", browser->context_id); + fmt_context_id(browser->context_id, context_id_str); GtkWidget *tab_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_set_name(tab_box, "browser__tabbox"); diff --git a/badwolf.h b/badwolf.h @@ -26,7 +26,7 @@ struct Client GtkWidget *auto_load_images; GtkWidget *location; - int context_id; + uint64_t context_id; WebKitWebView *webView; struct Window *window; diff --git a/interface.txt b/interface.txt @@ -3,7 +3,7 @@ - Each tab contains a Browser View or the Downloads View ## Tab Labels -- An hexadecimal number identifying the webkit process context +- An A-Z represented number identifying the webkit process context - An icon to indicate if a media is playing - The title of the web view - A close button