Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitc2b4c8fb07b50c064d8ffe5ce02e84e21b6cffaa (patch)
Author
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-10-26 07:28:06 +0100
Committer
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-10-26 07:30:29 +0100
Files4913fdb8d251920eaa94d36b0258d0f589359b8b
goodwolf-c2b4c8fb07b50c064d8ffe5ce02e84e21b6cffaa.tar
goodwolf-c2b4c8fb07b50c064d8ffe5ce02e84e21b6cffaa.tar.gz
goodwolf-c2b4c8fb07b50c064d8ffe5ce02e84e21b6cffaa.zip
Parent74b19d30081537e052b314acf3752c5ee26a0e2c (diff)
Use [A..Z] instead of [0..F] for representing the context_id
3 files changed, 28 insertions, 5 deletions
-rw-r--r--badwolf.c29
-rw-r--r--badwolf.h2
-rw-r--r--interface.txt2
diff --git a/badwolf.c b/badwolf.c
index 665f144..0d391e1 100644
--- 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
index a375be6..8a4edec 100644
--- 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
index f23a149..42f7f5c 100644
--- 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