Added widget builder API

This commit is contained in:
Scoopta
2020-06-22 22:45:51 -07:00
parent 2afc0b9809
commit 5c59d8317c
7 changed files with 296 additions and 27 deletions

34
inc/widget_builder.h Normal file
View File

@@ -0,0 +1,34 @@
/*
* 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 WIDGET_BUILDER_H
#define WIDGET_BUILDER_H
#include <widget_builder_api.h>
#include <property_box.h>
struct widget_builder {
WofiPropertyBox* box;
struct widget* widget;
struct mode* mode;
size_t actions;
};
void wofi_free_widget_builder(struct widget_builder* builder);
#endif

41
inc/widget_builder_api.h Normal file
View File

@@ -0,0 +1,41 @@
/*
* 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 WIDGET_BUILDER_API_H
#define WIDGET_BUILDER_API_H
#include <stddef.h>
#include <wofi_api.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
struct widget_builder* wofi_create_widget_builder(struct mode* mode, size_t actions);
void wofi_widget_builder_set_search_text(struct widget_builder* builder, char* search_text);
void wofi_widget_builder_set_action(struct widget_builder* builder, char* action);
void wofi_widget_builder_insert_text(struct widget_builder* builder, char* text, char* css_name);
void wofi_widget_builder_insert_image(struct widget_builder* builder, GdkPixbuf* pixbuf, char* css_name);
struct widget_builder* wofi_widget_builder_get_idx(struct widget_builder* builder, size_t idx);
struct widget* wofi_widget_builder_get_widget(struct widget_builder* builder);
#endif

View File

@@ -24,6 +24,21 @@
#include <map.h>
#include <gtk/gtk.h>
struct widget {
size_t action_count;
char* mode, **text, *search_text, **actions;
struct widget_builder* builder;
};
struct mode {
void (*mode_exec)(const gchar* cmd);
struct widget* (*mode_get_widget)(void);
char* name, *dso;
struct wl_list link;
};
void wofi_init(struct map* config);
void wofi_load_css(bool nyan);