libxputty  0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
xfile-dialog.c
Go to the documentation of this file.
1 /*
2  * 0BSD
3  *
4  * BSD Zero Clause License
5  *
6  * Copyright (c) 2019 Hermann Meyer
7  *
8  * Permission to use, copy, modify, and/or distribute this software for any
9  * purpose with or without fee is hereby granted.
10 
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13  * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  *
19  */
20 
21 
22 /*
23 #ifndef _GNU_SOURCE
24 #define _GNU_SOURCE 1
25 #endif
26 */
27 
28 #include <dirent.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <stdarg.h>
32 #include <string.h>
33 #include <unistd.h>
34 
35 #include <libgen.h>
36 
37 #include "xfile-dialog.h"
38 
39 
40 static void draw_window(void *w_, void* user_data) {
41  Widget_t *w = (Widget_t*)w_;
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;
47 
48  cairo_rectangle(w->crb,0,0,width,height);
50  cairo_fill (w->crb);
51 
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);
64  cairo_show_text(w->crb, w->label);
66 }
67 
68 static void button_quit_callback(void *w_, void* user_data) {
69  Widget_t *w = (Widget_t*)w_;
70  FileDialog *file_dialog = (FileDialog *)w->parent_struct;
71 
72  if (w->flags & HAS_POINTER && !adj_get_value(w->adj)){
73  file_dialog->parent->func.dialog_callback(file_dialog->parent,NULL);
74  file_dialog->send_clear_func = false;
75  destroy_widget(file_dialog->w,file_dialog->w->app);
76  }
77 }
78 
79 static inline int clear(Widget_t *w) {
80  destroy_widget(w,w->app);
81  return 0;
82 }
83 
84 static inline int set_files(FileDialog *file_dialog) {
85  listview_set_list(file_dialog->ft,file_dialog->fp->file_names , (int)file_dialog->fp->file_counter);
86  int ret = 0;
87  int i = 0;
88  for (; i<(int)file_dialog->fp->file_counter; i++) {
89  if(file_dialog->fp->selected_file && strcmp(file_dialog->fp->file_names[i],
90  basename(file_dialog->fp->selected_file))==0 ) ret = i;
91  }
92  return ret;
93 }
94 
95 static void set_dirs(FileDialog *file_dialog) {
96  int i = 0;
97  for (; i<(int)file_dialog->fp->dir_counter; i++) {
98  combobox_add_entry(file_dialog->ct,file_dialog->fp->dir_names[i]);
99  }
100 }
101 
102 static void center_widget(Widget_t *wid, Widget_t *w) {
103  XMoveWindow(wid->app->dpy,w->widget,w->scale.init_x /
104  wid->scale.cscale_x,w->scale.init_y / wid->scale.cscale_y);
105  XResizeWindow (wid->app->dpy, w->widget, max(1,
106  w->scale.init_width / (wid->scale.cscale_x)),
107  max(1,w->scale.init_height / (wid->scale.cscale_y)));
108 }
109 
110 static void set_selected_file(FileDialog *file_dialog) {
111  if(adj_get_value(file_dialog->ft->adj)<0 ||
112  adj_get_value(file_dialog->ft->adj) > file_dialog->fp->file_counter) return;
113  Widget_t* menu = file_dialog->ct->childlist->childs[1];
114  Widget_t* view_port = menu->childlist->childs[0];
115  if(!childlist_has_child(view_port->childlist)) return ;
116  Widget_t *dir = view_port->childlist->childs[(int)adj_get_value(file_dialog->ct->adj)];
117  free(file_dialog->fp->selected_file);
118  file_dialog->fp->selected_file = NULL;
119  asprintf(&file_dialog->fp->selected_file, "%s/%s",dir->label,
120  file_dialog->fp->file_names[(int)adj_get_value(file_dialog->ft->adj)]);
121  assert(file_dialog->fp->selected_file != NULL);
122 }
123 
124 static void file_released_callback(void *w_, void* user_data) {
125  Widget_t *w = (Widget_t*)w_;
126  FileDialog *file_dialog = (FileDialog *)w->parent_struct;
127  set_selected_file(file_dialog);
128  if(file_dialog->fp->selected_file) {
129  file_dialog->w->label = file_dialog->fp->selected_file;
130  expose_widget(file_dialog->w);
131  }
132 }
133 
134 static void reload_file_entrys(FileDialog *file_dialog) {
135  clear(file_dialog->ft);
136  fp_get_files(file_dialog->fp,file_dialog->fp->path, 0);
137  file_dialog->ft = add_listview(file_dialog->w, "", 20, 90, 620, 225);
138  file_dialog->ft->parent_struct = file_dialog;
139  file_dialog->ft->func.value_changed_callback = file_released_callback;
140  int set_f = set_files(file_dialog);
141  center_widget(file_dialog->w,file_dialog->ft);
142  listview_set_active_entry(file_dialog->ft, set_f);
143  widget_show_all(file_dialog->w);
144 }
145 
146 static void combo_response(void *w_, void* user_data) {
147  Widget_t *w = (Widget_t*)w_;
148  FileDialog *file_dialog = (FileDialog *)w->parent_struct;
149  Widget_t* menu = w->childlist->childs[1];
150  Widget_t* view_port = menu->childlist->childs[0];
151  if(!childlist_has_child(view_port->childlist)) return ;
152  Widget_t *entry = view_port->childlist->childs[(int)adj_get_value(w->adj)];
153  free(file_dialog->fp->path);
154  file_dialog->fp->path = NULL;
155  asprintf(&file_dialog->fp->path, "%s",entry->label);
156  assert(file_dialog->fp->path != NULL);
157  reload_file_entrys(file_dialog);
158 }
159 
160 static void button_ok_callback(void *w_, void* user_data) {
161  Widget_t *w = (Widget_t*)w_;
162  FileDialog *file_dialog = (FileDialog *)w->parent_struct;
163  if (w->flags & HAS_POINTER && !*(int*)user_data){
164  if(!file_dialog->fp->selected_file) {
165  set_selected_file(file_dialog);
166  }
167  if(file_dialog->fp->selected_file) {
168  file_dialog->parent->func.dialog_callback(file_dialog->parent,&file_dialog->fp->selected_file);
169  file_dialog->send_clear_func = false;
170  }
171  destroy_widget(file_dialog->w,file_dialog->w->app);
172  }
173 }
174 
175 static void dummy(void *w_, void* user_data) {
176 
177 }
178 
179 static void reload_all(FileDialog *file_dialog) {
180  file_dialog->ct->func.value_changed_callback = dummy;
181  file_dialog->ft->func.value_changed_callback = dummy;
182  Widget_t* menu = file_dialog->ct->childlist->childs[1];
183  Widget_t* view_port = menu->childlist->childs[0];
184  if(!childlist_has_child(view_port->childlist)) return ;
185  Widget_t *entry = view_port->childlist->childs[(int)adj_get_value(file_dialog->ct->adj)];
186  free(file_dialog->fp->path);
187  file_dialog->fp->path = NULL;
188  asprintf(&file_dialog->fp->path, "%s",entry->label);
189  assert(file_dialog->fp->path != NULL);
190  clear(file_dialog->ft);
191  clear(file_dialog->ct);
192  int ds = fp_get_files(file_dialog->fp,file_dialog->fp->path, 1);
193  file_dialog->ct = add_combobox(file_dialog->w, "", 20, 40, 550, 30);
194  center_widget(file_dialog->w,file_dialog->ct);
195  file_dialog->ct->parent_struct = file_dialog;
196  file_dialog->ct->func.value_changed_callback = combo_response;
197  file_dialog->ft = add_listview(file_dialog->w, "", 20, 90, 620, 225);
198  file_dialog->ft->parent_struct = file_dialog;
199  file_dialog->ft->func.value_changed_callback = file_released_callback;
200  int set_f = set_files(file_dialog);
201  center_widget(file_dialog->w,file_dialog->ft);
202  set_dirs(file_dialog);
203  combobox_set_active_entry(file_dialog->ct, ds);
204  listview_set_active_entry(file_dialog->ft, set_f);
205  widget_show_all(file_dialog->w);
206 }
207 
208 static void open_dir_callback(void *w_, void* user_data) {
209  Widget_t *w = (Widget_t*)w_;
210  FileDialog *file_dialog = (FileDialog *)w->parent_struct;
211  if (w->flags & HAS_POINTER && !*(int*)user_data){
212  reload_all(file_dialog);
213  }
214 }
215 
216 static void button_hidden_callback(void *w_, void* user_data) {
217  Widget_t *w = (Widget_t*)w_;
218  FileDialog *file_dialog = (FileDialog *)w->parent_struct;
219  if (w->flags & HAS_POINTER) {
220  file_dialog->fp->show_hidden = adj_get_value(w->adj) ? true : false;
221  reload_all(file_dialog);
222  }
223 }
224 
225 static void set_filter_callback(void *w_, void* user_data) {
226  Widget_t *w = (Widget_t*)w_;
227  FileDialog *file_dialog = (FileDialog *)w->parent_struct;
228  if (file_dialog->fp->use_filter != (int)adj_get_value(w->adj)) {
229  file_dialog->fp->use_filter = (int)adj_get_value(w->adj);
230  Widget_t* menu = w->childlist->childs[1];
231  Widget_t* view_port = menu->childlist->childs[0];
232  if(!childlist_has_child(view_port->childlist)) return ;
233  Widget_t *entry = view_port->childlist->childs[(int)adj_get_value(w->adj)];
234  free(file_dialog->fp->filter);
235  file_dialog->fp->filter = NULL;
236  asprintf(&file_dialog->fp->filter, "%s",entry->label);
237  assert(file_dialog->fp->filter != NULL);
238 
239  reload_file_entrys(file_dialog);
240  }
241 }
242 
243 static void fd_mem_free(void *w_, void* user_data) {
244  Widget_t *w = (Widget_t*)w_;
245  FileDialog *file_dialog = (FileDialog *)w->parent_struct;
246  if(file_dialog->icon) {
247  XFreePixmap(w->app->dpy, (*file_dialog->icon));
248  file_dialog->icon = NULL;
249  }
250  if(file_dialog->send_clear_func)
251  file_dialog->parent->func.dialog_callback(file_dialog->parent,NULL);
252  fp_free(file_dialog->fp);
253  free(file_dialog->fp);
254  free(file_dialog);
255 }
256 
257 Widget_t *open_file_dialog(Widget_t *w, const char *path, const char *filter) {
258  FileDialog *file_dialog = (FileDialog*)malloc(sizeof(FileDialog));
259 
260  file_dialog->fp = (FilePicker*)malloc(sizeof(FilePicker));
261  fp_init(file_dialog->fp, (path) ? path : "/");
262  file_dialog->parent = w;
263  file_dialog->send_clear_func = true;
264  file_dialog->icon = NULL;
265 
266  file_dialog->w = create_window(w->app, DefaultRootWindow(w->app->dpy), 0, 0, 660, 420);
267  file_dialog->w->flags |= HAS_MEM;
268  file_dialog->w->parent_struct = file_dialog;
269  widget_set_title(file_dialog->w, "File Selector");
270  file_dialog->w->func.expose_callback = draw_window;
271  file_dialog->w->func.mem_free_callback = fd_mem_free;
272  widget_set_icon_from_png(file_dialog->w,file_dialog->icon,LDVAR(directory_png));
273 
274  file_dialog->ct = add_combobox(file_dialog->w, "", 20, 40, 550, 30);
275  file_dialog->ct->parent_struct = file_dialog;
276  file_dialog->ct->func.value_changed_callback = combo_response;
277 
278  file_dialog->sel_dir = add_button(file_dialog->w, "Open", 580, 40, 60, 30);
279  file_dialog->sel_dir->parent_struct = file_dialog;
280  file_dialog->sel_dir->scale.gravity = CENTER;
281  add_tooltip(file_dialog->sel_dir,"Open sub-directory's");
282  file_dialog->sel_dir->func.value_changed_callback = open_dir_callback;
283 
284  file_dialog->ft = add_listview(file_dialog->w, "", 20, 90, 620, 225);
285  file_dialog->ft->parent_struct = file_dialog;
286  file_dialog->ft->func.value_changed_callback = file_released_callback;
287 
288  int ds = fp_get_files(file_dialog->fp,file_dialog->fp->path, 1);
289  int set_f = set_files(file_dialog);
290  set_dirs(file_dialog);
291  combobox_set_active_entry(file_dialog->ct, ds);
292  listview_set_active_entry(file_dialog->ft, set_f);
293 
294  file_dialog->w_quit = add_button(file_dialog->w, "Quit", 580, 350, 60, 60);
295  file_dialog->w_quit->parent_struct = file_dialog;
296  file_dialog->w_quit->scale.gravity = CENTER;
297  add_tooltip(file_dialog->w_quit,"Exit file selector");
298  file_dialog->w_quit->func.value_changed_callback = button_quit_callback;
299 
300  file_dialog->w_okay = add_button(file_dialog->w, "Load", 510, 350, 60, 60);
301  file_dialog->w_okay->parent_struct = file_dialog;
302  file_dialog->w_okay->scale.gravity = CENTER;
303  add_tooltip(file_dialog->w_okay,"Load selected file");
304  file_dialog->w_okay->func.value_changed_callback = button_ok_callback;
305 
306  file_dialog->set_filter = add_combobox(file_dialog->w, "", 360, 355, 120, 30);
307  file_dialog->set_filter->parent_struct = file_dialog;
308  combobox_add_entry(file_dialog->set_filter,"all");
309  combobox_add_entry(file_dialog->set_filter,"application");
310  combobox_add_entry(file_dialog->set_filter,"audio");
311  combobox_add_entry(file_dialog->set_filter,"font");
312  combobox_add_entry(file_dialog->set_filter,"image");
313  combobox_add_entry(file_dialog->set_filter,"text");
314  combobox_add_entry(file_dialog->set_filter,"video");
315  combobox_add_entry(file_dialog->set_filter,"x-content");
316  if(filter !=NULL && strlen(filter))
317  combobox_add_entry(file_dialog->set_filter,filter);
318  combobox_set_active_entry(file_dialog->set_filter, 0);
319  file_dialog->set_filter->func.value_changed_callback = set_filter_callback;
320  if(filter !=NULL && strlen(filter))
321  combobox_set_active_entry(file_dialog->set_filter, 8);
322  add_tooltip(file_dialog->set_filter->childlist->childs[0], "File filter type");
323 
324  file_dialog->w_hidden = add_check_button(file_dialog->w, "", 20, 365, 20, 20);
325  file_dialog->w_hidden->parent_struct = file_dialog;
326  file_dialog->w_hidden->scale.gravity = CENTER;
327  add_tooltip(file_dialog->w_hidden,"Show hidden files and folders");
328  file_dialog->w_hidden->func.value_changed_callback = button_hidden_callback;
329 
330  widget_show_all(file_dialog->w);
331  return file_dialog->w;
332 }
333 
334 /*---------------------------------------------------------------------
335 -----------------------------------------------------------------------
336  add_file_button
337 -----------------------------------------------------------------------
338 ----------------------------------------------------------------------*/
339 
340 static void fdialog_response(void *w_, void* user_data) {
341  Widget_t *w = (Widget_t*)w_;
342  FileButton *filebutton = (FileButton *)w->parent_struct;
343  if(user_data !=NULL) {
344  char *tmp = strdup(*(const char**)user_data);
345  free(filebutton->last_path);
346  filebutton->last_path = NULL;
347  filebutton->last_path = strdup(dirname(tmp));
348  filebutton->path = filebutton->last_path;
349  free(tmp);
350  }
351  w->func.user_callback(w,user_data);
352  filebutton->is_active = false;
353  adj_set_value(w->adj,0.0);
354 }
355 
356 static void fbutton_callback(void *w_, void* user_data) {
357  Widget_t *w = (Widget_t*)w_;
358  FileButton *filebutton = (FileButton *)w->parent_struct;
359  if (w->flags & HAS_POINTER && adj_get_value(w->adj)){
360  filebutton->w = open_file_dialog(w,filebutton->path,filebutton->filter);
361  filebutton->is_active = true;
362  } else if (w->flags & HAS_POINTER && !adj_get_value(w->adj)){
363  if(filebutton->is_active)
364  destroy_widget(filebutton->w,w->app);
365  }
366 }
367 
368 static void fbutton_mem_free(void *w_, void* user_data) {
369  Widget_t *w = (Widget_t*)w_;
370  FileButton *filebutton = (FileButton *)w->parent_struct;
371  free(filebutton->last_path);
372  filebutton->last_path = NULL;
373  free(filebutton);
374  filebutton = NULL;
375 }
376 
377 Widget_t *add_file_button(Widget_t *parent, int x, int y, int width, int height,
378  const char *path, const char *filter) {
379  FileButton *filebutton = (FileButton*)malloc(sizeof(FileButton));
380  filebutton->path = path;
381  filebutton->filter = filter;
382  filebutton->last_path = NULL;
383  filebutton->w = NULL;
384  filebutton->is_active = false;
385  Widget_t *fbutton = add_image_toggle_button(parent, "", x, y, width, height);
386  fbutton->parent_struct = filebutton;
387  fbutton->flags |= HAS_MEM;
388  widget_get_png(fbutton, LDVAR(directory_open_png));
389  fbutton->scale.gravity = CENTER;
390  fbutton->func.mem_free_callback = fbutton_mem_free;
391  fbutton->func.value_changed_callback = fbutton_callback;
392  fbutton->func.dialog_callback = fdialog_response;
393  return fbutton;
394 }
FileDialog::w_quit
Widget_t * w_quit
Definition: xfile-dialog.h:40
FileButton::last_path
char * last_path
Definition: xfile-dialog.h:53
fp_get_files
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
Definition: xfilepicker.c:131
expose_widget
void expose_widget(Widget_t *w)
expose_widgets - send a expose event (EXPOSE) to a Widget_t
Definition: xwidget.c:461
FilePicker::selected_file
char * selected_file
Definition: xfilepicker.h:68
Resize_t::gravity
Gravity gravity
Definition: xwidget.h:192
Resize_t::init_x
int init_x
Definition: xwidget.h:194
widget_set_title
void widget_set_title(Widget_t *w, const char *title)
widget_set_title - set window title for a Widget_t
Definition: xwidget.c:387
FileDialog::ct
Widget_t * ct
Definition: xfile-dialog.h:38
fp_free
void fp_free(FilePicker *filepicker)
fp_free - release all memory used by the filepicker
Definition: xfilepicker.c:176
FilePicker::path
char * path
Definition: xfilepicker.h:67
Resize_t::cscale_y
float cscale_y
Definition: xwidget.h:208
FileButton
Definition: xfile-dialog.h:51
Widget_t::parent_struct
void * parent_struct
Definition: xwidget.h:306
add_file_button
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....
Definition: xfile-dialog.c:377
FilePicker::file_names
char ** file_names
Definition: xfilepicker.h:69
FileDialog::w_hidden
Widget_t * w_hidden
Definition: xfile-dialog.h:42
Childlist_t::childs
Widget_t ** childs
Definition: xchildlist.h:51
combobox_add_entry
Widget_t * combobox_add_entry(Widget_t *wid, const char *label)
combobox_add_entry - add a entry to the combobox
Definition: xcombobox.c:56
FileDialog::sel_dir
Widget_t * sel_dir
Definition: xfile-dialog.h:43
widget_set_scale
void widget_set_scale(Widget_t *w)
widget_set_scale - set scaling mode to scale a image surface to the size of the Widget_t surface
Definition: xwidget.c:141
Func_t::expose_callback
xevfunc expose_callback
Definition: xwidget.h:80
adj_get_value
float adj_get_value(Adjustment_t *adj)
adj_get_value - get the current value of the Adjustment_t
Definition: xadjustment.c:154
CENTER
@ CENTER
Definition: xwidget.h:165
HAS_POINTER
@ HAS_POINTER
Definition: xwidget.h:247
Widget_t::crb
cairo_t * crb
Definition: xwidget.h:318
listview_set_active_entry
void listview_set_active_entry(Widget_t *w, int active)
listview_set_active_entry - set the active listview entry
Definition: xlistview.c:27
FileDialog
Definition: xfile-dialog.h:35
Func_t::user_callback
xevfunc user_callback
Definition: xwidget.h:86
Widget_t::flags
long long flags
Definition: xwidget.h:324
FilePicker::filter
char * filter
Definition: xfilepicker.h:66
adj_set_value
void adj_set_value(Adjustment_t *adj, float value)
adj_set_value - set the current value to the Adjustment_t
Definition: xadjustment.c:163
FileDialog::fp
FilePicker * fp
Definition: xfile-dialog.h:47
add_image_toggle_button
Widget_t * add_image_toggle_button(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_image_toggle_button - add a button to a Widget_t connect to func.value_changed_callback to implem...
Definition: xbutton.c:73
Widget_t::adj
Adjustment_t * adj
Definition: xwidget.h:334
use_fg_color_scheme
void use_fg_color_scheme(Widget_t *w, Color_state st)
use_fg_color_scheme - use forground Colors to paint on Widget_t
Definition: xcolor.c:178
Widget_t::scale
Resize_t scale
Definition: xwidget.h:356
BACKGROUND_
@ BACKGROUND_
Definition: xcolor.h:53
FileButton::w
Widget_t * w
Definition: xfile-dialog.h:52
fp_init
void fp_init(FilePicker *filepicker, const char *path)
fp_init - set default values used by the filepicker
Definition: xfilepicker.c:184
FilePicker
Definition: xfilepicker.h:61
FileDialog::icon
Pixmap * icon
Definition: xfile-dialog.h:46
FileButton::filter
const char * filter
Definition: xfile-dialog.h:55
FileDialog::w_okay
Widget_t * w_okay
Definition: xfile-dialog.h:41
HAS_MEM
@ HAS_MEM
Definition: xwidget.h:251
Widget_t::app
Xputty * app
Definition: xwidget.h:300
FilePicker::file_counter
unsigned int file_counter
Definition: xfilepicker.h:64
Resize_t::init_y
int init_y
Definition: xwidget.h:196
Xputty::dpy
Display * dpy
Definition: xputty.h:181
FileButton::is_active
bool is_active
Definition: xfile-dialog.h:56
FilePicker::show_hidden
bool show_hidden
Definition: xfilepicker.h:63
widget_get_png
void widget_get_png(Widget_t *w, const unsigned char *name)
widget_get_png - read png into Widget_t xlib surface
Definition: xpngloader.c:41
combobox_set_active_entry
void combobox_set_active_entry(Widget_t *w, int active)
combobox_set_active_entry - set the active combobox entry
Definition: xcombobox.c:25
FileDialog::w
Widget_t * w
Definition: xfile-dialog.h:37
asprintf
int asprintf(char *strp[], const char *fmt,...)
Definition: xasprintf.c:36
FileButton::path
const char * path
Definition: xfile-dialog.h:54
FileDialog::ft
Widget_t * ft
Definition: xfile-dialog.h:39
Widget_t::widget
Window widget
Definition: xwidget.h:302
XColor_t::selected
Colors selected
Definition: xcolor.h:91
Widget_t
Widget_t - struct to hold the basic Widget_t info.
Definition: xwidget.h:298
NORMAL_
@ NORMAL_
Definition: xcolor.h:39
FileDialog::set_filter
Widget_t * set_filter
Definition: xfile-dialog.h:44
FileDialog::send_clear_func
bool send_clear_func
Definition: xfile-dialog.h:48
LDVAR
#define LDVAR(NAME)
Definition: xpngloader.h:71
widget_reset_scale
void widget_reset_scale(Widget_t *w)
widget_reset_scale - used to reset scaling mode after a image surface is drawn to the Widget_t surfac...
Definition: xwidget.c:137
FilePicker::use_filter
int use_filter
Definition: xfilepicker.h:62
destroy_widget
void destroy_widget(Widget_t *w, Xputty *main)
destroy_widget - destroy a widget When a Widget_t receive a destroy_widget() call,...
Definition: xwidget.c:71
Func_t::mem_free_callback
xevfunc mem_free_callback
Definition: xwidget.h:87
FilePicker::dir_counter
unsigned int dir_counter
Definition: xfilepicker.h:65
Widget_t::childlist
Childlist_t * childlist
Definition: xwidget.h:336
add_check_button
Widget_t * add_check_button(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_check_button - add a button to a Widget_t connect to func.value_changed_callback to implement you...
Definition: xbutton.c:105
create_window
Widget_t * create_window(Xputty *app, Window win, int x, int y, int width, int height)
*create_window - create a Window You need to create as least minimun one Window to get started....
Definition: xwidget.c:145
open_file_dialog
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...
Definition: xfile-dialog.c:257
set_pattern
void set_pattern(Widget_t *w, Colors *from, Colors *to, Color_mod mod)
set_pattern - set pattern for the selected Colors
Definition: xcolor.c:227
FileDialog::parent
Widget_t * parent
Definition: xfile-dialog.h:36
Widget_t::func
Func_t func
Definition: xwidget.h:310
listview_set_list
void listview_set_list(Widget_t *listview, char **list, int list_size)
listview_set_list - set a list to a listview Widget_t
Definition: xlistview.c:85
widget_set_icon_from_png
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 ...
Definition: xpngloader.c:124
add_listview
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
Definition: xlistview.c:64
xfile-dialog.h
Xputty::color_scheme
XColor_t * color_scheme
Definition: xputty.h:183
add_combobox
Widget_t * add_combobox(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_combobox - add a combobox
Definition: xcombobox.c:32
childlist_has_child
int childlist_has_child(Childlist_t *childlist)
childlist_has_child - check if a Widget_t Childlist_t contain a child
Definition: xchildlist.c:91
max
#define max(x, y)
max - set a minimal value (x) as return value
Definition: xputty.h:86
Widget_t::label
const char * label
Definition: xwidget.h:326
Func_t::value_changed_callback
xevfunc value_changed_callback
Definition: xwidget.h:85
add_tooltip
void add_tooltip(Widget_t *w, const char *label)
add_tooltip - add a tooltip to Widget_t
Definition: xtooltip.c:41
add_button
Widget_t * add_button(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_button - add a button to a Widget_t connect to func.value_changed_callback to implement your acti...
Definition: xbutton.c:26
Resize_t::cscale_x
float cscale_x
Definition: xwidget.h:206
Resize_t::init_width
int init_width
Definition: xwidget.h:198
XColor_t::normal
Colors normal
Definition: xcolor.h:89
Resize_t::init_height
int init_height
Definition: xwidget.h:200
widget_show_all
void widget_show_all(Widget_t *w)
widget_show_all - map/show Widget_t with all childs
Definition: xwidget.c:405
Func_t::dialog_callback
xevfunc dialog_callback
Definition: xwidget.h:91
FilePicker::dir_names
char ** dir_names
Definition: xfilepicker.h:70