From 1bb534fc7c547475767eca5937ec57430fa5628b Mon Sep 17 00:00:00 2001 From: Jeremy Attali Date: Tue, 16 Feb 2021 23:18:17 -0500 Subject: [PATCH] chore(notification): remove libnotify dependency and notifications Closes #58 --- .github/workflows/build.yml | 4 ++-- README.md | 1 - include/notification.h | 3 --- meson.build | 8 -------- meson_options.txt | 1 - src/clipboard.c | 4 ---- src/notification.c | 16 ---------------- src/pixbuf.c | 9 --------- 8 files changed, 2 insertions(+), 44 deletions(-) delete mode 100644 include/notification.h delete mode 100644 src/notification.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9353de0..bb1ac82 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: - name: GCC run: | sudo apt-get update - sudo apt --yes install libgtk-3-dev libnotify-dev meson ninja-build scdoc + sudo apt --yes install libgtk-3-dev meson ninja-build scdoc pkg-config --list-all CC=gcc meson build ninja -C build @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v1 - name: Clang run: | - sudo apt --yes install libgtk-3-dev libnotify-dev meson ninja-build scdoc clang clang-format clang-tidy + sudo apt --yes install libgtk-3-dev meson ninja-build scdoc clang clang-format clang-tidy CC=clang meson build ninja -C build echo "Making sure clang-format is correct..." diff --git a/README.md b/README.md index 7918d52..8b32397 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,6 @@ Install dependencies (on Arch, name can vary for other distros): Optional dependencies: - `wl-clipboard` (to make sure the copy is saved if you close swappy) -- `libnotify` (not get notified when swappshot is copied or saved) - `otf-font-awesome` (to draw the paint icons properly) Then run: diff --git a/include/notification.h b/include/notification.h deleted file mode 100644 index aac2929..0000000 --- a/include/notification.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void notification_send(char *title, char *message); diff --git a/meson.build b/meson.build index 847f450..a311e65 100644 --- a/meson.build +++ b/meson.build @@ -43,12 +43,6 @@ math = cc.find_library('m') gtk = dependency('gtk+-3.0', version: '>=3.20.0') gio = dependency('gio-2.0') -libnotify = dependency('libnotify', required: get_option('libnotify')) - -if libnotify.found() - add_project_arguments('-DHAVE_LIBNOTIFY', language: 'c') -endif - subdir('res') subdir('src/po') @@ -66,7 +60,6 @@ executable( 'src/paint.c', 'src/pixbuf.c', 'src/render.c', - 'src/notification.c', 'src/util.c', ]), dependencies: [ @@ -74,7 +67,6 @@ executable( pango, gio, gtk, - libnotify, math, ], link_args: '-rdynamic', diff --git a/meson_options.txt b/meson_options.txt index d6dbce9..e40a23d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1 @@ option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages') -option('libnotify', type: 'feature', value: 'auto', description: 'Send desktop notifications') diff --git a/src/clipboard.c b/src/clipboard.c index 6310d35..188c33c 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -4,7 +4,6 @@ #include #include -#include "notification.h" #include "pixbuf.h" #include "util.h" @@ -81,9 +80,6 @@ bool clipboard_copy_drawing_area_to_selection(struct swappy_state *state) { send_pixbuf_to_gdk_clipboard(pixbuf); } - char message[MAX_PATH]; - g_snprintf(message, MAX_PATH, "Swappshot copied to clipboard\n"); - notification_send("Swappy", message); g_object_unref(pixbuf); return true; diff --git a/src/notification.c b/src/notification.c deleted file mode 100644 index af68b08..0000000 --- a/src/notification.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "notification.h" - -#ifdef HAVE_LIBNOTIFY -#include -#endif - -void notification_send(char *title, char *message) { -#ifdef HAVE_LIBNOTIFY - notify_init("Hello world!"); - NotifyNotification *notification = - notify_notification_new(title, message, "image"); - notify_notification_show(notification, NULL); - g_object_unref(G_OBJECT(notification)); - notify_uninit(); -#endif -} diff --git a/src/pixbuf.c b/src/pixbuf.c index 95ad9d7..fdecdca 100644 --- a/src/pixbuf.c +++ b/src/pixbuf.c @@ -3,8 +3,6 @@ #include #include -#include "notification.h" - GdkPixbuf *pixbuf_get_from_state(struct swappy_state *state) { guint width = cairo_image_surface_get_width(state->rendering_surface); guint height = cairo_image_surface_get_height(state->rendering_surface); @@ -22,13 +20,6 @@ static void write_file(GdkPixbuf *pixbuf, char *path) { g_critical("unable to save drawing area to pixbuf: %s", error->message); g_error_free(error); } - - char *msg = "Saved Swappshot to: "; - size_t len = strlen(msg) + strlen(path) + 1; - char *message = g_new(char, len); - g_snprintf(message, len, "%s%s", msg, path); - notification_send("Swappy", message); - g_free(message); } void pixbuf_save_state_to_folder(GdkPixbuf *pixbuf, char *folder,