|
libxputty
0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
|
|
Go to the documentation of this file.
40 static void draw_window(
void *w_,
void* user_data) {
42 XWindowAttributes attrs;
43 XGetWindowAttributes(w->
app->
dpy, (Window)w->
widget, &attrs);
44 int width = attrs.width;
45 int height = attrs.height;
46 if (attrs.map_state != IsViewable)
return;
48 cairo_rectangle(w->
crb,0,0,width,height);
54 cairo_set_font_size (w->
crb, 12.0);
55 cairo_move_to (w->
crb, 20, 35);
56 cairo_show_text(w->
crb,
"Directory");
57 cairo_move_to (w->
crb, 20, 85);
58 cairo_show_text(w->
crb,
"File");
59 cairo_move_to (w->
crb, 20, 340);
60 cairo_show_text(w->
crb,
"Load: ");
61 cairo_move_to (w->
crb, 45, 380);
62 cairo_show_text(w->
crb,
"Show hidden files");
63 cairo_move_to (w->
crb, 60, 340);
68 static void button_quit_callback(
void *w_,
void* user_data) {
79 static inline int clear(
Widget_t *w) {
84 static inline int set_files(
FileDialog *file_dialog) {
95 static void set_dirs(
FileDialog *file_dialog) {
110 static void set_selected_file(
FileDialog *file_dialog) {
124 static void file_released_callback(
void *w_,
void* user_data) {
127 set_selected_file(file_dialog);
134 static void reload_file_entrys(
FileDialog *file_dialog) {
135 clear(file_dialog->
ft);
140 int set_f = set_files(file_dialog);
141 center_widget(file_dialog->
w,file_dialog->
ft);
146 static void combo_response(
void *w_,
void* user_data) {
153 free(file_dialog->
fp->
path);
154 file_dialog->
fp->
path = NULL;
156 assert(file_dialog->
fp->
path != NULL);
157 reload_file_entrys(file_dialog);
160 static void button_ok_callback(
void *w_,
void* user_data) {
165 set_selected_file(file_dialog);
175 static void dummy(
void *w_,
void* user_data) {
179 static void reload_all(
FileDialog *file_dialog) {
186 free(file_dialog->
fp->
path);
187 file_dialog->
fp->
path = NULL;
189 assert(file_dialog->
fp->
path != NULL);
190 clear(file_dialog->
ft);
191 clear(file_dialog->
ct);
194 center_widget(file_dialog->
w,file_dialog->
ct);
200 int set_f = set_files(file_dialog);
201 center_widget(file_dialog->
w,file_dialog->
ft);
202 set_dirs(file_dialog);
208 static void open_dir_callback(
void *w_,
void* user_data) {
212 reload_all(file_dialog);
216 static void button_hidden_callback(
void *w_,
void* user_data) {
221 reload_all(file_dialog);
225 static void set_filter_callback(
void *w_,
void* user_data) {
237 assert(file_dialog->
fp->
filter != NULL);
239 reload_file_entrys(file_dialog);
243 static void fd_mem_free(
void *w_,
void* user_data) {
246 if(file_dialog->
icon) {
247 XFreePixmap(w->
app->
dpy, (*file_dialog->
icon));
248 file_dialog->
icon = NULL;
253 free(file_dialog->
fp);
261 fp_init(file_dialog->
fp, (path) ? path :
"/");
264 file_dialog->
icon = NULL;
289 int set_f = set_files(file_dialog);
290 set_dirs(file_dialog);
316 if(filter !=NULL && strlen(filter))
320 if(filter !=NULL && strlen(filter))
331 return file_dialog->
w;
340 static void fdialog_response(
void *w_,
void* user_data) {
343 if(user_data !=NULL) {
344 char *tmp = strdup(*(
const char**)user_data);
347 filebutton->
last_path = strdup(dirname(tmp));
356 static void fbutton_callback(
void *w_,
void* user_data) {
368 static void fbutton_mem_free(
void *w_,
void* user_data) {
378 const char *path,
const char *filter) {
380 filebutton->
path = path;
381 filebutton->
filter = filter;
383 filebutton->
w = NULL;
int fp_get_files(FilePicker *filepicker, char *path, int get_dirs)
fp_get_files - fill file_names and dir_names with the results from readdir path
void fp_free(FilePicker *filepicker)
fp_free - release all memory used by the filepicker
Widget_t * add_file_button(Widget_t *parent, int x, int y, int width, int height, const char *path, const char *filter)
add_file_button - add a pre-defined button which will pop-up a file dialog when pressed....
Widget_t * combobox_add_entry(Widget_t *wid, const char *label)
combobox_add_entry - add a entry to the combobox
float adj_get_value(Adjustment_t *adj)
adj_get_value - get the current value of the Adjustment_t
void listview_set_active_entry(Widget_t *w, int active)
listview_set_active_entry - set the active listview entry
void adj_set_value(Adjustment_t *adj, float value)
adj_set_value - set the current value to the Adjustment_t
void use_fg_color_scheme(Widget_t *w, Color_state st)
use_fg_color_scheme - use forground Colors to paint on Widget_t
void fp_init(FilePicker *filepicker, const char *path)
fp_init - set default values used by the filepicker
unsigned int file_counter
void widget_get_png(Widget_t *w, const unsigned char *name)
widget_get_png - read png into Widget_t xlib surface
void combobox_set_active_entry(Widget_t *w, int active)
combobox_set_active_entry - set the active combobox entry
int asprintf(char *strp[], const char *fmt,...)
xevfunc mem_free_callback
Widget_t * open_file_dialog(Widget_t *w, const char *path, const char *filter)
open_file_dialog - open a non blocking dialog window, to select a file. The path to open the file-sel...
void set_pattern(Widget_t *w, Colors *from, Colors *to, Color_mod mod)
set_pattern - set pattern for the selected Colors
void listview_set_list(Widget_t *listview, char **list, int list_size)
listview_set_list - set a list to a listview Widget_t
void widget_set_icon_from_png(Widget_t *w, Pixmap *icon_, const unsigned char *name)
widget_set_icon_from_png - set icon image from png binary to Widget_t those icon will be used in the ...
Widget_t * add_listview(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_label - add a listview to a Widget_t
Widget_t * add_combobox(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_combobox - add a combobox
int childlist_has_child(Childlist_t *childlist)
childlist_has_child - check if a Widget_t Childlist_t contain a child
#define max(x, y)
max - set a minimal value (x) as return value
xevfunc value_changed_callback