mirror of
https://github.com/jtheoof/swappy.git
synced 2024-09-11 14:55:49 +03:00
fix(meson): able to build on standard platforms
This commit is contained in:
parent
c5ec285ee7
commit
8abc5d52ec
@ -1,6 +1,3 @@
|
||||
#ifndef _NOTIFICATION_H
|
||||
#define _NOTIFICATION_H
|
||||
#pragma once
|
||||
|
||||
void notification_send(char *title, char *message);
|
||||
|
||||
#endif
|
15
meson.build
15
meson.build
@ -12,22 +12,30 @@ project(
|
||||
)
|
||||
|
||||
add_project_arguments('-Wno-unused-parameter', language: 'c')
|
||||
#add_project_arguments('-Wno-format-truncation', language: 'c')
|
||||
|
||||
swappy_inc = include_directories('include')
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
if cc.get_id() == 'clang'
|
||||
message('clang')
|
||||
add_global_arguments('-Wno-missing-field-initializers', language: 'c')
|
||||
endif
|
||||
|
||||
cairo = dependency('cairo')
|
||||
math = cc.find_library('m')
|
||||
realtime = cc.find_library('rt')
|
||||
gtk = dependency('gtk+-wayland-3.0', version: '>=3.22.0')
|
||||
gtk_layer_shell = dependency('gtk-layer-shell-0', version: '>= 0.1.0')
|
||||
libnotify = dependency('libnotify')
|
||||
wayland_client = dependency('wayland-client')
|
||||
wayland_cursor = dependency('wayland-cursor')
|
||||
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
|
||||
|
||||
libnotify = dependency('libnotify', required: false)
|
||||
|
||||
if libnotify.found()
|
||||
add_project_arguments('-DHAVE_LIBNOTIFY', language: 'c')
|
||||
endif
|
||||
|
||||
subdir('res')
|
||||
subdir('protocol')
|
||||
|
||||
@ -49,7 +57,6 @@ executable(
|
||||
cairo,
|
||||
client_protos,
|
||||
gtk,
|
||||
gtk_layer_shell,
|
||||
libnotify,
|
||||
math,
|
||||
realtime,
|
||||
|
@ -190,17 +190,19 @@ static void action_save_area_to_file(struct swappy_state *state) {
|
||||
char path[MAX_PATH];
|
||||
snprintf(path, MAX_PATH, "%s/%s %s", state->storage_path, "Swappshot",
|
||||
c_time_string);
|
||||
g_info("saving swappshot to: \"%s\"", path);
|
||||
gdk_pixbuf_savev(pixbuf, path, "png", NULL, NULL, &error);
|
||||
|
||||
if (error != NULL) {
|
||||
g_error("unable to save drawing area to pixbuf: %s", error->message);
|
||||
g_critical("unable to save drawing area to pixbuf: %s", error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
char message[MAX_PATH];
|
||||
snprintf(message, MAX_PATH, "Saved Swappshot to: %s\n", path);
|
||||
char *msg = "Saved Swappshot to: ";
|
||||
size_t len = strlen(msg) + strlen(path) + 1;
|
||||
char *message = g_new(char, len);
|
||||
snprintf(message, len, "%s%s", msg, path);
|
||||
notification_send("Swappy", message);
|
||||
g_free(message);
|
||||
}
|
||||
|
||||
void save_clicked_handler(GtkWidget *widget, struct swappy_state *state) {
|
||||
@ -559,8 +561,6 @@ static gint command_line_handler(GtkApplication *app,
|
||||
|
||||
bool application_init(struct swappy_state *state) {
|
||||
GError *error = NULL;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
|
||||
const GOptionEntry cli_options[] = {
|
||||
{
|
||||
.long_name = "geometry",
|
||||
@ -571,7 +571,6 @@ bool application_init(struct swappy_state *state) {
|
||||
"Set the region to capture. (Can be an output of slurp)",
|
||||
},
|
||||
{NULL}};
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
state->app = gtk_application_new("me.jtheoof.swappy",
|
||||
G_APPLICATION_HANDLES_COMMAND_LINE);
|
||||
|
@ -1,12 +1,16 @@
|
||||
#include "notification.h"
|
||||
|
||||
#ifdef HAVE_LIBNOTIFY
|
||||
#include <libnotify/notify.h>
|
||||
#endif
|
||||
|
||||
void notification_send(char *title, char *message) {
|
||||
#ifdef HAVE_LIBNOTIFY
|
||||
notify_init("Hello world!");
|
||||
NotifyNotification *notification =
|
||||
notify_notification_new(title, message, "dialog-information");
|
||||
notify_notification_show(notification, NULL);
|
||||
g_object_unref(G_OBJECT(notification));
|
||||
notify_uninit();
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user