Skip to content

Commit

Permalink
0.06 - Notifications support !
Browse files Browse the repository at this point in the history
  • Loading branch information
koutsie committed Feb 20, 2023
1 parent cb419bf commit 180fa94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 86 deletions.
76 changes: 0 additions & 76 deletions .github/workflows/codeql.yml

This file was deleted.

20 changes: 10 additions & 10 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
static GtkStatusIcon *tray_icon;
static GtkWidget *window;

char localver[20] = "0.05"; // Current version, update this while building!
char localver[20] = "0.06"; // Current version, update this while building!

// Horrible logger
void hlog(const char *type, const char *format, ...)
Expand Down Expand Up @@ -73,13 +73,15 @@ void hlog(const char *type, const char *format, ...)
va_end(args);
}

// Initial desktop notification crap
void set_notification_permissions(WebKitWebContext *context)
// Notification (permissions) now work!
static void on_permission_request(WebKitWebView *web_view, WebKitPermissionRequest *request, gpointer user_data)
{
WebKitSecurityOrigin *origin = webkit_security_origin_new("https", "cinny.the-sauna.icu", 443);
GList *allowed_origins = g_list_append(NULL, origin);
webkit_web_context_initialize_notification_permissions(context, allowed_origins, NULL);
g_list_free(allowed_origins);
if (WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(request))
{
hlog("lfc", "Notification permission request allowed.\n");
WebKitNotificationPermissionRequest *notification_request = WEBKIT_NOTIFICATION_PERMISSION_REQUEST(request);
webkit_permission_request_allow(WEBKIT_PERMISSION_REQUEST(notification_request));
}
}

static void on_window_close(GtkWidget *widget, GdkEvent *event, gpointer data)
Expand Down Expand Up @@ -302,9 +304,6 @@ int main(int argc, char *argv[])
// Use the settings object to configure a WebKitWebView...
webkit_web_view_set_settings(web_view, settings);

// Other useless crap like desktop notifications:
set_notification_permissions(context);

webkit_web_view_load_uri(web_view, "https://cinny.the-sauna.icu/");

GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);
Expand All @@ -322,6 +321,7 @@ int main(int argc, char *argv[])
g_signal_connect(tray_icon, "activate", G_CALLBACK(on_tray_icon_activate), NULL);
g_signal_connect(tray_icon, "popup-menu", G_CALLBACK(on_tray_icon_popup_menu), NULL);
g_signal_connect(window, "key-press-event", G_CALLBACK(on_key_press), NULL);
g_signal_connect(web_view, "permission-request", G_CALLBACK(on_permission_request), NULL);

// Check updates, set off a fire in GTK & return 0 if everything went to hell!
check_update();
Expand Down

0 comments on commit 180fa94

Please sign in to comment.