Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new lib: clipboard #62

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/clipboard/include/astal-clipboard-private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#ifndef ASTAL_CLIPBOARD_PRIVATE_H
#define ASTAL_CLIPBOARD_PRIVATE_H

#include "astal-clipboard.h"
#include "wlr-data-control-unstable-v1-client.h"

G_BEGIN_DECLS

AstalClipboardSelection *astal_clipboard_selection_new(struct zwlr_data_control_offer_v1 *offer);

struct zwlr_data_control_offer_v1 *astal_clipboard_selection_get_offer(
AstalClipboardSelection *self);

G_END_DECLS

#endif // !ASTAL_CLIPBOARD_PRIVATE_H
56 changes: 56 additions & 0 deletions lib/clipboard/include/astal-clipboard.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef ASTAL_CLIPBOARD_H
#define ASTAL_CLIPBOARD_H

#include "glib.h"
#include <glib-object.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

#define ASTAL_CLIPBOARD_MAJOR_VERSION @MAJOR_VERSION@
#define ASTAL_CLIPBOARD_MINOR_VERSION @MINOR_VERSION@
#define ASTAL_CLIPBOARD_MICRO_VERSION @MICRO_VERSION@
#define ASTAL_CLIPBOARD_VERSION "@VERSION@"


G_BEGIN_DECLS

/**
* ClipboardData:
* @mime_type: the mimetype of the data
* @data: the byte representation of the data
*
* This is an example struct.
*/
typedef struct clipboard_data {
gchar* mime_type;
GBytes *data;
} AstalClipboardClipboardData;

gchar* astal_clipboard_clipboard_data_to_string(AstalClipboardClipboardData *data);
GdkPixbuf* astal_clipboard_clipboard_data_to_pixbuf(AstalClipboardClipboardData *data);

#define ASTAL_CLIPBOARD_TYPE_SELECTION (astal_clipboard_selection_get_type())

G_DECLARE_FINAL_TYPE(AstalClipboardSelection, astal_clipboard_selection, ASTAL_CLIPBOARD, SELECTION, GObject)


GList *astal_clipboard_selection_get_data(AstalClipboardSelection *self);

#define ASTAL_CLIPBOARD_TYPE_CLIPBOARD (astal_clipboard_clipboard_get_type())

G_DECLARE_FINAL_TYPE(AstalClipboardClipboard, astal_clipboard_clipboard, ASTAL_CLIPBOARD, CLIPBOARD, GObject)


AstalClipboardClipboard *astal_clipboard_clipboard_get_default();
AstalClipboardClipboard *astal_clipboard_get_default();

AstalClipboardSelection* astal_clipboard_clipboard_get_selection(AstalClipboardClipboard *self);

guint astal_clipboard_clipboard_get_max_length(AstalClipboardClipboard* self);
void astal_clipboard_clipboard_set_max_length(AstalClipboardClipboard* self, guint max_length);

GList* astal_clipboard_clipboard_get_selection_history(AstalClipboardClipboard* self);
GList* astal_clipboard_clipboard_get_primary_selection_history(AstalClipboardClipboard* self);

G_END_DECLS

#endif // !ASTAL_CLIPBOARD_H
17 changes: 17 additions & 0 deletions lib/clipboard/include/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

config = configure_file(
input: 'astal-clipboard.h.in',
output: 'astal-clipboard.h',
configuration: {
'VERSION': meson.project_version(),
'MAJOR_VERSION': version_split[0],
'MINOR_VERSION': version_split[1],
'MICRO_VERSION': version_split[2],
},
)


astal_clipboard_inc = include_directories('.')
astal_clipboard_headers = config

install_headers(astal_clipboard_headers)
21 changes: 21 additions & 0 deletions lib/clipboard/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project(
'astal-clipboard',
'c',
version: '0.1.0',
default_options: ['c_std=gnu11', 'warning_level=3', 'prefix=/usr'],
)

add_project_arguments(['-Wno-pedantic', '-Wno-unused-parameter'], language: 'c')

version_split = meson.project_version().split('.')
lib_so_version = version_split[0] + '.' + version_split[1]

pkg_config = import('pkgconfig')
gnome = import('gnome')

wayland_glib = subproject('wayland-glib')
wayland_glib_dep = wayland_glib.get_variable('wayland_glib')

subdir('protocols')
subdir('include')
subdir('src')
13 changes: 13 additions & 0 deletions lib/clipboard/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
option(
'introspection',
type: 'boolean',
value: true,
description: 'Build gobject-introspection data',
)

option(
'vapi',
type: 'boolean',
value: true,
description: 'Generate vapi data (needs vapigen & introspection option)',
)
23 changes: 23 additions & 0 deletions lib/clipboard/protocols/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
wayland_scanner = find_program('wayland-scanner')

protocols = ['wlr-data-control-unstable-v1.xml']

gen_client_header = generator(
wayland_scanner,
output: ['@[email protected]'],
arguments: ['-c', 'client-header', '@INPUT@', '@BUILD_DIR@/@[email protected]'],
)

gen_private_code = generator(
wayland_scanner,
output: ['@[email protected]'],
arguments: ['-c', 'private-code', '@INPUT@', '@BUILD_DIR@/@[email protected]'],
)

client_protocol_srcs = []

foreach protocol : protocols
client_header = gen_client_header.process(protocol)
code = gen_private_code.process(protocol)
client_protocol_srcs += [client_header, code]
endforeach
Loading