| 1 | //#include <lttv/toolbar.h> |
| 2 | #include "toolbar.h" |
| 3 | |
| 4 | |
| 5 | inline LttvToolbars *lttv_toolbars_new() { |
| 6 | return g_array_new(FALSE, FALSE, sizeof(lttv_toolbar_closure)); |
| 7 | } |
| 8 | |
| 9 | /* MD: delete elements of the array also, but don't free pointed addresses |
| 10 | * (functions). |
| 11 | */ |
| 12 | inline void lttv_toolbars_destroy(LttvToolbars *h) { |
| 13 | g_array_free(h, TRUE); |
| 14 | } |
| 15 | |
| 16 | inline void lttv_toolbars_add(LttvToolbars *h, lttv_constructor f, char* tooltip, GdkPixmap * pixmap) |
| 17 | { |
| 18 | lttv_toolbar_closure c; |
| 19 | |
| 20 | /* if h is null, do nothing, or popup a warning message */ |
| 21 | if(h == NULL)return; |
| 22 | |
| 23 | c.con = f; |
| 24 | c.tooltip = tooltip; |
| 25 | c.pixmap = pixmap; |
| 26 | g_array_append_val(h,c); |
| 27 | } |
| 28 | |
| 29 | gboolean lttv_toolbars_remove(LttvToolbars *h, lttv_constructor f) |
| 30 | { |
| 31 | lttv_toolbar_closure * tmp; |
| 32 | gint i; |
| 33 | for(i=0;i<h->len;i++){ |
| 34 | tmp = & g_array_index(h, lttv_toolbar_closure, i); |
| 35 | if(tmp->con == f)break; |
| 36 | } |
| 37 | if(i<h->len){ |
| 38 | g_array_remove_index(h, i); |
| 39 | return TRUE; |
| 40 | }else return FALSE; |
| 41 | } |
| 42 | |
| 43 | unsigned lttv_toolbars_number(LttvToolbars *h) |
| 44 | { |
| 45 | return h->len; |
| 46 | } |
| 47 | |
| 48 | |