Moved the wofi api to wofi_api.h

This commit is contained in:
Scoopta 2020-01-20 16:22:14 -08:00
parent c47f7acdcd
commit 5b41ab2ca6
5 changed files with 68 additions and 38 deletions

View File

@ -18,13 +18,9 @@
#ifndef MAP_H #ifndef MAP_H
#define MAP_H #define MAP_H
#include <stdio.h> #include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <gmodule.h>
struct map* map_init(void); struct map* map_init(void);
struct map* map_init_void(void); struct map* map_init_void(void);

View File

@ -18,7 +18,8 @@
#ifndef WAIFU_H #ifndef WAIFU_H
#define WAIFU_H #define WAIFU_H
#include <map.h> #include <wofi_api.h>
#include <config.h> #include <config.h>
#include <property_box.h> #include <property_box.h>
@ -35,35 +36,5 @@
#include <gdk/gdkwayland.h> #include <gdk/gdkwayland.h>
#include <gio/gdesktopappinfo.h> #include <gio/gdesktopappinfo.h>
#include <wayland-client.h>
#include <wlr-layer-shell-unstable-v1-client-protocol.h> #include <wlr-layer-shell-unstable-v1-client-protocol.h>
struct cache_line {
char* line;
struct wl_list link;
};
void wofi_init(struct map* config);
char* wofi_parse_image_escapes(const char* text);
void wofi_write_cache(const gchar* mode, const gchar* cmd);
void wofi_remove_cache(const gchar* mode, const gchar* cmd);
struct wl_list* wofi_read_cache(char* mode);
struct widget* wofi_create_widget(char* mode, char** text, char* search_text, char** actions, size_t action_count);
bool wofi_allow_images(void);
bool wofi_allow_markup(void);
uint64_t wofi_get_image_size(void);
bool wofi_mod_shift(void);
bool wofi_mod_control(void);
void wofi_term_run(const char* cmd);
#endif #endif

57
inc/wofi_api.h Normal file
View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WOFI_API_H
#define WOFI_API_H
#include <map.h>
#include <stdint.h>
#include <stdbool.h>
#include <wayland-client.h>
struct cache_line {
char* line;
struct wl_list link;
};
void wofi_init(struct map* config);
char* wofi_parse_image_escapes(const char* text);
void wofi_write_cache(const char* mode, const char* cmd);
void wofi_remove_cache(const char* mode, const char* cmd);
struct wl_list* wofi_read_cache(char* mode);
struct widget* wofi_create_widget(char* mode, char** text, char* search_text, char** actions, size_t action_count);
bool wofi_allow_images(void);
bool wofi_allow_markup(void);
uint64_t wofi_get_image_size(void);
bool wofi_mod_shift(void);
bool wofi_mod_control(void);
void wofi_term_run(const char* cmd);
#endif

View File

@ -17,6 +17,12 @@
#include <map.h> #include <map.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmodule.h>
struct map { struct map {
GTree* tree; GTree* tree;
bool mman; bool mman;

View File

@ -415,7 +415,7 @@ static gboolean _insert_widget(gpointer data) {
return TRUE; return TRUE;
} }
void wofi_write_cache(const gchar* mode, const gchar* cmd) { void wofi_write_cache(const char* mode, const char* cmd) {
char* cache_path = get_cache_path(mode); char* cache_path = get_cache_path(mode);
struct wl_list lines; struct wl_list lines;
wl_list_init(&lines); wl_list_init(&lines);
@ -483,7 +483,7 @@ void wofi_write_cache(const gchar* mode, const gchar* cmd) {
free(tmp_path); free(tmp_path);
} }
void wofi_remove_cache(const gchar* mode, const gchar* cmd) { void wofi_remove_cache(const char* mode, const char* cmd) {
char* cache_path = get_cache_path(mode); char* cache_path = get_cache_path(mode);
if(access(cache_path, R_OK | W_OK) == 0) { if(access(cache_path, R_OK | W_OK) == 0) {
struct wl_list lines; struct wl_list lines;