24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
27 */ |
27 */ |
28 |
28 |
29 #include <ucx/map.h> |
|
30 |
29 |
31 #include "stock.h" |
30 #include "stock.h" |
32 #include "../ui/properties.h" |
31 #include "../ui/properties.h" |
33 |
32 |
34 static UcxMap *stock_items; |
|
35 |
|
36 void ui_stock_init() { |
|
37 stock_items = ucx_map_new(64); |
|
38 |
|
39 ui_add_stock_item(UI_STOCK_NEW, "New", "document-new"); |
|
40 ui_add_stock_item(UI_STOCK_OPEN, "Open", "document-open"); |
|
41 ui_add_stock_item(UI_STOCK_SAVE, "Save", "document-save"); |
|
42 ui_add_stock_item(UI_STOCK_SAVE_AS, "Save as ...", "document-save-as"); |
|
43 ui_add_stock_item(UI_STOCK_REVERT_TO_SAVED, "Revert to saved", "document-revert"); |
|
44 ui_add_stock_item(UI_STOCK_CLOSE, "Close", "window-close"); |
|
45 ui_add_stock_item(UI_STOCK_UNDO, "Undo", "edit-undo"); |
|
46 ui_add_stock_item(UI_STOCK_REDO, "Redo", "edit-redo"); |
|
47 ui_add_stock_item(UI_STOCK_GO_BACK, "Back", "go-previous"); |
|
48 ui_add_stock_item(UI_STOCK_GO_FORWARD, "Forward", "go-next"); |
|
49 ui_add_stock_item(UI_STOCK_CUT, "Cut", "edit-cut"); |
|
50 ui_add_stock_item(UI_STOCK_COPY, "Copy", "edit-copy"); |
|
51 ui_add_stock_item(UI_STOCK_PASTE, "Paste", "edit-paste"); |
|
52 ui_add_stock_item(UI_STOCK_DELETE, "Delete", "edit-delete"); |
|
53 } |
|
54 |
|
55 void ui_add_stock_item(char *id, char *label, char *icon) { |
|
56 UiStockItem *item = new UiStockItem(label, icon); |
|
57 ucx_map_cstr_put(stock_items, id, item); |
|
58 } |
|
59 |
|
60 UiStockItem* ui_get_stock_item(char *id) { |
|
61 UiStockItem *item = (UiStockItem*)ucx_map_cstr_get(stock_items, id); |
|
62 if(item) { |
|
63 char *label = uistr_n(id); |
|
64 if(label) { |
|
65 item->label = label; |
|
66 } |
|
67 } |
|
68 return item; |
|
69 } |
|
70 |
33 |
71 |
34 |
72 UiStockItem::UiStockItem(char* label, char* icon_name) { |
|
73 this->label = label; |
|
74 this->icon_name = icon_name; |
|
75 } |
|
76 |
35 |
77 |
|