|
libxputty
0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
|
|
Go to the documentation of this file.
41 static void draw_window(
void *w_,
void* user_data) {
43 XWindowAttributes attrs;
44 XGetWindowAttributes(w->
app->
dpy, (Window)w->
widget, &attrs);
45 int width = attrs.width;
46 int height = attrs.height;
47 if (attrs.map_state != IsViewable)
return;
49 cairo_rectangle(w->
crb,0,0,width,height);
55 cairo_set_font_size (w->
crb, 12.0);
56 cairo_move_to (w->
crb, 20, 35);
57 cairo_show_text(w->
crb,
"Directory");
58 cairo_move_to (w->
crb, 20, 85);
59 cairo_show_text(w->
crb,
"File");
60 cairo_move_to (w->
crb, 20, 340);
61 cairo_show_text(w->
crb,
"Save as: ");
62 cairo_move_to (w->
crb, 45, 380);
63 cairo_show_text(w->
crb,
"Show hidden files");
69 static void button_quit_callback(
void *w_,
void* user_data) {
80 static inline int clear(
Widget_t *w) {
85 static inline int set_files(
FileDialog *file_dialog) {
96 static void set_dirs(
FileDialog *file_dialog) {
111 static void get_entry(
Widget_t *w) {
119 static void set_selected_file(
FileDialog *file_dialog) {
136 static void file_released_callback(
void *w_,
void* user_data) {
139 set_selected_file(file_dialog);
146 static void forward_key_press(
void *w_,
void *key_,
void *user_data) {
152 static void reload_file_entrys(
FileDialog *file_dialog) {
153 clear(file_dialog->
ft);
158 int set_f = set_files(file_dialog);
159 center_widget(file_dialog->
w,file_dialog->
ft);
165 static void combo_response(
void *w_,
void* user_data) {
172 free(file_dialog->
fp->
path);
173 file_dialog->
fp->
path = NULL;
175 assert(file_dialog->
fp->
path != NULL);
176 reload_file_entrys(file_dialog);
179 static void save_and_exit(
void *w_) {
188 "Please enter a file name",NULL);
193 static void question_response(
void *w_,
void* user_data) {
194 if(user_data !=NULL) {
195 int response = *(
int*)user_data;
202 static void button_ok_callback(
void *w_,
void* user_data) {
206 set_selected_file(file_dialog);
209 "File already exsist, would you overwrite it?",NULL);
217 static void dummy(
void *w_,
void* user_data) {
221 static void reload_all(
FileDialog *file_dialog) {
228 free(file_dialog->
fp->
path);
229 file_dialog->
fp->
path = NULL;
231 assert(file_dialog->
fp->
path != NULL);
232 clear(file_dialog->
ft);
233 clear(file_dialog->
ct);
236 center_widget(file_dialog->
w,file_dialog->
ct);
243 int set_f = set_files(file_dialog);
244 center_widget(file_dialog->
w,file_dialog->
ft);
245 set_dirs(file_dialog);
252 static void open_dir_callback(
void *w_,
void* user_data) {
256 reload_all(file_dialog);
260 static void button_hidden_callback(
void *w_,
void* user_data) {
265 reload_all(file_dialog);
269 static void set_filter_callback(
void *w_,
void* user_data) {
281 assert(file_dialog->
fp->
filter != NULL);
283 reload_file_entrys(file_dialog);
287 static void draw_entry(
void *w_,
void* user_data) {
290 XWindowAttributes attrs;
291 XGetWindowAttributes(w->
app->
dpy, (Window)w->
widget, &attrs);
292 int width = attrs.width;
293 int height = attrs.height;
294 if (attrs.map_state != IsViewable)
return;
297 cairo_rectangle(w->
cr,0,0,width,height);
298 cairo_fill_preserve (w->
cr);
300 cairo_set_line_width(w->
cr, 2.0);
303 cairo_set_font_size (w->
cr, 9.0);
305 cairo_move_to (w->
cr, 2, 9);
306 cairo_show_text(w->
cr,
" ");
309 static void entry_add_text(
void *w_,
void *label_) {
312 char *label = (
char*)label_;
317 cairo_text_extents_t extents;
319 cairo_set_font_size (w->
cr, 11.0);
328 cairo_set_font_size (w->
cr, 12.0);
331 cairo_move_to (w->
cr, 2, 12.0+extents.height);
336 static void entry_clip(
Widget_t *w) {
338 cairo_text_extents_t extents;
340 cairo_set_font_size (w->
cr, 11.0);
360 cairo_set_font_size (w->
cr, 12.0);
363 cairo_move_to (w->
cr, 2, 12.0+extents.height);
368 static void entry_get_text(
void *w_,
void *key_,
void *user_data) {
371 XKeyEvent *key = (XKeyEvent*)key_;
380 Xutf8LookupString(w->
xic, key, buf,
sizeof(buf) - 1, &keysym, &status);
381 if(status == XLookupChars || status == XLookupBoth){
382 entry_add_text(w, buf);
387 static void fd_mem_free(
void *w_,
void* user_data) {
390 if(file_dialog->
icon) {
391 XFreePixmap(w->
app->
dpy, (*file_dialog->
icon));
392 file_dialog->
icon = NULL;
397 free(file_dialog->
fp);
405 fp_init(file_dialog->
fp, (path) ? path :
"/");
408 file_dialog->
icon = NULL;
436 int set_f = set_files(file_dialog);
437 set_dirs(file_dialog);
473 if(filter !=NULL && strlen(filter))
477 if(filter !=NULL && strlen(filter))
488 return file_dialog->
w;
497 static void fdialog_response(
void *w_,
void* user_data) {
500 if(user_data !=NULL) {
501 char *tmp = strdup(*(
const char**)user_data);
504 filebutton->
last_path = strdup(dirname(tmp));
513 static void fbutton_callback(
void *w_,
void* user_data) {
525 static void fbutton_mem_free(
void *w_,
void* user_data) {
535 const char *path,
const char *filter) {
537 filebutton->
path = path;
538 filebutton->
filter = filter;
540 filebutton->
w = NULL;
void use_text_color_scheme(Widget_t *w, Color_state st)
use_text_color_scheme - use text Colors to paint on Widget_t
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 * 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
Widget_t * add_save_file_button(Widget_t *parent, int x, int y, int width, int height, const char *path, const char *filter)
add_save_file_button - add a pre-defined button which will pop-up a file dialog when pressed....
evfunc key_press_callback
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,...)
Widget_t * save_file_dialog(Widget_t *w, const char *path, const char *filter)
save_file_dialog - open a non blocking dialog window, to select a file. The path to open the file-sel...
xevfunc mem_free_callback
Widget_t * open_message_dialog(Widget_t *w, int style, const char *title, const char *message, const char *choices)
open_message_dialog - open a non blocking dialog window, lines in message chould be separated by the ...
#define IS_UTF8(c)
IS_UTF8 - check if a char contain UTF 8 formated signs.
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
void use_base_color_scheme(Widget_t *w, Color_state st)
use_base_color_scheme - use base Colors to paint on Widget_t
xevfunc value_changed_callback