diff options
Use [A..Z] instead of [0..F] for representing the context_id
3 files changed, 28 insertions, 5 deletions
| -rw-r--r-- | badwolf.c | 29 | ||||
| -rw-r--r-- | badwolf.h | 2 | ||||
| -rw-r--r-- | interface.txt | 2 |
@@ -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"); @@ -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 |