From 90fef3b4682a6e31b1cf9e980b033bb5725ef7fe Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sun, 11 Feb 2024 14:06:23 +0100 Subject: [PATCH] refactor bar variable names --- config.h | 2 +- rose | Bin 43192 -> 43200 bytes rose.c | 55 ++++++++++++++++++++++++++----------------------------- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/config.h b/config.h index 70a1714..98653b7 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ // Key user config #define WIDTH 1920 // 960 for half-width, 1920 for full width #define HEIGHT 1080 -#define SEARCH_BAR_SIZE 1000 +#define BAR_SIZE 1000 // More user config #define ZOOM 1.6 /* Starting zoom level.*/ diff --git a/rose b/rose index 5e03967e2e654e4f4a1e88459307a8d1a6d31349..08caba5aeefc0851e959bbb9a7c94c0be5aee77b 100755 GIT binary patch delta 1766 zcmZ9MZA_b06vxl)8)a8brs7w8mze!AU13sHod0 z0;>bc$#gE7tu7jfFQIg1%UCA!1Dd$Z;B=A9m({S?Y1Gw#Uo@%bp6BiZy&rz}KIi{G zr{~`1K0PsKo0+qXuD3xfUS4M}YPY|AexTfaXUZ@<9}WHv2M*g?6211iYVjUU*Q^!$ z6W`b5-5_4X1z&||OcXuZ=}tMIT)>g$8gU4}YF;P0 z6IYsh9i^EnfYjK}nas%yjngSRWkzbRsOTw*dLwuLh=Z+nh))v7TX&RILN0)SHPAH* zJlxg<9-39$pA|1bU!QEO)@o0ddasUe&x(6>{0SWw^sGi3#`~nXjaC8*!LJrH7OV+6 zG1(`@3z*(3#cnjh(%egm4GLhUR$KIR02@gCke*b}-mG6ai6K&xI=8-VdF~$=3rn#Q z=ZNc=mCVh|EsE&xci^|-BHhcA80fDMofz$x=B!P1WPrPUdDR{~L+TK3^m;h5Z@Kyo zrb(S5Re*%aEH!{7uS;{9b3M?ueR=LV^pSd$-fJP9L|2Warq~T|5%=Us@eeZ}4W~4} z(N4cUvkG0V1d~)JN$+3Px%#jbK0*6YqgLgLc4ja0P38v}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KoS5=_zTNhN16|C?mL zl6NszRMD@j$G96k!V<;ibmmow%}{rkUKP*Tn|#cDqQ{FA=R8NWk36nP!Ta5wrTWLh zqtJBEr_jFue**I;Fref*@EICjqU0{j+rTMG3@BHB;s50wkuze zQ+Wl|#*|ghs=mV#b4#z;rHLl3a^;#)a0I*nehdBv-Udr46jzq-KGSajJIz^>Z5zeo zO77D>{KwSn15eXDM~!ln?wp343Mb$*4c-7<)G?^!TITw~Bh8`1`w#8i_xb@EA6%2X bHW*w&DTgyzGh9+2YbZ4OguFthM@#<$cKMS6 diff --git a/rose.c b/rose.c index 995f802..b8fd86f 100644 --- a/rose.c +++ b/rose.c @@ -1,10 +1,7 @@ -#include // necessary for free, malloc. +#include #include #include - #include "config.h" - -// Plugins #include "plugins/libre_redirect/libre_redirect.h" #include "plugins/readability/readability.h" #include "plugins/shortcuts/shortcuts.h" @@ -16,9 +13,9 @@ static GtkWindow* window; // Search, find and url bar static GtkHeaderBar* bar; -static GtkEntryBuffer* search_buf; -static GtkEntry* search; -static int entry_mode; +static GtkEntry* bar_line; // widget +static GtkEntryBuffer* bar_line_text; +static int bar_entry_mode; enum { _SEARCH, _FIND, _HIDDEN }; /* Plugins */ @@ -248,24 +245,24 @@ void notebook_append(GtkNotebook* notebook, const char* uri) void show_bar(GtkNotebook* notebook) { - if (entry_mode == _SEARCH) { + if (bar_entry_mode == _SEARCH) { const char* url = webkit_web_view_get_uri(notebook_get_webview(notebook)); - gtk_entry_set_placeholder_text(search, "Search"); - gtk_entry_buffer_set_text(search_buf, url, strlen(url)); + gtk_entry_set_placeholder_text(bar_line, "Search"); + gtk_entry_buffer_set_text(bar_line_text, url, strlen(url)); gtk_widget_show(GTK_WIDGET(bar)); - gtk_window_set_focus(window, GTK_WIDGET(search)); - } else if (entry_mode == _HIDDEN) { + gtk_window_set_focus(window, GTK_WIDGET(bar_line)); + } else if (bar_entry_mode == _HIDDEN) { gtk_widget_hide(GTK_WIDGET(bar)); } else { const char* search_text = webkit_find_controller_get_search_text( webkit_web_view_get_find_controller(notebook_get_webview(notebook))); if (search_text != NULL) - gtk_entry_buffer_set_text(search_buf, search_text, strlen(search_text)); + gtk_entry_buffer_set_text(bar_line_text, search_text, strlen(search_text)); - gtk_entry_set_placeholder_text(search, "Find"); + gtk_entry_set_placeholder_text(bar_line, "Find"); gtk_widget_show(GTK_WIDGET(bar)); - gtk_window_set_focus(window, GTK_WIDGET(search)); + gtk_window_set_focus(window, GTK_WIDGET(bar_line)); } } @@ -348,12 +345,12 @@ int handle_key(func id, GtkNotebook* notebook) break; case show_searchbar: - entry_mode = _SEARCH; + bar_entry_mode = _SEARCH; show_bar(notebook); break; case show_finder: - entry_mode = _FIND; + bar_entry_mode = _FIND; show_bar(notebook); break; @@ -370,12 +367,12 @@ int handle_key(func id, GtkNotebook* notebook) case new_tab: notebook_append(notebook, NULL); gtk_notebook_set_show_tabs(notebook, true); - entry_mode = _SEARCH; + bar_entry_mode = _SEARCH; show_bar(notebook); break; case hide_bar: - entry_mode = _HIDDEN; + bar_entry_mode = _HIDDEN; show_bar(notebook); break; @@ -415,13 +412,13 @@ int keypress(void* self, GdkEvent* e, GtkNotebook* notebook) void search_activate(GtkEntry* self, GtkNotebook* notebook) { - if (entry_mode == _SEARCH) + if (bar_entry_mode == _SEARCH) load_uri(notebook_get_webview(notebook), - gtk_entry_buffer_get_text(search_buf)); - else if (entry_mode == _FIND) + gtk_entry_buffer_get_text(bar_line_text)); + else if (bar_entry_mode == _FIND) webkit_find_controller_search( webkit_web_view_get_find_controller(notebook_get_webview(notebook)), - gtk_entry_buffer_get_text(search_buf), + gtk_entry_buffer_get_text(bar_line_text), WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | WEBKIT_FIND_OPTIONS_WRAP_AROUND, G_MAXUINT); @@ -436,11 +433,11 @@ void window_init(GtkNotebook* notebook) gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), 800); gtk_entry_buffer_new("", 0); - gtk_entry_set_alignment(search, 0.48); - gtk_widget_set_size_request(GTK_WIDGET(search), SEARCH_BAR_SIZE, -1); - gtk_header_bar_set_custom_title(bar, GTK_WIDGET(search)); + gtk_entry_set_alignment(bar_line, 0.48); + gtk_widget_set_size_request(GTK_WIDGET(bar_line), BAR_SIZE, -1); + gtk_header_bar_set_custom_title(bar, GTK_WIDGET(bar_line)); gtk_window_set_titlebar(window, GTK_WIDGET(bar)); - g_signal_connect(search, "activate", G_CALLBACK(search_activate), notebook); + g_signal_connect(bar_line, "activate", G_CALLBACK(search_activate), notebook); g_signal_connect(window, "key-press-event", G_CALLBACK(keypress), notebook); g_signal_connect(window, "destroy", G_CALLBACK(exit), notebook); } @@ -460,8 +457,8 @@ int main(int argc, char** argv) // Define GTK entities. These are declared globally window = GTK_WINDOW(gtk_window_new(0)); bar = GTK_HEADER_BAR(gtk_header_bar_new()); - search_buf = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0)); - search = GTK_ENTRY(gtk_entry_new_with_buffer(search_buf)); + bar_line_text = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0)); + bar_line = GTK_ENTRY(gtk_entry_new_with_buffer(bar_line_text)); gtk_window_set_default_size(window, WIDTH, HEIGHT); notebook = GTK_NOTEBOOK(gtk_notebook_new()); window_init(notebook);