GTK4: formatting pass

This commit is contained in:
NunoSempere 2024-07-21 10:13:27 -04:00
parent db4f980af9
commit d7781d308d

View File

@ -32,8 +32,8 @@ static int custom_style_enabled = 1;
/* Forward declarations */
void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode);
void notebook_create_new_tab(GtkNotebook* notebook, const char* uri);
static int handle_signal_keypress(void *self, int keyval, int keycode,
GdkModifierType state, void *controller);
static int handle_signal_keypress(void* self, int keyval, int keycode,
GdkModifierType state, void* controller);
/* Utils */
WebKitWebView* notebook_get_webview(GtkNotebook* notebook)
@ -130,8 +130,6 @@ void handle_signal_load_changed(WebKitWebView* self, WebKitLoadEvent load_event,
}
}
/* New tabs */
WebKitWebView* create_new_webview()
{
@ -152,7 +150,7 @@ WebKitWebView* create_new_webview()
WebKitWebView* view = g_object_new(WEBKIT_TYPE_WEB_VIEW, "settings", settings, "network-session", network_session, "user-content-manager", contentmanager, NULL);
GtkEventController *event_controller = gtk_event_controller_key_new();
GtkEventController* event_controller = gtk_event_controller_key_new();
g_signal_connect(event_controller, "key-pressed", G_CALLBACK(handle_signal_keypress), NULL);
gtk_widget_add_controller(GTK_WIDGET(view), event_controller);
@ -178,7 +176,6 @@ GtkWidget* handle_signal_create_new_tab(WebKitWebView* self,
return GTK_WIDGET(self); // NULL;
}
void notebook_create_new_tab_mini(GtkNotebook* notebook, const char* uri)
{
WebKitWebView* view = create_new_webview();
@ -288,8 +285,6 @@ void handle_signal_bar_press_enter(void* data)
gtk_widget_hide(GTK_WIDGET(bar.widget));
}
/* Handle shortcuts */
int handle_shortcut_mini(func id)
{
@ -430,11 +425,10 @@ int handle_shortcut(func id)
return 1;
}
/* Listen to keypresses */
static int handle_signal_keypress(void *self, int keyval, int keycode,
GdkModifierType state, void *controller)
static int handle_signal_keypress(void* self, int keyval, int keycode,
GdkModifierType state, void* controller)
{
// (void) self, (void) keycode, (void) controller;
@ -445,7 +439,7 @@ static int handle_signal_keypress(void *self, int keyval, int keycode,
printf("Keypress state: %d\n", state);
printf("Keypress value: %d\n", keyval);
}
for (int i = 0; i < sizeof(shortcut) / sizeof(shortcut[0]); i++){
for (int i = 0; i < sizeof(shortcut) / sizeof(shortcut[0]); i++) {
if ((state & shortcut[i].mod || shortcut[i].mod == 0x0) && keyval == shortcut[i].key) {
printf("New shortcut, with id: %d\n", shortcut[i].id);
return handle_shortcut(shortcut[i].id);
@ -453,7 +447,6 @@ static int handle_signal_keypress(void *self, int keyval, int keycode,
}
return 0;
}
int main(int argc, char** argv)
@ -486,7 +479,7 @@ int main(int argc, char** argv)
gtk_window_set_titlebar(window, GTK_WIDGET(bar.widget));
// Signals
GtkEventController *event_controller = gtk_event_controller_key_new();
GtkEventController* event_controller = gtk_event_controller_key_new();
g_signal_connect(event_controller, "key-pressed", G_CALLBACK(handle_signal_keypress), NULL);
gtk_widget_add_controller(GTK_WIDGET(window), event_controller);
@ -512,7 +505,7 @@ int main(int argc, char** argv)
}
// Enter the main event loop, and wait for user interaction
printf("\nEntering main loop");
printf("Entering main loop\n");
while (g_list_model_get_n_items(gtk_window_get_toplevels()) > 0 && num_tabs > 0)
g_main_context_iteration(NULL, TRUE);