application/window.c

changeset 88
e27526429d85
parent 87
5360027fb282
child 89
2fbb3cac05a5
--- a/application/window.c	Sun Nov 17 15:19:32 2024 +0100
+++ b/application/window.c	Tue Nov 26 10:40:45 2024 +0100
@@ -42,9 +42,29 @@
 
 static UiPathElm* dav_get_pathelm(const char *full_path, size_t len, size_t *ret_nelm, void* data);
 
+static UiMenuBuilder *contextmenu;
+
 void window_init(void) {
     folder_icon = ui_foldericon(16);
     file_icon = ui_fileicon(16);
+    
+    // initialize the browser context menu
+    ui_contextmenu(&contextmenu) {
+        ui_menuitem(.label = "New Folder", .onclick = action_mkcol, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
+        ui_menuitem(.label = "New File", .onclick = action_newfile, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
+        ui_menuseparator();
+        //ui_menuitem(.label = "Cut", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
+        //ui_menuitem(.label = "Copy", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
+        //ui_menuitem(.label = "Paste", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
+        ui_menuitem(.label = "Download", .onclick = action_download, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
+        ui_menuitem(.label = "Delete", .onclick = action_delete, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
+        ui_menuitem(.label = "Select All", .onclick = action_selectall, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
+        ui_menuseparator();
+        ui_menuitem(.label = "Rename", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
+        ui_menuseparator();
+        ui_menuitem("Open Properties", .onclick = action_open_properties, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
+        ui_menuitem("Open as Text File", .onclick = action_open_properties, .onclickdata = "text/plain", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
+    }
 }
 
 UiObject* window_create(void) {
@@ -75,7 +95,15 @@
     model->columnsize[0] = -1;
     model->columnsize[1] = 150;
     model->getvalue = (ui_getvaluefunc) window_resource_table_getvalue;
-    ui_table(obj, .fill = UI_ON, .model = model, .onselection = action_list_selection, .onactivate = action_list_activate, .ondrop = action_dnd_drop, .varname = "reslist", .multiselection = TRUE);
+    ui_table(obj,
+            .fill = UI_ON,
+            .model = model,
+            .onselection = action_list_selection,
+            .onactivate = action_list_activate,
+            .ondrop = action_dnd_drop,
+            .varname = "reslist",
+            .multiselection = TRUE,
+            .contextmenu = contextmenu);
 
     // status bar
 

mercurial