diff options
author | Dave Davenport <DaveDavenport@users.noreply.github.com> | 2018-06-09 19:13:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-09 19:13:57 +0200 |
commit | 441c511296dd4416b86d02ee8c0672cd08808f33 (patch) | |
tree | b5d3f7e13fddebe40f7bd7a6210b8e587ae290be /include | |
parent | ca1ae5dfcd8170ad3978f0846b523cc0ff8980a2 (diff) |
Add an generic icon fetcher that can be used by any widget and re-uses the main threadpool.
Add an generic icon fetcher that can be used by any widget and re-uses the main threadpool.
* Make threadpool more generic usable.
* Add generic icon fetcher, that caches icons.
* Make DRUN use this fetcher.
* Add icon widget.
#809
Diffstat (limited to 'include')
-rw-r--r-- | include/rofi-icon-fetcher.h | 21 | ||||
-rw-r--r-- | include/rofi-types.h | 11 | ||||
-rw-r--r-- | include/view-internal.h | 4 | ||||
-rw-r--r-- | include/widgets/icon.h | 63 | ||||
-rw-r--r-- | include/widgets/widget-internal.h | 3 | ||||
-rw-r--r-- | include/widgets/widget.h | 7 |
6 files changed, 109 insertions, 0 deletions
diff --git a/include/rofi-icon-fetcher.h b/include/rofi-icon-fetcher.h new file mode 100644 index 00000000..3198658e --- /dev/null +++ b/include/rofi-icon-fetcher.h @@ -0,0 +1,21 @@ +#ifndef ROFI_ICON_FETCHER_H +#define ROFI_ICON_FETCHER_H + +#include <glib.h> +#include <stdint.h> +#include <cairo.h> +#include "nkutils-xdg-theme.h" + +void rofi_icon_fetcher_init ( void ); + + +void rofi_icon_fetcher_destroy ( void ); + + +uint32_t rofi_icon_fetcher_query ( const char *name, const int size ); + + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ); + + +#endif // ROFI_ICON_FETCHER_H diff --git a/include/rofi-types.h b/include/rofi-types.h index 93fc683c..46b01f1b 100644 --- a/include/rofi-types.h +++ b/include/rofi-types.h @@ -235,5 +235,16 @@ typedef struct rofi_int_matcher_t gboolean invert; } rofi_int_matcher; +/** + * Structure with data to process by each worker thread. + * TODO: Make this more generic wrapper. + */ +typedef struct _thread_state +{ + void ( *callback )( struct _thread_state *t, gpointer data ); +} thread_state; + +extern GThreadPool *tpool; + G_END_DECLS #endif // INCLUDE_ROFI_TYPES_H diff --git a/include/view-internal.h b/include/view-internal.h index efbf7987..cb160293 100644 --- a/include/view-internal.h +++ b/include/view-internal.h @@ -32,6 +32,7 @@ #include "widgets/textbox.h" #include "widgets/listview.h" #include "widgets/box.h" +#include "widgets/icon.h" #include "keyb.h" #include "xcb.h" #include "theme.h" @@ -68,6 +69,9 @@ struct RofiViewState /** #textbox containing the message entry */ textbox *mesg_tb; + + icon *cur_icon; + /** Array with the levenshtein distance for each eleemnt. */ int *distance; /** Array with the translation between the filtered and unfiltered list. */ diff --git a/include/widgets/icon.h b/include/widgets/icon.h new file mode 100644 index 00000000..c7bf556f --- /dev/null +++ b/include/widgets/icon.h @@ -0,0 +1,63 @@ +/* + * rofi + * + * MIT/X11 License + * Copyright © 2013-2018 Qball Cow <qball@gmpclient.org> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef ROFI_ICON_H +#define ROFI_ICON_H + +#include "widget.h" + +/** + * @defgroup icon icon + * @ingroup widget + * + * + * @{ + */ + +/** + * Abstract handle to the icon widget internal state. + */ +typedef struct _icon icon; + +/** + * @param parent The widget's parent + * @param name The name of the widget. + * + * @returns a newly created icon, free with #widget_free + */ +icon * icon_create ( widget *parent, const char *name ); + +/** + * @param widget The icon widget handle. + * @param size The size of the icon. + * + */ +void icon_set_size ( widget *icon, const int size ); + +void icon_set_surface ( icon *icon, cairo_surface_t *surf ); +/*@}*/ +#endif // ROFI_ICON_H diff --git a/include/widgets/widget-internal.h b/include/widgets/widget-internal.h index e32c8766..762f5723 100644 --- a/include/widgets/widget-internal.h +++ b/include/widgets/widget-internal.h @@ -94,6 +94,9 @@ struct _widget /** Name of widget (used for theming) */ char *name; const char *state; + + /** Used for reference counting */ + int ref_count; }; /** diff --git a/include/widgets/widget.h b/include/widgets/widget.h index 2c72f2e8..28fd94c3 100644 --- a/include/widgets/widget.h +++ b/include/widgets/widget.h @@ -322,5 +322,12 @@ int widget_get_absolute_xpos ( widget *wid ); * @returns the absolute y-position of widget of the widget in pixels. */ int widget_get_absolute_ypos ( widget *wid ); + +/** + * @param wid The widget handle + * + * Increment the reference count on the widget. + */ +void widget_ref ( widget *wid ); /*@}*/ #endif // ROFI_WIDGET_H |