libxputty  0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
xfile-dialog.h
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 #pragma once
22 
23 #ifndef XFILE_DIALOG_H_
24 #define XFILE_DIALOG_H_
25 
26 #include "xwidgets.h"
27 #include "xdgmime.h"
28 #include "xasprintf.h"
29 #include "xfilepicker.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 typedef struct {
46  Pixmap *icon;
49 } FileDialog;
50 
51 typedef struct {
53  char *last_path;
54  const char *path;
55  const char *filter;
56  bool is_active;
57 } FileButton;
58 
59 /**
60  * @brief open_file_dialog - open a non blocking dialog window,
61  * to select a file. The path to open the file-selector could be NULL
62  * It will open then in $HOME.
63  * The filter to use could be NULL, then the file-selector will show all files.
64  * @return Widget_t* - pointer to the Widget_t struct
65  */
66 
67 Widget_t *open_file_dialog(Widget_t *w, const char *path, const char *filter);
68 
69 /**
70  * @brief save_file_dialog - open a non blocking dialog window,
71  * to select a file. The path to open the file-selector could be NULL
72  * It will open then in $HOME.
73  * The filter to use could be NULL, then the file-selector will show all files.
74  * @return Widget_t* - pointer to the Widget_t struct
75  */
76 
77 Widget_t *save_file_dialog(Widget_t *w, const char *path, const char *filter);
78 
79 /**
80  * @brief add_file_button - add a pre-defined button which will pop-up a file dialog
81  * when pressed. path and filter will e hand over to the file selector.
82  * @return Widget_t* - pointer to the Widget_t struct
83  */
84 
85 Widget_t *add_file_button(Widget_t *parent, int x, int y, int width, int height,
86  const char *path, const char *filter);
87 
88 /**
89  * @brief add_save_file_button - add a pre-defined button which will pop-up a file dialog
90  * when pressed. path and filter will e hand over to the file selector.
91  * @return Widget_t* - pointer to the Widget_t struct
92  */
93 
94 Widget_t *add_save_file_button(Widget_t *parent, int x, int y, int width, int height,
95  const char *path, const char *filter);
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif //XFILE_DIALOG_H_
FileDialog::w_quit
Widget_t * w_quit
Definition: xfile-dialog.h:40
FileButton::last_path
char * last_path
Definition: xfile-dialog.h:53
xfilepicker.h
xwidgets.h
FileDialog::ct
Widget_t * ct
Definition: xfile-dialog.h:38
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
FileButton
Definition: xfile-dialog.h:51
FileDialog::w_hidden
Widget_t * w_hidden
Definition: xfile-dialog.h:42
FileDialog::sel_dir
Widget_t * sel_dir
Definition: xfile-dialog.h:43
FileDialog
Definition: xfile-dialog.h:35
FileDialog::fp
FilePicker * fp
Definition: xfile-dialog.h:47
FileButton::w
Widget_t * w
Definition: xfile-dialog.h:52
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
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
FileButton::is_active
bool is_active
Definition: xfile-dialog.h:56
FileDialog::w
Widget_t * w
Definition: xfile-dialog.h:37
FileButton::path
const char * path
Definition: xfile-dialog.h:54
FileDialog::ft
Widget_t * ft
Definition: xfile-dialog.h:39
Widget_t
Widget_t - struct to hold the basic Widget_t info.
Definition: xwidget.h:298
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
FileDialog::text_entry
Widget_t * text_entry
Definition: xfile-dialog.h:45
FileDialog::parent
Widget_t * parent
Definition: xfile-dialog.h:36
save_file_dialog
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...
Definition: xsavefile-dialoge.c:401
xasprintf.h
add_save_file_button
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....
Definition: xsavefile-dialoge.c:534